Socket
Socket
Sign inDemoInstall

flowa

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flowa - npm Package Compare versions

Comparing version 3.5.2 to 4.0.0

task.js

129

index.js

@@ -8,6 +8,7 @@ /**

var is = require('is_js'),
async = require('async'),
_ = require('lodash');
var serial = require('./serial'),
var is = require('is_js'),
async = require('async'),
_ = require('lodash');
var Task = require('./task'),
serial = require('./serial'),
parallel = require('./parallel');

@@ -75,3 +76,3 @@

*/
this._defaultType = 'serial';
this._defaultRunnerType = 'serial';

@@ -145,3 +146,3 @@ /**

if (typeof task.type == 'undefined') {
task.type = this._defaultType;
task.type = this._defaultRunnerType;
}

@@ -272,2 +273,14 @@

/**
* Get a task by its name
*
* @param {String} taskName
* @return {Function|Object}
*/
Flowa.prototype._getTask = function(taskName) {
return this._tasks[taskName];
};
/**
* Debug a specific task

@@ -308,15 +321,18 @@ *

* take a callback argument: The callback will
* be called manually.
* be called manually with the returned value as a result.
* - If the execution is terminated the callback will
* be called manually without executing the task.
* - Inject the result of the task in the context with
* a key equal to the task's name if
* `runVariables.options.autoInjectResults` = `true`
*
* @param {String} taskName
* @param {Object} runVariables
* @param {Function} callback
* @param {Task} flowaTask
* @param {Function} callback
*/
Flowa.prototype.runTask = function(taskName, runVariables, callback) {
Flowa.prototype.runTask = function(flowaTask, callback) {
var self = this;
var task = self._tasks[taskName];
var runVariables = flowaTask._runVariables;
var timeout = runVariables.options.taskTimeout;
var taskName = flowaTask.name;
var returnedValue = null;

@@ -326,5 +342,18 @@

if (runVariables.terminated) {
return callback();
return callback(null);
}
// Automatically inject the result of the single tasks
// into the context object
if (runVariables.options.autoInjectResults && flowaTask._isSingleTask) {
var runTaskCallback = callback;
callback = function(error, result) {
runVariables.context[taskName] = result;
runTaskCallback(error, result);
};
}
// Debugging is on

@@ -336,6 +365,4 @@ if (runVariables.options.debug) {

// Is a compound task
if (self._isCompoundTask(taskName)) {
return self._runners[task.type](self, taskName, runVariables, callback);
if (!flowaTask._isSingleTask) {
return self._runners[flowaTask._task.type](self, taskName, runVariables, callback);
}

@@ -346,6 +373,4 @@

task = task.bind(new FlowaTask(taskName, callback, runVariables, self));
returnedValue = self._timeout(flowaTask._task.bind(flowaTask), timeout, runVariables, taskName)(runVariables.context, callback);
returnedValue = self._timeout(task, timeout, runVariables, taskName)(runVariables.context, callback);
} catch (error) {

@@ -365,5 +390,5 @@

// Doesn't return a promise and doesn't take a callback argument
if (task.length < 2) {
if (flowaTask._task.length < 2) {
return callback();
return callback(null, returnedValue);

@@ -483,2 +508,3 @@ }

taskTimeout: null,
autoInjectResults: true, // Inject the result of each task into the context
debug: false,

@@ -492,4 +518,5 @@ debugCallback: console.log

var runTask = self._timeout(self.runTask.bind(self), timeout, runVariables);
var flowaTask = new Task(self._rootName, runVariables, self)
runTask(self._rootName, runVariables, function(error, result) {
runTask(flowaTask, function(error, result) {

@@ -508,58 +535,2 @@ if (error) {

/**
* A task object to be bound when calling a task
*
* @param {String} taskName
* @param {Object} runVariables
* @param {Flowa} flowa
*/
function FlowaTask(taskName, callback, runVariables, flowa) {
/**
* The name of the task
* @type {String}
*/
this.name = taskName;
/**
* The task's callback
* @type {Function}
*/
this.callback = callback;
/**
* Variables needed for the current run
* @type {Object}
*/
this._runVariables = runVariables;
/**
* The task's runner type
* @type {String}
*/
this.runnerType = flowa._tasksRunnersTypes[taskName];
/**
* The task's depth
* @type {Number}
*/
depth = flowa._tasksDepths[taskName];
/**
* The task's parent
* @type {String}
*/
parent = flowa._tasksParents[taskName];
}
/**
* Set the execution as terminated
*/
FlowaTask.prototype.done = function() {
this._runVariables.terminated = true;
};
module.exports = Flowa;
{
"name": "flowa",
"version": "3.5.2",
"version": "4.0.0",
"description": "Service level control flow for Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,2 +9,3 @@ /**

var async = require('async');
var Task = require('./task');

@@ -28,3 +29,4 @@ /**

flowa.runTask(taskName, runVariables, callback);
var flowaTask = new Task(taskName, runVariables, flowa);
flowa.runTask(flowaTask, callback);

@@ -31,0 +33,0 @@ });

@@ -31,2 +31,3 @@ <p align="center"><img src="/logo.png?raw=true" alt="Flowa Logo"/></p>

* [Sync Tasks](#sync-tasks)
* [Terminating The Flow](#terminating-the-flow)
* [Jumping Between Tasks](#jumping-between-tasks)

@@ -114,5 +115,6 @@ * [Error Handling](#error-handling)

function task1(context, callback) {
context.task1 = 1;
console.log('Executing task 1');
setTimeout(callback, 500);
setTimeout(callback.bind(null, null, 'DummyValue1'), 500);
}

@@ -122,5 +124,7 @@

function task2(context) {
context.task2 = 2;
console.log('Executing task 2');
return new Promise();
context.extraDummyValue2 = 'extraDummyValue2';
return Promise.resolve('DummyValue2');
}

@@ -130,4 +134,6 @@

function task3(context) {
context.task3 = 3;
console.log('Executing task 3');
return 'DummyValue3';
}

@@ -241,23 +247,25 @@ ```

### Jumping Between Tasks
### Terminating The Flow
You can jump forward and backward between tasks that belong to the same parent task and the runner type is `serial` by passing the name of the task as the second argument to the callback function or as a resolved value if you use promises instead. You can jump into a compound task too.
You can terminate the flow (skip executing the remaining tasks) by calling the `done` method.
```js
function task1(context, callback) {
callback(null, 'task6');
this.done();
callback();
}
```
Or with promises
### Jumping Between Tasks
You can jump forward and backward between tasks that belong to the same parent task and the runner type is `serial` by calling the `jump` method with the task name as first argument to jump into it after executing the current task completely. You can jump into a compound task too.
```js
function task1(context) {
function task1(context, callback) {
return new Promise(function(resolve, reject) {
this.jump('task6');
callback();
resolve('task6');
});
}

@@ -292,3 +300,4 @@ ```

// Retry
callback(null, 'task1');
this.jump('task1');
callback();

@@ -532,6 +541,14 @@ }

<dd><p>Create a flow and execute it</p></dd>
<dt><a href="#run">run(context[, options])</a> ⇒ <code>Promise</code></dt>
<dt><a href="#flowa-instance-run">flowa.run(context[, options])</a> ⇒ <code>Promise</code></dt>
<dd><p>Execute the flow</p></dd>
<dt><a href="#task-done">task.done()</a></dt>
<dd><p>Skip the remaining tasks</p></dd>
<dt><a href="#task-jump">task.jump(taskName)</a></dt>
<dd><p>Jump into another task under the same parent after executing the current task</p></dd>
</dl>
### Note
> A new instance from the class `Task` is created for each execution for each task.
<a name="constructor"></a>

@@ -575,5 +592,5 @@

<a name="run"></a>
<a name="flowa-instance-run"></a>
## run(context, options) ⇒ <code>Promise</code>
## flowa.run(context, options) ⇒ <code>Promise</code>

@@ -593,7 +610,24 @@ Execute the flow. The Flowa object can be defined once and executed as many as you need.

* **taskTimeout**: a timeout for the single tasks in milliseconds. The promise will be rejected with an error object that has (code: `ETIMEDOUT`) if the timeout is exeeded (type: `Number`).
* **debug**: log the tasks' names in realtime (type: `Boolean`).
* **autoInjectResults**: Inject the result of each task into the context automatically (type: `Boolean`) (default: `true`).
* **debug**: log the tasks' names in realtime (type: `Boolean`) (default: `false`).
* **debugCallback**: the debug logging function (type: `Boolean`) (default: `console.log`).
<a name="task-done"></a>
## task.done()
Skip the remaining tasks. Check [Terminating The Flow](#terminating-the-flow).
<a name="task-jump"></a>
## task.jump(taskName)
Jump into another task under the same parent after executing the current task. Check [Jumping Between Tasks](#jumping-between-tasks).
| Param | Type | Description |
|----------|---------------------|--------------------------------|
| taskName | <code>String</code> | The name of the sibling task |
# License
This project is under the MIT license.

@@ -9,3 +9,4 @@ /**

var async = require('async'),
is = require('is_js');
is = require('is_js');
var Task = require('./task');

@@ -31,2 +32,4 @@ /**

var flowaTask = new Task(taskName, runVariables, flowa);
if (jumpToTask && jumpToTask != taskName) {

@@ -40,3 +43,3 @@ return callback();

flowa.runTask(taskName, runVariables, function(error, result) {
flowa.runTask(flowaTask, function(error, result) {

@@ -48,19 +51,7 @@ // Something wrong

// No jumpToTask
if (typeof result == 'undefined' || is.not.string(result)) {
return callback();
// The jump method is called
if (flowaTask._jumpToTask) {
jumpToTask = flowaTask._jumpToTask;
}
// Check exists
if (!flowa._isTask(result)) {
return callback(new Error('Jumping into an invalid task name `' + result + '` is not allowd'));
}
// Check same group
if (flowa._getTaskParent(taskName) != flowa._getTaskParent(result)) {
return callback(new Error('Jumping into a task that doesn\'t belong to the same parent task is not allowed'));
}
jumpToTask = result;
callback();

@@ -67,0 +58,0 @@

@@ -9,5 +9,5 @@ /**

* Generate a dummy task that adds
* a key `task${id}` = callsCounter into the context
* a key `_task${id}` = callsCounter into the context
* and calls its callback on the next event loop tick
* using `setImmediate`
* with the result `result${id}` using `setImmediate`
*

@@ -24,37 +24,6 @@ * - The `callsCounter` is incremented for each call

return function(context, callback) {
context['task' + id] = context['task' + id] ? context['task' + id] + 1 : 1;
setImmediate(callback);
};
}
context['_task' + id] = context['_task' + id] ? context['_task' + id] + 1 : 1;
setImmediate(callback.bind(null, null, 'result' + id));
/**
* Generate a dummy task that adds
* a key `task${id}` = callsCounter into the context
* and calls its callback on the next event loop tick
* using `setImmediate` with the arguments (null, jumpToTask)
* when it's called for the first time, otherwise without jumping
*
* - The `callsCounter` is incremented for each call
*
* @param {Number} id
* @param {String} jumpToTask
* @return {Function}
*/
function generateJumperTask(id, jumpToTask) {
var called = false;
var callsCounter = 1;
return function(context, callback) {
context['task' + id] = context['task' + id] ? context['task' + id] + 1 : 1;
if (!called) {
called = true;
return setImmediate(callback.bind(null, null, jumpToTask));
}
setImmediate(callback);
};

@@ -66,4 +35,4 @@

* Generate a dummy task that adds
* a key `task${id}` = callsCounter into the context
* and returns a promise that gets resolved on the
* a key `_task${id}` = callsCounter into the context
* and returns a promise that gets resolved with `result${id}` on the
* next event loop tick using `setImmediate`

@@ -82,7 +51,7 @@ *

context['task' + id] = context['task' + id] ? context['task' + id] + 1 : 1;
context['_task' + id] = context['_task' + id] ? context['_task' + id] + 1 : 1;
return new Promise(function(resolve, reject) {
setImmediate(resolve);
setImmediate(resolve.bind(null, 'result' + id));

@@ -97,3 +66,4 @@ });

* Generate a dummy async task that adds
* a key `task${id}` = callsCounter into the context
* a key `_task${id}` = callsCounter into the context
* and returns `result${id}`
*

@@ -111,3 +81,4 @@ * - The `callsCounter` is incremented for each call

context['task' + id] = context['task' + id] ? context['task' + id] + 1 : 1;
context['_task' + id] = context['_task' + id] ? context['_task' + id] + 1 : 1;
return 'result' + id;

@@ -120,6 +91,6 @@ };

* Generate a dummy task that adds
* a key `task${id}` = callsCounter into the context
* a key `_task${id}` = callsCounter into the context
* and calls its callback on the next event loop tick
* using `setImmediate` and terminiates the flow
* by calling `this.done()`
* using `setImmediate` and invoke `this.jump` method
* when it's called for the first time, otherwise without jumping
*

@@ -129,15 +100,21 @@ * - The `callsCounter` is incremented for each call

* @param {Number} id
* @param {String} jumpToTask
* @return {Function}
*/
function generateDummyTerminatingTask(id) {
function generateJumperTask(id, jumpToTask) {
var called = false;
var callsCounter = 1;
return function(context, callback) {
var self = this;
context['task' + id] = context['task' + id] ? context['task' + id] + 1 : 1;
setImmediate(function() {
self.done();
callback();
});
context['_task' + id] = context['_task' + id] ? context['_task' + id] + 1 : 1;
if (!called) {
called = true;
this.jump(jumpToTask);
}
setImmediate(callback);
};

@@ -149,6 +126,6 @@

* Generate a dummy task that adds
* a key `task${id}` = callsCounter into the context
* and returns a promise that gets resolved on the next event loop tick
* using `setImmediate` with the arguments (null, jumpToTask)
* when it's called for the first time, otherwise without jumping
* a key `_task${id}` = callsCounter into the context
* and calls its callback on the next event loop tick
* using `setImmediate` and terminiates the flow
* by calling `this.done()`
*

@@ -158,26 +135,16 @@ * - The `callsCounter` is incremented for each call

* @param {Number} id
* @param {String} jumpToTask
* @return {Function}
*/
function generateJumperPromiseTask(id, jumpToTask) {
function generateDummyTerminatingTask(id) {
var called = false;
var callsCounter = 1;
return function(context, callback) {
return function(context) {
context['task' + id] = context['task' + id] ? context['task' + id] + 1 : 1;
return new Promise(function(resolve, reject) {
if (!called) {
called = true;
return setImmediate(resolve.bind(null, jumpToTask));
}
setImmediate(resolve);
this.done();
context['_task' + id] = context['_task' + id] ? context['_task' + id] + 1 : 1;
setImmediate(function() {
callback();
});
};

@@ -189,3 +156,3 @@

* Generate a dummy task that adds
* a key `task${id}` = callsCounter into the context
* a key `_task${id}` = callsCounter into the context
* and calls its callback using a timer

@@ -203,4 +170,3 @@ *

context['task' + id] = context['task' + id] ? context['task' + id] + 1 : 1;
context['_task' + id] = context['_task' + id] ? context['_task' + id] + 1 : 1;
setTimeout(callback.bind(null, null), delay);

@@ -252,7 +218,6 @@

generateDummyTask: generateDummyTask,
generateJumperTask: generateJumperTask,
generateDummyPromiseTask: generateDummyPromiseTask,
generateDummySyncTask: generateDummySyncTask,
generateJumperTask: generateJumperTask,
generateDummyTerminatingTask: generateDummyTerminatingTask,
generateJumperPromiseTask: generateJumperPromiseTask,
generateDummyTimerTask: generateDummyTimerTask,

@@ -259,0 +224,0 @@ generateDummyErroredTask: generateDummyErroredTask,

@@ -7,6 +7,6 @@ /**

var chai = require('chai'),
sinon = require('sinon'),
_ = require('lodash');
var plugins = require('./plugins.js'),
var chai = require('chai'),
sinon = require('sinon'),
_ = require('lodash');
var plugins = require('./plugins.js'),
requireDir = require('./helpers/requiredir.js'),

@@ -25,3 +25,3 @@ generators = require('./helpers/generators.js');

// Testing suites and samples
var suites = requireDir('./suites'),
var suites = requireDir('./suites'),
samples = requireDir('./samples');

@@ -72,6 +72,5 @@

describe('Sample: Basic/Basic8', function(callback) {
suites.properties(samples.basic.basic8);
suites.output(samples.basic.basic8);
suites.flow(samples.basic.basic8);
describe('Sample: AutoInjectResults/AutoInjectResults1', function(callback) {
suites.flow(samples.autoInjectResults.autoInjectResults1);
suites.output(samples.autoInjectResults.autoInjectResults1);
});

@@ -83,2 +82,6 @@

describe('Sample: Done/Done1', function(callback) {
suites.flow(samples.done.done1);
});
describe('Sample: Jump/Jump2', function(callback) {

@@ -88,10 +91,2 @@ suites.flow(samples.jump.jump2);

describe('Sample: Jump/Jump3', function(callback) {
suites.flow(samples.jump.jump3);
});
describe('Sample: Jump/Jump4', function(callback) {
suites.flow(samples.jump.jump4);
});
describe('Sample: Timeout/Timeout1', function(callback) {

@@ -98,0 +93,0 @@ suites.timeout(samples.timeout.timeout1);

@@ -8,3 +8,3 @@

var chai = require('chai'),
var chai = require('chai'),
chaiAsPromised = require('chai-as-promised');

@@ -11,0 +11,0 @@

@@ -14,2 +14,10 @@ /**

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* A mapping between tasks names and runners types

@@ -91,14 +99,14 @@ * @type {Object}

module.exports.hints.context = {
task1: true,
task2: true,
task3: true,
task4: true,
task5: true,
task6: true,
task7: true,
task8: true,
task9: true,
task10: true,
task11: true,
task12: true
_task1: 1,
_task2: 1,
_task3: 1,
_task4: 1,
_task5: 1,
_task6: 1,
_task7: 1,
_task8: 1,
_task9: 1,
_task10: 1,
_task11: 1,
_task12: 1
};

@@ -112,9 +120,9 @@

{},
{task1: 1},
{task2: 1, task3: 1, task4: 1, task6: 1},
{task5: 1, task7: 1},
{task8: 1, task9: 1},
{task10: 1},
{task11: 1},
{task12: 1}
{_task1: 1},
{_task2: 1, _task3: 1, _task4: 1, _task6: 1},
{_task5: 1, _task7: 1},
{_task8: 1, _task9: 1},
{_task10: 1},
{_task11: 1},
{_task12: 1}
];

@@ -121,0 +129,0 @@

@@ -14,2 +14,10 @@ /**

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* A mapping between tasks names and runners types

@@ -91,14 +99,14 @@ * @type {Object}

module.exports.hints.context = {
task1: true,
task2: true,
task3: true,
task4: true,
task5: true,
task6: true,
task7: true,
task8: true,
task9: true,
task10: true,
task11: true,
task12: true
_task1: 1,
_task2: 1,
_task3: 1,
_task4: 1,
_task5: 1,
_task6: 1,
_task7: 1,
_task8: 1,
_task9: 1,
_task10: 1,
_task11: 1,
_task12: 1
};

@@ -113,14 +121,14 @@

{
task1: 1,
task2: 1,
task3: 1,
task4: 1,
task5: 1,
task6: 1,
task7: 1,
task8: 1,
task9: 1,
task10: 1,
task11: 1,
task12: 1
_task1: 1,
_task2: 1,
_task3: 1,
_task4: 1,
_task5: 1,
_task6: 1,
_task7: 1,
_task8: 1,
_task9: 1,
_task10: 1,
_task11: 1,
_task12: 1
}

@@ -127,0 +135,0 @@ ];

@@ -14,2 +14,10 @@ /**

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* A mapping between tasks names and runners types

@@ -91,14 +99,14 @@ * @type {Object}

module.exports.hints.context = {
task1: true,
task2: true,
task3: true,
task4: true,
task5: true,
task6: true,
task7: true,
task8: true,
task9: true,
task10: true,
task11: true,
task12: true
_task1: 1,
_task2: 1,
_task3: 1,
_task4: 1,
_task5: 1,
_task6: 1,
_task7: 1,
_task8: 1,
_task9: 1,
_task10: 1,
_task11: 1,
_task12: 1
};

@@ -112,14 +120,14 @@

{},
{task1: 1},
{task2: 1},
{task3: 1},
{task4: 1},
{task5: 1},
{task6: 1},
{task7: 1},
{task8: 1},
{task9: 1},
{task10: 1},
{task11: 1},
{task12: 1}
{_task1: 1},
{_task2: 1},
{_task3: 1},
{_task4: 1},
{_task5: 1},
{_task6: 1},
{_task7: 1},
{_task8: 1},
{_task9: 1},
{_task10: 1},
{_task11: 1},
{_task12: 1}
];

@@ -126,0 +134,0 @@

@@ -14,2 +14,10 @@ /**

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* A mapping between tasks names and runners types

@@ -46,3 +54,3 @@ * @type {Object}

module.exports.hints.context = {
task1: true
_task1: 1
};

@@ -56,3 +64,3 @@

{},
{task1: 1}
{_task1: 1}
];

@@ -59,0 +67,0 @@

@@ -14,2 +14,10 @@ /**

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* A mapping between tasks names and runners types

@@ -67,6 +75,6 @@ * @type {Object}

module.exports.hints.context = {
task1: true,
task2: true,
task3: true,
task4: true
_task1: 1,
_task2: 1,
_task3: 1,
_task4: 1
};

@@ -80,3 +88,3 @@

{},
{task1: 1, task2: 1, task3: 1, task4: 1}
{_task1: 1, _task2: 1, _task3: 1, _task4: 1}
];

@@ -83,0 +91,0 @@

@@ -14,2 +14,10 @@ /**

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* A mapping between tasks names and runners types

@@ -91,14 +99,14 @@ * @type {Object}

module.exports.hints.context = {
task1: true,
task2: true,
task3: true,
task4: true,
task5: true,
task6: true,
task7: true,
task8: true,
task9: true,
task10: true,
task11: true,
task12: true
_task1: 1,
_task2: 1,
_task3: 1,
_task4: 1,
_task5: 1,
_task6: 1,
_task7: 1,
_task8: 1,
_task9: 1,
_task10: 1,
_task11: 1,
_task12: 1
};

@@ -112,9 +120,9 @@

{},
{task1: 1},
{task2: 1, task3: 1, task4: 1, task6: 1},
{task5: 1, task7: 1},
{task8: 1, task9: 1},
{task10: 1},
{task11: 1},
{task12: 1}
{_task1: 1},
{_task2: 1, _task3: 1, _task4: 1, _task6: 1},
{_task5: 1, _task7: 1},
{_task8: 1, _task9: 1},
{_task10: 1},
{_task11: 1},
{_task12: 1}
];

@@ -121,0 +129,0 @@

@@ -14,2 +14,10 @@ /**

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* A mapping between tasks names and runners types

@@ -91,14 +99,14 @@ * @type {Object}

module.exports.hints.context = {
task1: true,
task2: true,
task3: true,
task4: true,
task5: true,
task6: true,
task7: true,
task8: true,
task9: true,
task10: true,
task11: true,
task12: true
_task1: 1,
_task2: 1,
_task3: 1,
_task4: 1,
_task5: 1,
_task6: 1,
_task7: 1,
_task8: 1,
_task9: 1,
_task10: 1,
_task11: 1,
_task12: 1
};

@@ -112,14 +120,14 @@

{
task1: 1,
task2: 1,
task3: 1,
task4: 1,
task5: 1,
task6: 1,
task7: 1,
task8: 1,
task9: 1,
task10: 1,
task11: 1,
task12: 1
_task1: 1,
_task2: 1,
_task3: 1,
_task4: 1,
_task5: 1,
_task6: 1,
_task7: 1,
_task8: 1,
_task9: 1,
_task10: 1,
_task11: 1,
_task12: 1
}

@@ -126,0 +134,0 @@ ];

/**
* Flow with forward jumping
* Flow with forward jumping with Task.jump()
*

@@ -14,2 +14,10 @@ * @author Mohammad Fares <faressoft.com@gmail.com>

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* The state of the context object in each event loop tick

@@ -20,5 +28,5 @@ * @type {Array}

{},
{task1: 1},
{task11: 1},
{task12: 1}
{_task1: 1},
{_task11: 1},
{_task12: 1}
];

@@ -25,0 +33,0 @@

/**
* Flow with backward jumping
* Flow with backward jumping with Task.jump()
*

@@ -14,2 +14,10 @@ * @author Mohammad Fares <faressoft.com@gmail.com>

/**
* Flowa options
* @type {Object}
*/
module.exports.hints.options = {
autoInjectResults: false
};
/**
* The state of the context object in each event loop tick

@@ -20,15 +28,15 @@ * @type {Array}

{},
{task1: 1},
{task2: 1, task3: 1, task4: 1, task6: 1},
{task5: 1, task7: 1},
{task8: 1, task9: 1},
{task10: 1},
{task11: 1},
{task1: 2},
{task2: 2, task3: 2, task4: 2, task6: 2},
{task5: 2, task7: 2},
{task8: 2, task9: 2},
{task10: 2},
{task11: 2},
{task12: 1}
{_task1: 1},
{_task2: 1, _task3: 1, _task4: 1, _task6: 1},
{_task5: 1, _task7: 1},
{_task8: 1, _task9: 1},
{_task10: 1},
{_task11: 1},
{_task1: 2},
{_task2: 2, _task3: 2, _task4: 2, _task6: 2},
{_task5: 2, _task7: 2},
{_task8: 2, _task9: 2},
{_task10: 2},
{_task11: 2},
{_task12: 1}
];

@@ -35,0 +43,0 @@

@@ -7,5 +7,5 @@ /**

var chai = require('chai'),
sinon = require('sinon');
var Flowa = require('../../index.js');
var chai = require('chai'),
sinon = require('sinon');
var Flowa = require('../../index.js');
var expect = chai.expect;

@@ -12,0 +12,0 @@

@@ -7,8 +7,8 @@ /**

var chai = require('chai'),
var chai = require('chai'),
TicksTracer = require('ticks-tracer'),
sinon = require('sinon'),
_ = require('lodash');
var Flowa = require('../../index.js');
var expect = chai.expect;
sinon = require('sinon'),
_ = require('lodash');
var Flowa = require('../../index.js');
var expect = chai.expect;

@@ -28,2 +28,5 @@ /**

// The context status at each tick
var actualTimeline = [];
var runOptions = {

@@ -34,4 +37,5 @@ debug: true,

// The context status at each tick
var actualTimeline = [];
if (typeof sample.hints.options != 'undefined') {
_.defaults(runOptions, sample.hints.options);
}

@@ -38,0 +42,0 @@ describe('Flow', function() {

@@ -7,5 +7,5 @@ /**

var chai = require('chai'),
sinon = require('sinon');
var Flowa = require('../../index.js');
var chai = require('chai'),
sinon = require('sinon');
var Flowa = require('../../index.js');
var expect = chai.expect;

@@ -12,0 +12,0 @@

@@ -7,4 +7,5 @@ /**

var chai = require('chai');
var Flowa = require('../../index.js');
var chai = require('chai'),
_ = require('lodash');
var Flowa = require('../../index.js');
var expect = chai.expect;

@@ -19,8 +20,13 @@

var flowa = new Flowa(sample.flow, 'ping');
var context = {testing: true};
var runResult = flowa.run(context);
var runWithoutContextResult = flowa.run();
var flowa = new Flowa(sample.flow, 'ping');
var context = {};
var runOptions = {};
if (typeof sample.hints.options != 'undefined') {
_.defaults(runOptions, sample.hints.options);
}
var runResult = flowa.run(context, runOptions);
var runWithoutContextResult = flowa.run(undefined, runOptions);
describe('Output', function() {

@@ -30,3 +36,3 @@

return expect(runResult).to.eventually.equal(context);
return expect(runResult).to.eventually.equal(context).deep.equal(sample.hints.context);

@@ -37,3 +43,3 @@ });

return expect(runWithoutContextResult).to.eventually.be.an('object').that.has.all.keys(Object.keys(sample.hints.context));
return expect(runWithoutContextResult).to.eventually.be.an('object');

@@ -40,0 +46,0 @@ });

@@ -7,4 +7,4 @@ /**

var chai = require('chai');
var Flowa = require('../../index.js');
var chai = require('chai');
var Flowa = require('../../index.js');
var expect = chai.expect;

@@ -99,7 +99,7 @@

describe('_defaultType', function() {
describe('_defaultRunnerType', function() {
it('Should be the serial runner type', function() {
expect(flowa._defaultType).to.equal('serial');
expect(flowa._defaultRunnerType).to.equal('serial');

@@ -106,0 +106,0 @@ });

@@ -7,4 +7,4 @@ /**

var chai = require('chai');
var Flowa = require('../../index.js');
var chai = require('chai');
var Flowa = require('../../index.js');
var expect = chai.expect;

@@ -11,0 +11,0 @@

@@ -7,5 +7,5 @@ /**

var chai = require('chai'),
sinon = require('sinon');
var Flowa = require('../../index.js');
var chai = require('chai'),
sinon = require('sinon');
var Flowa = require('../../index.js');
var expect = chai.expect;

@@ -12,0 +12,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc