Skip to content
Browse files

change project name from react to autoflow

Facebook asked if I could rename my project to allow their
React to use the react npm name so I switched to autoflow
  • Loading branch information...
1 parent e649d9a commit 68727941e3406b211dbfaee9710f59b4c52f59dd @jeffbski committed Dec 9, 2013
View
4 Jakefile.js
@@ -24,12 +24,12 @@ function runRequireJs(argStr) {
desc('Create core single-file developer dist');
task('dist', function () {
- runRequireJs('-o src/dist.build.requirejs out=dist/react.js');
+ runRequireJs('-o src/dist.build.requirejs out=dist/autoflow.js');
});
desc('Create full single-file minified dist');
task('min', function () {
- runRequireJs('-o src/dist.build.requirejs out=dist/react.min.js optimize=uglify');
+ runRequireJs('-o src/dist.build.requirejs out=dist/autoflow.min.js optimize=uglify');
});
desc('Create all dist versions');
View
82 README.md
@@ -1,14 +1,14 @@
-# React.js
+# autoflow.js
[![Build Status](https://secure.travis-ci.org/jeffbski/react.png?branch=master)](http://travis-ci.org/jeffbski/react)
-React is a javascript module to make it easier to work with asynchronous code, by reducing boilerplate code and improving error and exception handling while allowing variable and task dependencies when defining flow. This project is applying the concepts of Reactive programming or Dataflow to controlling application flow.
+autoflow (formerly named react) is a javascript module to make it easier to work with asynchronous code, by reducing boilerplate code and improving error and exception handling while allowing variable and task dependencies when defining flow. This project is applying the concepts of Reactive programming or Dataflow to controlling application flow.
-This async flow control module is initially designed to work with Node.js but is planned to be extended to browser and other environments.
+This Async flow control module is initially designed to work with Node.js but is planned to be extended to browser and other environments.
-React gets its name from similarities with how "chain reactions" work in the physical world. You start the reaction and then it cascades and continues until complete.
+Autoflow (formerly named react) got its original name from similarities with how "chain reactions" work in the physical world. You start the reaction and then it cascades and continues until complete.
-Also "Reactive Programming" or "Dataflow" describe defining flow which reacts to the data similar to how a spreadsheet updates cells. These are good examples of how React controls flow based on when data is available
+Also "Reactive Programming" or "Dataflow" describe defining flow which reacts to the data similar to how a spreadsheet updates cells. These are good examples of how autoflow controls flow based on when data is available
- Reactive programming - <http://en.wikipedia.org/wiki/Reactive_programming>
- Dataflow programming - <http://en.wikipedia.org/wiki/Dataflow>
@@ -21,7 +21,7 @@ It takes inspiration from several projects including:
## Example Video and Comparison
-Ryan Atkinson did a nice job of demonstrating some of the power of react as compared to async and native callback code. http://www.youtube.com/embed/5EDucc56UnA?rel=0
+Ryan Atkinson did a nice job of demonstrating some of the power of autoflow (React) as compared to async and native callback code. http://www.youtube.com/embed/5EDucc56UnA?rel=0
[![Ryan Atkinson React Video](https://github.com/jeffbski/react/raw/master/doc/react-youtube-ryan.png)](http://www.youtube.com/embed/5EDucc56UnA?rel=0)
@@ -45,7 +45,7 @@ You can read more and see his example site here https://github.com/ryanatkn/reac
- object instance method calls
- class method calls
- selectFirst flow where the first task that returns defined, non-null value is used
- - promise style functions - also automatic resolution of promise inputs (optionally loaded with `react.resolvePromises();`)
+ - promise style functions - also automatic resolution of promise inputs (optionally loaded with `autoflow.resolvePromises();`)
- use of resulting flow function as callback style or promise style (if no callback provided) (provided via plugin corresponding to the promise library used) See https://github.com/jeffbski/react-deferred and https://github.com/jeffbski/react-q
- supports ES5 browsers (can work with others by using polyfills)
- (planned) iteration on arrays, streams, sockets
@@ -57,15 +57,15 @@ The tasks can be mixed, meaning you can use async, sync, object method calls, cl
## Concept
Borrowing heavily from Tim and Elijah's ideas for conductor, this async flow control module provides a way to construct a flow from a
-collection of rules based on functions or methods (referred to as _tasks_ in this module). It allows dependencies to be defined between the tasks so they can run in parallel as their dependencies are satisfied. React can us both variable dependencies and task dependencies.
+collection of rules based on functions or methods (referred to as _tasks_ in this module). It allows dependencies to be defined between the tasks so they can run in parallel as their dependencies are satisfied. autoflow can us both variable dependencies and task dependencies.
-As tasks complete, React watches the dependencies and kicks off additional tasks that have all their dependencies met and are ready to execute. This allows the flow to run at maximum speed without needing to arbitrarily block tasks into groups of parallel and serial flow.
+As Tasks complete, autoflow watches the dependencies and kicks off additional tasks that have all their dependencies met and are ready to execute. This allows the flow to run at maximum speed without needing to arbitrarily block tasks into groups of parallel and serial flow.
-To reduce the boilerplate code needed and improve error handling, React automatically provides callback functions for your asynchronous code. These React-provided callback functions perform these steps:
+To Reduce the boilerplate code needed and improve error handling, autoflow automatically provides callback functions for your asynchronous code. These autoflow-provided callback functions perform these steps:
- 1. check for error and handle by calling outer callback function with this error after augmenting it with additional context information for easier debugging
+ 1. Check for error and handle by calling outer callback function with this error after augmenting it with additional context information for easier debugging
2. save the callback variables into a context for future reference
- 3. call back into React (and it will kick off additional tasks that are now ready to go)
+ 3. call back into autoflow (and it will kick off additional tasks that are now ready to go)
4. Using the dependencies specified for each
## Design
@@ -76,7 +76,7 @@ To reduce the boilerplate code needed and improve error handling, React automati
## Installing
- npm install react
+ npm install autoflow
OR
@@ -101,7 +101,7 @@ Pull from github - http://github.com/jeffbski/react
```javascript
// in your foobar module
-var react = require('react');
+var autoflow = require('autoflow');
// some normal async and sync functions
function loadFoo(fooPath, cb) {
@@ -120,15 +120,15 @@ function render(foo, bar) {
return ['<html>', foo, '/', bar, '</html>'].join('');
}
-// define fn, glue together with react, it will parallelize
+// define fn, glue together with autoflow, it will parallelize
// starts with name and in/out params, then the tasks
-var loadRender = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
+var loadRender = autoflow('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
loadFoo, 'fooPath, cb -> err, foo', // async cb function
loadBar, 'barPath, barP2, cb -> err, bar', // async cb function
render, 'foo, bar -> renderedOut' // sync function using outputs from first two
);
-exports.loadRender = loadRender; // is a normal fn created by react
+exports.loadRender = loadRender; // is a normal fn created by autoflow
// in a different module far far away, use this as any other node function
@@ -139,9 +139,9 @@ foobar.loadRender('foo.txt', 'bar.txt', 'BBB', function (err, renderedOut) {
});
```
-Below is a graph of how the dependencies are mapped by React which
-also indicates how the tasks will be executed. This was generated by the
-react plugin [react-graphviz](https://github.com/jeffbski/react-graphviz)
+Below is a graph of how the dependencies are mapped by autoflow which
+Also Indicates how the tasks will be executed. This was generated by the
+autoflow plugin [react-graphviz](https://github.com/jeffbski/react-graphviz)
which you can use to also graph your flows.
![simple.png](https://github.com/jeffbski/react/raw/master/doc/simple.png)
@@ -150,12 +150,12 @@ which you can use to also graph your flows.
## User API
-The main function returned from require('react') can be used to define the AST used for the processing of the rules or flow.
+The main function returned from require('autoflow') can be used to define the AST used for the processing of the rules or flow.
It takes the following arguments to define a flow function:
```javascript
-var fn = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
+var fn = autoflow('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
loadFoo, 'fooPath, cb -> err, foo',
loadBar, 'barPath, barP2, cb -> err, bar',
render, 'foo, bar -> renderedOut'
@@ -164,33 +164,33 @@ var fn = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
![color-def](https://github.com/jeffbski/react/raw/master/doc/color-def.png)
- 1. **flow/function name** - string - represents the name of the flow or function that will be created. React will use the name when generating events so you can monitor progress and performance and also when errors occur.
- 2. **in/out flow parameter definition** - string - the inputs and outputs for the flow function. The parameters are specified in one single string for easy typing, separated by commas. The output follows the input after being separated by a `->`. Use the parameter name `cb` or `callback` to specify the Node style callback and `err` to represent the error parameter as the first output parameter of the callback. Literal values can also be specified directly (true, false, numbers, this, null). Literal strings can simply be quoted using single or double quotes.
- 3. **optional flow options** - object - If an object is provided immediately after the in/out flow def, then these options will be provided to react to customize the flow. The `locals` property can contain an object map of any local variables you want to reference in the flow (other than what is passed in as parameters). For example: `{ locals: { foo: foo, bar: bar }}` would make local vars available in the flow. Note that global variables are already available in the flow.
+ 1. **flow/function name** - string - represents the name of the flow or function that will be created. autoflow will use the name when generating events so you can monitor progress and performance and also when errors occur.
+ 2. **In/out flow parameter definition** - string - the inputs and outputs for the flow function. The parameters are specified in one single string for easy typing, separated by commas. The output follows the input after being separated by a `->`. Use the parameter name `cb` or `callback` to specify the Node style callback and `err` to represent the error parameter as the first output parameter of the callback. Literal values can also be specified directly (true, false, numbers, this, null). Literal strings can simply be quoted using single or double quotes.
+ 3. **optional flow options** - object - If an object is provided immediately after the in/out flow def, then these options will be provided to autoflow to customize the flow. The `locals` property can contain an object map of any local variables you want to reference in the flow (other than what is passed in as parameters). For example: `{ locals: { foo: foo, bar: bar }}` would make local vars available in the flow. Note that global variables are already available in the flow.
4. **function reference or method string** - Specify the function to be called for this task, or if calling a method off of an object being passed in or returned by a task, use a string to specify like `'obj.method'`. These can be asynchronous Node-style callback `cb(err, ...)` functions or synchronous functions which simply return values directly.
- 5. **in/out task parameter definition** - string - similar to the in/out flow parameter definition above, these are the inputs and outputs that are passed to a task function and returned from a task function. The inputs will need to match either those from the flow inputs or outputs from other tasks that will run before this task. React will use the inputs as dependencies, so it will invoke and wait for response from the tasks that provide the dependent inputs. So simply by specifying inputs and outputs for the tasks, React will prioritize and parallelize tasks to run as fast as possible. Use `cb` or `callback` along with `err` to specify asynchronous Node style `cb(err, ...)` task, or omit both to specify a synchronous task.A synchronous task can only have a single return parameter.
- 6. **optional task options** - object - if an object is provided this can be used to specify additional options for this task. Currently the valid options for a task are:
- - **name** - string - specifies a name for a task, otherwise React will try to use the function name or method string if it is unique in the flow. If a name is not unique subsequent tasks will have `_index` (zero based index of the task) added to create unique name. If you specify a name, you will also want to indicate a unique name for within the flow otherwise it will get a suffix as well. Example: `{ name: 'myTaskName' }`
+ 5. **in/out task parameter definition** - string - similar to the in/out flow parameter definition above, these are the inputs and outputs that are passed to a task function and returned from a task function. The inputs will need to match either those from the flow inputs or outputs from other tasks that will run before this task. autoflow will use the inputs as dependencies, so it will invoke and wait for response from the tasks that provide the dependent inputs. So simply by specifying inputs and outputs for the tasks, autoflow will prioritize and parallelize tasks to run as fast as possible. Use `cb` or `callback` along with `err` to specify asynchronous Node style `cb(err, ...)` task, or omit both to specify a synchronous task.A synchronous task can only have a single return parameter.
+ 6. **Optional task options** - object - if an object is provided this can be used to specify additional options for this task. Currently the valid options for a task are:
+ - **name** - string - specifies a name for a task, otherwise autoflow will try to use the function name or method string if it is unique in the flow. If a name is not unique subsequent tasks will have `_index` (zero based index of the task) added to create unique name. If you specify a name, you will also want to indicate a unique name for within the flow otherwise it will get a suffix as well. Example: `{ name: 'myTaskName' }`
- **after** - string, function reference, or array of string or function refs - specify additional preconditions that need to be complete before this task can run. In addition to the input dependencies being met, wait for these named tasks to complete before running. The preconditions are specified using the name of the task or if the task function was only used once and is a named function (not anonymous), you can just provide the function reference and it will determine name from it. Example: `{ after: 'foo' }` or `{ after: ['foo', 'bar'] }`
- 7. **repeat 4-6** - repeat steps 4-6 to specify additional tasks in this flow. As dependencies are met for tasks, React will invoke additional tasks that are ready to run in the order they are defined in this flow definition. So while the order does have some influence on the execution, it is primarily defined by the input dependencies and any other additonal preconditions specified with the `after` option. If you want to guarantee that something only runs after something else completes, then it will need to use an output from that task or specify the dependency with an `after`.
+ 7. **repeat 4-6** - repeat steps 4-6 to specify additional tasks in this flow. As dependencies are met for tasks, autoflow will invoke additional tasks that are ready to run in the order they are defined in this flow definition. So while the order does have some influence on the execution, it is primarily defined by the input dependencies and any other additonal preconditions specified with the `after` option. If you want to guarantee that something only runs after something else completes, then it will need to use an output from that task or specify the dependency with an `after`.
-The flow function created by react from the input definition is a normal Node-style function which can be used like any other. These flow functions can be defined in a module and exported, they can be passed into other functions, used as methods on objects (the `this` context is passed in and available).
+The Flow function created by autoflow from the input definition is a normal Node-style function which can be used like any other. These flow functions can be defined in a module and exported, they can be passed into other functions, used as methods on objects (the `this` context is passed in and available).
-### Debugging React
+### Debugging autoflow
-React has a built-in plugin which can be loaded that will enable logging of tasks and flow as it executes very useful for debugging. For full details see [Advanced React - LogEvents](https://github.com/jeffbski/react/blob/master/doc/advanced.md#LogEvents) along with the other plugins and an explanation of the AST React uses.
+autoflow has a built-in plugin which can be loaded that will enable logging of tasks and flow as it executes very useful for debugging. For full details see [Advanced autoflow - LogEvents](https://github.com/jeffbski/react/blob/master/doc/advanced.md#LogEvents) along with the other plugins and an explanation of the AST autoflow uses.
-```javascript
-var react = require('react');
-react.logEvents(); // turn on flow and task logging for all react functions
+```Javascript
+var autoflow = require('autoflow');
+react.logEvents(); // turn on flow and task logging for all autoflow functions
```
-### Advanced React
+### Advanced autoflow
-React has many additional plugins and features which enable logging, monitoring, promise resolution, etc.
+autoflow has many additional plugins and features which enable logging, monitoring, promise resolution, etc.
-See the [Advanced React](https://github.com/jeffbski/react/blob/master/doc/advanced.md) for details on the AST React uses for processing and other plugins that are available.
+See The [Advanced autoflow](https://github.com/jeffbski/react/blob/master/doc/advanced.md) for details on the AST autoflow uses for processing and other plugins that are available.
@@ -202,17 +202,17 @@ See the [Advanced React](https://github.com/jeffbski/react/blob/master/doc/advan
- 2012-09-12 - Upgrade RequireJS@2.0.6, mocha@1.4.2, chai@1.2.0, jake@0.3.16. Update travis config to include Node 0.8 (v0.6.2)
- 2012-04-25 - Browser compatibility issue with process check, (v0.6.1)
- 2012-04-05 - Remove dependency on sprint, use util.format
- - 2012-03-28 - Make react AMD-enabled and compatible with ES5 browsers and node.js, provide single file dist and min, add browser tests (v0.6.0)
+ - 2012-03-28 - Make autoflow AMD-enabled and compatible with ES5 browsers and node.js, provide single file dist and min, add browser tests (v0.6.0)
- 2012-03-24 - Add Travis-CI, remove promised-io since failing to install in travis-ci for node 0.6/0.7, switch from tap to mocha/chai
- 2012-03-12 - Pass ast.define events to process (v0.5.2)
- 2012-01-18 - Remove old DSL interfaces, improve plugin loading, log flow name with task name, ast.defined event, test with node 0.7.0 (v0.5.1)
- 2012-01-17 - Additional documentation (v0.3.5)
- 2012-01-16 - Refine events and create logging plugin (v0.3.3)
- 2012-01-13 - Add promise tasks, promise resolution, refactor alternate DSL interfaces as optional requires (v0.3.0)
- 2012-01-11 - Provide warning/error when name is skipped in default DSL, literal check in validate (v0.2.5)
- - 2012-01-10 - Create default DSL for react(), create error for missing variables, list remaining tasks when flow won't complete
+ - 2012-01-10 - Create default DSL for autoflow(), create error for missing variables, list remaining tasks when flow won't complete
- 2011-12-21 - Refactor from ground up with tests, changes to the interfaces
- - 2011-10-26 - React is in active development and interface may change frequently in these early stages. Current code is functional but does not perform validation yet. Additional interfaces are planned to make it easy to define flows in a variety of ways. Documentation and examples forthcoming.
+ - 2011-10-26 - autoflow is in active development and interface may change frequently in these early stages. Current code is functional but does not perform validation yet. Additional interfaces are planned to make it easy to define flows in a variety of ways. Documentation and examples forthcoming.
## Test Results
View
22 browser-test/dist.html
@@ -13,31 +13,31 @@
baseUrl: "..",
packages: [
{
- name: "react",
+ name: "autoflow",
location: "dist",
- main: "react"
+ main: "autoflow"
}
],
paths: {
jQuery: "vendor/jquery/jquery-1.7.1",
- eventemitter2: "dist/react",
- util: "dist/react",
- "ensure-array": "dist/react",
+ eventemitter2: "dist/autoflow",
+ util: "dist/autoflow",
+ "ensure-array": "dist/autoflow",
test: "test"
}
});
- require(["react", "jQuery"],
- function (react, jquery) {
+ require(["autoflow", "jQuery"],
+ function (autoflow, jquery) {
- require(["react/sprintf", "react/validate", "react/task", "react/cb-task",
- "react/vcon", "react/event-manager", "react/input-parser",
- "react/base-task", "react/ret-task", "util"],
+ require(["autoflow/sprintf", "autoflow/validate", "autoflow/task", "autoflow/cb-task",
+ "autoflow/vcon", "autoflow/event-manager", "autoflow/input-parser",
+ "autoflow/base-task", "autoflow/ret-task", "util"],
function (sprintf, validate, taskUtil, CbTask,
VContext, EventManager, inputParser,
BaseTask, RetTask, util) {
// save refs on window for these
- window.react = react;
+ window.autoflow = autoflow;
window.sprintf = sprintf;
window.util = util;
window.validate = validate;
View
14 browser-test/index.html
@@ -13,9 +13,9 @@
baseUrl: "..",
packages: [
{
- name: "react",
+ name: "autoflow",
location: "lib",
- main: "react"
+ main: "autoflow"
}
],
paths: {
@@ -27,14 +27,14 @@
}
});
- require(["react", "react/sprintf", "util", "react/validate", "react/task",
- "react/cb-task", "react/vcon", "react/event-manager", "react/input-parser",
- "react/base-task", "react/ret-task", "react/validate", "jquery"],
- function (react, sprintf, util, validate, taskUtil,
+ require(["autoflow", "autoflow/sprintf", "util", "autoflow/validate", "autoflow/task",
+ "autoflow/cb-task", "autoflow/vcon", "autoflow/event-manager", "autoflow/input-parser",
+ "autoflow/base-task", "autoflow/ret-task", "autoflow/validate", "jquery"],
+ function (autoflow, sprintf, util, validate, taskUtil,
CbTask, VContext, EventManager, inputParser,
BaseTask, RetTask, validate, jquery) {
// save refs on window for these
- window.react = react;
+ window.autoflow = autoflow;
window.sprintf = sprintf;
window.util = util;
window.validate = validate;
View
22 browser-test/min.html
@@ -13,31 +13,31 @@
baseUrl: "..",
packages: [
{
- name: "react",
+ name: "autoflow",
location: "dist",
- main: "react.min"
+ main: "autoflow.min"
}
],
paths: {
jQuery: "vendor/jquery/jquery-1.7.1.min",
- eventemitter2: "dist/react.min",
- util: "dist/react.min",
- "ensure-array": "dist/react.min",
+ eventemitter2: "dist/autoflow.min",
+ util: "dist/autoflow.min",
+ "ensure-array": "dist/autoflow.min",
test: "test"
}
});
- require(["react", "jQuery"],
- function (react, jquery) {
+ require(["autoflow", "jQuery"],
+ function (autoflow, jquery) {
- require(["react/sprintf", "react/validate", "react/task", "react/cb-task",
- "react/vcon", "react/event-manager", "react/input-parser",
- "react/base-task", "react/ret-task", "util"],
+ require(["autoflow/sprintf", "autoflow/validate", "autoflow/task", "autoflow/cb-task",
+ "autoflow/vcon", "autoflow/event-manager", "autoflow/input-parser",
+ "autoflow/base-task", "autoflow/ret-task", "util"],
function (sprintf, validate, taskUtil, CbTask,
VContext, EventManager, inputParser,
BaseTask, RetTask, util) {
// save refs on window for these
- window.react = react;
+ window.autoflow = autoflow;
window.sprintf = sprintf;
window.util = util;
window.validate = validate;
View
206 dist/react.js → dist/autoflow.js
@@ -564,7 +564,7 @@
-define('react/eventemitter',['eventemitter2'], function (EventEmitterMod) {
+define('autoflow/eventemitter',['eventemitter2'], function (EventEmitterMod) {
/**
@@ -1111,7 +1111,7 @@ exports._extend = function(origin, add) {
-define('react/error',['util'], function (util) {
+define('autoflow/error',['util'], function (util) {
function ensureStackTraceLimitSet(stackTraceLimit) {
@@ -1164,7 +1164,7 @@ define('react/error',['util'], function (util) {
-define('react/sprintf',['util'], function (util) {
+define('autoflow/sprintf',['util'], function (util) {
/**
@@ -1211,7 +1211,7 @@ define('react/sprintf',['util'], function (util) {
-define('react/status',[], function () {
+define('autoflow/status',[], function () {
var STATUS = { READY: 'ready', RUNNING: 'running', ERRORED: 'errored', COMPLETE: 'complete' };
@@ -1223,7 +1223,7 @@ define('react/status',[], function () {
-define('react/event-manager',['./eventemitter'], function (EventEmitter) {
+define('autoflow/event-manager',['./eventemitter'], function (EventEmitter) {
/*jshint regexp:false */
@@ -1310,7 +1310,7 @@ define('react/event-manager',['./eventemitter'], function (EventEmitter) {
-define('react/base-task',['ensure-array', './status', './event-manager'],
+define('autoflow/base-task',['ensure-array', './status', './event-manager'],
function (array, STATUS, EventManager) {
@@ -1429,7 +1429,7 @@ define('react/base-task',['ensure-array', './status', './event-manager'],
-define('react/cb-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
+define('autoflow/cb-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
function format_error(errmsg, obj) {
@@ -1512,7 +1512,7 @@ define('react/cb-task',['util', './sprintf', './base-task'], function (util, spr
-define('react/promise-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
+define('autoflow/promise-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
/**
@@ -1603,7 +1603,7 @@ define('react/promise-task',['util', './sprintf', './base-task'], function (util
-define('react/ret-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
+define('autoflow/ret-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
function format_error(errmsg, obj) {
@@ -1672,7 +1672,7 @@ define('react/ret-task',['util', './sprintf', './base-task'], function (util, sp
-define('react/when-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
+define('autoflow/when-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
/**
@@ -1754,7 +1754,7 @@ define('react/when-task',['util', './sprintf', './base-task'], function (util, s
-define('react/finalcb-task',['./sprintf', 'util', './status', './event-manager'],
+define('autoflow/finalcb-task',['./sprintf', 'util', './status', './event-manager'],
function (sprintf, util, STATUS, EventManager) {
@@ -1817,7 +1817,7 @@ define('react/finalcb-task',['./sprintf', 'util', './status', './event-manager']
-define('react/vcon',[], function () {
+define('autoflow/vcon',[], function () {
var LAST_RESULTS_KEY = ':LAST_RESULTS';
@@ -1929,7 +1929,7 @@ define('react/vcon',[], function () {
-define('react/finalcb-first-task',['./sprintf', 'util', './status', './vcon', './event-manager'],
+define('autoflow/finalcb-first-task',['./sprintf', 'util', './status', './vcon', './event-manager'],
function (sprintf, util, STATUS, VContext, EventManager) {
@@ -1995,7 +1995,7 @@ define('react/finalcb-first-task',['./sprintf', 'util', './status', './vcon', '.
-define('react/task',['util', './sprintf', 'ensure-array', './cb-task', './promise-task',
+define('autoflow/task',['util', './sprintf', 'ensure-array', './cb-task', './promise-task',
'./ret-task', './when-task', './finalcb-task', './finalcb-first-task',
'./status', './error', './vcon', './event-manager'],
function (util, sprintf, array, CbTask, PromiseTask,
@@ -2244,7 +2244,7 @@ function (util, sprintf, array, CbTask, PromiseTask,
-define('react/validate',['util', './sprintf', 'ensure-array', './task'], function (util, sprintf, array, taskUtil) {
+define('autoflow/validate',['util', './sprintf', 'ensure-array', './task'], function (util, sprintf, array, taskUtil) {
/*jshint latedef:false */
@@ -2401,11 +2401,11 @@ define('react/validate',['util', './sprintf', 'ensure-array', './task'], functio
-define('react/input-parser',['./event-manager'], function (EventManager) {
+define('autoflow/input-parser',['./event-manager'], function (EventManager) {
var defaultExecOptions = {
- reactExecOptions: true,
+ autoflowExecOptions: true,
outputStyle: 'cb',
};
@@ -2414,7 +2414,7 @@ define('react/input-parser',['./event-manager'], function (EventManager) {
NONE: 'none'
};
- function isExecOptions(x) { return (x && x.reactExecOptions); }
+ function isExecOptions(x) { return (x && x.autoflowExecOptions); }
function execOptionsFilter(x) { return isExecOptions(x); }
function nonExecOptionsFilter(x) { return !isExecOptions(x); }
function mergeExecOptions(accum, options) {
@@ -2455,7 +2455,7 @@ define('react/input-parser',['./event-manager'], function (EventManager) {
-define('react/id',[], function () {
+define('autoflow/id',[], function () {
var startingId = 0;
@@ -2475,24 +2475,24 @@ define('react/id',[], function () {
-define('react/core',['./eventemitter', './error', './validate', './task', './status',
+define('autoflow/core',['./eventemitter', './error', './validate', './task', './status',
'./vcon', './event-manager', './input-parser', './id', './sprintf'],
function (EventEmitter, error, validate, taskUtil, STATUS,
VContext, EventManager, inputParser, idGenerator, sprintf) {
- var reactOptions = {
+ var autoflowOptions = {
stackTraceLimitMin: 30
};
- var reactEmitter = EventManager.global; // the top emitter
+ var autoflowEmitter = EventManager.global; // the top emitter
/**
- merge global react options with parsed options
+ merge global autoflow options with parsed options
*/
function mergeOptions(parsedOptions) {
- return Object.keys(reactOptions).reduce(function (accum, k) {
- if (!accum[k]) accum[k] = reactOptions[k];
+ return Object.keys(autoflowOptions).reduce(function (accum, k) {
+ if (!accum[k]) accum[k] = autoflowOptions[k];
return accum;
}, parsedOptions);
}
@@ -2505,13 +2505,13 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
}
/**
- Creates react function which the AST can be manipulated and then
+ Creates autoflow function which the AST can be manipulated and then
is ready to be executed. Can be used directly or a DSL can wrap this
to provide the AST.
@example
- var react = require('react');
- var fn = react();
+ var autoflow = require('autoflow');
+ var fn = autoflow();
var valid2 = fn.setAndValidateAST({
name: 'optionalName',
inParams: ['a', 'b'],
@@ -2523,12 +2523,12 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
console.log(fn.ast); // view
fn(123, 456, cb);
*/
- function reactFactory() {
- if (arguments.length) throw new Error('react() takes no args, check API');
+ function autoflowFactory() {
+ if (arguments.length) throw new Error('autoflow() takes no args, check API');
- error.ensureStackTraceLimitSet(reactOptions.stackTraceLimitMin);
+ error.ensureStackTraceLimitSet(autoflowOptions.stackTraceLimitMin);
var flowEmitter = EventManager.create();
- flowEmitter.parent = reactEmitter;
+ flowEmitter.parent = autoflowEmitter;
var ast = {
name: undefined,
@@ -2574,7 +2574,7 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
env.vCon = vCon;
env.taskDefs = ast.tasks.slice(); // create copy
env.outTaskDef = Object.create(ast.outTask); // create copy
- reactEmitter.emit(EventManager.TYPES.EXEC_TASKS_PRECREATE, env); // hook
+ autoflowEmitter.emit(EventManager.TYPES.EXEC_TASKS_PRECREATE, env); // hook
var tasks = env.taskDefs.map(taskUtil.create);
var tasksByName = taskUtil.nameTasks(tasks); // map names to working tasks
@@ -2596,22 +2596,22 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
return outTask.retValue; // could return promise
}
- var reactFn = exec; // make the exec() the function returned
- reactFn.ast = ast; // put AST hanging off the fn so it can be inspected
- reactFn.setAndValidateAST = setAndValidateAST; // call to set AST and then validate
- reactFn.events = flowEmitter; // used to listen to execution events for this flow
- return reactFn;
+ var autoflowFn = exec; // make the exec() the function returned
+ autoflowFn.ast = ast; // put AST hanging off the fn so it can be inspected
+ autoflowFn.setAndValidateAST = setAndValidateAST; // call to set AST and then validate
+ autoflowFn.events = flowEmitter; // used to listen to execution events for this flow
+ return autoflowFn;
}
- reactFactory.options = reactOptions; // global react options
- reactFactory.events = reactEmitter; // global react emitter
- return reactFactory; // module returns reactFactory to create a react fn
+ autoflowFactory.options = autoflowOptions; // global autoflow options
+ autoflowFactory.events = autoflowEmitter; // global autoflow emitter
+ return autoflowFactory; // module returns autoflowFactory to create a autoflow fn
});
/*global define:true */
-define('react/parse',['./sprintf'], function (sprintf) {
+define('autoflow/parse',['./sprintf'], function (sprintf) {
function splitTrimFilterArgs(commaSepArgs) { //parse 'one, two' into ['one', 'two']
@@ -2651,7 +2651,7 @@ define('react/parse',['./sprintf'], function (sprintf) {
-define('react/dsl',['./sprintf', './core', './parse', './task'],
+define('autoflow/dsl',['./sprintf', './core', './parse', './task'],
function (sprintf, core, parse, taskUtil) {
/*jshint regexp: false */
@@ -2740,7 +2740,7 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
function dslDefine(name, arg1, arg2, argN) {
- var reactFn = core();
+ var autoflowFn = core();
if (name && INOUT_RE.test(name)) throw new Error(sprintf(MISSING_NAME, name));
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
var inOutDef = parseInOutParams(defObj.inOutParamStr);
@@ -2751,16 +2751,16 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
outTask: { a: inOutDef.outDef }
};
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
- var errors = reactFn.setAndValidateAST(ast);
+ var errors = autoflowFn.setAndValidateAST(ast);
if (errors.length) {
var errorStr = errors.join('\n');
throw new Error(errorStr);
}
- return reactFn;
+ return autoflowFn;
}
function selectFirst(name, arg1, arg2, argN) {
- var reactFn = core();
+ var autoflowFn = core();
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
var inOutDef = parseInOutParams(defObj.inOutParamStr);
var tasks = taskUtil.serializeTasks(parseTasks(defObj.taskDefArr));
@@ -2771,12 +2771,12 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
outTask: { type: 'finalcbFirst', a: inOutDef.outDef },
};
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
- var errors = reactFn.setAndValidateAST(ast);
+ var errors = autoflowFn.setAndValidateAST(ast);
if (errors.length) {
var errorStr = errors.join('\n');
throw new Error(errorStr);
}
- return reactFn;
+ return autoflowFn;
}
dslDefine.selectFirst = selectFirst;
@@ -2787,7 +2787,7 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
-define('react/track-tasks',[], function () {
+define('autoflow/track-tasks',[], function () {
/**
@@ -2805,49 +2805,49 @@ define('react/track-tasks',[], function () {
- emits flow errored with flowEnv
@example
- var react = require('react');
- react.trackTasks(); // enable task and flow tracking
+ var autoflow = require('autoflow');
+ autoflow.trackTasks(); // enable task and flow tracking
*/
var trackingTasks = false;
- function trackTasks(react) {
+ function trackTasks(autoflow) {
if (trackingTasks) return; // already tracking
trackingTasks = true;
- react.events.on(react.events.TYPES.EXEC_FLOW_START, function (env) {
+ autoflow.events.on(autoflow.events.TYPES.EXEC_FLOW_START, function (env) {
env.startTime = Date.now();
- env.flowEmitter.emit(react.events.TYPES.FLOW_BEGIN, env); //fire public ev
+ env.flowEmitter.emit(autoflow.events.TYPES.FLOW_BEGIN, env); //fire public ev
});
- react.events.on(react.events.TYPES.EXEC_TASK_START, function (task) {
+ autoflow.events.on(autoflow.events.TYPES.EXEC_TASK_START, function (task) {
task.startTime = Date.now();
- task.env.flowEmitter.emit(react.events.TYPES.TASK_BEGIN, task); //fire public ev
+ task.env.flowEmitter.emit(autoflow.events.TYPES.TASK_BEGIN, task); //fire public ev
});
- react.events.on(react.events.TYPES.EXEC_TASK_COMPLETE, function (task) {
+ autoflow.events.on(autoflow.events.TYPES.EXEC_TASK_COMPLETE, function (task) {
task.endTime = Date.now();
task.elapsedTime = task.endTime - task.startTime;
- task.env.flowEmitter.emit(react.events.TYPES.TASK_COMPLETE, task); // fire public ev
+ task.env.flowEmitter.emit(autoflow.events.TYPES.TASK_COMPLETE, task); // fire public ev
});
- react.events.on(react.events.TYPES.EXEC_TASK_ERRORED, function (task) {
+ autoflow.events.on(autoflow.events.TYPES.EXEC_TASK_ERRORED, function (task) {
task.endTime = Date.now();
task.elapsedTime = task.endTime - task.startTime;
- task.env.flowEmitter.emit(react.events.TYPES.TASK_ERRORED, task); // fire public ev
+ task.env.flowEmitter.emit(autoflow.events.TYPES.TASK_ERRORED, task); // fire public ev
});
- react.events.on(react.events.TYPES.EXEC_FLOW_COMPLETE, function (env) {
+ autoflow.events.on(autoflow.events.TYPES.EXEC_FLOW_COMPLETE, function (env) {
env.endTime = Date.now();
env.elapsedTime = env.endTime - env.startTime;
- env.flowEmitter.emit(react.events.TYPES.FLOW_COMPLETE, env); //fire public ev
+ env.flowEmitter.emit(autoflow.events.TYPES.FLOW_COMPLETE, env); //fire public ev
});
- react.events.on(react.events.TYPES.EXEC_FLOW_ERRORED, function (env) {
+ autoflow.events.on(autoflow.events.TYPES.EXEC_FLOW_ERRORED, function (env) {
env.endTime = Date.now();
env.elapsedTime = env.endTime - env.startTime;
- env.flowEmitter.emit(react.events.TYPES.FLOW_ERRORED, env); //fire public ev
+ env.flowEmitter.emit(autoflow.events.TYPES.FLOW_ERRORED, env); //fire public ev
});
}
@@ -2859,7 +2859,7 @@ define('react/track-tasks',[], function () {
-define('react/log-events',['util'], function (util) { // TODO replace util.inspect with something portable to browser
+define('autoflow/log-events',['util'], function (util) { // TODO replace util.inspect with something portable to browser
var logEventsMod = { };
@@ -2868,11 +2868,11 @@ define('react/log-events',['util'], function (util) { // TODO replace util.inspe
Log events to console.error
@example
- var react = require('react');
- react.logEvents(); // log all task and flow events on all react functions
- react.logEvents('task.*'); // log all task events on all react functions
- react.logEvents(flowFn); // log all task and flow events on flowFn only
- react.logEvents(flowFn, 'flow.*'); // log all flow events on flowFn only
+ var autoflow = require('autoflow');
+ autoflow.logEvents(); // log all task and flow events on all autoflow functions
+ autoflow.logEvents('task.*'); // log all task events on all autoflow functions
+ autoflow.logEvents(flowFn); // log all task and flow events on flowFn only
+ autoflow.logEvents(flowFn, 'flow.*'); // log all flow events on flowFn only
*/
var ALL_FLOW_EVENTS = 'flow.*';
@@ -2915,15 +2915,15 @@ define('react/log-events',['util'], function (util) { // TODO replace util.inspe
}
/**
- Log flow and task events for a flowFn or all of react.
+ Log flow and task events for a flowFn or all of autoflow.
If called multiple times, remove previous listener (if any) before
adding.
@example
- var react = require('react');
- react.logEvents(flowFn, eventWildcard); //log events on flowfn matching wildcard
+ var autoflow = require('autoflow');
+ autoflow.logEvents(flowFn, eventWildcard); //log events on flowfn matching wildcard
- @param flowFn Flow function or global react object
+ @param flowFn Flow function or global autoflow object
@param eventWildcard wildcarded event type, if not provided use flow.* and task.*
*/
function logEvents(flowFn, eventWildcard) {
@@ -2958,7 +2958,7 @@ define('react/log-events',['util'], function (util) { // TODO replace util.inspe
-define('react/promise-resolve',[], function () {
+define('autoflow/promise-resolve',[], function () {
/**
@@ -2975,11 +2975,11 @@ define('react/promise-resolve',[], function () {
var resolvingPromises = false;
- function resolvePromises(react) {
+ function resolvePromises(autoflow) {
if (resolvingPromises) return; // already resolving
resolvingPromises = true;
- react.events.on(react.events.TYPES.EXEC_TASKS_PRECREATE, function (env) {
+ autoflow.events.on(autoflow.events.TYPES.EXEC_TASKS_PRECREATE, function (env) {
var vConValues = env.vCon.values;
var promiseParams = env.ast.inParams.filter(function (p) {
var value = vConValues[p];
@@ -3006,14 +3006,14 @@ define('react/promise-resolve',[], function () {
-define('react/event-collector',[], function () {
+define('autoflow/event-collector',[], function () {
/**
create an instance of the event collector
*/
- function instantiate(react) {
- react.trackTasks(); // enable task tracking
+ function instantiate(autoflow) {
+ autoflow.trackTasks(); // enable task tracking
var AST_EVENTS_RE = /^ast\./;
var TASK_EVENTS_RE = /^task\./;
@@ -3023,10 +3023,10 @@ define('react/event-collector',[], function () {
Accumulator to make it easy to capture events
@example
- var react = require('react');
- var collector = react.createEventCollector();
- collector.capture(); // capture all flow and task events for all react flows
- collector.capture('flow.*'); // capture all flow events for all react flows
+ var autoflow = require('autoflow');
+ var collector = autoflow.createEventCollector();
+ collector.capture(); // capture all flow and task events for all autoflow flows
+ collector.capture('flow.*'); // capture all flow events for all autoflow flows
collector.capture(flowFn, 'task.*'); // capture task events on a flow
collector.capture(flowFn, 'flow.*'); // add capture flow events on a flow
var events = collector.list(); // retrieve the list of events
@@ -3038,15 +3038,15 @@ define('react/event-collector',[], function () {
/**
register listener to capture events for a specific flow
- @param flowFn the react flow function or can pass global react
+ @param flowFn the autoflow flow function or can pass global autoflow
@param eventId event id or wildcarded id
*/
EventCollector.prototype.capture = function (flowFn, eventId) {
/*jshint validthis: true */
if (!eventId && typeof(flowFn) === 'string') { // only eventId provided
eventId = flowFn;
- flowFn = react; // global react
- } else if (!flowFn) flowFn = react; // global react
+ flowFn = autoflow; // global autoflow
+ } else if (!flowFn) flowFn = autoflow; // global autoflow
if (!eventId) eventId = '*'; // default to all
var emitter = flowFn.events;
var self = this;
@@ -3085,39 +3085,39 @@ define('react/event-collector',[], function () {
-define('react/react',['./core', './dsl', './track-tasks', './log-events', './promise-resolve', './event-collector'],
+define('autoflow/autoflow',['./core', './dsl', './track-tasks', './log-events', './promise-resolve', './event-collector'],
function (core, dsl, trackTasksFn, logEventsMod, resolvePromisesFn, eventCollectorFactory) {
- var react = dsl; // core + default dsl
+ var autoflow = dsl; // core + default dsl
/**
Enable detection of promises and resolution
*/
function resolvePromises() {
- resolvePromisesFn(react);
+ resolvePromisesFn(autoflow);
}
/**
Enable tracking of tasks and flow execution, emitting events and
tracking start, end, elapsed time
*/
function trackTasks() {
- trackTasksFn(react);
+ trackTasksFn(autoflow);
}
/**
If called, load the built-in plugin for log events and invoke
- @param flowFn [function] if not provided uses global react
+ @param flowFn [function] if not provided uses global autoflow
@param eventWildcard [string] pattern to log events for
*/
function logEvents(flowFn, eventWildcard) {
if (typeof(flowFn) !== 'function') { // only wildcard provided
eventWildcard = flowFn;
flowFn = undefined;
}
- if (!flowFn) flowFn = react; // use global
+ if (!flowFn) flowFn = autoflow; // use global
trackTasks();
return logEventsMod.logEvents(flowFn, eventWildcard);
}
@@ -3126,16 +3126,16 @@ define('react/react',['./core', './dsl', './track-tasks', './log-events', './pro
Instantiate an event collector
*/
function createEventCollector() {
- return eventCollectorFactory(react);
+ return eventCollectorFactory(autoflow);
}
- react.options = core.options; // global react options
- react.events = core.events; // global react event emitter
- react.logEvents = logEvents; // enable event logging
- react.resolvePromises = resolvePromises; // enable promise resolution
- react.trackTasks = trackTasks; // enable tracking of tasks
- react.createEventCollector = createEventCollector; // create instance of EventCollector
- return react;
+ autoflow.options = core.options; // global autoflow options
+ autoflow.events = core.events; // global autoflow event emitter
+ autoflow.logEvents = logEvents; // enable event logging
+ autoflow.resolvePromises = resolvePromises; // enable promise resolution
+ autoflow.trackTasks = trackTasks; // enable tracking of tasks
+ autoflow.createEventCollector = createEventCollector; // create instance of EventCollector
+ return autoflow;
});
-define('react', ['react/react'], function (main) { return main; });
+define('autoflow', ['autoflow/autoflow'], function (main) { return main; });
View
22 dist/autoflow.min.js
@@ -0,0 +1,22 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+!function(e,t){function i(){this._events={},this._conf&&s.call(this,this._conf)}function s(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners&&(this._events.maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this.newListener=e.newListener),this.wildcard&&(this.listenerTree={}))}function o(e){this._events={},this.newListener=!1,s.call(this,e)}function u(e,t,n,r){if(!n)return[];var i=[],s,o,a,f,l,c,h,p=t.length,d=t[r],v=t[r+1];if(r===p&&n._listeners){if(typeof n._listeners=="function")return e&&e.push(n._listeners),[n];for(s=0,o=n._listeners.length;s<o;s++)e&&e.push(n._listeners[s]);return[n]}if(d==="*"||d==="**"||n[d]){if(d==="*"){for(a in n)a!=="_listeners"&&n.hasOwnProperty(a)&&(i=i.concat(u(e,t,n[a],r+1)));return i}if(d==="**"){h=r+1===p||r+2===p&&v==="*",h&&n._listeners&&(i=i.concat(u(e,t,n,p)));for(a in n)a!=="_listeners"&&n.hasOwnProperty(a)&&(a==="*"||a==="**"?(n[a]._listeners&&!h&&(i=i.concat(u(e,t,n[a],p))),i=i.concat(u(e,t,n[a],r))):a===v?i=i.concat(u(e,t,n[a],r+2)):i=i.concat(u(e,t,n[a],r)));return i}i=i.concat(u(e,t,n[d],r+1))}f=n["*"],f&&u(e,t,f,r+1),l=n["**"];if(l)if(r<p){l._listeners&&u(e,t,l,p);for(a in l)a!=="_listeners"&&l.hasOwnProperty(a)&&(a===v?u(e,t,l[a],r+2):a===d?u(e,t,l[a],r+1):(c={},c[a]=l[a],u(e,t,{"**":c},r+1)))}else l._listeners?u(e,t,l,p):l["*"]&&l["*"]._listeners&&u(e,t,l["*"],p);return i}function a(e,t){e=typeof e=="string"?e.split(this.delimiter):e.slice();for(var i=0,s=e.length;i+1<s;i++)if(e[i]==="**"&&e[i+1]==="**")return;var o=this.listenerTree,u=e.shift();while(u){o[u]||(o[u]={}),o=o[u];if(e.length===0){if(!o._listeners)o._listeners=t;else if(typeof o._listeners=="function")o._listeners=[o._listeners,t];else if(n(o._listeners)){o._listeners.push(t);if(!o._listeners.warned){var a=r;typeof this._events.maxListeners!="undefined"&&(a=this._events.maxListeners),a>0&&o._listeners.length>a&&(o._listeners.warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",o._listeners.length),console.trace())}}return!0}u=e.shift()}return!0}var n=Array.isArray?Array.isArray:function(t){return Object.prototype.toString.call(t)==="[object Array]"},r=10;o.prototype.delimiter=".",o.prototype.setMaxListeners=function(e){this._events||i.call(this),this._events.maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e},o.prototype.event="",o.prototype.once=function(e,t){return this.many(e,1,t),this},o.prototype.many=function(e,t,n){function i(){--t===0&&r.off(e,i),n.apply(this,arguments)}var r=this;if(typeof n!="function")throw new Error("many only accepts instances of Function");return i._origin=n,this.on(e,i),r},o.prototype.emit=function(){this._events||i.call(this);var e=arguments[0];if(e==="newListener"&&!this.newListener&&!this._events.newListener)return!1;if(this._all){var t=arguments.length,n=new Array(t-1);for(var r=1;r<t;r++)n[r-1]=arguments[r];for(r=0,t=this._all.length;r<t;r++)this.event=e,this._all[r].apply(this,n)}if(e==="error"&&!this._all&&!this._events.error&&(!this.wildcard||!this.listenerTree.error))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");var s;if(this.wildcard){s=[];var o=typeof e=="string"?e.split(this.delimiter):e.slice();u.call(this,s,o,this.listenerTree,0)}else s=this._events[e];if(typeof s=="function"){this.event=e;if(arguments.length===1)s.call(this);else if(arguments.length>1)switch(arguments.length){case 2:s.call(this,arguments[1]);break;case 3:s.call(this,arguments[1],arguments[2]);break;default:var t=arguments.length,n=new Array(t-1);for(var r=1;r<t;r++)n[r-1]=arguments[r];s.apply(this,n)}return!0}if(s){var t=arguments.length,n=new Array(t-1);for(var r=1;r<t;r++)n[r-1]=arguments[r];var a=s.slice();for(var r=0,t=a.length;r<t;r++)this.event=e,a[r].apply(this,n);return a.length>0||this._all}return this._all},o.prototype.on=function(e,t){if(typeof e=="function")return this.onAny(e),this;if(typeof t!="function")throw new Error("on only accepts instances of Function");this._events||i.call(this),this.emit("newListener",e,t);if(this.wildcard)return a.call(this,e,t),this;if(!this._events[e])this._events[e]=t;else if(typeof this._events[e]=="function")this._events[e]=[this._events[e],t];else if(n(this._events[e])){this._events[e].push(t);if(!this._events[e].warned){var s=r;typeof this._events.maxListeners!="undefined"&&(s=this._events.maxListeners),s>0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}}return this},o.prototype.onAny=function(e){this._all||(this._all=[]);if(typeof e!="function")throw new Error("onAny only accepts instances of Function");return this._all.push(e),this},o.prototype.addListener=o.prototype.on,o.prototype.off=function(e,t){if(typeof t!="function")throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var s=typeof e=="string"?e.split(this.delimiter):e.slice();i=u.call(this,null,s,this.listenerTree,0)}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var o=0;o<i.length;o++){var a=i[o];r=a._listeners;if(n(r)){var f=-1;for(var l=0,c=r.length;l<c;l++)if(r[l]===t||r[l].listener&&r[l].listener===t||r[l]._origin&&r[l]._origin===t){f=l;break}if(f<0)return this;this.wildcard?a._listeners.splice(f,1):this._events[e].splice(f,1),r.length===0&&(this.wildcard?delete a._listeners:delete this._events[e])}else if(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)this.wildcard?delete a._listeners:delete this._events[e]}return this},o.prototype.offAny=function(e){var t=0,n=0,r;if(e&&this._all&&this._all.length>0){r=this._all;for(t=0,n=r.length;t<n;t++)if(e===r[t])return r.splice(t,1),this}else this._all=[];return this},o.prototype.removeListener=o.prototype.off,o.prototype.removeAllListeners=function(e){if(arguments.length===0)return!this._events||i.call(this),this;if(this.wildcard){var t=typeof e=="string"?e.split(this.delimiter):e.slice(),n=u.call(this,null,t,this.listenerTree,0);for(var r=0;r<n.length;r++){var s=n[r];s._listeners=null}}else{if(!this._events[e])return this;this._events[e]=null}return this},o.prototype.listeners=function(e){if(this.wildcard){var t=[],r=typeof e=="string"?e.split(this.delimiter):e.slice();return u.call(this,t,r,this.listenerTree,0),t}return this._events||i.call(this),this._events[e]||(this._events[e]=[]),n(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]},o.prototype.listenersAny=function(){return this._all?this._all:[]},typeof define=="function"&&define.amd?define("eventemitter2",[],function(){return o}):e.EventEmitter2=o}(typeof process!="undefined"&&typeof process.title!="undefined"&&typeof exports!="undefined"?exports:window),define("autoflow/eventemitter",["eventemitter2"],function(e){var t=e?e.EventEmitter2?e.EventEmitter2:e:EventEmitter2;return t}),define("util",["require","exports","module"],function(e,t,n){function s(e,t,n,r){var i={showHidden:t,seen:[],stylize:r?a:f};return l(i,e,typeof n=="undefined"?2:n)}function a(e,t){var n=u[t];return n?"["+o[n][0]+"m"+e+"["+o[n][1]+"m":e}function f(e,t){return e}function l(e,n,r){if(n&&typeof n.inspect=="function"&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n))return n.inspect(r);var i=c(e,n);if(i)return i;var s=Object.keys(n),o=e.showHidden?Object.getOwnPropertyNames(n):s;if(o.length===0){if(typeof n=="function"){var u=n.name?": "+n.name:"";return e.stylize("[Function"+u+"]","special")}if(g(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(y(n))return e.stylize(Date.prototype.toString.call(n),"date");if(b(n))return h(n)}var a="",f=!1,l=["{","}"];m(n)&&(f=!0,l=["[","]"]);if(typeof n=="function"){var w=n.name?": "+n.name:"";a=" [Function"+w+"]"}g(n)&&(a=" "+RegExp.prototype.toString.call(n)),y(n)&&(a=" "+Date.prototype.toUTCString.call(n)),b(n)&&(a=" "+h(n));if(o.length!==0||!!f&&n.length!==0){if(r<0)return g(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special");e.seen.push(n);var E;return f?E=p(e,n,r,s,o):E=o.map(function(t){return d(e,n,r,s,t,f)}),e.seen.pop(),v(E,a,l)}return l[0]+a+l[1]}function c(e,t){switch(typeof t){case"undefined":return e.stylize("undefined","undefined");case"string":var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string");case"number":return e.stylize(""+t,"number");case"boolean":return e.stylize(""+t,"boolean")}if(t===null)return e.stylize("null","null")}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,n,r,i){var s=[];for(var o=0,u=t.length;o<u;++o)Object.prototype.hasOwnProperty.call(t,String(o))?s.push(d(e,t,n,r,String(o),!0)):s.push("");return i.forEach(function(i){i.match(/^\d+$/)||s.push(d(e,t,n,r,i,!0))}),s}function d(e,t,n,r,i,s){var o,u,a;a=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},a.get?a.set?u=e.stylize("[Getter/Setter]","special"):u=e.stylize("[Getter]","special"):a.set&&(u=e.stylize("[Setter]","special")),r.indexOf(i)<0&&(o="["+i+"]"),u||(e.seen.indexOf(a.value)<0?(n===null?u=l(e,a.value,null):u=l(e,a.value,n-1),u.indexOf("\n")>-1&&(s?u=u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):u="\n"+u.split("\n").map(function(e){return" "+e}).join("\n"))):u=e.stylize("[Circular]","special"));if(typeof o=="undefined"){if(s&&i.match(/^\d+$/))return u;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+u}function v(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.length+1},0);return i>60?n[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function m(e){return Array.isArray(e)||typeof e=="object"&&w(e)==="[object Array]"}function g(e){return typeof e=="object"&&w(e)==="[object RegExp]"}function y(e){return typeof e=="object"&&w(e)==="[object Date]"}function b(e){return typeof e=="object"&&w(e)==="[object Error]"}function w(e){return Object.prototype.toString.call(e)}function E(e){return e<10?"0"+e.toString(10):e.toString(10)}function x(){var e=new Date,t=[E(e.getHours()),E(e.getMinutes()),E(e.getSeconds())].join(":");return[e.getDate(),S[e.getMonth()],t].join(" ")}var r=/%[sdj%]/g;t.format=function(e){if(typeof e!="string"){var t=[];for(var n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}var i=1,o=arguments,u=o.length,a=String(e).replace(r,function(e){if(e==="%%")return"%";if(i>=u)return e;switch(e){case"%s":return String(o[i++]);case"%d":return Number(o[i++]);case"%j":return JSON.stringify(o[i++]);default:return e}});for(var f=o[i];i<u;f=o[++i])f===null||typeof f!="object"?a+=" "+f:a+=" "+s(f);return a},t.print=function(){for(var e=0,t=arguments.length;e<t;++e)process.stdout.write(String(arguments[e]))},t.puts=function(){for(var e=0,t=arguments.length;e<t;++e)process.stdout.write(arguments[e]+"\n")},t.debug=function(e){process.stderr.write("DEBUG: "+e+"\n")};var i=t.error=function(e){for(var t=0,n=arguments.length;t<n;++t)process.stderr.write(arguments[t]+"\n")};t.inspect=s;var o={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u={special:"cyan",number:"yellow","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};t.isArray=m,t.isRegExp=g,t.isDate=y,t.isError=b;var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];t.log=function(e){t.puts(x()+" - "+e.toString())},t.pump=function(e,t,n){function i(e,t,i){n&&!r&&(n(e,t,i),r=!0)}var r=!1;e.addListener("data",function(n){t.write(n)===!1&&e.pause()}),t.addListener("drain",function(){e.resume()}),e.addListener("end",function(){t.end()}),e.addListener("close",function(){i()}),e.addListener("error",function(e){t.end(),i(e)}),t.addListener("error",function(t){e.destroy(),i(t)})},t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t._extend=function(e,t){if(!t)return e;var n=Object.keys(t),r=n.length;while(r--)e[n[r]]=t[n[r]];return e}}),define("autoflow/error",["util"],function(e){function t(e){if(!Error.stackTraceLimit||Error.stackTraceLimit<e)Error.stackTraceLimit=e}function n(e){return e?e&&e.name?e.name:e:"undefined"}function r(t){if(!t.meta)return;var r=t.meta.vcon,i=t.meta.task,s="\n\n";return i&&i.f&&i.a&&(s+="Error occurs in Task function: "+n(i.f)+"("+i.a.join(",")+")\n\n"),r&&(s+="Variable Context: \n",s+=e.inspect(r),s+="\n\n"),i&&i.f&&(s+="Task Source:\n\n",s+=i.f.toString(),s+="\n\n"),s}function i(e,t){typeof e=="string"&&(e=new Error(e));var n=e.toString();return e.meta=t,e.toString=function(){return n+r(e)},e}return{ensureStackTraceLimitSet:t,augmentError:i}}),define("autoflow/sprintf",["util"],function(e){var t=e.format;return t}),function(e,t){typeof exports=="object"?module.exports=t():typeof define=="function"&&define.amd?define("ensure-array",[],t):e.ensureArray=t()}(this,function(){function e(e,t,n){if(arguments.length===0)return[];if(arguments.length===1){if(e===undefined||e===null)return[];if(Array.isArray(e))return e}return Array.prototype.slice.call(arguments)}return e}),define("autoflow/status",[],function(){var e={READY:"ready",RUNNING:"running",ERRORED:"errored",COMPLETE:"complete"};return e}),define("autoflow/event-manager",["./eventemitter"],function(e){function i(){}var t={wildcard:!0,delimiter:".",maxListeners:30},n=/^ast.defined$/,r={AST_DEFINED:"ast.defined",FLOW_BEGIN:"flow.begin",TASK_BEGIN:"task.begin",TASK_COMPLETE:"task.complete",TASK_ERRORED:"task.errored",FLOW_COMPLETE:"flow.complete",FLOW_ERRORED:"flow.errored",EXEC_FLOW_START:"exec.flow.start",EXEC_INPUT_PREPROCESS:"exec.input.preprocess",EXEC_TASKS_PRECREATE:"exec.tasks.precreate",EXEC_OUTTASK_CREATE:"exec.outTask.create",EXEC_TASK_START:"exec.task.start",EXEC_TASK_COMPLETE:"exec.task.complete",EXEC_TASK_ERRORED:"exec.task.errored",EXEC_FLOW_COMPLETE:"exec.flow.complete",EXEC_FLOW_ERRORED:"exec.flow.errored"};return i.create=function(){return new i},i.TYPES=r,i.prototype.TYPES=r,i.prototype.isEnabled=function(){return!!(this.emitter||this.parent&&this.parent.isEnabled())},i.prototype.on=function(n,r){this.emitter||(this.emitter=new e(t)),n==="*"?this.emitter.onAny(r):this.emitter.on(n,r)},i.prototype.emit=function(e,t,r,i){if(e===undefined)throw new Error("event is undefined");this.emitter&&this.emitter.emit.apply(this.emitter,arguments),this.parent&&this.parent.isEnabled()&&this.parent.emit.apply(this.parent,arguments),n.test(e)&&typeof process!="undefined"&&process.emit&&process.emit.apply(process,arguments)},i.prototype.removeListener=function(e,t){this.emitter&&this.emitter.removeListener.apply(this.emitter,arguments)},i.prototype.removeAllListeners=function(e){this.emitter&&this.emitter.removeAllListeners.apply(this.emitter,arguments)},i.global=i.create(),i}),define("autoflow/base-task",["ensure-array","./status","./event-manager"],function(e,t,n){function r(){}function i(e){return e.indexOf(".")!==-1}return r.prototype.getOutParams=function(){return e(this.out)},r.prototype.isComplete=function(){return this.status===t.COMPLETE},r.prototype.start=function(e){this.args=e,this.env.currentTask=this,this.env.flowEmitter.emit(n.TYPES.EXEC_TASK_START,this)},r.prototype.complete=function(e){this.status=t.COMPLETE,this.results=e,this.env.currentTask=this,this.env.flowEmitter.emit(n.TYPES.EXEC_TASK_COMPLETE,this)},r.prototype.functionExists=function(e){var t=this.f;if(!t)return!1;if(t instanceof Function)return!0;if(typeof t=="string"){var n=e.getVar(t);if(n&&n instanceof Function)return!0}return!1},r.prototype.areAllDepArgsDefined=function(e){return this.a.every(function(t){return e.getVar(t)!==undefined})},r.prototype.depTasksAreDone=function(e){return!this.after||!this.after.length||this.after.every(function(t){return e[t].isComplete()})},r.prototype.parentExists=function(e,t){if(!i(e))return!0;var n=e.split(".");n.pop();var r=n.reduce(function(e,t){return e===undefined||e===null?undefined:e[t]},t.values);return r!==undefined&&r!==null},r.prototype.outParentsExist=function(e){var t=this;return this.getOutParams().every(function(n){return n===null?!0:t.parentExists(n,e)})},r.prototype.isReady=function(e,t){return!this.status&&this.functionExists(e)&&this.areAllDepArgsDefined(e)&&this.depTasksAreDone(t)&&(!this.outParentsExist||this.outParentsExist(e))},r.prototype.isMethodCall=function(){return typeof this.f=="string"&&/^.*\..*$/.test(this.f)},r.prototype.getMethodObj=function(e){var t=this.f;if(!t)return undefined;var n=t.split(".");n.pop();if(!n.length)return undefined;var r=e.resolveNameArr(n);return r},r}),define("autoflow/cb-task",["util","./sprintf","./base-task"],function(e,t,n){function r(n,r){return t("%s - %s",n,e.inspect(r))}function a(e){var t=this;Object.keys(e).forEach(function(n){t[n]=e[n]})}var i="cbTask requires f, a, out",s="cbTask requires f to be a function or string",o="cbTask requires a to be an array of string param names",u="cbTask requires out to be an array of string param names";return a.prototype=new n,a.prototype.constructor=a,a.validate=function(e){var t=[];if(!e.f||!e.a||!e.out)t.push(r(i,e));else{var n=typeof e.f;e.f instanceof Function||n==="string"||t.push(r(s,e)),(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(r(o,e)),(!Array.isArray(e.out)||!e.out.every(function(e){return typeof e=="string"}))&&t.push(r(u,e))}return t},a.prototype.prepare=function(t,n,r){var i=this;this.cbFun=function(e,s,o,u){var a=Array.prototype.slice.call(arguments,1);if(e){t(i,e);return}n.saveResults(i.out,a),i.complete(a),r()}},a.prototype.exec=function(t,n,r){try{var i=this.a.map(function(e){return t.getVar(e)});this.start(i),i.push(this.cbFun);var s=this.f,o=t.getVar("this");this.isMethodCall()?(s=t.getVar(this.f),o=this.getMethodObj(t)):typeof s=="string"&&(s=t.getVar(s)),s.apply(o,i)}catch(u){n(this,u)}},a}),define("autoflow/promise-task",["util","./sprintf","./base-task"],function(e,t,n){function r(n,r){return t("%s - %s",n,e.inspect(r))}function a(e){var t=this;Object.keys(e).forEach(function(n){t[n]=e[n]})}var i="promiseTask requires f, a, out",s="promiseTask requires f to be a function or string",o="promiseTask requires a to be an array of string param names",u="promiseTask requires out to be an array[1] of string param names";return a.prototype=new n,a.prototype.constructor=a,a.validate=function(e){var t=[];if(!e.f||!e.a||!e.out)t.push(r(i,e));else{var n=typeof e.f;e.f instanceof Function||n==="string"||t.push(r(s,e)),(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(r(o,e)),Array.isArray(e.out)&&e.out.length<=1&&e.out.every(function(e){return typeof e=="string"})||t.push(r(u,e))}return t},a.prototype.prepare=function(t,n,r){var i=this;this.nextFn=function(e){var t=Array.prototype.slice.call(arguments);n.saveResults(i.out,t),i.complete(t),r()},this.failFn=function(e){t(i,e)}},a.prototype.exec=function(t,n,r){try{var i=this.a.map(function(e){return t.getVar(e)});this.start(i);var s=this.f,o=t.getVar("this");this.isMethodCall()?(s=t.getVar(this.f),o=this.getMethodObj(t)):typeof s=="string"&&(s=t.getVar(s));var u=s.apply(o,i);u&&typeof u.then=="function"?u.then(this.nextFn,this.failFn):this.nextFn(u)}catch(a){n(this,a)}},a}),define("autoflow/ret-task",["util","./sprintf","./base-task"],function(e,t,n){function r(n,r){return t("%s - %s",n,e.inspect(r))}function a(e){var t=this;Object.keys(e).forEach(function(n){t[n]=e[n]})}var i="retTask requires f, a, out",s="retTask requires f to be a function or string",o="retTask requires a to be an array of string param names",u="retTask requires out to be an array with single string param name or []";return a.prototype=new n,a.prototype.constructor=a,a.validate=function(e){var t=[];if(!e.f||!e.a||!e.out)t.push(r(i,e));else{var n=typeof e.f;e.f instanceof Function||n==="string"||t.push(r(s,e)),(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(r(o,e)),(!Array.isArray(e.out)||!(e.out.length===0||e.out.length===1&&typeof (e.out[0]==="string")))&&t.push(r(u,e))}return t},a.prototype.exec=function(t,n,r){try{var i=this.a.map(function(e){return t.getVar(e)});this.start(i);var s=this.f,o=t.getVar("this");this.isMethodCall()?(s=t.getVar(this.f),o=this.getMethodObj(t)):typeof s=="string"&&(s=t.getVar(s));var u=[s.apply(o,i)];t.saveResults(this.out,u),this.complete(u),r()}catch(a){n(this,a)}},a}),define("autoflow/when-task",["util","./sprintf","./base-task"],function(e,t,n){function r(n,r){return t("%s - %s",n,e.inspect(r))}function u(e){var t=this;Object.keys(e).forEach(function(n){t[n]=e[n]})}var i="whenTask requires a, out",s="whenTask requires a to be an array[1] of string param names",o="whenTask requires out to be an array[1] of string param names";return u.prototype=new n,u.prototype.constructor=u,u.prototype.f=function(){},u.validate=function(e){var t=[];return!e.a||!e.out?t.push(r(i,e)):((!Array.isArray(e.a)||e.a.length!==1||!e.a.every(function(e){return typeof e=="string"}))&&t.push(r(s,e)),Array.isArray(e.out)&&e.out.length<=1&&e.out.every(function(e){return typeof e=="string"})||t.push(r(o,e))),t},u.prototype.prepare=function(t,n,r){var i=this;this.nextFn=function(e){var t=Array.prototype.slice.call(arguments);n.saveResults(i.out,t),i.complete(t),r()},this.failFn=function(e){t(i,e)}},u.prototype.exec=function(t,n,r){try{var i=this.a.map(function(e){return t.getVar(e)});this.start(i);var s=i[0];s&&typeof s.then=="function"?s.then(this.nextFn,this.failFn):this.nextFn(s)}catch(o){n(this,o)}},u}),define("autoflow/finalcb-task",["./sprintf","util","./status","./event-manager"],function(e,t,n,r){function s(e){var t=e.taskDef;if(typeof e.cbFunc!="function")throw new Error("callback is not a function");var n=this;for(var r in t)n[r]=t[r];this.f=e.cbFunc,this.tasks=e.tasks,this.vCon=e.vCon,this.retValue=e.retValue,this.execOptions=e.execOptions,this.env=e.env}function o(n,r){return e("%s - %s",n,t.inspect(r))}var i="ast.outTask.a should be an array of string param names";return s.validate=function(e){var t=[];return(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(o(i,e)),t},s.prototype.isReady=function(){return this.tasks.every(function(e){return e.status===n.COMPLETE})},s.prototype.exec=function(e){if(!this.f)return;if(e)this.env.error=e,this.env.flowEmitter.emit(r.TYPES.EXEC_FLOW_ERRORED,this.env),this.f.call(null,e);else{var t=this.vCon,n=this.a.map(function(e){return t.getVar(e)});n.unshift(null),this.env.results=n,this.env.flowEmitter.emit(r.TYPES.EXEC_FLOW_COMPLETE,this.env),this.f.apply(null,n)}this.f=null},s}),define("autoflow/vcon",[],function(){function t(){}var e=":LAST_RESULTS";return t.prototype.getLastResults=function(){return this.getVar(e)},t.prototype.setLastResults=function(t){this.setVar(e,t)},t.prototype.getVar=function(e){var t=this.values;if(typeof e!="string")return e;e=e.trim();if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(/^-?[0-9]+$/.test(e))return parseInt(e,10);if(/^-?[0-9.]+$/.test(e))return parseFloat(e);var n=/^("|')([^\1]*)\1$/.exec(e);if(n)return n[2];var r=e.split("."),i=this.resolveNameArr(r);return i},t.prototype.resolveNameArr=function(e){var t=this.values,n=e.reduce(function(e,t){return e===undefined||e===null?undefined:e[t]},t);return n===undefined&&this.global!==undefined&&(n=e.reduce(function(e,t){return e===undefined||e===null?undefined:e[t]},this.global)),n},t.prototype.saveResults=function(e,t){var n=this;e.forEach(function(e,r){n.setVar(e,t[r]!==undefined?t[r]:null)}),this.setLastResults(t)},t.prototype.setVar=function(e,t){if(!e)return;var n=this.values,r=e.split("."),i=r.pop(),s=r.reduce(function(e,t){var n=e[t];if(n===undefined||n===null)n=e[t]={};return n},n);s[i]=t},t.create=function(e,n,r,i){var s={};i&&(s["this"]=i),r&&Object.keys(r).forEach(function(e){s[e]=r[e]});var o=new t;return o.values=e.reduce(function(e,t,r){var i=n[r];return i&&(e[i]=t!==undefined?t:null),e},s),typeof global=="object"?o.global=global:o.global=(new Function("return this"))(),o},t}),define("autoflow/finalcb-first-task",["./sprintf","util","./status","./vcon","./event-manager"],function(e,t,n,r,i){function o(e){var t=e.taskDef;if(typeof e.cbFunc!="function")throw new Error("callback is not a function");var n=this;for(var r in t)n[r]=t[r];this.f=e.cbFunc,this.tasks=e.tasks,this.vCon=e.vCon,this.retValue=e.retValue,this.env=e.env}function u(n,r){return e("%s - %s",n,t.inspect(r))}var s="ast.outTask.a should be an array of string param names";return o.validate=function(e){var t=[];return(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(u(s,e)),t},o.prototype.isReady=function(){var e=this.vCon.getLastResults();return e?e.some(function(e){return e!==undefined&&e!==null}):!1},o.prototype.exec=function(e){if(!this.f)return;if(e)this.env.error=e,this.env.flowEmitter.emit(i.TYPES.EXEC_FLOW_ERRORED,this.env),this.f.call(null,e);else{var t=this.vCon,n=this.a.map(function(e){return t.getVar(e)});n.unshift(null),this.env.results=n,this.env.flowEmitter.emit(i.TYPES.EXEC_FLOW_COMPLETE,this.env),this.f.apply(null,n)}this.f=null},o}),define("autoflow/task",["util","./sprintf","ensure-array","./cb-task","./promise-task","./ret-task","./when-task","./finalcb-task","./finalcb-first-task","./status","./error","./vcon","./event-manager"],function(e,t,n,r,i,s,o,u,a,f,l,c,h){function v(){return Object.keys(p)}function g(){return Object.keys(m)}function S(n,r){return t("%s - %s",n,e.inspect(r))}function x(e){return e.type?e:(e.type="cb",e)}function T(e){e.type||(e.type=Object.keys(m)[0])}function N(e){if(!e.after)return;var t=n(e.after);t=t.map(function(e){return typeof e=="function"?e.name:e}),e.after=t}function C(e){if(!e||typeof e!="object")return[S(b,e)];x(e),N(e);var t=[];return t=t.concat(k(e)),t=t.concat(L(e)),t}function k(e){var t=[];return Object.keys(p).some(function(t){return e.type===t})||t.push(S(E,e)),t}function L(e){var t=[],n=p[e.type];return n&&(t=t.concat(n.validate(e))),t}function A(e){var t=[];T(e);var n=m[e.type];return t=t.concat(n.validate(e)),t}function O(e,n,r){function s(){}var i=[],o=e.map(function(e){return s}),u=c.create(o,e,r),a=n.map(D),f=a.filter(function(e){return e.type!=="when"});return f.forEach(function(e,n){if(!e.functionExists(u))if(!e.isMethodCall())i.push(t(y,e.f,n));else{var r=e.getMethodObj(u);r&&r!==s&&i.push(t(y,e.f,n))}}),i}function M(e){return typeof e=="function"?e.name:e?e:""}function _(e){var n=e.reduce(function(e,t){return t.name&&(e[t.name]=t),e},{});return e.forEach(function(e,r){if(!e.name){var i=M(e.f);i||(i=t(d,r));if(!i||n[i])i=t("%s_%s",i,r);e.name=i,n[i]=e}}),n}function D(e){var t=p[e.type];return new t(e)}function P(e,t,n,r,i,s){T(e);var o={taskDef:e,cbFunc:t,tasks:n,vCon:r,execOptions:i,env:s,TaskConstructor:m[e.type]};h.global.emit(h.TYPES.EXEC_OUTTASK_CREATE,o);var u=o.TaskConstructor;return new u(o)}function H(e,t){return function(r,i){r.status=f.ERRORED,r.error=i,t.env.currentTask=r,t.env.flowEmitter.emit(h.TYPES.EXEC_TASK_ERRORED,r);var s=l.augmentError(i,{task:r,vcon:e});t.exec(s)}}function B(e,t,n){return t.filter(function(t){return t.isReady(e,n)})}function j(e,t,n,r){e.forEach(function(e){e.status=f.READY}),e.forEach(function(e){e.exec(t,n,r)})}function F(e,n,r,i){var s=n.filter(function(e){return e.status===f.RUNNING||e.status===f.READY});if(!s.length){var o=n.filter(function(e){return!e.status}),u=o.map(function(e){return e.name}),a=t(w,u.join(", ")),l={env:i};r(l,new Error(a))}}function I(e,t,n,r,i,s){var o=B(e,t,n);o.length||F(e,t,r,s),j(o,e,r,i)}function q(e){return _(e),e.forEach(function(e,t,n){t!==0&&(e.after=[n[t-1].name])}),e}var p={cb:r,ret:s,promise:i,when:o},d="task_%s",m={finalcb:u,finalcbFirst:a},y="function: %s not found in locals or input params - task[%s]",b="task must be an object",w="no tasks running, flow will not complete, remaining tasks: %s",E="task.type should match one of "+Object.keys(p).join(", ");return{serializeTasks:q,TASK_TYPES:p,taskTypeKeys:v,OUT_TASK_TYPES:m,outTaskTypeKeys:g,setMissingType:x,validate:C,validateOutTask:A,validateLocalFunctions:O,nameTasks:_,create:D,createOutTask:P,createErrorHandler:H,findReadyAndExec:I}}),define("autoflow/validate",["util","./sprintf","ensure-array","./task"],function(e,t,n,r){function h(n,r){return t("%s - %s",n,e.inspect(r))}function p(e){return c.test(e)}function d(e){if(!e||!e.inParams||!e.tasks||!e.outTask)return[i];var t=[];return t=t.concat(v(e.inParams)),t=t.concat(m(e.tasks)),t=t.concat(g(e.tasks)),t=t.concat(r.validateOutTask(e.outTask)),t=t.concat(y(e.locals)),t.length===0&&(e.outTask.type!=="finalcbFirst"&&(t=t.concat(w(e.tasks))),t=t.concat(r.validateLocalFunctions(e.inParams,e.tasks,e.locals)),t=t.concat(E(e))),t}function v(e){return!Array.isArray(e)||!e.every(function(e){return typeof e=="string"})?[s]:[]}function m(e){if(!Array.isArray(e))return[o];var t=[];return e.forEach(function(e){t=t.concat(r.validate(e))}),t}function g(e){if(!Array.isArray(e))return[];var n=[],r=e.filter(function(e){return e.name}),i=r.map(function(e){return e.name});return i.reduce(function(e,r){return e[r]?n.push(t("%s %s",u,r)):e[r]=!0,e},{}),n}function y(e){var t=[];return e===null&&t.push(a),t}function b(e){return n(e.out)}function w(e){var n=[];return e.reduce(function(e,r){return b(r).forEach(function(r){e[r]!==undefined?n.push(t("%s: %s",f,r)):e[r]=!0}),e},{}),n}function E(e){var n=[],r={};return e.locals&&(r=Object.keys(e.locals).reduce(function(e,t){return e[t]=!0,e},r)),e.inParams.reduce(function(e,t){return e[t]=!0,e},r),e.tasks.reduce(function(e,t){return t.out.reduce(function(e,t){return e[t]=!0,e},e)},r),e.tasks.reduce(function(e,n){return n.a.reduce(function(e,n){return!p(n)&&!r[n]&&e.push(t(l,n)),e},e)},n),e.outTask.a.reduce(function(e,n){return!p(n)&&!r[n]&&e.push(t(l,n)),e},n),n}var i="ast must be an object with inParams, tasks, and outTask",s="ast.inParams must be an array of strings",o="ast.tasks must be an array of tasks",u="ast.tasks that specify name need to be unique, duplicate:",a="ast.locals should not be null",f="multiple tasks output the same param, must be unique. param",l="missing or mispelled variable referenced in flow definition: %s",c=/^(true|false|this|null|\-?[0-9\.]+)$|'|"|\./i;return d}),define("autoflow/input-parser",["./event-manager"],function(e){function r(e){return e&&e.autoflowExecOptions}function i(e){return r(e)}function s(e){return!r(e)}function o(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e}function u(e,t,r){var i={};return i.args=t.map(function(t){return e.shift()}),r===n.CALLBACK&&e.length&&(i.cb=e.shift()),i.extra=e,i}function a(n,r){var a={},f=n.filter(i);f.unshift(t),a.options=f.reduce(o,{});var l=n.filter(s),c=u(l,r.inParams,a.options.outputStyle);return a.args=c.args,a.cb=c.cb,c.outputStyle&&(a.options.outputStyle=c.outputStyle),c.extra&&(a.extraArgs=c.extra),e.global.emit(e.TYPES.EXEC_INPUT_PREPROCESS,a),a}var t={autoflowExecOptions:!0,outputStyle:"cb"},n={CALLBACK:"cb",NONE:"none"};return a.defaultExecOptions=t,a}),define("autoflow/id",[],function(){function t(){return e+=1,e===Number.MAX_VALUE&&(e=0),e}var e=0;return{createUniqueId:t}}),define("autoflow/core",["./eventemitter","./error","./validate","./task","./status","./vcon","./event-manager","./input-parser","./id","./sprintf"],function(e,t,n,r,i,s,o,u,a,f){function h(e){return Object.keys(l).reduce(function(e,t){return e[t]||(e[t]=l[t]),e},e)}function p(){return f("flow_%s",a.createUniqueId())}function d(){function f(t){Object.keys(t).forEach(function(e){i[e]=t[e]});var s=n(i);return s.length||(i.name||(i.name=p()),r.nameTasks(i.tasks)),Object.freeze&&(Object.keys(t).forEach(function(e){typeof t[e]=="object"&&Object.freeze(t[e])}),Object.freeze(t)),e.emit(o.TYPES.AST_DEFINED,i),s}function d(t,n,f,l){function E(){if(!b.f)return;if(b.isReady())return b.exec();r.findReadyAndExec(m,g,y,w,E,d)}var p=Array.prototype.slice.call(arguments),d={execId:a.createUniqueId(),args:p,ast:i,flowEmitter:e};d.name=i.name||d.execId,e.emit(o.TYPES.EXEC_FLOW_START,d);var v=u(p,i),m=s.create(v.args,i.inParams,i.locals,this);d.parsedInput=v,d.options=h(v.options),d.vCon=m,d.taskDefs=i.tasks.slice(),d.outTaskDef=Object.create(i.outTask),c.emit(o.TYPES.EXEC_TASKS_PRECREATE,d);var g=d.taskDefs.map(r.create),y=r.nameTasks(g),b=r.createOutTask(d.outTaskDef,v.cb,g,m,d.options,d),w=r.createErrorHandler(m,b);return g.forEach(function(t){t.id=a.createUniqueId(),t.env=d,t.prepare&&t.prepare(w,m,E,e)}),E(),b.retValue}if(arguments.length)throw new Error("autoflow() takes no args, check API");t.ensureStackTraceLimitSet(l.stackTraceLimitMin);var e=o.create();e.parent=c;var i={name:undefined,inParams:[],tasks:[],outTask:{},locals:{}},v=d;return v.ast=i,v.setAndValidateAST=f,v.events=e,v}var l={stackTraceLimitMin:30},c=o.global;return d.options=l,d.events=c,d}),define("autoflow/parse",["./sprintf"],function(e){function t(e){return e?e.split(",").map(function(e){return e.trim()}).filter(function(e){return e}):[]}function n(e,t){if(typeof e!="string")return e;var n=t.regex?t.regex.exec(e):e.split(t.splitStr);return n?t.fn(n,e):e}function r(t,r,i){var s=r.reduce(n,t);if(typeof s!="string")return s;throw new Error(e(i,t))}return{splitTrimFilterArgs:t,parseStr:r}}),define("autoflow/dsl",["./sprintf","./core","./parse","./task"],function(e,t,n,r){function h(e){return e.length&&e[e.length-1].match(l)&&e.pop(),e}function p(e){return e.length&&e[0].match(c)&&e.shift(),e}function v(e){var t=n.parseStr(e,[d],s);return t.inDef=h(t.inDef),t}function m(t){var n=[],r,i,s;while(t.length>=2){i={},r=t.shift(),s=v(t.shift()),typeof t[0]=="object"&&(i=t.shift()),i.f=r,i.a=s.inDef;var o=s.type;i.out=s.outDef,i.type=o,n.push(i)}if(t.length)throw new Error(e(a,t[0]));return n}function g(e){var t=e.shift()||"",n=e.length&&typeof e[0]=="object"?e.shift():{},r=e,i={inOutParamStr:t,taskDefArr:r,options:n};return i}function y(n,r,s,o){var u=t();if(n&&f.test(n))throw new Error(e(i,n));var a=g(Array.prototype.slice.call(arguments,1)),l=v(a.inOutParamStr),c={name:n,inParams:l.inDef,tasks:m(a.taskDefArr),outTask:{a:l.outDef}};a.options&&Object.keys(a.options).forEach(function(e){c[e]=a.options[e]});var h=u.setAndValidateAST(c);if(h.length){var p=h.join("\n");throw new Error(p)}return u}function b(e,n,i,s){var o=t(),u=g(Array.prototype.slice.call(arguments,1)),a=v(u.inOutParamStr),f=r.serializeTasks(m(u.taskDefArr)),l={name:e,inParams:a.inDef,tasks:f,outTask:{type:"finalcbFirst",a:a.outDef}};u.options&&Object.keys(u.options).forEach(function(e){l[e]=u.options[e]});var c=o.setAndValidateAST(l);if(c.length){var h=c.join("\n");throw new Error(h)}return o}var i="first flow parameter should be the flow name, but found in/out def: %s",s='params in wrong format, wanted "foo, bar, cb -> err, baz" - found: %s',o='callback specified, but first out param was not "err", use for clarity. Found in/out def: %s',u="found err param, but cb/callback is not specified, is this cb-style async or sync function? Found in/out def: %s",a="extra unmatched task arg: %s",f=/\->/,l=/^cb|callback$/i,c=/^err$/i,d={splitStr:"->",fn:function(t,r){var i=n.splitTrimFilterArgs(t[0]),s=i[i.length-1],a=s&&l.test(s)?"cb":"ret",f=n.splitTrimFilterArgs(t[1]),d=f[0];if(a==="cb"&&(!d||!c.test(d)))throw new Error(e(o,r));if(a==="ret"&&d&&c.test(d))throw new Error(e(u,r));return{type:a,inDef:h(i),outDef:p(f)}}};return y.selectFirst=b,y}),define("autoflow/track-tasks",[],function(){function t(t){if(e)return;e=!0,t.events.on(t.events.TYPES.EXEC_FLOW_START,function(e){e.startTime=Date.now(),e.flowEmitter.emit(t.events.TYPES.FLOW_BEGIN,e)}),t.events.on(t.events.TYPES.EXEC_TASK_START,function(e){e.startTime=Date.now(),e.env.flowEmitter.emit(t.events.TYPES.TASK_BEGIN,e)}),t.events.on(t.events.TYPES.EXEC_TASK_COMPLETE,function(e){e.endTime=Date.now(),e.elapsedTime=e.endTime-e.startTime,e.env.flowEmitter.emit(t.events.TYPES.TASK_COMPLETE,e)}),t.events.on(t.events.TYPES.EXEC_TASK_ERRORED,function(e){e.endTime=Date.now(),e.elapsedTime=e.endTime-e.startTime,e.env.flowEmitter.emit(t.events.TYPES.TASK_ERRORED,e)}),t.events.on(t.events.TYPES.EXEC_FLOW_COMPLETE,function(e){e.endTime=Date.now(),e.elapsedTime=e.endTime-e.startTime,e.flowEmitter.emit(t.events.TYPES.FLOW_COMPLETE,e)}),t.events.on(t.events.TYPES.EXEC_FLOW_ERRORED,function(e){e.endTime=Date.now(),e.elapsedTime=e.endTime-e.startTime,e.flowEmitter.emit(t.events.TYPES.FLOW_ERRORED,e)})}var e=!1;return t}),define("autoflow/log-events",["util"],function(e){function s(t){var n=new Date;n.setTime(t.startTime);var r=t.args.filter(function(e){return typeof e!="function"}),i=n.toISOString();if(this.event==="flow.complete"){var s=t;console.error("%s: %s msecs: %s \n args: %s \n results: %s\n",this.event,s.name,s.elapsedTime,e.inspect(r),e.inspect(s.results))}else{var o=t.name,u=t.args;console.error("%s: %s \n args: %s\n",this.event,o,e.inspect(r))}}function o(t){var n=new Date;n.setTime(t.startTime);var r=t.args.filter(function(e){return typeof e!="function"}),i=n.toISOString();if(this.event==="task.complete"){var s=t;console.error("%s: %s:%s msecs: %s \n args: %s \n results: %s\n",this.event,s.env.name,s.name,s.elapsedTime,e.inspect(r),e.inspect(s.results))}else{var o=t.name,u=t.args;console.error("%s: %s:%s \n args: %s\n",this.event,t.env.name,t.name,e.inspect(r))}}function u(e,t){if(!e)throw new Error("flowFn is required");e.events._loggingEvents||(e.events._loggingEvents=[]);if(t===!1)e.events._loggingEvents.forEach(function(t){e.events.removeAllListeners(t)}),e.events._loggingEvents.length=0;else if(t&&t!=="*"){var u=i.test(t)?s:o;e.events.removeListener(t,u),e.events.on(t,u),e.events._loggingEvents.push(t)}else e.events.removeListener(n,s),e.events.on(n,s),e.events._loggingEvents.push(n),e.events.removeListener(r,o),e.events.on(r,o),e.events._loggingEvents.push(r)}var t={},n="flow.*",r="task.*",i=/^flow\./;return t.logEvents=u,t}),define("autoflow/promise-resolve",[],function(){function n(n){if(t)return;t=!0,n.events.on(n.events.TYPES.EXEC_TASKS_PRECREATE,function(t){var n=t.vCon.values,r=t.ast.inParams.filter(function(e){var t=n[e];return t&&typeof t.then=="function"});r.forEach(function(r){var i=r+e;n[i]=n[r],n[r]=undefined,t.taskDefs.push({type:"when",a:[i],out:[r]})})})}var e="__promise",t=!1;return n}),define("autoflow/event-collector",[],function(){function e(e){function i(){this.events=[]}e.trackTasks();var t=/^ast\./,n=/^task\./,r=/^flow\./;return i.prototype.capture=function(i,s){function a(e){var i={event:this.event,time:Date.now()};r.test(this.event)?i.env=e:n.test(this.event)?i.task=e:t.test(this.event)&&(i.ast=e),u.events.push(i)}!s&&typeof i=="string"?(s=i,i=e):i||(i=e),s||(s="*");var o=i.events,u=this;o.on(s,a)},i.prototype.list=function(){return this.events},i.prototype.clear=function(){this.events=[]},new i}return e}),define("autoflow/autoflow",["./core","./dsl","./track-tasks","./log-events","./promise-resolve","./event-collector"],function(e,t,n,r,i,s){function u(){i(o)}function a(){n(o)}function f(e,t){return typeof e!="function"&&(t=e,e=undefined),e||(e=o),a(),r.logEvents(e,t)}function l(){return s(o)}var o=t;return o.options=e.options,o.events=e.events,o.logEvents=f,o.resolvePromises=u,o.trackTasks=a,o.createEventCollector=l,o}),define("autoflow",["autoflow/autoflow"],function(e){return e});
View
22 dist/react.min.js
@@ -1,22 +0,0 @@
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-!function(e,t){function i(){this._events={},this._conf&&s.call(this,this._conf)}function s(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners&&(this._events.maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this.newListener=e.newListener),this.wildcard&&(this.listenerTree={}))}function o(e){this._events={},this.newListener=!1,s.call(this,e)}function u(e,t,n,r){if(!n)return[];var i=[],s,o,a,f,l,c,h,p=t.length,d=t[r],v=t[r+1];if(r===p&&n._listeners){if(typeof n._listeners=="function")return e&&e.push(n._listeners),[n];for(s=0,o=n._listeners.length;s<o;s++)e&&e.push(n._listeners[s]);return[n]}if(d==="*"||d==="**"||n[d]){if(d==="*"){for(a in n)a!=="_listeners"&&n.hasOwnProperty(a)&&(i=i.concat(u(e,t,n[a],r+1)));return i}if(d==="**"){h=r+1===p||r+2===p&&v==="*",h&&n._listeners&&(i=i.concat(u(e,t,n,p)));for(a in n)a!=="_listeners"&&n.hasOwnProperty(a)&&(a==="*"||a==="**"?(n[a]._listeners&&!h&&(i=i.concat(u(e,t,n[a],p))),i=i.concat(u(e,t,n[a],r))):a===v?i=i.concat(u(e,t,n[a],r+2)):i=i.concat(u(e,t,n[a],r)));return i}i=i.concat(u(e,t,n[d],r+1))}f=n["*"],f&&u(e,t,f,r+1),l=n["**"];if(l)if(r<p){l._listeners&&u(e,t,l,p);for(a in l)a!=="_listeners"&&l.hasOwnProperty(a)&&(a===v?u(e,t,l[a],r+2):a===d?u(e,t,l[a],r+1):(c={},c[a]=l[a],u(e,t,{"**":c},r+1)))}else l._listeners?u(e,t,l,p):l["*"]&&l["*"]._listeners&&u(e,t,l["*"],p);return i}function a(e,t){e=typeof e=="string"?e.split(this.delimiter):e.slice();for(var i=0,s=e.length;i+1<s;i++)if(e[i]==="**"&&e[i+1]==="**")return;var o=this.listenerTree,u=e.shift();while(u){o[u]||(o[u]={}),o=o[u];if(e.length===0){if(!o._listeners)o._listeners=t;else if(typeof o._listeners=="function")o._listeners=[o._listeners,t];else if(n(o._listeners)){o._listeners.push(t);if(!o._listeners.warned){var a=r;typeof this._events.maxListeners!="undefined"&&(a=this._events.maxListeners),a>0&&o._listeners.length>a&&(o._listeners.warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",o._listeners.length),console.trace())}}return!0}u=e.shift()}return!0}var n=Array.isArray?Array.isArray:function(t){return Object.prototype.toString.call(t)==="[object Array]"},r=10;o.prototype.delimiter=".",o.prototype.setMaxListeners=function(e){this._events||i.call(this),this._events.maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e},o.prototype.event="",o.prototype.once=function(e,t){return this.many(e,1,t),this},o.prototype.many=function(e,t,n){function i(){--t===0&&r.off(e,i),n.apply(this,arguments)}var r=this;if(typeof n!="function")throw new Error("many only accepts instances of Function");return i._origin=n,this.on(e,i),r},o.prototype.emit=function(){this._events||i.call(this);var e=arguments[0];if(e==="newListener"&&!this.newListener&&!this._events.newListener)return!1;if(this._all){var t=arguments.length,n=new Array(t-1);for(var r=1;r<t;r++)n[r-1]=arguments[r];for(r=0,t=this._all.length;r<t;r++)this.event=e,this._all[r].apply(this,n)}if(e==="error"&&!this._all&&!this._events.error&&(!this.wildcard||!this.listenerTree.error))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");var s;if(this.wildcard){s=[];var o=typeof e=="string"?e.split(this.delimiter):e.slice();u.call(this,s,o,this.listenerTree,0)}else s=this._events[e];if(typeof s=="function"){this.event=e;if(arguments.length===1)s.call(this);else if(arguments.length>1)switch(arguments.length){case 2:s.call(this,arguments[1]);break;case 3:s.call(this,arguments[1],arguments[2]);break;default:var t=arguments.length,n=new Array(t-1);for(var r=1;r<t;r++)n[r-1]=arguments[r];s.apply(this,n)}return!0}if(s){var t=arguments.length,n=new Array(t-1);for(var r=1;r<t;r++)n[r-1]=arguments[r];var a=s.slice();for(var r=0,t=a.length;r<t;r++)this.event=e,a[r].apply(this,n);return a.length>0||this._all}return this._all},o.prototype.on=function(e,t){if(typeof e=="function")return this.onAny(e),this;if(typeof t!="function")throw new Error("on only accepts instances of Function");this._events||i.call(this),this.emit("newListener",e,t);if(this.wildcard)return a.call(this,e,t),this;if(!this._events[e])this._events[e]=t;else if(typeof this._events[e]=="function")this._events[e]=[this._events[e],t];else if(n(this._events[e])){this._events[e].push(t);if(!this._events[e].warned){var s=r;typeof this._events.maxListeners!="undefined"&&(s=this._events.maxListeners),s>0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}}return this},o.prototype.onAny=function(e){this._all||(this._all=[]);if(typeof e!="function")throw new Error("onAny only accepts instances of Function");return this._all.push(e),this},o.prototype.addListener=o.prototype.on,o.prototype.off=function(e,t){if(typeof t!="function")throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var s=typeof e=="string"?e.split(this.delimiter):e.slice();i=u.call(this,null,s,this.listenerTree,0)}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var o=0;o<i.length;o++){var a=i[o];r=a._listeners;if(n(r)){var f=-1;for(var l=0,c=r.length;l<c;l++)if(r[l]===t||r[l].listener&&r[l].listener===t||r[l]._origin&&r[l]._origin===t){f=l;break}if(f<0)return this;this.wildcard?a._listeners.splice(f,1):this._events[e].splice(f,1),r.length===0&&(this.wildcard?delete a._listeners:delete this._events[e])}else if(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)this.wildcard?delete a._listeners:delete this._events[e]}return this},o.prototype.offAny=function(e){var t=0,n=0,r;if(e&&this._all&&this._all.length>0){r=this._all;for(t=0,n=r.length;t<n;t++)if(e===r[t])return r.splice(t,1),this}else this._all=[];return this},o.prototype.removeListener=o.prototype.off,o.prototype.removeAllListeners=function(e){if(arguments.length===0)return!this._events||i.call(this),this;if(this.wildcard){var t=typeof e=="string"?e.split(this.delimiter):e.slice(),n=u.call(this,null,t,this.listenerTree,0);for(var r=0;r<n.length;r++){var s=n[r];s._listeners=null}}else{if(!this._events[e])return this;this._events[e]=null}return this},o.prototype.listeners=function(e){if(this.wildcard){var t=[],r=typeof e=="string"?e.split(this.delimiter):e.slice();return u.call(this,t,r,this.listenerTree,0),t}return this._events||i.call(this),this._events[e]||(this._events[e]=[]),n(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]},o.prototype.listenersAny=function(){return this._all?this._all:[]},typeof define=="function"&&define.amd?define("eventemitter2",[],function(){return o}):e.EventEmitter2=o}(typeof process!="undefined"&&typeof process.title!="undefined"&&typeof exports!="undefined"?exports:window),define("react/eventemitter",["eventemitter2"],function(e){var t=e?e.EventEmitter2?e.EventEmitter2:e:EventEmitter2;return t}),define("util",["require","exports","module"],function(e,t,n){function s(e,t,n,r){var i={showHidden:t,seen:[],stylize:r?a:f};return l(i,e,typeof n=="undefined"?2:n)}function a(e,t){var n=u[t];return n?"["+o[n][0]+"m"+e+"["+o[n][1]+"m":e}function f(e,t){return e}function l(e,n,r){if(n&&typeof n.inspect=="function"&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n))return n.inspect(r);var i=c(e,n);if(i)return i;var s=Object.keys(n),o=e.showHidden?Object.getOwnPropertyNames(n):s;if(o.length===0){if(typeof n=="function"){var u=n.name?": "+n.name:"";return e.stylize("[Function"+u+"]","special")}if(g(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(y(n))return e.stylize(Date.prototype.toString.call(n),"date");if(b(n))return h(n)}var a="",f=!1,l=["{","}"];m(n)&&(f=!0,l=["[","]"]);if(typeof n=="function"){var w=n.name?": "+n.name:"";a=" [Function"+w+"]"}g(n)&&(a=" "+RegExp.prototype.toString.call(n)),y(n)&&(a=" "+Date.prototype.toUTCString.call(n)),b(n)&&(a=" "+h(n));if(o.length!==0||!!f&&n.length!==0){if(r<0)return g(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special");e.seen.push(n);var E;return f?E=p(e,n,r,s,o):E=o.map(function(t){return d(e,n,r,s,t,f)}),e.seen.pop(),v(E,a,l)}return l[0]+a+l[1]}function c(e,t){switch(typeof t){case"undefined":return e.stylize("undefined","undefined");case"string":var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string");case"number":return e.stylize(""+t,"number");case"boolean":return e.stylize(""+t,"boolean")}if(t===null)return e.stylize("null","null")}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,n,r,i){var s=[];for(var o=0,u=t.length;o<u;++o)Object.prototype.hasOwnProperty.call(t,String(o))?s.push(d(e,t,n,r,String(o),!0)):s.push("");return i.forEach(function(i){i.match(/^\d+$/)||s.push(d(e,t,n,r,i,!0))}),s}function d(e,t,n,r,i,s){var o,u,a;a=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},a.get?a.set?u=e.stylize("[Getter/Setter]","special"):u=e.stylize("[Getter]","special"):a.set&&(u=e.stylize("[Setter]","special")),r.indexOf(i)<0&&(o="["+i+"]"),u||(e.seen.indexOf(a.value)<0?(n===null?u=l(e,a.value,null):u=l(e,a.value,n-1),u.indexOf("\n")>-1&&(s?u=u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):u="\n"+u.split("\n").map(function(e){return" "+e}).join("\n"))):u=e.stylize("[Circular]","special"));if(typeof o=="undefined"){if(s&&i.match(/^\d+$/))return u;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+u}function v(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.length+1},0);return i>60?n[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function m(e){return Array.isArray(e)||typeof e=="object"&&w(e)==="[object Array]"}function g(e){return typeof e=="object"&&w(e)==="[object RegExp]"}function y(e){return typeof e=="object"&&w(e)==="[object Date]"}function b(e){return typeof e=="object"&&w(e)==="[object Error]"}function w(e){return Object.prototype.toString.call(e)}function E(e){return e<10?"0"+e.toString(10):e.toString(10)}function x(){var e=new Date,t=[E(e.getHours()),E(e.getMinutes()),E(e.getSeconds())].join(":");return[e.getDate(),S[e.getMonth()],t].join(" ")}var r=/%[sdj%]/g;t.format=function(e){if(typeof e!="string"){var t=[];for(var n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}var i=1,o=arguments,u=o.length,a=String(e).replace(r,function(e){if(e==="%%")return"%";if(i>=u)return e;switch(e){case"%s":return String(o[i++]);case"%d":return Number(o[i++]);case"%j":return JSON.stringify(o[i++]);default:return e}});for(var f=o[i];i<u;f=o[++i])f===null||typeof f!="object"?a+=" "+f:a+=" "+s(f);return a},t.print=function(){for(var e=0,t=arguments.length;e<t;++e)process.stdout.write(String(arguments[e]))},t.puts=function(){for(var e=0,t=arguments.length;e<t;++e)process.stdout.write(arguments[e]+"\n")},t.debug=function(e){process.stderr.write("DEBUG: "+e+"\n")};var i=t.error=function(e){for(var t=0,n=arguments.length;t<n;++t)process.stderr.write(arguments[t]+"\n")};t.inspect=s;var o={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u={special:"cyan",number:"yellow","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};t.isArray=m,t.isRegExp=g,t.isDate=y,t.isError=b;var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];t.log=function(e){t.puts(x()+" - "+e.toString())},t.pump=function(e,t,n){function i(e,t,i){n&&!r&&(n(e,t,i),r=!0)}var r=!1;e.addListener("data",function(n){t.write(n)===!1&&e.pause()}),t.addListener("drain",function(){e.resume()}),e.addListener("end",function(){t.end()}),e.addListener("close",function(){i()}),e.addListener("error",function(e){t.end(),i(e)}),t.addListener("error",function(t){e.destroy(),i(t)})},t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t._extend=function(e,t){if(!t)return e;var n=Object.keys(t),r=n.length;while(r--)e[n[r]]=t[n[r]];return e}}),define("react/error",["util"],function(e){function t(e){if(!Error.stackTraceLimit||Error.stackTraceLimit<e)Error.stackTraceLimit=e}function n(e){return e?e&&e.name?e.name:e:"undefined"}function r(t){if(!t.meta)return;var r=t.meta.vcon,i=t.meta.task,s="\n\n";return i&&i.f&&i.a&&(s+="Error occurs in Task function: "+n(i.f)+"("+i.a.join(",")+")\n\n"),r&&(s+="Variable Context: \n",s+=e.inspect(r),s+="\n\n"),i&&i.f&&(s+="Task Source:\n\n",s+=i.f.toString(),s+="\n\n"),s}function i(e,t){typeof e=="string"&&(e=new Error(e));var n=e.toString();return e.meta=t,e.toString=function(){return n+r(e)},e}return{ensureStackTraceLimitSet:t,augmentError:i}}),define("react/sprintf",["util"],function(e){var t=e.format;return t}),function(e,t){typeof exports=="object"?module.exports=t():typeof define=="function"&&define.amd?define("ensure-array",[],t):e.ensureArray=t()}(this,function(){function e(e,t,n){if(arguments.length===0)return[];if(arguments.length===1){if(e===undefined||e===null)return[];if(Array.isArray(e))return e}return Array.prototype.slice.call(arguments)}return e}),define("react/status",[],function(){var e={READY:"ready",RUNNING:"running",ERRORED:"errored",COMPLETE:"complete"};return e}),define("react/event-manager",["./eventemitter"],function(e){function i(){}var t={wildcard:!0,delimiter:".",maxListeners:30},n=/^ast.defined$/,r={AST_DEFINED:"ast.defined",FLOW_BEGIN:"flow.begin",TASK_BEGIN:"task.begin",TASK_COMPLETE:"task.complete",TASK_ERRORED:"task.errored",FLOW_COMPLETE:"flow.complete",FLOW_ERRORED:"flow.errored",EXEC_FLOW_START:"exec.flow.start",EXEC_INPUT_PREPROCESS:"exec.input.preprocess",EXEC_TASKS_PRECREATE:"exec.tasks.precreate",EXEC_OUTTASK_CREATE:"exec.outTask.create",EXEC_TASK_START:"exec.task.start",EXEC_TASK_COMPLETE:"exec.task.complete",EXEC_TASK_ERRORED:"exec.task.errored",EXEC_FLOW_COMPLETE:"exec.flow.complete",EXEC_FLOW_ERRORED:"exec.flow.errored"};return i.create=function(){return new i},i.TYPES=r,i.prototype.TYPES=r,i.prototype.isEnabled=function(){return!!(this.emitter||this.parent&&this.parent.isEnabled())},i.prototype.on=function(n,r){this.emitter||(this.emitter=new e(t)),n==="*"?this.emitter.onAny(r):this.emitter.on(n,r)},i.prototype.emit=function(e,t,r,i){if(e===undefined)throw new Error("event is undefined");this.emitter&&this.emitter.emit.apply(this.emitter,arguments),this.parent&&this.parent.isEnabled()&&this.parent.emit.apply(this.parent,arguments),n.test(e)&&typeof process!="undefined"&&process.emit&&process.emit.apply(process,arguments)},i.prototype.removeListener=function(e,t){this.emitter&&this.emitter.removeListener.apply(this.emitter,arguments)},i.prototype.removeAllListeners=function(e){this.emitter&&this.emitter.removeAllListeners.apply(this.emitter,arguments)},i.global=i.create(),i}),define("react/base-task",["ensure-array","./status","./event-manager"],function(e,t,n){function r(){}function i(e){return e.indexOf(".")!==-1}return r.prototype.getOutParams=function(){return e(this.out)},r.prototype.isComplete=function(){return this.status===t.COMPLETE},r.prototype.start=function(e){this.args=e,this.env.currentTask=this,this.env.flowEmitter.emit(n.TYPES.EXEC_TASK_START,this)},r.prototype.complete=function(e){this.status=t.COMPLETE,this.results=e,this.env.currentTask=this,this.env.flowEmitter.emit(n.TYPES.EXEC_TASK_COMPLETE,this)},r.prototype.functionExists=function(e){var t=this.f;if(!t)return!1;if(t instanceof Function)return!0;if(typeof t=="string"){var n=e.getVar(t);if(n&&n instanceof Function)return!0}return!1},r.prototype.areAllDepArgsDefined=function(e){return this.a.every(function(t){return e.getVar(t)!==undefined})},r.prototype.depTasksAreDone=function(e){return!this.after||!this.after.length||this.after.every(function(t){return e[t].isComplete()})},r.prototype.parentExists=function(e,t){if(!i(e))return!0;var n=e.split(".");n.pop();var r=n.reduce(function(e,t){return e===undefined||e===null?undefined:e[t]},t.values);return r!==undefined&&r!==null},r.prototype.outParentsExist=function(e){var t=this;return this.getOutParams().every(function(n){return n===null?!0:t.parentExists(n,e)})},r.prototype.isReady=function(e,t){return!this.status&&this.functionExists(e)&&this.areAllDepArgsDefined(e)&&this.depTasksAreDone(t)&&(!this.outParentsExist||this.outParentsExist(e))},r.prototype.isMethodCall=function(){return typeof this.f=="string"&&/^.*\..*$/.test(this.f)},r.prototype.getMethodObj=function(e){var t=this.f;if(!t)return undefined;var n=t.split(".");n.pop();if(!n.length)return undefined;var r=e.resolveNameArr(n);return r},r}),define("react/cb-task",["util","./sprintf","./base-task"],function(e,t,n){function r(n,r){return t("%s - %s",n,e.inspect(r))}function a(e){var t=this;Object.keys(e).forEach(function(n){t[n]=e[n]})}var i="cbTask requires f, a, out",s="cbTask requires f to be a function or string",o="cbTask requires a to be an array of string param names",u="cbTask requires out to be an array of string param names";return a.prototype=new n,a.prototype.constructor=a,a.validate=function(e){var t=[];if(!e.f||!e.a||!e.out)t.push(r(i,e));else{var n=typeof e.f;e.f instanceof Function||n==="string"||t.push(r(s,e)),(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(r(o,e)),(!Array.isArray(e.out)||!e.out.every(function(e){return typeof e=="string"}))&&t.push(r(u,e))}return t},a.prototype.prepare=function(t,n,r){var i=this;this.cbFun=function(e,s,o,u){var a=Array.prototype.slice.call(arguments,1);if(e){t(i,e);return}n.saveResults(i.out,a),i.complete(a),r()}},a.prototype.exec=function(t,n,r){try{var i=this.a.map(function(e){return t.getVar(e)});this.start(i),i.push(this.cbFun);var s=this.f,o=t.getVar("this");this.isMethodCall()?(s=t.getVar(this.f),o=this.getMethodObj(t)):typeof s=="string"&&(s=t.getVar(s)),s.apply(o,i)}catch(u){n(this,u)}},a}),define("react/promise-task",["util","./sprintf","./base-task"],function(e,t,n){function r(n,r){return t("%s - %s",n,e.inspect(r))}function a(e){var t=this;Object.keys(e).forEach(function(n){t[n]=e[n]})}var i="promiseTask requires f, a, out",s="promiseTask requires f to be a function or string",o="promiseTask requires a to be an array of string param names",u="promiseTask requires out to be an array[1] of string param names";return a.prototype=new n,a.prototype.constructor=a,a.validate=function(e){var t=[];if(!e.f||!e.a||!e.out)t.push(r(i,e));else{var n=typeof e.f;e.f instanceof Function||n==="string"||t.push(r(s,e)),(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(r(o,e)),Array.isArray(e.out)&&e.out.length<=1&&e.out.every(function(e){return typeof e=="string"})||t.push(r(u,e))}return t},a.prototype.prepare=function(t,n,r){var i=this;this.nextFn=function(e){var t=Array.prototype.slice.call(arguments);n.saveResults(i.out,t),i.complete(t),r()},this.failFn=function(e){t(i,e)}},a.prototype.exec=function(t,n,r){try{var i=this.a.map(function(e){return t.getVar(e)});this.start(i);var s=this.f,o=t.getVar("this");this.isMethodCall()?(s=t.getVar(this.f),o=this.getMethodObj(t)):typeof s=="string"&&(s=t.getVar(s));var u=s.apply(o,i);u&&typeof u.then=="function"?u.then(this.nextFn,this.failFn):this.nextFn(u)}catch(a){n(this,a)}},a}),define("react/ret-task",["util","./sprintf","./base-task"],function(e,t,n){function r(n,r){return t("%s - %s",n,e.inspect(r))}function a(e){var t=this;Object.keys(e).forEach(function(n){t[n]=e[n]})}var i="retTask requires f, a, out",s="retTask requires f to be a function or string",o="retTask requires a to be an array of string param names",u="retTask requires out to be an array with single string param name or []";return a.prototype=new n,a.prototype.constructor=a,a.validate=function(e){var t=[];if(!e.f||!e.a||!e.out)t.push(r(i,e));else{var n=typeof e.f;e.f instanceof Function||n==="string"||t.push(r(s,e)),(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(r(o,e)),(!Array.isArray(e.out)||!(e.out.length===0||e.out.length===1&&typeof (e.out[0]==="string")))&&t.push(r(u,e))}return t},a.prototype.exec=function(t,n,r){try{var i=this.a.map(function(e){return t.getVar(e)});this.start(i);var s=this.f,o=t.getVar("this");this.isMethodCall()?(s=t.getVar(this.f),o=this.getMethodObj(t)):typeof s=="string"&&(s=t.getVar(s));var u=[s.apply(o,i)];t.saveResults(this.out,u),this.complete(u),r()}catch(a){n(this,a)}},a}),define("react/when-task",["util","./sprintf","./base-task"],function(e,t,n){function r(n,r){return t("%s - %s",n,e.inspect(r))}function u(e){var t=this;Object.keys(e).forEach(function(n){t[n]=e[n]})}var i="whenTask requires a, out",s="whenTask requires a to be an array[1] of string param names",o="whenTask requires out to be an array[1] of string param names";return u.prototype=new n,u.prototype.constructor=u,u.prototype.f=function(){},u.validate=function(e){var t=[];return!e.a||!e.out?t.push(r(i,e)):((!Array.isArray(e.a)||e.a.length!==1||!e.a.every(function(e){return typeof e=="string"}))&&t.push(r(s,e)),Array.isArray(e.out)&&e.out.length<=1&&e.out.every(function(e){return typeof e=="string"})||t.push(r(o,e))),t},u.prototype.prepare=function(t,n,r){var i=this;this.nextFn=function(e){var t=Array.prototype.slice.call(arguments);n.saveResults(i.out,t),i.complete(t),r()},this.failFn=function(e){t(i,e)}},u.prototype.exec=function(t,n,r){try{var i=this.a.map(function(e){return t.getVar(e)});this.start(i);var s=i[0];s&&typeof s.then=="function"?s.then(this.nextFn,this.failFn):this.nextFn(s)}catch(o){n(this,o)}},u}),define("react/finalcb-task",["./sprintf","util","./status","./event-manager"],function(e,t,n,r){function s(e){var t=e.taskDef;if(typeof e.cbFunc!="function")throw new Error("callback is not a function");var n=this;for(var r in t)n[r]=t[r];this.f=e.cbFunc,this.tasks=e.tasks,this.vCon=e.vCon,this.retValue=e.retValue,this.execOptions=e.execOptions,this.env=e.env}function o(n,r){return e("%s - %s",n,t.inspect(r))}var i="ast.outTask.a should be an array of string param names";return s.validate=function(e){var t=[];return(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(o(i,e)),t},s.prototype.isReady=function(){return this.tasks.every(function(e){return e.status===n.COMPLETE})},s.prototype.exec=function(e){if(!this.f)return;if(e)this.env.error=e,this.env.flowEmitter.emit(r.TYPES.EXEC_FLOW_ERRORED,this.env),this.f.call(null,e);else{var t=this.vCon,n=this.a.map(function(e){return t.getVar(e)});n.unshift(null),this.env.results=n,this.env.flowEmitter.emit(r.TYPES.EXEC_FLOW_COMPLETE,this.env),this.f.apply(null,n)}this.f=null},s}),define("react/vcon",[],function(){function t(){}var e=":LAST_RESULTS";return t.prototype.getLastResults=function(){return this.getVar(e)},t.prototype.setLastResults=function(t){this.setVar(e,t)},t.prototype.getVar=function(e){var t=this.values;if(typeof e!="string")return e;e=e.trim();if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(/^-?[0-9]+$/.test(e))return parseInt(e,10);if(/^-?[0-9.]+$/.test(e))return parseFloat(e);var n=/^("|')([^\1]*)\1$/.exec(e);if(n)return n[2];var r=e.split("."),i=this.resolveNameArr(r);return i},t.prototype.resolveNameArr=function(e){var t=this.values,n=e.reduce(function(e,t){return e===undefined||e===null?undefined:e[t]},t);return n===undefined&&this.global!==undefined&&(n=e.reduce(function(e,t){return e===undefined||e===null?undefined:e[t]},this.global)),n},t.prototype.saveResults=function(e,t){var n=this;e.forEach(function(e,r){n.setVar(e,t[r]!==undefined?t[r]:null)}),this.setLastResults(t)},t.prototype.setVar=function(e,t){if(!e)return;var n=this.values,r=e.split("."),i=r.pop(),s=r.reduce(function(e,t){var n=e[t];if(n===undefined||n===null)n=e[t]={};return n},n);s[i]=t},t.create=function(e,n,r,i){var s={};i&&(s["this"]=i),r&&Object.keys(r).forEach(function(e){s[e]=r[e]});var o=new t;return o.values=e.reduce(function(e,t,r){var i=n[r];return i&&(e[i]=t!==undefined?t:null),e},s),typeof global=="object"?o.global=global:o.global=(new Function("return this"))(),o},t}),define("react/finalcb-first-task",["./sprintf","util","./status","./vcon","./event-manager"],function(e,t,n,r,i){function o(e){var t=e.taskDef;if(typeof e.cbFunc!="function")throw new Error("callback is not a function");var n=this;for(var r in t)n[r]=t[r];this.f=e.cbFunc,this.tasks=e.tasks,this.vCon=e.vCon,this.retValue=e.retValue,this.env=e.env}function u(n,r){return e("%s - %s",n,t.inspect(r))}var s="ast.outTask.a should be an array of string param names";return o.validate=function(e){var t=[];return(!Array.isArray(e.a)||!e.a.every(function(e){return typeof e=="string"}))&&t.push(u(s,e)),t},o.prototype.isReady=function(){var e=this.vCon.getLastResults();return e?e.some(function(e){return e!==undefined&&e!==null}):!1},o.prototype.exec=function(e){if(!this.f)return;if(e)this.env.error=e,this.env.flowEmitter.emit(i.TYPES.EXEC_FLOW_ERRORED,this.env),this.f.call(null,e);else{var t=this.vCon,n=this.a.map(function(e){return t.getVar(e)});n.unshift(null),this.env.results=n,this.env.flowEmitter.emit(i.TYPES.EXEC_FLOW_COMPLETE,this.env),this.f.apply(null,n)}this.f=null},o}),define("react/task",["util","./sprintf","ensure-array","./cb-task","./promise-task","./ret-task","./when-task","./finalcb-task","./finalcb-first-task","./status","./error","./vcon","./event-manager"],function(e,t,n,r,i,s,o,u,a,f,l,c,h){function v(){return Object.keys(p)}function g(){return Object.keys(m)}function S(n,r){return t("%s - %s",n,e.inspect(r))}function x(e){return e.type?e:(e.type="cb",e)}function T(e){e.type||(e.type=Object.keys(m)[0])}function N(e){if(!e.after)return;var t=n(e.after);t=t.map(function(e){return typeof e=="function"?e.name:e}),e.after=t}function C(e){if(!e||typeof e!="object")return[S(b,e)];x(e),N(e);var t=[];return t=t.concat(k(e)),t=t.concat(L(e)),t}function k(e){var t=[];return Object.keys(p).some(function(t){return e.type===t})||t.push(S(E,e)),t}function L(e){var t=[],n=p[e.type];return n&&(t=t.concat(n.validate(e))),t}function A(e){var t=[];T(e);var n=m[e.type];return t=t.concat(n.validate(e)),t}function O(e,n,r){function s(){}var i=[],o=e.map(function(e){return s}),u=c.create(o,e,r),a=n.map(D),f=a.filter(function(e){return e.type!=="when"});return f.forEach(function(e,n){if(!e.functionExists(u))if(!e.isMethodCall())i.push(t(y,e.f,n));else{var r=e.getMethodObj(u);r&&r!==s&&i.push(t(y,e.f,n))}}),i}function M(e){return typeof e=="function"?e.name:e?e:""}function _(e){var n=e.reduce(function(e,t){return t.name&&(e[t.name]=t),e},{});return e.forEach(function(e,r){if(!e.name){var i=M(e.f);i||(i=t(d,r));if(!i||n[i])i=t("%s_%s",i,r);e.name=i,n[i]=e}}),n}function D(e){var t=p[e.type];return new t(e)}function P(e,t,n,r,i,s){T(e);var o={taskDef:e,cbFunc:t,tasks:n,vCon:r,execOptions:i,env:s,TaskConstructor:m[e.type]};h.global.emit(h.TYPES.EXEC_OUTTASK_CREATE,o);var u=o.TaskConstructor;return new u(o)}function H(e,t){return function(r,i){r.status=f.ERRORED,r.error=i,t.env.currentTask=r,t.env.flowEmitter.emit(h.TYPES.EXEC_TASK_ERRORED,r);var s=l.augmentError(i,{task:r,vcon:e});t.exec(s)}}function B(e,t,n){return t.filter(function(t){return t.isReady(e,n)})}function j(e,t,n,r){e.forEach(function(e){e.status=f.READY}),e.forEach(function(e){e.exec(t,n,r)})}function F(e,n,r,i){var s=n.filter(function(e){return e.status===f.RUNNING||e.status===f.READY});if(!s.length){var o=n.filter(function(e){return!e.status}),u=o.map(function(e){return e.name}),a=t(w,u.join(", ")),l={env:i};r(l,new Error(a))}}function I(e,t,n,r,i,s){var o=B(e,t,n);o.length||F(e,t,r,s),j(o,e,r,i)}function q(e){return _(e),e.forEach(function(e,t,n){t!==0&&(e.after=[n[t-1].name])}),e}var p={cb:r,ret:s,promise:i,when:o},d="task_%s",m={finalcb:u,finalcbFirst:a},y="function: %s not found in locals or input params - task[%s]",b="task must be an object",w="no tasks running, flow will not complete, remaining tasks: %s",E="task.type should match one of "+Object.keys(p).join(", ");return{serializeTasks:q,TASK_TYPES:p,taskTypeKeys:v,OUT_TASK_TYPES:m,outTaskTypeKeys:g,setMissingType:x,validate:C,validateOutTask:A,validateLocalFunctions:O,nameTasks:_,create:D,createOutTask:P,createErrorHandler:H,findReadyAndExec:I}}),define("react/validate",["util","./sprintf","ensure-array","./task"],function(e,t,n,r){function h(n,r){return t("%s - %s",n,e.inspect(r))}function p(e){return c.test(e)}function d(e){if(!e||!e.inParams||!e.tasks||!e.outTask)return[i];var t=[];return t=t.concat(v(e.inParams)),t=t.concat(m(e.tasks)),t=t.concat(g(e.tasks)),t=t.concat(r.validateOutTask(e.outTask)),t=t.concat(y(e.locals)),t.length===0&&(e.outTask.type!=="finalcbFirst"&&(t=t.concat(w(e.tasks))),t=t.concat(r.validateLocalFunctions(e.inParams,e.tasks,e.locals)),t=t.concat(E(e))),t}function v(e){return!Array.isArray(e)||!e.every(function(e){return typeof e=="string"})?[s]:[]}function m(e){if(!Array.isArray(e))return[o];var t=[];return e.forEach(function(e){t=t.concat(r.validate(e))}),t}function g(e){if(!Array.isArray(e))return[];var n=[],r=e.filter(function(e){return e.name}),i=r.map(function(e){return e.name});return i.reduce(function(e,r){return e[r]?n.push(t("%s %s",u,r)):e[r]=!0,e},{}),n}function y(e){var t=[];return e===null&&t.push(a),t}function b(e){return n(e.out)}function w(e){var n=[];return e.reduce(function(e,r){return b(r).forEach(function(r){e[r]!==undefined?n.push(t("%s: %s",f,r)):e[r]=!0}),e},{}),n}function E(e){var n=[],r={};return e.locals&&(r=Object.keys(e.locals).reduce(function(e,t){return e[t]=!0,e},r)),e.inParams.reduce(function(e,t){return e[t]=!0,e},r),e.tasks.reduce(function(e,t){return t.out.reduce(function(e,t){return e[t]=!0,e},e)},r),e.tasks.reduce(function(e,n){return n.a.reduce(function(e,n){return!p(n)&&!r[n]&&e.push(t(l,n)),e},e)},n),e.outTask.a.reduce(function(e,n){return!p(n)&&!r[n]&&e.push(t(l,n)),e},n),n}var i="ast must be an object with inParams, tasks, and outTask",s="ast.inParams must be an array of strings",o="ast.tasks must be an array of tasks",u="ast.tasks that specify name need to be unique, duplicate:",a="ast.locals should not be null",f="multiple tasks output the same param, must be unique. param",l="missing or mispelled variable referenced in flow definition: %s",c=/^(true|false|this|null|\-?[0-9\.]+)$|'|"|\./i;return d}),define("react/input-parser",["./event-manager"],function(e){function r(e){return e&&e.reactExecOptions}function i(e){return r(e)}function s(e){return!r(e)}function o(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e}function u(e,t,r){var i={};return i.args=t.map(function(t){return e.shift()}),r===n.CALLBACK&&e.length&&(i.cb=e.shift()),i.extra=e,i}function a(n,r){var a={},f=n.filter(i);f.unshift(t),a.options=f.reduce(o,{});var l=n.filter(s),c=u(l,r.inParams,a.options.outputStyle);return a.args=c.args,a.cb=c.cb,c.outputStyle&&(a.options.outputStyle=c.outputStyle),c.extra&&(a.extraArgs=c.extra),e.global.emit(e.TYPES.EXEC_INPUT_PREPROCESS,a),a}var t={reactExecOptions:!0,outputStyle:"cb"},n={CALLBACK:"cb",NONE:"none"};return a.defaultExecOptions=t,a}),define("react/id",[],function(){function t(){return e+=1,e===Number.MAX_VALUE&&(e=0),e}var e=0;return{createUniqueId:t}}),define("react/core",["./eventemitter","./error","./validate","./task","./status","./vcon","./event-manager","./input-parser","./id","./sprintf"],function(e,t,n,r,i,s,o,u,a,f){function h(e){return Object.keys(l).reduce(function(e,t){return e[t]||(e[t]=l[t]),e},e)}function p(){return f("flow_%s",a.createUniqueId())}function d(){function f(t){Object.keys(t).forEach(function(e){i[e]=t[e]});var s=n(i);return s.length||(i.name||(i.name=p()),r.nameTasks(i.tasks)),Object.freeze&&(Object.keys(t).forEach(function(e){typeof t[e]=="object"&&Object.freeze(t[e])}),Object.freeze(t)),e.emit(o.TYPES.AST_DEFINED,i),s}function d(t,n,f,l){function E(){if(!b.f)return;if(b.isReady())return b.exec();r.findReadyAndExec(m,g,y,w,E,d)}var p=Array.prototype.slice.call(arguments),d={execId:a.createUniqueId(),args:p,ast:i,flowEmitter:e};d.name=i.name||d.execId,e.emit(o.TYPES.EXEC_FLOW_START,d);var v=u(p,i),m=s.create(v.args,i.inParams,i.locals,this);d.parsedInput=v,d.options=h(v.options),d.vCon=m,d.taskDefs=i.tasks.slice(),d.outTaskDef=Object.create(i.outTask),c.emit(o.TYPES.EXEC_TASKS_PRECREATE,d);var g=d.taskDefs.map(r.create),y=r.nameTasks(g),b=r.createOutTask(d.outTaskDef,v.cb,g,m,d.options,d),w=r.createErrorHandler(m,b);return g.forEach(function(t){t.id=a.createUniqueId(),t.env=d,t.prepare&&t.prepare(w,m,E,e)}),E(),b.retValue}if(arguments.length)throw new Error("react() takes no args, check API");t.ensureStackTraceLimitSet(l.stackTraceLimitMin);var e=o.create();e.parent=c;var i={name:undefined,inParams:[],tasks:[],outTask:{},locals:{}},v=d;return v.ast=i,v.setAndValidateAST=f,v.events=e,v}var l={stackTraceLimitMin:30},c=o.global;return d.options=l,d.events=c,d}),define("react/parse",["./sprintf"],function(e){function t(e){return e?e.split(",").map(function(e){return e.trim()}).filter(function(e){return e}):[]}function n(e,t){if(typeof e!="string")return e;var n=t.regex?t.regex.exec(e):e.split(t.splitStr);return n?t.fn(n,e):e}function r(t,r,i){var s=r.reduce(n,t);if(typeof s!="string")return s;throw new Error(e(i,t))}return{splitTrimFilterArgs:t,parseStr:r}}),define("react/dsl",["./sprintf","./core","./parse","./task"],function(e,t,n,r){function h(e){return e.length&&e[e.length-1].match(l)&&e.pop(),e}function p(e){return e.length&&e[0].match(c)&&e.shift(),e}function v(e){var t=n.parseStr(e,[d],s);return t.inDef=h(t.inDef),t}function m(t){var n=[],r,i,s;while(t.length>=2){i={},r=t.shift(),s=v(t.shift()),typeof t[0]=="object"&&(i=t.shift()),i.f=r,i.a=s.inDef;var o=s.type;i.out=s.outDef,i.type=o,n.push(i)}if(t.length)throw new Error(e(a,t[0]));return n}function g(e){var t=e.shift()||"",n=e.length&&typeof e[0]=="object"?e.shift():{},r=e,i={inOutParamStr:t,taskDefArr:r,options:n};return i}function y(n,r,s,o){var u=t();if(n&&f.test(n))throw new Error(e(i,n));var a=g(Array.prototype.slice.call(arguments,1)),l=v(a.inOutParamStr),c={name:n,inParams:l.inDef,tasks:m(a.taskDefArr),outTask:{a:l.outDef}};a.options&&Object.keys(a.options).forEach(function(e){c[e]=a.options[e]});var h=u.setAndValidateAST(c);if(h.length){var p=h.join("\n");throw new Error(p)}return u}function b(e,n,i,s){var o=t(),u=g(Array.prototype.slice.call(arguments,1)),a=v(u.inOutParamStr),f=r.serializeTasks(m(u.taskDefArr)),l={name:e,inParams:a.inDef,tasks:f,outTask:{type:"finalcbFirst",a:a.outDef}};u.options&&Object.keys(u.options).forEach(function(e){l[e]=u.options[e]});var c=o.setAndValidateAST(l);if(c.length){var h=c.join("\n");throw new Error(h)}return o}var i="first flow parameter should be the flow name, but found in/out def: %s",s='params in wrong format, wanted "foo, bar, cb -> err, baz" - found: %s',o='callback specified, but first out param was not "err", use for clarity. Found in/out def: %s',u="found err param, but cb/callback is not specified, is this cb-style async or sync function? Found in/out def: %s",a="extra unmatched task arg: %s",f=/\->/,l=/^cb|callback$/i,c=/^err$/i,d={splitStr:"->",fn:function(t,r){var i=n.splitTrimFilterArgs(t[0]),s=i[i.length-1],a=s&&l.test(s)?"cb":"ret",f=n.splitTrimFilterArgs(t[1]),d=f[0];if(a==="cb"&&(!d||!c.test(d)))throw new Error(e(o,r));if(a==="ret"&&d&&c.test(d))throw new Error(e(u,r));return{type:a,inDef:h(i),outDef:p(f)}}};return y.selectFirst=b,y}),define("react/track-tasks",[],function(){function t(t){if(e)return;e=!0,t.events.on(t.events.TYPES.EXEC_FLOW_START,function(e){e.startTime=Date.now(),e.flowEmitter.emit(t.events.TYPES.FLOW_BEGIN,e)}),t.events.on(t.events.TYPES.EXEC_TASK_START,function(e){e.startTime=Date.now(),e.env.flowEmitter.emit(t.events.TYPES.TASK_BEGIN,e)}),t.events.on(t.events.TYPES.EXEC_TASK_COMPLETE,function(e){e.endTime=Date.now(),e.elapsedTime=e.endTime-e.startTime,e.env.flowEmitter.emit(t.events.TYPES.TASK_COMPLETE,e)}),t.events.on(t.events.TYPES.EXEC_TASK_ERRORED,function(e){e.endTime=Date.now(),e.elapsedTime=e.endTime-e.startTime,e.env.flowEmitter.emit(t.events.TYPES.TASK_ERRORED,e)}),t.events.on(t.events.TYPES.EXEC_FLOW_COMPLETE,function(e){e.endTime=Date.now(),e.elapsedTime=e.endTime-e.startTime,e.flowEmitter.emit(t.events.TYPES.FLOW_COMPLETE,e)}),t.events.on(t.events.TYPES.EXEC_FLOW_ERRORED,function(e){e.endTime=Date.now(),e.elapsedTime=e.endTime-e.startTime,e.flowEmitter.emit(t.events.TYPES.FLOW_ERRORED,e)})}var e=!1;return t}),define("react/log-events",["util"],function(e){function s(t){var n=new Date;n.setTime(t.startTime);var r=t.args.filter(function(e){return typeof e!="function"}),i=n.toISOString();if(this.event==="flow.complete"){var s=t;console.error("%s: %s msecs: %s \n args: %s \n results: %s\n",this.event,s.name,s.elapsedTime,e.inspect(r),e.inspect(s.results))}else{var o=t.name,u=t.args;console.error("%s: %s \n args: %s\n",this.event,o,e.inspect(r))}}function o(t){var n=new Date;n.setTime(t.startTime);var r=t.args.filter(function(e){return typeof e!="function"}),i=n.toISOString();if(this.event==="task.complete"){var s=t;console.error("%s: %s:%s msecs: %s \n args: %s \n results: %s\n",this.event,s.env.name,s.name,s.elapsedTime,e.inspect(r),e.inspect(s.results))}else{var o=t.name,u=t.args;console.error("%s: %s:%s \n args: %s\n",this.event,t.env.name,t.name,e.inspect(r))}}function u(e,t){if(!e)throw new Error("flowFn is required");e.events._loggingEvents||(e.events._loggingEvents=[]);if(t===!1)e.events._loggingEvents.forEach(function(t){e.events.removeAllListeners(t)}),e.events._loggingEvents.length=0;else if(t&&t!=="*"){var u=i.test(t)?s:o;e.events.removeListener(t,u),e.events.on(t,u),e.events._loggingEvents.push(t)}else e.events.removeListener(n,s),e.events.on(n,s),e.events._loggingEvents.push(n),e.events.removeListener(r,o),e.events.on(r,o),e.events._loggingEvents.push(r)}var t={},n="flow.*",r="task.*",i=/^flow\./;return t.logEvents=u,t}),define("react/promise-resolve",[],function(){function n(n){if(t)return;t=!0,n.events.on(n.events.TYPES.EXEC_TASKS_PRECREATE,function(t){var n=t.vCon.values,r=t.ast.inParams.filter(function(e){var t=n[e];return t&&typeof t.then=="function"});r.forEach(function(r){var i=r+e;n[i]=n[r],n[r]=undefined,t.taskDefs.push({type:"when",a:[i],out:[r]})})})}var e="__promise",t=!1;return n}),define("react/event-collector",[],function(){function e(e){function i(){this.events=[]}e.trackTasks();var t=/^ast\./,n=/^task\./,r=/^flow\./;return i.prototype.capture=function(i,s){function a(e){var i={event:this.event,time:Date.now()};r.test(this.event)?i.env=e:n.test(this.event)?i.task=e:t.test(this.event)&&(i.ast=e),u.events.push(i)}!s&&typeof i=="string"?(s=i,i=e):i||(i=e),s||(s="*");var o=i.events,u=this;o.on(s,a)},i.prototype.list=function(){return this.events},i.prototype.clear=function(){this.events=[]},new i}return e}),define("react/react",["./core","./dsl","./track-tasks","./log-events","./promise-resolve","./event-collector"],function(e,t,n,r,i,s){function u(){i(o)}function a(){n(o)}function f(e,t){return typeof e!="function"&&(t=e,e=undefined),e||(e=o),a(),r.logEvents(e,t)}function l(){return s(o)}var o=t;return o.options=e.options,o.events=e.events,o.logEvents=f,o.resolvePromises=u,o.trackTasks=a,o.createEventCollector=l,o}),define("react",["react/react"],function(e){return e});
View
70 doc/advanced.md
@@ -1,20 +1,20 @@
-# Advanced React
+# Advanced autoflow
-<a name="directAST"/>
+<A Name="directAST"/>
## Example defining directly using AST
Defining flow directly using the AST. Additional DSL interfaces can be built by simply having them build the proper AST.
```javascript
-var react = require('react');
+var autoflow = require('autoflow');
function load(res, cb) { setTimeout(cb, 100, null, res + '-loaded'); }
function prefix(prefstr, str, cb) { setTimeout(cb, 100, null, prefstr + str); }
function postfix(str, poststr, cb) { setTimeout(cb, 100, null, str + poststr); }
function upper(str) { return str.toUpperCase(); }
-var fn = react();
+var fn = autoflow();
var errors = fn.setAndValidateAST({
inParams: ['res', 'prefstr', 'poststr'],
tasks: [
@@ -36,15 +36,15 @@ fn('foo', 'pre-', '-post', function cb(err, lres) {
## AST Definition
-The abstract syntax tree or AST provided by React represents the data necessary to define the flow. By abstracting this from the DSL, it allows new skins or interfaces to be developed without need to change the core engine.
+The abstract syntax tree or AST provided by autoflow represents the data necessary to define the flow. By abstracting this from the DSL, it allows new skins or interfaces to be developed without need to change the core engine.
-The AST is normally created at parse time when the React main function is called (or one of the alternate DSL's is called). This can be done a module load time such that after loading the React defined flow function's AST is generated and ready to process eliminating parsing and validation overhead when it is invoked in the future. This has the added advantage that since validation has also been performed that additional syntax issues or incomplete flow defintion errors can be caught quickly.
+The AST is normally created at parse time when the autoflow main function is called (or one of the alternate DSL's is called). This can be done a module load time such that after loading the autoflow defined flow function's AST is generated and ready to process eliminating parsing and validation overhead when it is invoked in the future. This has the added advantage that since validation has also been performed that additional syntax issues or incomplete flow defintion errors can be caught quickly.
After the flow function has been created, you can review the generated AST for a function by accessing the ast.
```javascript
-var react = require('react');
-var fn = react('my-flow-name', 'paramName1, paramName2, cb -> err, outParamName1, outParamName2',
+var autoflow = require('autoflow');
+var fn = autoflow('my-flow-name', 'paramName1, paramName2, cb -> err, outParamName1, outParamName2',
functionRefOrMethodStr, 'paramName1, cb -> err, outParamName2', // async cb task
functionRefOrMethodStr2, 'paramName2, paramName1 -> outParamName1' // sync task
);
@@ -63,18 +63,18 @@ The AST contains the following pieces:
locals: {}
};
```
- - **name** - string - represents the name of the flow or function that will be created. React will use the name when generating events so you can monitor progress and performance and also when errors occur.
- - **inParams** - array of strings - the flow input parameter names (excluding the callback param)
+ - **name** - string - represents the name of the flow or function that will be created. autoflow will use the name when generating events so you can monitor progress and performance and also when errors occur.
+ - **InParams** - array of strings - the flow input parameter names (excluding the callback param)
- **tasks** - array of task defintion objects - each containing:
- **f** - function reference or method string - async or sync function to be used for this task
- **a** - array of input parameter names (excluding the callback param)
- **out** - array of output parameter names (excluding the err parame)
- **type** - type of function determining how function is invoked and its output style - one of: ('cb', 'ret', 'promise', 'when')
- - **name** - string - unique name for each task provided or generated by React
- - **outTask** - task definition object specifying the flow's output style and parameters containing:
+ - **name** - string - unique name for each task provided or generated by autoflow
+ - **OutTask** - task definition object specifying the flow's output style and parameters containing:
- **f** - will contain reference to the callback function at runtime
- **a** - parameters being passed as output from the flow
- - **locals** - object provided which contains additional values that will become part of the React variable space like input parameters but can be defined in advance at flow definition. This can be used to provide functions and objects to React enabling string based DSL's. The global variables are already built-in, but any locals that are needed would be specified here.
+ - **locals** - object provided which contains additional values that will become part of the autoflow variable space like input parameters but can be defined in advance at flow definition. This can be used to provide functions and objects to autoflow enabling string based DSL's. The global variables are already built-in, but any locals that are needed would be specified here.
## Plugins (optional requires which turn on additional functionality)
@@ -83,29 +83,29 @@ Additional functionality which is not enabled by default but available by requir
<a name="LogEvents"/>
-### LogEvents - log react progress to stderr
+### LogEvents - log autoflow progress to stderr
-For convenience in debugging or in monitoring flow and performance, React has a built-in plugin for easily logging progress to stderr which is loaded and activated calling the react method `logEvents`. It can be specified to log globally for all react functions or only for particular react functions. You also may optionally listen to select events rather than all flow and task events.
+For convenience in debugging or in monitoring flow and performance, autoflow has a built-in plugin for easily logging progress to stderr which is loaded and activated calling the autoflow method `logEvents`. It can be specified to log globally for all autoflow functions or only for particular autoflow functions. You also may optionally listen to select events rather than all flow and task events.
-```javascript
-var react = require('react');
-react.logEvents(); // turn on flow and task logging for all react functions
+```Javascript
+var autoflow = require('autoflow');
+autoflow.logEvents(); // turn on flow and task logging for all autoflow functions
// OR
-react.logEvents(myReactFn); // turn on flow and task logging for a specific function, repeat as needed
-react.logEvents(myReactFn).logEvents(myReactFn2); // can also chain
+autoflow.logEvents(myautoflowFn); // turn on flow and task logging for a specific function, repeat as needed
+autoflow.LogEvents(myautoflowFn).logEvents(myautoflowFn2); // can also chain
// Both methods can also take an optional event wildcard to specify what you want to listen to
-react.logEvents('flow.*'); // turn on flow logging for all react functions
-react.logEvents(myReactFn, 'task.*'); // turn on task logging for myReactFn
+autoflow.logEvents('flow.*'); // turn on flow logging for all autoflow functions
+autoflow.logEvents(myautoflowFn, 'task.*'); // turn on task logging for myautoflowFn
```
To turn off logging
```javascript
-react.logEvents(false); // turn off logging
+autoflow.logEvents(false); // turn off logging
```
@@ -121,11 +121,11 @@ Available Events that can be logged:
### Automatic Promise Resolution for inputs
-If you want to automatically resolve promises in React without having to manually call `when` or `then`, React provides a plugin which will detect the existence of a `then` method (indicating a promise) at runtime from any inputs to the flow and will internally create `when` tasks to resolve them before passing the values to other tasks. This built-in plugin is not loaded normally but is loaded by invoking the react method `resolvePromises`. External plugins like `react-deferred` and `react-q` also enable this but also provide additional promise integration. See https://github.com/jeffbski/react-deferred and https://github.com/jeffbski/react-q
+If you want to automatically resolve promises in autoflow without having to manually call `when` or `then`, autoflow provides a plugin which will detect the existence of a `then` method (indicating a promise) at runtime from any inputs to the flow and will internally create `when` tasks to resolve them before passing the values to other tasks. This built-in plugin is not loaded normally but is loaded by invoking the autoflow method `resolvePromises`. External plugins like `react-deferred` and `react-q` also enable this but also provide additional promise integration. See https://github.com/jeffbski/react-deferred and https://github.com/jeffbski/react-q
-```javascript
-var react = require('react');
-react.resolvePromises(); // turn on automatic promise detection and resolution
+```Javascript
+var autoflow = require('autoflow');
+autoflow.resolvePromises(); // turn on automatic promise detection and resolution
```
### Track tasks - enable task tracking
@@ -135,8 +135,8 @@ Instead of only logging events to stderr (like LogEvents), this built-in plugin
Enable this like the other built-in plugins using the method `trackTasks`
```javascript
-var react = require('react');
-react.trackTasks(); // turn on flow and task tracking events
+var autoflow = require('autoflow');
+autoflow.trackTasks(); // turn on flow and task tracking events
```
Available Events that can be consumed
@@ -157,11 +157,11 @@ When developing or debugging it is often useful to accumulate events and then in
To make this easier to accomplish, this plugin provides a simple event accumulator for development use. Note that this accumulator is designed for short term debug use, as it will continue to accumulate events and does not have any size restrictions, it should not be used in production since it will just continue to grow in size unless manually cleared.
```javascript
-var react = require('react');
-var collector = react.createEventCollector();
+var autoflow = require('autoflow');
+var collector = autoflow.createEventCollector();
-collector.capture(); // capture all flow and task events for all react flows
-collector.capture('flow.*'); // capture all flow events for all react flows
+collector.capture(); // capture all flow and task events for all autoflow flows
+collector.capture('flow.*'); // capture all flow events for all autoflow flows
collector.capture(flowFn, 'task.*'); // capture task events on a flow
collector.capture(flowFn, 'flow.*'); // add capture flow events on a flow
@@ -171,5 +171,5 @@ collector.clear(); // clear the list of events;
### External Plugins
- - https://github.com/jeffbski/react-deferred - integrates jQuery style Deferred/Promises with react, providing automatic promise resolution and optional usage for react functions where by calling without a callback returns a promise.
- - https://github.com/jeffbski/react-q - integrates Q-style Deferred/Promises with react, providing automatic promise resolution and optional usage for react functions where by calling without a callback returns a promise.
+ - https://github.com/jeffbski/react-deferred - integrates jQuery style Deferred/Promises with autoflow, providing automatic promise resolution and optional usage for autoflow functions where by calling without a callback returns a promise.
+ - https://github.com/jeffbski/react-q - integrates Q-style Deferred/Promises with autoflow, providing automatic promise resolution and optional usage for autoflow functions where by calling without a callback returns a promise.
View
6 examples/longer-example.js
@@ -1,7 +1,7 @@
'use strict';
/*jshint white: false */
-var react = require('../'); // require('react');
+var autoflow = require('../'); // require('autoflow');
function loadUser(uid, cb){ setTimeout(cb, 100, null, "User"+uid); }
function loadFile(filename, cb){ setTimeout(cb, 100, null, 'Filedata'+filename); }
@@ -21,9 +21,9 @@ function useHtml(err, html, user, bytesWritten) {
console.log('final result: %s, user: %s, written:%s', html, user, bytesWritten);
}
-// define fn, glue together with react, it will parallelize
+// define fn, glue together with autoflow, it will parallelize
// starts with name and in/out params, then the tasks
-var loadAndSave = react('loadAndSave', 'filename, uid, outDir, cb -> err, html, user, bytes',
+var loadAndSave = autoflow('loadAndSave', 'filename, uid, outDir, cb -> err, html, user, bytes',
loadUser, 'uid, cb -> err, user', // calling async loadUser with uid, cb called with err and user
loadFile, 'filename, cb -> err, filedata',
markdown, 'filedata -> html', // using a sync function
View
6 examples/simple.js
@@ -14,7 +14,7 @@
the tasks have completed.
*/
-var react = require('../'); // require('react');
+var autoflow = require('../'); // require('autoflow');
function loadFoo(fooPath, cb) {
setTimeout(function () {
@@ -33,7 +33,7 @@ function render(foo, bar) {
}
-var fn = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
+var fn = autoflow('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
loadFoo, 'fooPath, cb -> err, foo',
loadBar, 'barPath, barP2, cb -> err, bar',
render, 'foo, bar -> renderedOut'
@@ -42,4 +42,4 @@ var fn = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
fn('foo.txt', 'bar.txt', 'BBB', function (err, renderedOut) {
console.error('results:', renderedOut);
-});
+});
View
4 examples/using-ast-directly.js
@@ -4,14 +4,14 @@
Advanced example using the AST directly which most users will not do.
For general use, see other examples like simple.js
*/
-var react = require('../'); // require('react');
+var autoflow = require('../'); // require('autoflow');
function load(res, cb) { setTimeout(cb, 100, null, res + '-loaded'); }
function prefix(prefstr, str, cb) { setTimeout(cb, 100, null, prefstr + str); }
function postfix(str, poststr, cb) { setTimeout(cb, 100, null, str + poststr); }
function upper(str) { return str.toUpperCase(); }
-var fn = react();
+var fn = autoflow();
var errors = fn.setAndValidateAST({
inParams: ['res', 'prefstr', 'poststr'],
tasks: [
View
10 examples/using-events1.js
@@ -5,11 +5,11 @@
Default DSL, showing use of events
*/
-var react = require('../'); // require('react');
-react.trackTasks(); // turn on flow and task tracking events
+var autoflow = require('../'); // require('autoflow');
+autoflow.trackTasks(); // turn on flow and task tracking events
//output events as tasks start and complete
-react.events.on('flow.*', function (obj) {
+autoflow.events.on('flow.*', function (obj) {
/*jshint validthis: true */
var time = new Date();
time.setTime(obj.time);
@@ -26,7 +26,7 @@ react.events.on('flow.*', function (obj) {
}
});
-react.events.on('task.*', function (obj) {
+autoflow.events.on('task.*', function (obj) {
/*jshint validthis: true */
var time = new Date();
time.setTime(obj.time);
@@ -62,7 +62,7 @@ function useHtml(err, html, user, bytesWritten) {
console.log('final result: %s, user: %s, written:%s', html, user, bytesWritten);
}
-var loadAndSave = react('loadAndSave', 'filename, uid, outDirname, cb -> err, html, user, bytesWritten', // name, in/out params
+var loadAndSave = autoflow('loadAndSave', 'filename, uid, outDirname, cb -> err, html, user, bytesWritten', // name, in/out params
loadUser, 'uid, cb -> err, user', // calling async fn loadUser with uid, callback is called with err and user
loadFile, 'filename, cb -> err, filedata',
markdown, 'filedata -> html', // using a sync function
View
6 examples/using-log-events.js
@@ -5,8 +5,8 @@
Default DSL, showing use of events
*/
-var react = require('../'); // require('react');
-react.logEvents(); // turn on logging of all flow and task events for all react functions
+var autoflow = require('../'); // require('autoflow');
+autoflow.logEvents(); // turn on logging of all flow and task events for all autoflow functions
function loadUser(uid, cb){ setTimeout(cb, 100, null, "User"+uid); }
@@ -26,7 +26,7 @@ function useHtml(err, html, user, bytesWritten) {
console.log('final result: %s, user: %s, written:%s', html, user, bytesWritten);
}
-var loadAndSave = react('loadAndSave', 'filename, uid, outDirname, cb -> err, html, user, bytesWritten', // name, in/out params
+var loadAndSave = autoflow('loadAndSave', 'filename, uid, outDirname, cb -> err, html, user, bytesWritten', // name, in/out params
loadUser, 'uid, cb -> err, user', // calling async fn loadUser with uid, callback is called with err and user
loadFile, 'filename, cb -> err, filedata',
markdown, 'filedata -> html', // using a sync function
View
26 lib/react.js → lib/autoflow.js
@@ -8,35 +8,35 @@ define(['./core', './dsl', './track-tasks', './log-events', './promise-resolve',
function (core, dsl, trackTasksFn, logEventsMod, resolvePromisesFn, eventCollectorFactory) {
'use strict';
- var react = dsl; // core + default dsl
+ var autoflow = dsl; // core + default dsl
/**
Enable detection of promises and resolution
*/
function resolvePromises() {
- resolvePromisesFn(react);
+ resolvePromisesFn(autoflow);
}
/**
Enable tracking of tasks and flow execution, emitting events and
tracking start, end, elapsed time
*/
function trackTasks() {
- trackTasksFn(react);
+ trackTasksFn(autoflow);
}
/**
If called, load the built-in plugin for log events and invoke
- @param flowFn [function] if not provided uses global react
+ @param flowFn [function] if not provided uses global autoflow
@param eventWildcard [string] pattern to log events for
*/
function logEvents(flowFn, eventWildcard) {
if (typeof(flowFn) !== 'function') { // only wildcard provided
eventWildcard = flowFn;
flowFn = undefined;
}
- if (!flowFn) flowFn = react; // use global
+ if (!flowFn) flowFn = autoflow; // use global
trackTasks();
return logEventsMod.logEvents(flowFn, eventWildcard);
}
@@ -45,15 +45,15 @@ define(['./core', './dsl', './track-tasks', './log-events', './promise-resolve',
Instantiate an event collector
*/
function createEventCollector() {
- return eventCollectorFactory(react);
+ return eventCollectorFactory(autoflow);
}
- react.options = core.options; // global react options
- react.events = core.events; // global react event emitter
- react.logEvents = logEvents; // enable event logging
- react.resolvePromises = resolvePromises; // enable promise resolution
- react.trackTasks = trackTasks; // enable tracking of tasks
- react.createEventCollector = createEventCollector; // create instance of EventCollector
- return react;
+ autoflow.options = core.options; // global autoflow options
+ autoflow.events = core.events; // global autoflow event emitter
+ autoflow.logEvents = logEvents; // enable event logging
+ autoflow.resolvePromises = resolvePromises; // enable promise resolution
+ autoflow.trackTasks = trackTasks; // enable tracking of tasks
+ autoflow.createEventCollector = createEventCollector; // create instance of EventCollector
+ return autoflow;
});
View
42 lib/core.js
@@ -10,18 +10,18 @@ define(['./eventemitter', './error', './validate', './task', './status',
VContext, EventManager, inputParser, idGenerator, sprintf) {
'use strict';
- var reactOptions = {
+ var autoflowOptions = {
stackTraceLimitMin: 30
};
- var reactEmitter = EventManager.global; // the top emitter
+ var autoflowEmitter = EventManager.global; // the top emitter
/**
- merge global react options with parsed options
+ merge global autoflow options with parsed options
*/
function mergeOptions(parsedOptions) {
- return Object.keys(reactOptions).reduce(function (accum, k) {
- if (!accum[k]) accum[k] = reactOptions[k];
+ return Object.keys(autoflowOptions).reduce(function (accum, k) {
+ if (!accum[k]) accum[k] = autoflowOptions[k];
return accum;
}, parsedOptions);
}
@@ -34,13 +34,13 @@ define(['./eventemitter', './error', './validate', './task', './status',
}
/**
- Creates react function which the AST can be manipulated and then
+ Creates autoflow function which the AST can be manipulated and then
is ready to be executed. Can be used directly or a DSL can wrap this
to provide the AST.
@example
- var react = require('react');
- var fn = react();
+ var autoflow = require('autoflow');
+ var fn = autoflow();
var valid2 = fn.setAndValidateAST({
name: 'optionalName',
inParams: ['a', 'b'],
@@ -52,12 +52,12 @@ define(['./eventemitter', './error', './validate', './task', './status',
console.log(fn.ast); // view
fn(123, 456, cb);
*/
- function reactFactory() {
- if (arguments.length) throw new Error('react() takes no args, check API');
+ function autoflowFactory() {
+ if (arguments.length) throw new Error('autoflow() takes no args, check API');
- error.ensureStackTraceLimitSet(reactOptions.stackTraceLimitMin);
+ error.ensureStackTraceLimitSet(autoflowOptions.stackTraceLimitMin);
var flowEmitter = EventManager.create();
- flowEmitter.parent = reactEmitter;
+ flowEmitter.parent = autoflowEmitter;
var ast = {
name: undefined,
@@ -103,7 +103,7 @@ define(['./eventemitter', './error', './validate', './task', './status',
env.vCon = vCon;
env.taskDefs = ast.tasks.slice(); // create copy
env.outTaskDef = Object.create(ast.outTask); // create copy
- reactEmitter.emit(EventManager.TYPES.EXEC_TASKS_PRECREATE, env); // hook
+ autoflowEmitter.emit(EventManager.TYPES.EXEC_TASKS_PRECREATE, env); // hook
var tasks = env.taskDefs.map(taskUtil.create);
var tasksByName = taskUtil.nameTasks(tasks); // map names to working tasks
@@ -125,14 +125,14 @@ define(['./eventemitter', './error', './validate', './task', './status',
return outTask.retValue; // could return promise
}
- var reactFn = exec; // make the exec() the function returned
- reactFn.ast = ast; // put AST hanging off the fn so it can be inspected
- reactFn.setAndValidateAST = setAndValidateAST; // call to set AST and then validate
- reactFn.events = flowEmitter; // used to listen to execution events for this flow
- return reactFn;
+ var autoflowFn = exec; // make the exec() the function returned
+ autoflowFn.ast = ast; // put AST hanging off the fn so it can be inspected
+ autoflowFn.setAndValidateAST = setAndValidateAST; // call to set AST and then validate
+ autoflowFn.events = flowEmitter; // used to listen to execution events for this flow
+ return autoflowFn;
}
- reactFactory.options = reactOptions; // global react options
- reactFactory.events = reactEmitter; // global react emitter
- return reactFactory; // module returns reactFactory to create a react fn
+ autoflowFactory.options = autoflowOptions; // global autoflow options
+ autoflowFactory.events = autoflowEmitter; // global autoflow emitter
+ return autoflowFactory; // module returns autoflowFactory to create a autoflow fn
});
View
12 lib/dsl.js
@@ -93,7 +93,7 @@ define(['./sprintf', './core', './parse', './task'],
function dslDefine(name, arg1, arg2, argN) {
- var reactFn = core();
+ var autoflowFn = core();
if (name && INOUT_RE.test(name)) throw new Error(sprintf(MISSING_NAME, name));
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
var inOutDef = parseInOutParams(defObj.inOutParamStr);
@@ -104,16 +104,16 @@ define(['./sprintf', './core', './parse', './task'],
outTask: { a: inOutDef.outDef }
};
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
- var errors = reactFn.setAndValidateAST(ast);
+ var errors = autoflowFn.setAndValidateAST(ast);
if (errors.length) {
var errorStr = errors.join('\n');
throw new Error(errorStr);
}
- return reactFn;
+ return autoflowFn;
}
function selectFirst(name, arg1, arg2, argN) {
- var reactFn = core();
+ var autoflowFn = core();
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
var inOutDef = parseInOutParams(defObj.inOutParamStr);
var tasks = taskUtil.serializeTasks(parseTasks(defObj.taskDefArr));
@@ -124,12 +124,12 @@ define(['./sprintf', './core', './parse', './task'],
outTask: { type: 'finalcbFirst', a: inOutDef.outDef },
};
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
- var errors = reactFn.setAndValidateAST(ast);
+ var errors = autoflowFn.setAndValidateAST(ast);
if (errors.length) {
var errorStr = errors.join('\n');
throw new Error(errorStr);
}
- return reactFn;
+ return autoflowFn;
}
dslDefine.selectFirst = selectFirst;
View
18 lib/event-collector.js
@@ -10,8 +10,8 @@ define([], function () {
/**
create an instance of the event collector
*/
- function instantiate(react) {
- react.trackTasks(); // enable task tracking
+ function instantiate(autoflow) {
+ autoflow.trackTasks(); // enable task tracking
var AST_EVENTS_RE = /^ast\./;
var TASK_EVENTS_RE = /^task\./;
@@ -21,10 +21,10 @@ define([], function () {
Accumulator to make it easy to capture events
@example
- var react = require('react');
- var collector = react.createEventCollector();
- collector.capture(); // capture all flow and task events for all react flows
- collector.capture('flow.*'); // capture all flow events for all react flows
+ var autoflow = require('autoflow');
+ var collector = autoflow.createEventCollector();
+ collector.capture(); // capture all flow and task events for all autoflow flows
+ collector.capture('flow.*'); // capture all flow events for all autoflow flows
collector.capture(flowFn, 'task.*'); // capture task events on a flow
collector.capture(flowFn, 'flow.*'); // add capture flow events on a flow
var events = collector.list(); // retrieve the list of events
@@ -36,15 +36,15 @@ define([], function () {
/**
register listener to capture events for a specific flow
- @param flowFn the react flow function or can pass global react
+ @param flowFn the autoflow flow function or can pass global autoflow
@param eventId event id or wildcarded id
*/
EventCollector.prototype.capture = function (flowFn, eventId) {
/*jshint validthis: true */
if (!eventId && typeof(flowFn) === 'string') { // only eventId provided
eventId = flowFn;
- flowFn = react; // global react
- } else if (!flowFn) flowFn = react; // global react
+ flowFn = autoflow; // global autoflow
+ } else if (!flowFn) flowFn = autoflow; // global autoflow
if (!eventId) eventId = '*'; // default to all
var emitter = flowFn.events;
var self = this;
View
4 lib/input-parser.js
@@ -8,7 +8,7 @@ define(['./event-manager'], function (EventManager) {
'use strict';
var defaultExecOptions = {
- reactExecOptions: true,
+ autoflowExecOptions: true,
outputStyle: 'cb',
};
@@ -17,7 +17,7 @@ define(['./event-manager'], function (EventManager) {
NONE: 'none'
};