Added some tests
This commit is contained in:
4
tests/node_modules/resumer/.travis.yml
generated
vendored
Normal file
4
tests/node_modules/resumer/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
18
tests/node_modules/resumer/LICENSE
generated
vendored
Normal file
18
tests/node_modules/resumer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
8
tests/node_modules/resumer/example/resume.js
generated
vendored
Normal file
8
tests/node_modules/resumer/example/resume.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
var resumer = require('../');
|
||||
createStream().pipe(process.stdout);
|
||||
|
||||
function createStream () {
|
||||
var stream = resumer();
|
||||
stream.queue('beep boop\n');
|
||||
return stream;
|
||||
}
|
||||
29
tests/node_modules/resumer/index.js
generated
vendored
Normal file
29
tests/node_modules/resumer/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
var through = require('through');
|
||||
var nextTick = typeof setImmediate !== 'undefined'
|
||||
? setImmediate
|
||||
: process.nextTick
|
||||
;
|
||||
|
||||
module.exports = function (write, end) {
|
||||
var tr = through(write, end);
|
||||
tr.pause();
|
||||
var resume = tr.resume;
|
||||
var pause = tr.pause;
|
||||
var paused = false;
|
||||
|
||||
tr.pause = function () {
|
||||
paused = true;
|
||||
return pause.apply(this, arguments);
|
||||
};
|
||||
|
||||
tr.resume = function () {
|
||||
paused = false;
|
||||
return resume.apply(this, arguments);
|
||||
};
|
||||
|
||||
nextTick(function () {
|
||||
if (!paused) tr.resume();
|
||||
});
|
||||
|
||||
return tr;
|
||||
};
|
||||
74
tests/node_modules/resumer/package.json
generated
vendored
Normal file
74
tests/node_modules/resumer/package.json
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"_from": "resumer@^0.0.0",
|
||||
"_id": "resumer@0.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=",
|
||||
"_location": "/resumer",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "resumer@^0.0.0",
|
||||
"name": "resumer",
|
||||
"escapedName": "resumer",
|
||||
"rawSpec": "^0.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/tape"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz",
|
||||
"_shasum": "f1e8f461e4064ba39e82af3cdc2a8c893d076759",
|
||||
"_spec": "resumer@^0.0.0",
|
||||
"_where": "/home/lilleman/go/src/gitlab.larvit.se/power-plan/auth/tests/node_modules/tape",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/resumer/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"through": "~2.3.4"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "a through stream that starts paused and resumes on the next tick",
|
||||
"devDependencies": {
|
||||
"concat-stream": "~0.1.1",
|
||||
"tap": "~0.4.0",
|
||||
"tape": "~1.0.2"
|
||||
},
|
||||
"homepage": "https://github.com/substack/resumer",
|
||||
"keywords": [
|
||||
"through",
|
||||
"stream",
|
||||
"pause",
|
||||
"resume"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "resumer",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/resumer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/6..latest",
|
||||
"chrome/20..latest",
|
||||
"firefox/10..latest",
|
||||
"safari/latest",
|
||||
"opera/11.0..latest",
|
||||
"iphone/6",
|
||||
"ipad/6"
|
||||
]
|
||||
},
|
||||
"version": "0.0.0"
|
||||
}
|
||||
59
tests/node_modules/resumer/readme.markdown
generated
vendored
Normal file
59
tests/node_modules/resumer/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# resumer
|
||||
|
||||
Return a through stream that starts out paused and resumes on the next tick,
|
||||
unless somebody called `.pause()`.
|
||||
|
||||
This module has the same signature as
|
||||
[through](https://npmjs.com/package/through).
|
||||
|
||||
[](http://ci.testling.com/substack/resumer)
|
||||
|
||||
[](http://travis-ci.org/substack/resumer)
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var resumer = require('resumer');
|
||||
var s = createStream();
|
||||
s.pipe(process.stdout);
|
||||
|
||||
function createStream () {
|
||||
var stream = resumer();
|
||||
stream.queue('beep boop\n');
|
||||
return stream;
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
$ node example/resume.js
|
||||
beep boop
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var resumer = require('resumer')
|
||||
```
|
||||
|
||||
## resumer(write, end)
|
||||
|
||||
Return a new through stream from `write` and `end`, which default to
|
||||
pass-through `.queue()` functions if not specified.
|
||||
|
||||
The stream starts out paused and will be resumed on the next tick unless you
|
||||
call `.pause()` first.
|
||||
|
||||
`write` and `end` get passed directly through to
|
||||
[through](https://npmjs.com/package/through).
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install resumer
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
37
tests/node_modules/resumer/test/resume.js
generated
vendored
Normal file
37
tests/node_modules/resumer/test/resume.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var test = require('tape');
|
||||
var resumer = require('../');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
test('implicit resume', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var s = createStream();
|
||||
s.pipe(concat(function (err, body) {
|
||||
t.equal(body, 'beep boop\n');
|
||||
}));
|
||||
});
|
||||
|
||||
test('pause/resume', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var s = createStream();
|
||||
s.pause();
|
||||
|
||||
var paused = true;
|
||||
setTimeout(function () {
|
||||
paused = false;
|
||||
s.resume();
|
||||
}, 100);
|
||||
|
||||
s.pipe(concat(function (err, body) {
|
||||
t.equal(paused, false);
|
||||
t.equal(body, 'beep boop\n');
|
||||
}));
|
||||
});
|
||||
|
||||
function createStream () {
|
||||
var stream = resumer();
|
||||
stream.queue('beep boop\n');
|
||||
stream.queue(null);
|
||||
return stream;
|
||||
}
|
||||
36
tests/node_modules/resumer/test/through.js
generated
vendored
Normal file
36
tests/node_modules/resumer/test/through.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
var test = require('tape');
|
||||
var resumer = require('../');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
test('through write/end', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var s = createStream();
|
||||
|
||||
s.on('okok', function () {
|
||||
t.ok(true);
|
||||
});
|
||||
|
||||
s.pipe(concat(function (err, body) {
|
||||
t.equal(body, 'BEGIN\nRAWR\nEND\n');
|
||||
}));
|
||||
|
||||
setTimeout(function () {
|
||||
s.end('rawr\n');
|
||||
}, 50);
|
||||
});
|
||||
|
||||
function createStream () {
|
||||
var stream = resumer(write, end);
|
||||
stream.queue('BEGIN\n');
|
||||
return stream;
|
||||
|
||||
function write (x) {
|
||||
this.queue(String(x).toUpperCase());
|
||||
}
|
||||
function end () {
|
||||
this.emit('okok');
|
||||
this.queue('END\n');
|
||||
this.queue(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user