Add new restructureOrLines match target + update join command to use it
This commit is contained in:
@@ -26,6 +26,15 @@ export const joinDestructured = (val: StrDestructured['value']): string =>
|
||||
.map(part => `${part.prefix || ''}${part.value}`)
|
||||
.join('')
|
||||
|
||||
export const destructureToLines = (val: string): StrDestructured['value'] => val
|
||||
.split('\n')
|
||||
.map((line, idx) => {
|
||||
if ( idx ) {
|
||||
return { prefix: '\n', value: line }
|
||||
}
|
||||
return { value: line }
|
||||
})
|
||||
|
||||
export type StrRVal =
|
||||
{ term: 'string', value: string, literal?: true }
|
||||
| { term: 'int', value: number }
|
||||
|
||||
@@ -20,7 +20,7 @@ export class Join extends Command<{ with?: StrTerm }> {
|
||||
|
||||
execute(vm: StrVM, data: { with?: StrTerm }): Awaitable<StrVM> {
|
||||
return vm.replaceContextMatchingTerm(ctx => ({
|
||||
restructure: parts => {
|
||||
restructureOrLines: parts => {
|
||||
if ( data.with ) {
|
||||
return parts
|
||||
.map(part => part.value)
|
||||
|
||||
Reference in New Issue
Block a user