Comparing version 0.2.5 to 0.3.0
45
index.js
@@ -6,6 +6,9 @@ var EventEmitter = require('events').EventEmitter; | ||
module.exports = Seq; | ||
function Seq () { | ||
var xs = [].slice.call(arguments); | ||
function Seq (xs) { | ||
if (xs && !Array.isArray(xs) || arguments.length > 1) { | ||
throw new Error('Optional argument to Seq() is exactly one Array'); | ||
} | ||
var ch = Chainsaw(function (saw) { | ||
builder.call(this, saw, xs); | ||
builder.call(this, saw, xs || []); | ||
}); | ||
@@ -21,8 +24,3 @@ | ||
Seq.ap = function (xs) { | ||
if (!Array.isArray(xs)) { | ||
throw new Error('argument to .ap() is not an Array'); | ||
} | ||
return Seq().extend(xs); | ||
}; | ||
Seq.ap = Seq; // for compatability with versions <0.3 | ||
@@ -101,5 +99,5 @@ function builder (saw, xs) { | ||
var args = [].slice.call(arguments); | ||
args.unshift.apply(args, bound.map((function (arg) { | ||
args.unshift.apply(args, bound.map(function (arg) { | ||
return arg === Seq ? this : arg | ||
}).bind(this))); | ||
}, this)); | ||
@@ -133,5 +131,5 @@ cb.apply(this, args); | ||
var args = [].slice.call(arguments); | ||
args.unshift.apply(args, bound.map((function (arg) { | ||
args.unshift.apply(args, bound.map(function (arg) { | ||
return arg === Seq ? this : arg | ||
}).bind(this))); | ||
}, this)); | ||
@@ -161,3 +159,3 @@ cb.apply(this, args); | ||
[ 'seq', 'par' ].forEach((function (name) { | ||
[ 'seq', 'par' ].forEach(function (name) { | ||
this[name + '_'] = function (key) { | ||
@@ -184,3 +182,3 @@ var args = [].slice.call(arguments); | ||
}; | ||
}).bind(this)); | ||
}, this); | ||
@@ -297,3 +295,3 @@ this['catch'] = function (cb) { | ||
[ 'forEach', 'seqEach', 'parEach', 'seqMap', 'parMap' ] | ||
.forEach((function (name) { | ||
.forEach(function (name) { | ||
this[name + '_'] = function (cb) { | ||
@@ -306,7 +304,7 @@ this[name].call(this, function () { | ||
}; | ||
}).bind(this)) | ||
}, this) | ||
; | ||
['push','pop','shift','unshift','splice'] | ||
.forEach((function (name) { | ||
.forEach(function (name) { | ||
this[name] = function () { | ||
@@ -320,3 +318,3 @@ context.stack[name].apply( | ||
}; | ||
}).bind(this)) | ||
}, this) | ||
; | ||
@@ -345,2 +343,7 @@ | ||
this.unflatten = function () { | ||
context.stack = [context.stack]; | ||
saw.next(); | ||
}; | ||
this.empty = function () { | ||
@@ -351,4 +354,4 @@ context.stack = []; | ||
this.set = function () { | ||
context.stack = [].slice.call(arguments); | ||
this.set = function (stack) { | ||
context.stack = stack; | ||
saw.next(); | ||
@@ -355,0 +358,0 @@ }; |
{ | ||
"name" : "seq", | ||
"version" : "0.2.5", | ||
"version" : "0.3.0", | ||
"description" : "Chainable asynchronous flow control with sequential and parallel primitives and pipeline-style error handling", | ||
@@ -11,5 +11,11 @@ "main" : "./index.js", | ||
"dependencies" : { | ||
"chainsaw" : ">=0.0.5", | ||
"hashish" : ">=0.0.2" | ||
"chainsaw" : ">=0.0.7 <0.1", | ||
"hashish" : ">=0.0.2 <0.1" | ||
}, | ||
"devDependencies" : { | ||
"expresso" : "=0.7.x" | ||
}, | ||
"script" : { | ||
"test" : "expresso" | ||
}, | ||
"keywords" : [ | ||
@@ -25,3 +31,5 @@ "flow-control", "flow", "control", "async", "asynchronous", "chain", | ||
"license" : "MIT/X11", | ||
"engine" : { "node" : ">=0.2.0" } | ||
"engine" : { | ||
"node" : ">=0.4.0" | ||
} | ||
} |
@@ -9,3 +9,3 @@ var Seq = require('seq'); | ||
Seq('xxx') | ||
Seq(['xxx']) | ||
.seq_('pow', function (next, x) { | ||
@@ -52,3 +52,3 @@ assert.eql(next, this); | ||
var acc = []; | ||
Seq(7, 8, 9) | ||
Seq([7,8,9]) | ||
.forEach_(function (next, x) { | ||
@@ -71,3 +71,3 @@ assert.eql(next, this); | ||
var acc = []; | ||
Seq(7, 8, 9) | ||
Seq([7,8,9]) | ||
.seqEach_(function (next, x) { | ||
@@ -94,3 +94,3 @@ assert.eql(next, this); | ||
var acc = []; | ||
Seq(7, 8, 9) | ||
Seq([7,8,9]) | ||
.parEach_(function (next, x) { | ||
@@ -117,3 +117,3 @@ assert.eql(next, this); | ||
var acc = []; | ||
Seq(7, 8, 9) | ||
Seq([7,8,9]) | ||
.seqMap_(function (next, x) { | ||
@@ -140,3 +140,3 @@ assert.eql(next, this); | ||
var acc = []; | ||
Seq(7, 8, 9) | ||
Seq([7,8,9]) | ||
.parMap_(function (next, x) { | ||
@@ -143,0 +143,0 @@ assert.eql(next, this); |
@@ -9,3 +9,3 @@ var Seq = require('seq'); | ||
Seq(0) | ||
Seq([0]) | ||
.seq('pow', function (n) { | ||
@@ -39,3 +39,3 @@ this(null, 1); | ||
Seq(3,4,5) | ||
Seq([3,4,5]) | ||
.seq(function () { | ||
@@ -63,3 +63,3 @@ this.into('w')(null, 5); | ||
var calls = {}; | ||
Seq(1) | ||
Seq([1]) | ||
.seq(function (n) { | ||
@@ -241,3 +241,3 @@ assert.eql(n, 1); | ||
var count = 0; | ||
Seq(1,2,3) | ||
Seq([1,2,3]) | ||
.push(4) | ||
@@ -262,3 +262,3 @@ .forEach(function (x, i) { | ||
var ii = 0; | ||
Seq(1,2,3) | ||
Seq([1,2,3]) | ||
.seqEach(function (x, i) { | ||
@@ -288,3 +288,3 @@ assert.eql(i, ii++); | ||
var values = []; | ||
Seq(1,2,3,4) | ||
Seq([1,2,3,4]) | ||
.seqEach(function (x, i) { | ||
@@ -317,3 +317,3 @@ values.push([i,x]); | ||
var values = []; | ||
Seq(1,2,3,4) | ||
Seq([1,2,3,4]) | ||
.parEach(function (x, i) { | ||
@@ -359,3 +359,3 @@ values.push([i,x]); | ||
Seq(1,2,3,4) | ||
Seq([1,2,3,4]) | ||
.parEach(function (x, i) { | ||
@@ -380,3 +380,3 @@ setTimeout((function () { | ||
var values = []; | ||
Seq(1,2,3,4) | ||
Seq([1,2,3,4]) | ||
.parEach(function (x, i) { | ||
@@ -404,3 +404,3 @@ values.push([i,x]); | ||
var values = []; | ||
Seq(1,2,3,4,5,6,7,8,9,10) | ||
Seq([1,2,3,4,5,6,7,8,9,10]) | ||
.parEach(3, function (x, i) { | ||
@@ -433,3 +433,3 @@ running ++; | ||
var values = []; | ||
Seq(1,2,3,4,5,6,7,8,9,10) | ||
Seq([1,2,3,4,5,6,7,8,9,10]) | ||
.parMap(2, function (x, i) { | ||
@@ -459,3 +459,3 @@ running ++; | ||
var values = []; | ||
Seq(1,2,3,4,5,6,7,8,9,10) | ||
Seq([1,2,3,4,5,6,7,8,9,10]) | ||
.parMap(function (x, i) { | ||
@@ -479,3 +479,3 @@ this(null, x * 10); | ||
var values = []; | ||
Seq(1,2,3,4,5,6,7,8,9,10) | ||
Seq([1,2,3,4,5,6,7,8,9,10]) | ||
.seqMap(function (x, i) { | ||
@@ -503,3 +503,3 @@ running ++; | ||
Seq(4,5,6) | ||
Seq([4,5,6]) | ||
.seq(function (x, y, z) { | ||
@@ -511,3 +511,3 @@ assert.eql(arguments.length, 3); | ||
}) | ||
.set(3,4) | ||
.set([3,4]) | ||
.seq(function (x, y) { | ||
@@ -548,3 +548,3 @@ assert.eql(arguments.length, 2); | ||
}) | ||
.set(['a',['b']],['c','d',['e']]) | ||
.set([['a',['b']],['c','d',['e']]]) | ||
.flatten(false) // only flatten one level | ||
@@ -557,3 +557,3 @@ .seq(function (a, b, c, d, e) { | ||
}) | ||
.set(['a','b'],['c','d',['e']]) | ||
.set([['a','b'],['c','d',['e']]]) | ||
.flatten() | ||
@@ -607,3 +607,3 @@ .seq(function (a, b, c, d, e) { | ||
Seq(4, 5) | ||
Seq([4,5]) | ||
.seq(function (a, b, c, d) { | ||
@@ -633,3 +633,3 @@ assert.eql(a, 2); | ||
Seq('c') | ||
Seq(['c']) | ||
.par(function (a, b, c) { | ||
@@ -636,0 +636,0 @@ clearTimeout(t1); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45883
1182
346
1
+ Addedchainsaw@0.0.9(transitive)
- Removedchainsaw@0.1.0(transitive)
Updatedchainsaw@>=0.0.7 <0.1
Updatedhashish@>=0.0.2 <0.1