mirror of
https://github.com/TECHNOFAB11/ergogen.git
synced 2025-12-13 00:20:06 +01:00
Outlining improvements
This commit is contained in:
parent
5a25c1c423
commit
5e68bdb630
5 changed files with 92 additions and 80 deletions
|
|
@ -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)) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue