fix bye
This commit is contained in:
parent
abb7420ce7
commit
f5b8eb0780
|
@ -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)
|
||||
);
|
Loading…
Reference in New Issue
Block a user