Codebase list node-pump / 27be6eb
Import Debian changes 3.0.0-1 node-pump (3.0.0-1) unstable; urgency=low * New upstream release Ying-Chun Liu (PaulLiu) 6 years ago
12 changed file(s) with 97 addition(s) and 63 deletion(s). Raw diff Collapse all Expand all
4646
4747 If `source`, `transform`, `anotherTransform` or `dest` closes all of them will be destroyed.
4848
49 Similarly to `stream.pipe()`, `pump()` returns the last stream passed in, so you can do:
50
51 ```
52 return pump(s1, s2) // returns s2
53 ```
54
55 If you want to return a stream that combines *both* s1 and s2 to a single stream use
56 [pumpify](https://github.com/mafintosh/pumpify) instead.
57
4958 ## License
5059
5160 MIT
0 node-pump (3.0.0-1) unstable; urgency=low
1
2 * New upstream release
3
4 -- Ying-Chun Liu (PaulLiu) <paulliu@debian.org> Fri, 20 Apr 2018 15:30:50 +0800
5
06 node-pump (2.0.0-1) unstable; urgency=low
17
28 * New upstream release
00 package.json usr/lib/nodejs/pump/
11 .travis.yml usr/lib/nodejs/pump/
22 index.js usr/lib/nodejs/pump/
3 test.js usr/lib/nodejs/pump/
3 test-node.js usr/lib/nodejs/pump/
44 test-browser.js usr/lib/nodejs/pump/
55 #.npmignore usr/lib/nodejs/pump/
00 Tests: require
11 Depends: node-pump
22
3 Tests: runtest
4 Depends: node-pump
3 Tests: run-test-node
4 Depends: @
5
6 Tests: run-test-browser
7 Depends: @
0 #!/bin/sh
1 set -e
2 nodejs test-browser.js
0 #!/bin/sh
1 set -e
2 nodejs /usr/lib/nodejs/pump/test-node.js
+0
-3
debian/tests/runtest less more
0 #!/bin/sh
1 set -e
2 nodejs /usr/lib/nodejs/pump/test.js
22 var fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes
33
44 var noop = function () {}
5 var ancient = /^v?\.0/.test(process.version)
56
67 var isFn = function (fn) {
78 return typeof fn === 'function'
89 }
910
1011 var isFS = function (stream) {
12 if (!ancient) return false // newer node version do not need to care about fs is a special way
1113 if (!fs) return false // browser
1214 return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close)
1315 }
7375 })
7476 })
7577
76 streams.reduce(pipe)
78 return streams.reduce(pipe)
7779 }
7880
7981 module.exports = pump
00 {
11 "name": "pump",
2 "version": "2.0.0",
2 "version": "3.0.0",
33 "repository": "git://github.com/mafintosh/pump.git",
44 "license": "MIT",
55 "description": "pipe streams together and close all of them if one of them closes",
1818 "once": "^1.3.1"
1919 },
2020 "scripts": {
21 "test": "node test.js"
21 "test": "node test-browser.js && node test-node.js"
2222 }
2323 }
2929 var callbackCalled = false
3030
3131 var check = function () {
32 if (wsClosed && rsClosed && callbackCalled) console.log('done')
32 if (wsClosed && rsClosed && callbackCalled) {
33 console.log('test-browser.js passes')
34 clearTimeout(timeout)
35 }
3336 }
3437
3538 ws.on('finish', function () {
4245 check()
4346 })
4447
45 pump(rs, toHex(), toHex(), toHex(), ws, function () {
48 var res = pump(rs, toHex(), toHex(), toHex(), ws, function () {
4649 callbackCalled = true
4750 check()
4851 })
52
53 if (res !== ws) {
54 throw new Error('should return last stream')
55 }
4956
5057 setTimeout(function () {
5158 rs.push(null)
5259 rs.emit('close')
5360 }, 1000)
5461
55 setTimeout(function () {
56 if (!check()) throw new Error('timeout')
62 var timeout = setTimeout(function () {
63 check()
64 throw new Error('timeout')
5765 }, 5000)
0 var pump = require('./index')
1
2 var rs = require('fs').createReadStream('/dev/random')
3 var ws = require('fs').createWriteStream('/dev/null')
4
5 var toHex = function () {
6 var reverse = new (require('stream').Transform)()
7
8 reverse._transform = function (chunk, enc, callback) {
9 reverse.push(chunk.toString('hex'))
10 callback()
11 }
12
13 return reverse
14 }
15
16 var wsClosed = false
17 var rsClosed = false
18 var callbackCalled = false
19
20 var check = function () {
21 if (wsClosed && rsClosed && callbackCalled) {
22 console.log('test-node.js passes')
23 clearTimeout(timeout)
24 }
25 }
26
27 ws.on('close', function () {
28 wsClosed = true
29 check()
30 })
31
32 rs.on('close', function () {
33 rsClosed = true
34 check()
35 })
36
37 var res = pump(rs, toHex(), toHex(), toHex(), ws, function () {
38 callbackCalled = true
39 check()
40 })
41
42 if (res !== ws) {
43 throw new Error('should return last stream')
44 }
45
46 setTimeout(function () {
47 rs.destroy()
48 }, 1000)
49
50 var timeout = setTimeout(function () {
51 throw new Error('timeout')
52 }, 5000)
+0
-50
test.js less more
0 var pump = require('./index')
1
2 var rs = require('fs').createReadStream('/dev/random')
3 var ws = require('fs').createWriteStream('/dev/null')
4
5 var toHex = function () {
6 var reverse = new (require('stream').Transform)()
7
8 reverse._transform = function (chunk, enc, callback) {
9 reverse.push(chunk.toString('hex'))
10 callback()
11 }
12
13 return reverse
14 }
15
16 var wsClosed = false
17 var rsClosed = false
18 var callbackCalled = false
19
20 var check = function () {
21 if (wsClosed && rsClosed && callbackCalled) process.exit(0)
22 }
23
24 ws.on('close', function () {
25 wsClosed = true
26 check()
27 })
28
29 rs.on('close', function () {
30 rsClosed = true
31 check()
32 })
33
34 var res = pump(rs, toHex(), toHex(), toHex(), ws, function () {
35 callbackCalled = true
36 check()
37 })
38
39 if (res) {
40 process.exit(1);
41 }
42
43 setTimeout(function () {
44 rs.destroy()
45 }, 1000)
46
47 setTimeout(function () {
48 throw new Error('timeout')
49 }, 5000)