import {Command, hashStrRVal, ParseContext, unwrapDestructured, wrapDestructured, wrapString} from "./command.js"; import {LexInput} from "../lexer.js"; import {StrVM} from "../vm.js"; import {Awaitable} from "../../util/types.js"; export class Unique extends Command<{}> { isParseCandidate(token: LexInput): boolean { return this.isKeyword(token, 'unique') } attemptParse(context: ParseContext): {} { return {} } getDisplayName(): string { return 'unique' } execute(vm: StrVM): Awaitable { return vm.replaceContextMatchingTerm({ destructuredOrLines: sub => { const seen: Record = {} return sub.filter(part => { const hash = hashStrRVal(part.value) if ( seen[hash] ) { return false } seen[hash] = true return true }) }, }) } }