Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/papandreou/node-seq into …

…papandreou
  • Loading branch information...
commit 616ec3f5c0a340432a3fb2effc64405a7ccd66a7 2 parents b2fa700 + 004ef08
@substack authored
Showing with 23 additions and 12 deletions.
  1. +6 −0 README.markdown
  2. +17 −12 index.js
View
6 README.markdown
@@ -229,6 +229,12 @@ flatten(fully=true)
Recursively flatten all the arrays in the stack. Set `fully=false` to flatten
only one level.
+unflatten()
+-----------
+
+Turn the contents of the stack into a single array item. You can think of it
+as the inverse of `flatten(false)`.
+
extend([x,y...])
----------------
View
29 index.js
@@ -96,9 +96,9 @@ function builder (saw, xs) {
function () {
context.stack_ = [];
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));
cb.apply(this, args);
}, function () {
@@ -127,9 +127,9 @@ function builder (saw, xs) {
}
var cb_ = function () {
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));
cb.apply(this, args);
};
@@ -154,7 +154,7 @@ function builder (saw, xs) {
saw.next();
};
- [ 'seq', 'par' ].forEach((function (name) {
+ [ 'seq', 'par' ].forEach(function (name) {
this[name + '_'] = function (key) {
var args = [].slice.call(arguments);
@@ -176,7 +176,7 @@ function builder (saw, xs) {
this[name].apply(this, args);
};
- }).bind(this));
+ }, this);
this['catch'] = function (cb) {
if (context.error) {
@@ -288,7 +288,7 @@ function builder (saw, xs) {
};
[ 'forEach', 'seqEach', 'parEach', 'seqMap', 'parMap' ]
- .forEach((function (name) {
+ .forEach(function (name) {
this[name + '_'] = function (cb) {
this[name].call(this, function () {
var args = [].slice.call(arguments);
@@ -296,11 +296,11 @@ function builder (saw, xs) {
cb.apply(this, args);
});
};
- }).bind(this))
+ }, this)
;
['push','pop','shift','unshift','splice']
- .forEach((function (name) {
+ .forEach(function (name) {
this[name] = function () {
context.stack[name].apply(
context.stack,
@@ -309,7 +309,7 @@ function builder (saw, xs) {
saw.next();
return this;
};
- }).bind(this))
+ }, this)
;
this.extend = function (xs) {
@@ -333,13 +333,18 @@ function builder (saw, xs) {
saw.next();
};
+ this.unflatten = function () {
+ context.stack = [context.stack];
+ saw.next();
+ };
+
this.empty = function () {
context.stack = [];
saw.next();
};
- this.set = function () {
- context.stack = [].slice.call(arguments);
+ this.set = function (stack) {
+ context.stack = stack;
saw.next();
};
Please sign in to comment.
Something went wrong with that request. Please try again.