Outlining improvements

This commit is contained in:
Bán Dénes 2022-05-29 20:25:52 +02:00
parent 5a25c1c423
commit 5e68bdb630
5 changed files with 92 additions and 80 deletions

View file

@ -1,10 +1,16 @@
const op_prefix = exports.op_prefix = str => {
const prefix = str[0]
const suffix = str.slice(1)
if (str.startsWith('+')) return {name: suffix, operation: 'add'}
if (str.startsWith('-')) return {name: suffix, operation: 'subtract'}
if (str.startsWith('~')) return {name: suffix, operation: 'intersect'}
if (str.startsWith('^')) return {name: suffix, operation: 'stack'}
return {name: str, operation: 'add'}
const result = {name: suffix, operation: 'add'}
if (prefix == '+') ; // noop
else if (prefix == '-') result.operation = 'subtract'
else if (prefix == '~') result.operation = 'intersect'
else if (prefix == '^') result.operation = 'stack'
else result.name = str // no prefix, so the name was the whole string
return result
}
exports.operation = (str, choices={}, order=Object.keys(choices)) => {