diff --git a/src/client/types/steps-lists.js b/src/client/types/steps-lists.js deleted file mode 100644 index 2013f68..0000000 --- a/src/client/types/steps-lists.js +++ /dev/null @@ -1,64 +0,0 @@ -import {flatten} from '@avocado/core'; -import {Context} from '@avocado/behavior'; -import {Traversal} from '@avocado/behavior/item/traversal'; - -import {typeFits} from './typing'; - -export const variableStepsList = ( - context, - previousSteps, - key, - variable, - variableType, - type, - isFinal, -) => { - const steps = []; - if (typeFits(type, variableType)) { - steps.push({type: 'key', key}); - } - const traversal = new Traversal({steps: previousSteps.concat(steps)}); - const description = Context.typeDescription( - variableType, - traversal.get(context), - ); - // TODO invoke can only work at the end of steps chain - if (typeFits(type, variableType)) { - if ('function' === typeof variable) { - steps.push({type: 'invoke', args: []}); - } - } - if (isFinal) { - return [steps]; - } - const sublists = Object.entries(description) - .map(([nextKey, newDescription]) => ( - variableStepsList( - context, - previousSteps.concat(steps), - nextKey, - ('object' === typeof variable && null !== variable) ? variable[nextKey] : undefined, - newDescription.type, - type, - newDescription.cycle, - ) - )) - .map((childLists) => ( - childLists.map((stepsList) => ( - stepsList.length > 0 - ? [{type: 'key', key}].concat(stepsList) - : [] - )) - )); - return sublists.length > 0 ? [steps].concat(flatten(sublists)) : [steps]; -}; - -export const contextStepsList = (context, type) => ( - flatten( - Object.entries(context.all()) - .map(([key, [variable, variableType]]) => ( - variableStepsList(context, [{type: 'key', key}], key, variable, variableType, type, false) - )), - ) - .filter((stepsList) => stepsList.length > 0) -);