react 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +4 -0
- package/Jakefile.js +39 -0
- package/README.md +18 -26
- package/browser-test/dist.html +89 -0
- package/browser-test/index.html +85 -0
- package/browser-test/min.html +89 -0
- package/dist/react.js +3093 -0
- package/dist/react.min.js +1 -0
- package/doc/advanced.md +7 -2
- package/doc/simple.dot +25 -0
- package/doc/simple.png +0 -0
- package/examples/{default1.js → longer-example.js} +0 -0
- package/examples/{default-simple.js → simple.js} +0 -0
- package/examples/{ast1.js → using-ast-directly.js} +4 -0
- package/examples/{default-events1.js → using-events1.js} +1 -1
- package/examples/{default-log-events.js → using-log-events.js} +0 -0
- package/lib/base-task.js +116 -110
- package/lib/cb-task.js +71 -67
- package/lib/core.js +118 -107
- package/lib/dsl.js +120 -115
- package/lib/error.js +44 -36
- package/lib/event-collector.js +69 -53
- package/lib/event-manager.js +69 -55
- package/lib/eventemitter.js +20 -0
- package/lib/finalcb-first-task.js +56 -53
- package/lib/finalcb-task.js +55 -51
- package/lib/id.js +18 -6
- package/lib/input-parser.js +49 -41
- package/lib/log-events.js +79 -73
- package/lib/parse.js +34 -25
- package/lib/promise-resolve.js +42 -27
- package/lib/promise-task.js +78 -74
- package/lib/react.js +59 -0
- package/lib/ret-task.js +59 -55
- package/lib/sprintf.js +18 -0
- package/lib/status.js +11 -2
- package/lib/task.js +216 -213
- package/lib/track-tasks.js +72 -58
- package/lib/validate.js +136 -136
- package/lib/vcon.js +78 -69
- package/lib/when-task.js +69 -65
- package/package.json +10 -9
- package/src/dist.build.requirejs +20 -0
- package/test/ast.mocha.js +136 -0
- package/test/cb-task.mocha.js +220 -0
- package/test/core-deferred.mocha.js +143 -0
- package/test/core-when.mocha.js +96 -0
- package/test/core.mocha.js +589 -0
- package/test/dsl.mocha.js +350 -0
- package/test/event-manager.mocha.js +119 -0
- package/test/exec-options.mocha.js +48 -0
- package/test/finalcb-task.mocha.js +58 -0
- package/test/input-parser.mocha.js +86 -0
- package/test/mocha.opts +2 -0
- package/test/module-use.mocha.js +147 -0
- package/test/promise-auto-resolve.mocha.js +68 -0
- package/test/ret-task.mocha.js +220 -0
- package/test/task.mocha.js +42 -0
- package/test/validate-cb-task.mocha.js +100 -0
- package/test/validate-ret-task.mocha.js +110 -0
- package/test/validate.mocha.js +324 -0
- package/test/vcon.mocha.js +193 -0
- package/vendor/chai/chai.js +2038 -0
- package/vendor/jquery/jquery-1.7.1.js +9266 -0
- package/vendor/jquery/jquery-1.7.1.min.js +4 -0
- package/vendor/mocha/mocha.css +135 -0
- package/vendor/mocha/mocha.js +3589 -0
- package/vendor/node/util.js +531 -0
- package/vendor/requirejs/require.js +2053 -0
- package/vendor/requirejs/require.min.js +33 -0
- package/doc/default-simple.dot +0 -19
- package/doc/default-simple.dot.png +0 -0
- package/react.js +0 -40
- package/test/ast.test.js +0 -69
- package/test/cb-task.test.js +0 -197
- package/test/core-deferred.test.js +0 -134
- package/test/core-promised.test.js +0 -132
- package/test/core-when.test.js +0 -84
- package/test/core.test.js +0 -568
- package/test/dsl.test.js +0 -330
- package/test/event-manager.test.js +0 -102
- package/test/exec-options.test.js +0 -33
- package/test/finalcb-task.test.js +0 -38
- package/test/input-parser.test.js +0 -66
- package/test/module-use.test.js +0 -134
- package/test/promise-auto-resolve.test.js +0 -52
- package/test/ret-task.test.js +0 -199
- package/test/task.test.js +0 -21
- package/test/validate-cb-task.test.js +0 -74
- package/test/validate-ret-task.test.js +0 -83
- package/test/validate.test.js +0 -295
- package/test/vcon.test.js +0 -173
package/lib/promise-resolve.js
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
/*global define:true */
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
if (typeof define !== 'function') {
|
|
5
|
+
var define = require('amdefine')(module);
|
|
6
|
+
}
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
define([], function () {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
Auto resolve promises passed in as arguments to the flow
|
|
12
|
+
|
|
13
|
+
- Detects promises by checking for .then()
|
|
14
|
+
- Create promise name for param (param__promise)
|
|
15
|
+
- moves existing vCon promise into the param__promise
|
|
16
|
+
- creates WhenTask which resolves param__promise into param
|
|
10
17
|
*/
|
|
11
18
|
|
|
12
19
|
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
var PROMISE_SUFFIX = '__promise'; // added to param names that are promises
|
|
21
|
+
|
|
22
|
+
var resolvingPromises = false;
|
|
23
|
+
|
|
24
|
+
function resolvePromises(react) {
|
|
25
|
+
if (resolvingPromises) return; // already resolving
|
|
26
|
+
resolvingPromises = true;
|
|
27
|
+
|
|
28
|
+
react.events.on(react.events.TYPES.EXEC_TASKS_PRECREATE, function (env) {
|
|
29
|
+
var vConValues = env.vCon.values;
|
|
30
|
+
var promiseParams = env.ast.inParams.filter(function (p) {
|
|
31
|
+
var value = vConValues[p];
|
|
32
|
+
return (value && typeof(value.then) === 'function');
|
|
33
|
+
});
|
|
34
|
+
promiseParams.forEach(function (p) {
|
|
35
|
+
var promiseName = p + PROMISE_SUFFIX;
|
|
36
|
+
vConValues[promiseName] = vConValues[p];
|
|
37
|
+
vConValues[p] = undefined;
|
|
38
|
+
env.taskDefs.push({
|
|
39
|
+
type: 'when',
|
|
40
|
+
a: [promiseName],
|
|
41
|
+
out: [p]
|
|
42
|
+
});
|
|
43
|
+
});
|
|
31
44
|
});
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
45
|
|
|
35
|
-
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return resolvePromises;
|
|
49
|
+
|
|
50
|
+
});
|
package/lib/promise-task.js
CHANGED
|
@@ -1,89 +1,93 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
/*global define:true */
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
4
|
+
if (typeof define !== 'function') {
|
|
5
|
+
var define = require('amdefine')(module);
|
|
6
|
+
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
var sprintf = require('sprintf').sprintf;
|
|
8
|
+
define(['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
PromiseTask is a task which executes a fn that returns a promise
|
|
12
|
+
and when it completes it sets the values in vCon
|
|
13
|
+
*/
|
|
12
14
|
|
|
13
|
-
function format_error(errmsg, obj) {
|
|
14
|
-
|
|
15
|
-
}
|
|
15
|
+
function format_error(errmsg, obj) {
|
|
16
|
+
return sprintf('%s - %s', errmsg, util.inspect(obj));
|
|
17
|
+
}
|
|
16
18
|
|
|
17
|
-
var REQ = 'promiseTask requires f, a, out';
|
|
18
|
-
var FN_REQ = 'promiseTask requires f to be a function or string';
|
|
19
|
-
var A_REQ = 'promiseTask requires a to be an array of string param names';
|
|
20
|
-
var OUT_REQ = 'promiseTask requires out to be an array[1] of string param names';
|
|
19
|
+
var REQ = 'promiseTask requires f, a, out';
|
|
20
|
+
var FN_REQ = 'promiseTask requires f to be a function or string';
|
|
21
|
+
var A_REQ = 'promiseTask requires a to be an array of string param names';
|
|
22
|
+
var OUT_REQ = 'promiseTask requires out to be an array[1] of string param names';
|
|
21
23
|
|
|
22
|
-
function PromiseTask(taskDef) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
24
|
+
function PromiseTask(taskDef) {
|
|
25
|
+
var self = this;
|
|
26
|
+
Object.keys(taskDef).forEach(function (k) { self[k] = taskDef[k]; });
|
|
27
|
+
}
|
|
26
28
|
|
|
27
|
-
PromiseTask.prototype = new BaseTask();
|
|
28
|
-
PromiseTask.prototype.constructor = PromiseTask;
|
|
29
|
+
PromiseTask.prototype = new BaseTask();
|
|
30
|
+
PromiseTask.prototype.constructor = PromiseTask;
|
|
29
31
|
|
|
30
|
-
PromiseTask.validate = function (taskDef) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
PromiseTask.validate = function (taskDef) {
|
|
33
|
+
var errors = [];
|
|
34
|
+
if (!taskDef.f || !taskDef.a || !taskDef.out) {
|
|
35
|
+
errors.push(format_error(REQ, taskDef));
|
|
36
|
+
} else {
|
|
37
|
+
var ftype = typeof(taskDef.f);
|
|
38
|
+
if (! ((taskDef.f instanceof Function) || (ftype === 'string'))) {
|
|
39
|
+
errors.push(format_error(FN_REQ, taskDef));
|
|
40
|
+
}
|
|
41
|
+
if (! (Array.isArray(taskDef.a) &&
|
|
42
|
+
taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
43
|
+
errors.push(format_error(A_REQ, taskDef));
|
|
44
|
+
}
|
|
45
|
+
if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
|
|
46
|
+
taskDef.out.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
47
|
+
errors.push(format_error(OUT_REQ, taskDef));
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
errors.push(format_error(A_REQ, taskDef));
|
|
42
|
-
}
|
|
43
|
-
if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
|
|
44
|
-
taskDef.out.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
45
|
-
errors.push(format_error(OUT_REQ, taskDef));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return errors;
|
|
49
|
-
};
|
|
50
|
+
return errors;
|
|
51
|
+
};
|
|
50
52
|
|
|
51
|
-
PromiseTask.prototype.prepare = function prepare(handleTaskError, vCon, contExec) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
PromiseTask.prototype.prepare = function prepare(handleTaskError, vCon, contExec) {
|
|
54
|
+
var self = this;
|
|
55
|
+
this.nextFn = function (arg) {
|
|
56
|
+
var args = Array.prototype.slice.call(arguments);
|
|
57
|
+
vCon.saveResults(self.out, args);
|
|
58
|
+
self.complete(args);
|
|
59
|
+
contExec();
|
|
60
|
+
};
|
|
61
|
+
this.failFn = function (err) {
|
|
62
|
+
handleTaskError(self, err);
|
|
63
|
+
};
|
|
58
64
|
};
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
|
|
66
|
+
PromiseTask.prototype.exec = function exec(vCon, handleError, contExec) {
|
|
67
|
+
try {
|
|
68
|
+
var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
|
|
69
|
+
//console.error('PromiseTask.exec.args=', args);
|
|
70
|
+
//console.error('PromiseTask.exec.vCon=', vCon);
|
|
71
|
+
this.start(args); //note the start time, args
|
|
72
|
+
var func = this.f;
|
|
73
|
+
var bindObj = vCon.getVar('this'); //global space or the original this
|
|
74
|
+
if (this.isMethodCall()) { //if method call then reset func and bindObj
|
|
75
|
+
func = vCon.getVar(this.f);
|
|
76
|
+
bindObj = this.getMethodObj(vCon);
|
|
77
|
+
} else if (typeof(func) === 'string') {
|
|
78
|
+
func = vCon.getVar(func); // we want the actual fn from this string
|
|
79
|
+
}
|
|
80
|
+
var retValue = func.apply(bindObj, args);
|
|
81
|
+
if (retValue && typeof(retValue.then) === 'function') { // is a promise
|
|
82
|
+
retValue.then(this.nextFn, this.failFn);
|
|
83
|
+
} else { // just a value, proceed now
|
|
84
|
+
this.nextFn(retValue);
|
|
85
|
+
}
|
|
86
|
+
} catch (err) { //catch and handle the task error, calling final cb
|
|
87
|
+
handleError(this, err);
|
|
88
|
+
}
|
|
61
89
|
};
|
|
62
|
-
};
|
|
63
90
|
|
|
64
|
-
PromiseTask
|
|
65
|
-
try {
|
|
66
|
-
var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
|
|
67
|
-
//console.error('PromiseTask.exec.args=', args);
|
|
68
|
-
//console.error('PromiseTask.exec.vCon=', vCon);
|
|
69
|
-
this.start(args); //note the start time, args
|
|
70
|
-
var func = this.f;
|
|
71
|
-
var bindObj = vCon.getVar('this'); //global space or the original this
|
|
72
|
-
if (this.isMethodCall()) { //if method call then reset func and bindObj
|
|
73
|
-
func = vCon.getVar(this.f);
|
|
74
|
-
bindObj = this.getMethodObj(vCon);
|
|
75
|
-
} else if (typeof(func) === 'string') {
|
|
76
|
-
func = vCon.getVar(func); // we want the actual fn from this string
|
|
77
|
-
}
|
|
78
|
-
var retValue = func.apply(bindObj, args);
|
|
79
|
-
if (retValue && typeof(retValue.then) === 'function') { // is a promise
|
|
80
|
-
retValue.then(this.nextFn, this.failFn);
|
|
81
|
-
} else { // just a value, proceed now
|
|
82
|
-
this.nextFn(retValue);
|
|
83
|
-
}
|
|
84
|
-
} catch (err) { //catch and handle the task error, calling final cb
|
|
85
|
-
handleError(this, err);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
91
|
+
return PromiseTask;
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
});
|
package/lib/react.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/*global define:true */
|
|
3
|
+
|
|
4
|
+
if (typeof define !== 'function') {
|
|
5
|
+
var define = require('amdefine')(module);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
define(['./core', './dsl', './track-tasks', './log-events', './promise-resolve', './event-collector'],
|
|
9
|
+
function (core, dsl, trackTasksFn, logEventsMod, resolvePromisesFn, eventCollectorFactory) {
|
|
10
|
+
|
|
11
|
+
var react = dsl; // core + default dsl
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
Enable detection of promises and resolution
|
|
15
|
+
*/
|
|
16
|
+
function resolvePromises() {
|
|
17
|
+
resolvePromisesFn(react);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
Enable tracking of tasks and flow execution, emitting events and
|
|
22
|
+
tracking start, end, elapsed time
|
|
23
|
+
*/
|
|
24
|
+
function trackTasks() {
|
|
25
|
+
trackTasksFn(react);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
If called, load the built-in plugin for log events and invoke
|
|
30
|
+
|
|
31
|
+
@param flowFn [function] if not provided uses global react
|
|
32
|
+
@param eventWildcard [string] pattern to log events for
|
|
33
|
+
*/
|
|
34
|
+
function logEvents(flowFn, eventWildcard) {
|
|
35
|
+
if (!eventWildcard && typeof(flowFn) === 'string') { // only wildcard provided
|
|
36
|
+
eventWildcard = flowFn;
|
|
37
|
+
flowFn = undefined;
|
|
38
|
+
}
|
|
39
|
+
if (!flowFn) flowFn = react; // use global
|
|
40
|
+
trackTasks();
|
|
41
|
+
return logEventsMod.logEvents(flowFn, eventWildcard);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
Instantiate an event collector
|
|
46
|
+
*/
|
|
47
|
+
function createEventCollector() {
|
|
48
|
+
return eventCollectorFactory(react);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
react.options = core.options; // global react options
|
|
52
|
+
react.events = core.events; // global react event emitter
|
|
53
|
+
react.logEvents = logEvents; // enable event logging
|
|
54
|
+
react.resolvePromises = resolvePromises; // enable promise resolution
|
|
55
|
+
react.trackTasks = trackTasks; // enable tracking of tasks
|
|
56
|
+
react.createEventCollector = createEventCollector; // create instance of EventCollector
|
|
57
|
+
return react;
|
|
58
|
+
|
|
59
|
+
});
|
package/lib/ret-task.js
CHANGED
|
@@ -1,67 +1,71 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
/*global define:true */
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
var
|
|
4
|
+
if (typeof define !== 'function') {
|
|
5
|
+
var define = require('amdefine')(module);
|
|
6
|
+
}
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
define(['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
|
|
9
|
+
|
|
10
|
+
function format_error(errmsg, obj) {
|
|
11
|
+
return sprintf('%s - %s', errmsg, util.inspect(obj));
|
|
12
|
+
}
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
var REQ = 'retTask requires f, a, out';
|
|
15
|
+
var FN_REQ = 'retTask requires f to be a function or string';
|
|
16
|
+
var A_REQ = 'retTask requires a to be an array of string param names';
|
|
17
|
+
var RET_REQ = 'retTask requires out to be an array with single string param name or []';
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
function RetTask(taskDef) {
|
|
20
|
+
var self = this;
|
|
21
|
+
Object.keys(taskDef).forEach(function (k) { self[k] = taskDef[k]; });
|
|
22
|
+
}
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.keys(taskDef).forEach(function (k) { self[k] = taskDef[k]; });
|
|
20
|
-
}
|
|
24
|
+
RetTask.prototype = new BaseTask();
|
|
25
|
+
RetTask.prototype.constructor = RetTask;
|
|
21
26
|
|
|
22
|
-
RetTask.
|
|
23
|
-
|
|
27
|
+
RetTask.validate = function (taskDef) {
|
|
28
|
+
var errors = [];
|
|
29
|
+
if (!taskDef.f || !taskDef.a || !taskDef.out) {
|
|
30
|
+
errors.push(format_error(REQ, taskDef));
|
|
31
|
+
} else {
|
|
32
|
+
var ftype = typeof(taskDef.f);
|
|
33
|
+
if (! ((taskDef.f instanceof Function) || (ftype === 'string'))) {
|
|
34
|
+
errors.push(format_error(FN_REQ, taskDef));
|
|
35
|
+
}
|
|
36
|
+
if (! (Array.isArray(taskDef.a) &&
|
|
37
|
+
taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
38
|
+
errors.push(format_error(A_REQ, taskDef));
|
|
39
|
+
}
|
|
24
40
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var ftype = typeof(taskDef.f);
|
|
31
|
-
if (! ((taskDef.f instanceof Function) || (ftype === 'string'))) {
|
|
32
|
-
errors.push(format_error(FN_REQ, taskDef));
|
|
33
|
-
}
|
|
34
|
-
if (! (Array.isArray(taskDef.a) &&
|
|
35
|
-
taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
36
|
-
errors.push(format_error(A_REQ, taskDef));
|
|
41
|
+
if (! (Array.isArray(taskDef.out) &&
|
|
42
|
+
(taskDef.out.length === 0 ||
|
|
43
|
+
(taskDef.out.length === 1 && typeof(taskDef.out[0] === 'string'))))) {
|
|
44
|
+
errors.push(format_error(RET_REQ, taskDef));
|
|
45
|
+
}
|
|
37
46
|
}
|
|
47
|
+
return errors;
|
|
48
|
+
};
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
RetTask.prototype.exec = function exec(vCon, handleError, contExec) {
|
|
51
|
+
try {
|
|
52
|
+
var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
|
|
53
|
+
this.start(args); //note the start time, args
|
|
54
|
+
var func = this.f;
|
|
55
|
+
var bindObj = vCon.getVar('this'); //global space or the original this
|
|
56
|
+
if (this.isMethodCall()) { //if method call then reset func and bindObj
|
|
57
|
+
func = vCon.getVar(this.f);
|
|
58
|
+
bindObj = this.getMethodObj(vCon);
|
|
59
|
+
} else if (typeof(func) === 'string') {
|
|
60
|
+
func = vCon.getVar(func); // we want the actual fn from this string
|
|
61
|
+
}
|
|
62
|
+
var results = [func.apply(bindObj, args)];
|
|
63
|
+
vCon.saveResults(this.out, results); // save retval, takes arrays
|
|
64
|
+
this.complete(results);
|
|
65
|
+
contExec(); // continue since no callback to run this
|
|
66
|
+
} catch (err) { handleError(this, err); } // catch and handle the task error, calling final cb
|
|
67
|
+
};
|
|
47
68
|
|
|
48
|
-
RetTask
|
|
49
|
-
try {
|
|
50
|
-
var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
|
|
51
|
-
this.start(args); //note the start time, args
|
|
52
|
-
var func = this.f;
|
|
53
|
-
var bindObj = vCon.getVar('this'); //global space or the original this
|
|
54
|
-
if (this.isMethodCall()) { //if method call then reset func and bindObj
|
|
55
|
-
func = vCon.getVar(this.f);
|
|
56
|
-
bindObj = this.getMethodObj(vCon);
|
|
57
|
-
} else if (typeof(func) === 'string') {
|
|
58
|
-
func = vCon.getVar(func); // we want the actual fn from this string
|
|
59
|
-
}
|
|
60
|
-
var results = [func.apply(bindObj, args)];
|
|
61
|
-
vCon.saveResults(this.out, results); // save retval, takes arrays
|
|
62
|
-
this.complete(results);
|
|
63
|
-
contExec(); // continue since no callback to run this
|
|
64
|
-
} catch (err) { handleError(this, err); } // catch and handle the task error, calling final cb
|
|
65
|
-
};
|
|
69
|
+
return RetTask;
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
});
|
package/lib/sprintf.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/*global define:true sprint:true */
|
|
3
|
+
|
|
4
|
+
if (typeof define !== 'function') {
|
|
5
|
+
var define = require('amdefine')(module);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
define(['util'], function (util) {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
Abstract the details of getting a sprintf function.
|
|
12
|
+
Currently using the simple format capabilities of node's util.format
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
var sprintf = util.format;
|
|
16
|
+
return sprintf;
|
|
17
|
+
|
|
18
|
+
});
|