@nodescript/stdlib
Version:
Standard Node Definitions
28 lines (27 loc) • 661 B
JavaScript
export const module = {
version: '1.2.2',
moduleName: 'Flow / Fallback',
description: 'Runs the steps one-by-one and returns the first non-null result.',
params: {
steps: {
deferred: true,
schema: {
type: 'array',
items: { type: 'any' },
},
},
},
result: {
async: true,
schema: { type: 'any' },
}
};
export const compute = async (params, ctx) => {
for (const step of params.steps) {
const value = await ctx.resolveDeferred(step);
if (value != null) {
return value;
}
}
return null;
};