diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-07-25 16:59:01 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-07-25 16:59:01 -0300 |
commit | c06233c6e480b1966fa27c11c8b794055f9ec737 (patch) | |
tree | 153e0ba63339a70aae4d6d6a7c2bebdf4ac4f94a | |
parent | 91fb34c3ec48483d6f451ff74b266799ce0e5e42 (diff) |
composite: simplify getStaticInputMetadata
Since it always operates on inputMapping, we can make more assumptions about shape. (All input names are always provided i.e. non-null, and they are always present as input tokens.)
-rw-r--r-- | src/data/composite.js | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/data/composite.js b/src/data/composite.js index 5af1becf..eb81bb4c 100644 --- a/src/data/composite.js +++ b/src/data/composite.js @@ -72,30 +72,22 @@ function getInputTokenValue(token) { } } -function getStaticInputMetadata(inputOptions) { +function getStaticInputMetadata(inputMapping) { const metadata = {}; - for (const [name, token] of Object.entries(inputOptions)) { - if (typeof token === 'string') { - metadata[input.staticDependency(name)] = token; - metadata[input.staticValue(name)] = null; - } else if (isInputToken(token)) { - const tokenShape = getInputTokenShape(token); - const tokenValue = getInputTokenValue(token); - - metadata[input.staticDependency(name)] = - (tokenShape === 'input.dependency' - ? tokenValue - : null); - - metadata[input.staticValue(name)] = - (tokenShape === 'input.value' - ? tokenValue - : null); - } else { - metadata[input.staticDependency(name)] = null; - metadata[input.staticValue(name)] = null; - } + for (const [name, token] of Object.entries(inputMapping)) { + const tokenShape = getInputTokenShape(token); + const tokenValue = getInputTokenValue(token); + + metadata[input.staticDependency(name)] = + (tokenShape === 'input.dependency' + ? tokenValue + : null); + + metadata[input.staticValue(name)] = + (tokenShape === 'input.value' + ? tokenValue + : null); } return metadata; @@ -350,6 +342,8 @@ export function templateCompositeFrom(description) { if (typeof inputOptions[name] === 'string') { inputMapping[name] = input.dependency(inputOptions[name]); } else { + // This is always an input token, since only a string or + // an input token is a valid input option (asserted above). inputMapping[name] = inputOptions[name]; } } else if (tokenValue.defaultValue) { |