diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-09-23 22:12:54 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-23 22:12:54 -0300 |
commit | 3b458e5c403054bda58733e238ab666596cc9f70 (patch) | |
tree | 31036179d02c600bebf6b242763bfed9d2b9c734 /src | |
parent | 84b09a42c7baf248115f596217c07871e374d1af (diff) |
data: refactor/tidy input token construction
Diffstat (limited to 'src')
-rw-r--r-- | src/data/things/composite.js | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/data/things/composite.js b/src/data/things/composite.js index fdb80cf3..293952b7 100644 --- a/src/data/things/composite.js +++ b/src/data/things/composite.js @@ -355,35 +355,30 @@ import { const globalCompositeCache = {}; -export function input(nameOrDescription) { - if (typeof nameOrDescription === 'string') { - return Symbol.for(`hsmusic.composite.input:${nameOrDescription}`); - } else { - return { - symbol: Symbol.for('hsmusic.composite.input'), - shape: 'input', - value: nameOrDescription, - }; - } -} +const _valueIntoToken = shape => + (value = null) => + (value === null + ? Symbol.for(`hsmusic.composite.${shape}`) + : typeof value === 'string' + ? Symbol.for(`hsmusic.composite.${shape}:${value}`) + : { + symbol: Symbol.for(`hsmusic.composite.input`), + shape, + value, + }); +export const input = _valueIntoToken('input'); input.symbol = Symbol.for('hsmusic.composite.input'); -input.updateValue = (description = null) => - (description - ? { - symbol: input.symbol, - shape: 'input.updateValue', - value: description, - } - : Symbol.for('hsmusic.composite.input.updateValue')); +input.value = _valueIntoToken('input.value'); +input.dependency = _valueIntoToken('input.dependency'); input.myself = () => Symbol.for(`hsmusic.composite.input.myself`); -input.value = value => ({symbol: input.symbol, shape: 'input.value', value}); -input.dependency = name => Symbol.for(`hsmusic.composite.input.dependency:${name}`); -input.staticDependency = name => Symbol.for(`hsmusic.composite.input.staticDependency:${name}`); -input.staticValue = name => Symbol.for(`hsmusic.composite.input.staticValue:${name}`); +input.updateValue = _valueIntoToken('input.updateValue'); + +input.staticDependency = _valueIntoToken('input.staticDependency'); +input.staticValue = _valueIntoToken('input.staticValue'); function isInputToken(token) { if (typeof token === 'object') { |