@apidaze/node-red-contrib-apidaze
Version:
Node-RED module for Apidaze
31 lines (25 loc) • 684 B
JavaScript
const dirtyMethods = ['randomize', 'limit', 'orderBy', 'quicksort', 'wait'];
/**
* Mutates the flow to extend the contained arrays with the mentioned dirty methods
*
* @param {Array} flow - A node-red flow to prepare it for tests
* @return {Array} modified array with the dirty methods
*/
function prepareFlow(flow) {
for (const key of dirtyMethods) {
flow[key] = flow[key];
for (const node of flow) {
node[key] = flow[key];
if (node.wires) {
node.wires[key] = node.wires[key];
for (const wiredNode of node.wires) {
wiredNode[key] = flow[key];
}
}
}
}
return flow;
}
module.exports = {
prepareFlow,
};