react 0.2.3 → 0.2.4
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/README.md +1 -0
- package/lib/dsl.js +3 -0
- package/package.json +1 -1
- package/test/dsl.test.js +13 -0
package/README.md
CHANGED
|
@@ -242,6 +242,7 @@ fn(2, 3, function (err, m, s) {
|
|
|
242
242
|
|
|
243
243
|
## Status
|
|
244
244
|
|
|
245
|
+
- 2012-01-11 - Provide warning/error when name is skipped in default DSL (v0.2.4)
|
|
245
246
|
- 2012-01-10 - Create default DSL for react(), create error for missing variables, list remaining tasks when flow won't complete
|
|
246
247
|
- 2011-12-21 - Refactor from ground up with tests, changes to the interfaces
|
|
247
248
|
- 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.
|
package/lib/dsl.js
CHANGED
|
@@ -6,9 +6,11 @@ var core = require('./core.js');
|
|
|
6
6
|
var parse = require('./parse.js');
|
|
7
7
|
var tutil = require('./task.js');
|
|
8
8
|
|
|
9
|
+
var MISSING_NAME = 'param[0] should be the flow name, instead found in/out def: %s';
|
|
9
10
|
var INOUT_PARAMS_NO_MATCH = 'params in wrong format, wanted "foo, bar cb -> err, baz" - found: %s';
|
|
10
11
|
var EXTRA_TASKARG = 'extra unmatched task arg: %s';
|
|
11
12
|
|
|
13
|
+
var INOUT_RE = /\->/; // used to detect missing name, in/out as first arg
|
|
12
14
|
var CB_NAMES_RE = /^cb|callback$/i; //cb, Cb, CB, callback, Callback
|
|
13
15
|
var ERR_NAMES_RE = /^err$/i; // err, ERR, Err, ...
|
|
14
16
|
|
|
@@ -81,6 +83,7 @@ function parseVargs(vargs) {
|
|
|
81
83
|
|
|
82
84
|
function dslDefine(name, arg1, arg2, argN) {
|
|
83
85
|
var reactFn = core();
|
|
86
|
+
if (name && INOUT_RE.test(name)) throw new Error(sprintf(MISSING_NAME, name));
|
|
84
87
|
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
|
|
85
88
|
var inOutDef = parseInOutParams(defObj.inOutParamStr);
|
|
86
89
|
var ast = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react",
|
|
3
3
|
"description": "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.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"author": "Jeff Barczewski <jeff.barczewski@gmail.com>",
|
|
6
6
|
"repository": { "type": "git", "url": "http://github.com/jeffbski/react.git" },
|
|
7
7
|
"bugs" : { "url": "http://github.com/jeffbski/react/issues" },
|
package/test/dsl.test.js
CHANGED
|
@@ -191,6 +191,19 @@ test('object prop task params', function (t) {
|
|
|
191
191
|
t.end();
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
+
// Errors
|
|
195
|
+
|
|
196
|
+
test('missing name, throws error', function (t) {
|
|
197
|
+
var fn = function () {
|
|
198
|
+
var r = react('cb -> err, c',
|
|
199
|
+
falpha, 'cb -> err, c'
|
|
200
|
+
);
|
|
201
|
+
};
|
|
202
|
+
t.throws(fn, new Error('param[0] should be the flow name, instead found in/out def: cb -> err, c'));
|
|
203
|
+
t.end();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
|
|
194
207
|
test('extra arg throws error', function (t) {
|
|
195
208
|
var fn = function () {
|
|
196
209
|
var r = react('myName', 'a, b, cb -> err, c, d',
|