added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
'use strict';
var util = require('util')
, stream = require('stream')
, Readable = stream.Readable
module.exports = NumberReadable;
util.inherits(NumberReadable, Readable);
function NumberReadable (opts) {
if (!(this instanceof NumberReadable)) return new NumberReadable(opts);
Readable.call(this, opts);
this.idx = 0;
this.to = opts.to;
}
NumberReadable.prototype._read = function () {
if (this.idx > this.to) return this.push(null);
this.push('' + this.idx++);
}
+28
View File
@@ -0,0 +1,28 @@
'use strict';
/*jshint asi: true */
var test = require('tap').test
var devnull = require('../');
var tapstream = require('tap-stream')
var numbers = require('./fixtures/number-readable')
test('\npiping without devnull', function (t) {
var data = [];
numbers({ to: 2 })
.on('data', function (d) { data.push(d) })
.on('end', function () {
t.equal(data.length, 3, 'streams 3 numbers')
t.end()
})
})
test('\npiping through devnull', function (t) {
var data = [];
numbers({ to: 2 })
.on('end', function () {
t.equal(data.length, 0, 'streams 0 numbers')
t.end()
})
.pipe(devnull())
.on('data', function (d) { data.push(d) })
})