Introduce TermOperator helper and refactor execute()s to use replaceSubjectMatchingTerm
This commit is contained in:
@@ -38,8 +38,8 @@ export class Quote extends Command<{ with?: StrTerm }> {
|
||||
}
|
||||
|
||||
execute(vm: StrVM, data: { with?: StrTerm }): Awaitable<StrVM> {
|
||||
return vm.tapInPlace(ctx =>
|
||||
ctx.replaceSubjectAsString(sub => {
|
||||
return vm.replaceContextMatchingTerm(ctx => ({
|
||||
string: sub => {
|
||||
let quote = '\''
|
||||
if ( data.with ) {
|
||||
quote = ctx.resolveString(data.with)
|
||||
@@ -47,6 +47,7 @@ export class Quote extends Command<{ with?: StrTerm }> {
|
||||
|
||||
sub = stripQuotemarkLayer(sub)
|
||||
return `${quote}${sub}${quote}`
|
||||
}))
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user