[Pkg-javascript-commits] [node-stream-splicer] 37/71: <es5
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 15 09:55:50 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stream-splicer.
commit 9c3c18350d13bfdc55240d1e408fa08f57d9d232
Author: James Halliday <mail at substack.net>
Date: Mon Jun 9 17:00:51 2014 -0700
<es5
---
index.js | 7 ++++---
package.json | 6 ++++--
test/pop.js | 4 +---
test/push.js | 4 +---
test/shift.js | 4 +---
test/splice.js | 4 +---
test/unshift.js | 4 +---
7 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/index.js b/index.js
index b88f9e2..140fb46 100644
--- a/index.js
+++ b/index.js
@@ -3,6 +3,7 @@ var Readable = require('readable-stream').Readable;
var Pass = require('readable-stream').PassThrough;
var inherits = require('inherits');
var isArray = require('isarray');
+var indexof = require('indexof');
var wrap = require('readable-wrap');
var nextTick = typeof setImmediate !== 'undefined'
@@ -76,7 +77,7 @@ Pipeline.prototype._notEmpty = function () {
if (this._streams.length > 0) return;
var stream = new Pass(this._options);
stream.once('end', function () {
- var ix = self._streams.indexOf(stream);
+ var ix = indexof(self._streams, stream);
if (ix >= 0 && ix === self._streams.length - 1) {
Duplex.prototype.push.call(self, null);
}
@@ -128,7 +129,7 @@ Pipeline.prototype.splice = function (start, removeLen) {
});
stream = self._wrapStream(stream);
stream.once('end', function () {
- var ix = self._streams.indexOf(stream);
+ var ix = indexof(self._streams, stream);
if (ix >= 0 && ix === self._streams.length - 1) {
Duplex.prototype.push.call(self, null);
}
@@ -152,7 +153,7 @@ Pipeline.prototype.splice = function (start, removeLen) {
};
Pipeline.prototype.indexOf = function (stream) {
- return this._streams.indexOf(stream);
+ return indexof(this._streams, stream);
};
Pipeline.prototype._wrapStream = function (stream) {
diff --git a/package.json b/package.json
index aa3a21b..a822369 100644
--- a/package.json
+++ b/package.json
@@ -8,13 +8,15 @@
"isarray": "~0.0.1",
"readable-stream": "^1.1.13-1",
"readable-wrap": "^1.0.0",
- "through2": "^1.0.0"
+ "through2": "^1.0.0",
+ "indexof": "0.0.1"
},
"devDependencies": {
"tape": "^2.12.1",
"JSONStream": "~0.8.2",
"concat-stream": "^1.4.6",
- "split": "~0.3.0"
+ "split": "~0.3.0",
+ "object-keys": "~0.5.1"
},
"scripts": {
"test": "tape test/*.js"
diff --git a/test/pop.js b/test/pop.js
index e22270a..5de62fe 100644
--- a/test/pop.js
+++ b/test/pop.js
@@ -8,9 +8,7 @@ test('pop', function (t) {
var expected = {};
expected.replacer = [ '333', '444' ];
- t.plan(Object.keys(expected).reduce(function (sum, key) {
- return sum + expected[key].length;
- }, 0) + 1);
+ t.plan(3);
var a = split();
var b = through.obj(function (row, enc, next) {
diff --git a/test/push.js b/test/push.js
index 78fe2ec..67759de 100644
--- a/test/push.js
+++ b/test/push.js
@@ -10,9 +10,7 @@ test('push', function (t) {
expected.second = [ 6.66, 7.77 ];
expected.output = [ 3.33, 4.44, 5.55, 3, 2 ];
- t.plan(Object.keys(expected).reduce(function (sum, key) {
- return sum + expected[key].length;
- }, 0));
+ t.plan(5 + 2 + 5);
var a = split();
var b = through.obj(function (row, enc, next) {
diff --git a/test/shift.js b/test/shift.js
index a1bf995..309e5d1 100644
--- a/test/shift.js
+++ b/test/shift.js
@@ -11,9 +11,7 @@ test('shift', function (t) {
expected.c = [ 310, 410, 15, 16 ];
expected.output = [ 155, 205, 15/2, 8 ];
- t.plan(Object.keys(expected).reduce(function (sum, key) {
- return sum + expected[key].length;
- }, 0));
+ t.plan(2 + 4 + 4 + 4);
var a = through.obj(function (x, enc, next) {
var ex = expected.a.shift();
diff --git a/test/splice.js b/test/splice.js
index 9af35bd..cc00718 100644
--- a/test/splice.js
+++ b/test/splice.js
@@ -10,9 +10,7 @@ test('splice', function (t) {
expected.d = [ 3, 4 ];
expected.thousander = [ 5, 6 ];
- t.plan(Object.keys(expected).reduce(function (sum, key) {
- return sum + expected[key].length;
- }, 0) + 1);
+ t.plan(4 + 2 + 2 + 1);
var a = split();
var b = through.obj(function (row, enc, next) {
diff --git a/test/unshift.js b/test/unshift.js
index 905779c..4ec25a7 100644
--- a/test/unshift.js
+++ b/test/unshift.js
@@ -11,9 +11,7 @@ test('unshift', function (t) {
expected.c = [ 13, 14, 510, 610 ];
expected.output = [ 13/2, 7, 255, 305 ];
- t.plan(Object.keys(expected).reduce(function (sum, key) {
- return sum + expected[key].length;
- }, 0));
+ t.plan(2 + 4 + 4 + 4);
var a = through.obj(function (x, enc, next) {
var ex = expected.a.shift();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-splicer.git
More information about the Pkg-javascript-commits
mailing list