mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-01-21 08:51:54 +00:00
0.0.1
This commit is contained in:
21
node_modules/streamx/test/async-iterator.js
generated
vendored
Normal file
21
node_modules/streamx/test/async-iterator.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
const tape = require('tape')
|
||||
const { Readable } = require('../')
|
||||
|
||||
tape('streams are async iterators', async function (t) {
|
||||
const data = ['a', 'b', 'c', null]
|
||||
const expected = data.slice(0)
|
||||
|
||||
const r = new Readable({
|
||||
read (cb) {
|
||||
this.push(data.shift())
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
for await (const chunk of r) {
|
||||
t.same(chunk, expected.shift())
|
||||
}
|
||||
|
||||
t.same(expected, [null])
|
||||
t.end()
|
||||
})
|
||||
105
node_modules/streamx/test/backpressure.js
generated
vendored
Normal file
105
node_modules/streamx/test/backpressure.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
const tape = require('tape')
|
||||
const { Writable, Readable } = require('../')
|
||||
|
||||
tape('write backpressure', function (t) {
|
||||
const ws = new Writable()
|
||||
|
||||
for (let i = 0; i < 15; i++) {
|
||||
t.ok(ws.write('a'), 'not backpressured')
|
||||
t.notOk(Writable.isBackpressured(ws), 'static check')
|
||||
}
|
||||
|
||||
t.notOk(ws.write('a'), 'backpressured')
|
||||
t.ok(Writable.isBackpressured(ws), 'static check')
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
tape('write backpressure with drain', function (t) {
|
||||
const ws = new Writable()
|
||||
|
||||
for (let i = 0; i < 15; i++) {
|
||||
t.ok(ws.write('a'), 'not backpressured')
|
||||
t.notOk(Writable.isBackpressured(ws), 'static check')
|
||||
}
|
||||
|
||||
t.notOk(ws.write('a'), 'backpressured')
|
||||
t.ok(Writable.isBackpressured(ws), 'static check')
|
||||
|
||||
ws.on('drain', function () {
|
||||
t.notOk(Writable.isBackpressured(ws))
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('write backpressure with destroy', function (t) {
|
||||
const ws = new Writable()
|
||||
|
||||
ws.write('a')
|
||||
ws.destroy()
|
||||
|
||||
t.ok(Writable.isBackpressured(ws))
|
||||
t.end()
|
||||
})
|
||||
|
||||
tape('write backpressure with end', function (t) {
|
||||
const ws = new Writable()
|
||||
|
||||
ws.write('a')
|
||||
ws.end()
|
||||
|
||||
t.ok(Writable.isBackpressured(ws))
|
||||
t.end()
|
||||
})
|
||||
|
||||
tape('read backpressure', function (t) {
|
||||
const rs = new Readable()
|
||||
|
||||
for (let i = 0; i < 15; i++) {
|
||||
t.ok(rs.push('a'), 'not backpressured')
|
||||
t.notOk(Readable.isBackpressured(rs), 'static check')
|
||||
}
|
||||
|
||||
t.notOk(rs.push('a'), 'backpressured')
|
||||
t.ok(Readable.isBackpressured(rs), 'static check')
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
tape('read backpressure with later read', function (t) {
|
||||
const rs = new Readable()
|
||||
|
||||
for (let i = 0; i < 15; i++) {
|
||||
t.ok(rs.push('a'), 'not backpressured')
|
||||
t.notOk(Readable.isBackpressured(rs), 'static check')
|
||||
}
|
||||
|
||||
t.notOk(rs.push('a'), 'backpressured')
|
||||
t.ok(Readable.isBackpressured(rs), 'static check')
|
||||
|
||||
rs.once('readable', function () {
|
||||
rs.read()
|
||||
t.notOk(Readable.isBackpressured(rs))
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('read backpressure with destroy', function (t) {
|
||||
const rs = new Readable()
|
||||
|
||||
rs.push('a')
|
||||
rs.destroy()
|
||||
|
||||
t.ok(Readable.isBackpressured(rs))
|
||||
t.end()
|
||||
})
|
||||
|
||||
tape('read backpressure with push(null)', function (t) {
|
||||
const rs = new Readable()
|
||||
|
||||
rs.push('a')
|
||||
rs.push(null)
|
||||
|
||||
t.ok(Readable.isBackpressured(rs))
|
||||
t.end()
|
||||
})
|
||||
178
node_modules/streamx/test/compat.js
generated
vendored
Normal file
178
node_modules/streamx/test/compat.js
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
const eos = require('end-of-stream')
|
||||
const tape = require('tape')
|
||||
const stream = require('../')
|
||||
const finished = require('stream').finished
|
||||
|
||||
run(eos)
|
||||
run(finished)
|
||||
|
||||
function run (eos) {
|
||||
if (!eos) return
|
||||
const name = eos === finished ? 'nodeStream.finished' : 'eos'
|
||||
tape(name + ' readable', function (t) {
|
||||
const r = new stream.Readable()
|
||||
let ended = false
|
||||
|
||||
r.on('end', function () {
|
||||
ended = true
|
||||
})
|
||||
|
||||
eos(r, function (err) {
|
||||
t.error(err, 'no error')
|
||||
t.ok(ended)
|
||||
t.end()
|
||||
})
|
||||
|
||||
r.push('hello')
|
||||
r.push(null)
|
||||
r.resume()
|
||||
})
|
||||
|
||||
tape(name + ' readable destroy', function (t) {
|
||||
const r = new stream.Readable()
|
||||
let ended = false
|
||||
|
||||
r.on('end', function () {
|
||||
ended = true
|
||||
})
|
||||
|
||||
eos(r, function (err) {
|
||||
t.ok(err, 'had error')
|
||||
t.notOk(ended)
|
||||
t.end()
|
||||
})
|
||||
|
||||
r.push('hello')
|
||||
r.push(null)
|
||||
r.resume()
|
||||
r.destroy()
|
||||
})
|
||||
|
||||
tape(name + ' writable', function (t) {
|
||||
const w = new stream.Writable()
|
||||
let finished = false
|
||||
|
||||
w.on('finish', function () {
|
||||
finished = true
|
||||
})
|
||||
|
||||
eos(w, function (err) {
|
||||
t.error(err, 'no error')
|
||||
t.ok(finished)
|
||||
t.end()
|
||||
})
|
||||
|
||||
w.write('hello')
|
||||
w.end()
|
||||
})
|
||||
|
||||
tape(name + ' writable destroy', function (t) {
|
||||
const w = new stream.Writable()
|
||||
let finished = false
|
||||
|
||||
w.on('finish', function () {
|
||||
finished = true
|
||||
})
|
||||
|
||||
eos(w, function (err) {
|
||||
t.ok(err, 'had error')
|
||||
t.notOk(finished)
|
||||
t.end()
|
||||
})
|
||||
|
||||
w.write('hello')
|
||||
w.end()
|
||||
w.destroy()
|
||||
})
|
||||
|
||||
tape(name + ' duplex', function (t) {
|
||||
const s = new stream.Duplex()
|
||||
let ended = false
|
||||
let finished = false
|
||||
|
||||
s.on('end', () => { ended = true })
|
||||
s.on('finish', () => { finished = true })
|
||||
|
||||
eos(s, function (err) {
|
||||
t.error(err, 'no error')
|
||||
t.ok(ended)
|
||||
t.ok(finished)
|
||||
t.end()
|
||||
})
|
||||
|
||||
s.push('hello')
|
||||
s.push(null)
|
||||
s.resume()
|
||||
s.end()
|
||||
})
|
||||
|
||||
tape(name + ' duplex + deferred s.end()', function (t) {
|
||||
const s = new stream.Duplex()
|
||||
let ended = false
|
||||
let finished = false
|
||||
|
||||
s.on('end', function () {
|
||||
ended = true
|
||||
setImmediate(() => s.end())
|
||||
})
|
||||
|
||||
s.on('finish', () => { finished = true })
|
||||
|
||||
eos(s, function (err) {
|
||||
t.error(err, 'no error')
|
||||
t.ok(ended)
|
||||
t.ok(finished)
|
||||
t.end()
|
||||
})
|
||||
|
||||
s.push('hello')
|
||||
s.push(null)
|
||||
s.resume()
|
||||
})
|
||||
|
||||
tape(name + ' duplex + deferred s.push(null)', function (t) {
|
||||
const s = new stream.Duplex()
|
||||
let ended = false
|
||||
let finished = false
|
||||
|
||||
s.on('finish', function () {
|
||||
finished = true
|
||||
setImmediate(() => s.push(null))
|
||||
})
|
||||
|
||||
s.on('end', () => { ended = true })
|
||||
|
||||
eos(s, function (err) {
|
||||
t.error(err, 'no error')
|
||||
t.ok(ended)
|
||||
t.ok(finished)
|
||||
t.end()
|
||||
})
|
||||
|
||||
s.push('hello')
|
||||
s.end()
|
||||
s.resume()
|
||||
})
|
||||
|
||||
tape(name + ' duplex destroy', function (t) {
|
||||
const s = new stream.Duplex()
|
||||
let ended = false
|
||||
let finished = false
|
||||
|
||||
s.on('end', () => { ended = true })
|
||||
s.on('finish', () => { finished = true })
|
||||
|
||||
eos(s, function (err) {
|
||||
t.ok(err, 'had error')
|
||||
t.notOk(ended)
|
||||
t.notOk(finished)
|
||||
t.end()
|
||||
})
|
||||
|
||||
s.push('hello')
|
||||
s.push(null)
|
||||
s.resume()
|
||||
s.end()
|
||||
s.destroy()
|
||||
})
|
||||
}
|
||||
134
node_modules/streamx/test/pipe.js
generated
vendored
Normal file
134
node_modules/streamx/test/pipe.js
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
const tape = require('tape')
|
||||
const compat = require('stream')
|
||||
const { Readable, Writable } = require('../')
|
||||
|
||||
tape('pipe to node stream', function (t) {
|
||||
const expected = [
|
||||
'hi',
|
||||
'ho'
|
||||
]
|
||||
|
||||
const r = new Readable()
|
||||
const w = new compat.Writable({
|
||||
objectMode: true,
|
||||
write (data, enc, cb) {
|
||||
t.same(data, expected.shift())
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
r.push('hi')
|
||||
r.push('ho')
|
||||
r.push(null)
|
||||
|
||||
r.pipe(w)
|
||||
|
||||
w.on('finish', function () {
|
||||
t.same(expected.length, 0)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('pipe with callback - error case', function (t) {
|
||||
const r = new Readable()
|
||||
const w = new Writable({
|
||||
write (data, cb) {
|
||||
cb(new Error('blerg'))
|
||||
}
|
||||
})
|
||||
|
||||
r.pipe(w, function (err) {
|
||||
t.pass('callback called')
|
||||
t.same(err, new Error('blerg'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
r.push('hello')
|
||||
r.push('world')
|
||||
r.push(null)
|
||||
})
|
||||
|
||||
tape('pipe with callback - error case with destroy', function (t) {
|
||||
const r = new Readable()
|
||||
const w = new Writable({
|
||||
write (data, cb) {
|
||||
w.destroy(new Error('blerg'))
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
r.pipe(w, function (err) {
|
||||
t.pass('callback called')
|
||||
t.same(err, new Error('blerg'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
r.push('hello')
|
||||
r.push('world')
|
||||
})
|
||||
|
||||
tape('pipe with callback - error case node stream', function (t) {
|
||||
const r = new Readable()
|
||||
const w = new compat.Writable({
|
||||
write (data, enc, cb) {
|
||||
cb(new Error('blerg'))
|
||||
}
|
||||
})
|
||||
|
||||
r.pipe(w, function (err) {
|
||||
t.pass('callback called')
|
||||
t.same(err, new Error('blerg'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
r.push('hello')
|
||||
r.push('world')
|
||||
r.push(null)
|
||||
})
|
||||
|
||||
tape('simple pipe', function (t) {
|
||||
const buffered = []
|
||||
|
||||
const r = new Readable()
|
||||
const w = new Writable({
|
||||
write (data, cb) {
|
||||
buffered.push(data)
|
||||
cb(null)
|
||||
},
|
||||
|
||||
final () {
|
||||
t.pass('final called')
|
||||
t.same(buffered, ['hello', 'world'])
|
||||
t.end()
|
||||
}
|
||||
})
|
||||
|
||||
r.pipe(w)
|
||||
|
||||
r.push('hello')
|
||||
r.push('world')
|
||||
r.push(null)
|
||||
})
|
||||
|
||||
tape('pipe with callback', function (t) {
|
||||
const buffered = []
|
||||
|
||||
const r = new Readable()
|
||||
const w = new Writable({
|
||||
write (data, cb) {
|
||||
buffered.push(data)
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
r.pipe(w, function (err) {
|
||||
t.pass('callback called')
|
||||
t.same(err, null)
|
||||
t.same(buffered, ['hello', 'world'])
|
||||
t.end()
|
||||
})
|
||||
|
||||
r.push('hello')
|
||||
r.push('world')
|
||||
r.push(null)
|
||||
})
|
||||
119
node_modules/streamx/test/readable.js
generated
vendored
Normal file
119
node_modules/streamx/test/readable.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
const tape = require('tape')
|
||||
const { Readable } = require('../')
|
||||
|
||||
tape('ondata', function (t) {
|
||||
const r = new Readable()
|
||||
const buffered = []
|
||||
let ended = 0
|
||||
|
||||
r.push('hello')
|
||||
r.push('world')
|
||||
r.push(null)
|
||||
|
||||
r.on('data', data => buffered.push(data))
|
||||
r.on('end', () => ended++)
|
||||
r.on('close', function () {
|
||||
t.pass('closed')
|
||||
t.same(buffered, ['hello', 'world'])
|
||||
t.same(ended, 1)
|
||||
t.ok(r.destroyed)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('resume', function (t) {
|
||||
const r = new Readable()
|
||||
let ended = 0
|
||||
|
||||
r.push('hello')
|
||||
r.push('world')
|
||||
r.push(null)
|
||||
|
||||
r.resume()
|
||||
r.on('end', () => ended++)
|
||||
r.on('close', function () {
|
||||
t.pass('closed')
|
||||
t.same(ended, 1)
|
||||
t.ok(r.destroyed)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('shorthands', function (t) {
|
||||
t.plan(3 + 1)
|
||||
|
||||
const r = new Readable({
|
||||
read (cb) {
|
||||
this.push('hello')
|
||||
cb(null)
|
||||
},
|
||||
destroy (cb) {
|
||||
t.pass('destroyed')
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
r.once('readable', function () {
|
||||
t.same(r.read(), 'hello')
|
||||
t.same(r.read(), 'hello')
|
||||
r.destroy()
|
||||
t.same(r.read(), null)
|
||||
})
|
||||
})
|
||||
|
||||
tape('both push and the cb needs to be called for re-reads', function (t) {
|
||||
t.plan(2)
|
||||
|
||||
let once = true
|
||||
|
||||
const r = new Readable({
|
||||
read (cb) {
|
||||
t.ok(once, 'read called once')
|
||||
once = false
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
r.resume()
|
||||
|
||||
setTimeout(function () {
|
||||
once = true
|
||||
r.push('hi')
|
||||
}, 100)
|
||||
})
|
||||
|
||||
tape('from array', function (t) {
|
||||
const inc = []
|
||||
const r = Readable.from([1, 2, 3])
|
||||
r.on('data', data => inc.push(data))
|
||||
r.on('end', function () {
|
||||
t.same(inc, [1, 2, 3])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('from buffer', function (t) {
|
||||
const inc = []
|
||||
const r = Readable.from(Buffer.from('hello'))
|
||||
r.on('data', data => inc.push(data))
|
||||
r.on('end', function () {
|
||||
t.same(inc, [Buffer.from('hello')])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('from async iterator', function (t) {
|
||||
async function * test () {
|
||||
yield 1
|
||||
yield 2
|
||||
yield 3
|
||||
}
|
||||
|
||||
const inc = []
|
||||
const r = Readable.from(test())
|
||||
r.on('data', data => inc.push(data))
|
||||
r.on('end', function () {
|
||||
t.same(inc, [1, 2, 3])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
103
node_modules/streamx/test/writable.js
generated
vendored
Normal file
103
node_modules/streamx/test/writable.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
const tape = require('tape')
|
||||
const { Writable } = require('../')
|
||||
|
||||
tape('opens before writes', function (t) {
|
||||
t.plan(2)
|
||||
const trace = []
|
||||
const stream = new Writable({
|
||||
open (cb) {
|
||||
trace.push('open')
|
||||
return cb(null)
|
||||
},
|
||||
write (data, cb) {
|
||||
trace.push('write')
|
||||
return cb(null)
|
||||
}
|
||||
})
|
||||
stream.on('close', () => {
|
||||
t.equals(trace.length, 2)
|
||||
t.equals(trace[0], 'open')
|
||||
})
|
||||
stream.write('data')
|
||||
stream.end()
|
||||
})
|
||||
|
||||
tape('drain', function (t) {
|
||||
const stream = new Writable({
|
||||
highWaterMark: 1,
|
||||
write (data, cb) {
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
t.notOk(stream.write('a'))
|
||||
stream.on('drain', function () {
|
||||
t.pass('drained')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('drain multi write', function (t) {
|
||||
t.plan(4)
|
||||
|
||||
const stream = new Writable({
|
||||
highWaterMark: 1,
|
||||
write (data, cb) {
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
t.notOk(stream.write('a'))
|
||||
t.notOk(stream.write('a'))
|
||||
t.notOk(stream.write('a'))
|
||||
stream.on('drain', function () {
|
||||
t.pass('drained')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('drain async write', function (t) {
|
||||
let flushed = false
|
||||
|
||||
const stream = new Writable({
|
||||
highWaterMark: 1,
|
||||
write (data, cb) {
|
||||
setImmediate(function () {
|
||||
flushed = true
|
||||
cb(null)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.notOk(stream.write('a'))
|
||||
t.notOk(flushed)
|
||||
stream.on('drain', function () {
|
||||
t.ok(flushed)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('writev', function (t) {
|
||||
const expected = [[], ['ho']]
|
||||
|
||||
const s = new Writable({
|
||||
writev (batch, cb) {
|
||||
t.same(batch, expected.shift())
|
||||
cb(null)
|
||||
}
|
||||
})
|
||||
|
||||
for (let i = 0; i < 100; i++) {
|
||||
expected[0].push('hi-' + i)
|
||||
s.write('hi-' + i)
|
||||
}
|
||||
|
||||
s.on('drain', function () {
|
||||
s.write('ho')
|
||||
s.end()
|
||||
})
|
||||
|
||||
s.on('finish', function () {
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user