Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/node-red/node_modules/collect-all/test/ drwxr-xr-x | |
| Viewing file: Select action/file-type: var test = require('tape')
var collectAll = require('../')
test('collectAll', function (t) {
var stream = collectAll()
stream.on('readable', function () {
var chunk = this.read()
if (chunk) {
t.strictEqual(chunk, 'onetwo')
t.end()
}
})
stream.setEncoding('utf8')
stream.write('one')
stream.write('two')
stream.end()
})
test('.collectAll(through)', function (t) {
var stream = collectAll(function (data) {
return data + 'yeah?'
})
stream.on('readable', function () {
var chunk = this.read()
if (chunk) {
t.strictEqual(chunk, 'cliveyeah?')
t.end()
}
})
stream.setEncoding('utf8')
stream.end('clive')
})
test('.collectAll(through): object mode', function (t) {
function through (collected) {
collected.forEach(function (object) {
object.received = true
})
return collected
}
var stream = collectAll(through, { objectMode: true })
stream.on('readable', function () {
var collected = this.read()
if (collected) {
t.deepEqual(collected, [ { received: true }, { received: true } ])
t.end()
}
})
stream.write({})
stream.end({})
})
test('collect(through): readable object mode', function (t) {
var stream = collectAll(
function (data) {
t.strictEqual(data.toString(), 'yeah')
return { ok: true }
},
{ readableObjectMode: true }
)
stream.end('yeah')
t.end()
})
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0047 ]-- |