Add node_modules

This commit is contained in:
Anton Medvedev 2023-01-10 16:49:41 +01:00
parent e1f786311a
commit 554eb0b122
994 changed files with 195567 additions and 0 deletions

23
node_modules/split/test/options.asynct.js generated vendored Normal file
View file

@ -0,0 +1,23 @@
var it = require('it-is').style('colour')
, split = require('..')
exports ['maximum buffer limit'] = function (test) {
var s = split(JSON.parse, null, {
maxLength: 2
})
, caughtError = false
, rows = []
s.on('error', function (err) {
caughtError = true
})
s.on('data', function (row) { rows.push(row) })
s.write('{"a":1}\n{"')
s.write('{ "')
it(caughtError).equal(true)
s.end()
test.done()
}

34
node_modules/split/test/partitioned_unicode.js generated vendored Normal file
View file

@ -0,0 +1,34 @@
var it = require('it-is').style('colour')
, split = require('..')
exports ['split data with partitioned unicode character'] = function (test) {
var s = split(/,/g)
, caughtError = false
, rows = []
s.on('error', function (err) {
caughtError = true
})
s.on('data', function (row) { rows.push(row) })
var x = 'テスト試験今日とても,よい天気で'
unicodeData = new Buffer(x);
// partition of 日
piece1 = unicodeData.slice(0, 20);
piece2 = unicodeData.slice(20, unicodeData.length);
s.write(piece1);
s.write(piece2);
s.end()
it(caughtError).equal(false)
it(rows).deepEqual(['テスト試験今日とても', 'よい天気で']);
it(rows).deepEqual(x.split(','))
test.done()
}

137
node_modules/split/test/split.asynct.js generated vendored Normal file
View file

@ -0,0 +1,137 @@
var es = require('event-stream')
, it = require('it-is').style('colour')
, d = require('ubelt')
, split = require('..')
, join = require('path').join
, fs = require('fs')
, Stream = require('stream').Stream
, Readable = require('stream').Readable
, spec = require('stream-spec')
, through = require('through')
, stringStream = require('string-to-stream')
exports ['split() works like String#split'] = function (test) {
var readme = join(__filename)
, expected = fs.readFileSync(readme, 'utf-8').split('\n')
, cs = split()
, actual = []
, ended = false
, x = spec(cs).through()
var a = new Stream ()
a.write = function (l) {
actual.push(l.trim())
}
a.end = function () {
ended = true
expected.forEach(function (v,k) {
//String.split will append an empty string ''
//if the string ends in a split pattern.
//es.split doesn't which was breaking this test.
//clearly, appending the empty string is correct.
//tests are passing though. which is the current job.
if(v)
it(actual[k]).like(v)
})
//give the stream time to close
process.nextTick(function () {
test.done()
x.validate()
})
}
a.writable = true
fs.createReadStream(readme, {flags: 'r'}).pipe(cs)
cs.pipe(a)
}
exports ['split() takes mapper function'] = function (test) {
var readme = join(__filename)
, expected = fs.readFileSync(readme, 'utf-8').split('\n')
, cs = split(function (line) { return line.toUpperCase() })
, actual = []
, ended = false
, x = spec(cs).through()
var a = new Stream ()
a.write = function (l) {
actual.push(l.trim())
}
a.end = function () {
ended = true
expected.forEach(function (v,k) {
//String.split will append an empty string ''
//if the string ends in a split pattern.
//es.split doesn't which was breaking this test.
//clearly, appending the empty string is correct.
//tests are passing though. which is the current job.
if(v)
it(actual[k]).equal(v.trim().toUpperCase())
})
//give the stream time to close
process.nextTick(function () {
test.done()
x.validate()
})
}
a.writable = true
fs.createReadStream(readme, {flags: 'r'}).pipe(cs)
cs.pipe(a)
}
exports ['split() works with empty string chunks'] = function (test) {
var str = ' foo'
, expected = str.split(/[\s]*/).reduce(splitBy(/[\s]*/), [])
, cs1 = split(/[\s]*/)
, cs2 = split(/[\s]*/)
, actual = []
, ended = false
, x = spec(cs1).through()
, y = spec(cs2).through()
var a = new Stream ()
a.write = function (l) {
actual.push(l.trim())
}
a.end = function () {
ended = true
expected.forEach(function (v,k) {
//String.split will append an empty string ''
//if the string ends in a split pattern.
//es.split doesn't which was breaking this test.
//clearly, appending the empty string is correct.
//tests are passing though. which is the current job.
if(v)
it(actual[k]).like(v)
})
//give the stream time to close
process.nextTick(function () {
test.done()
x.validate()
y.validate()
})
}
a.writable = true
cs1.pipe(cs2)
cs2.pipe(a)
cs1.write(str)
cs1.end()
}
function splitBy (delimeter) {
return function (arr, piece) {
return arr.concat(piece.split(delimeter))
}
}

51
node_modules/split/test/try_catch.asynct.js generated vendored Normal file
View file

@ -0,0 +1,51 @@
var it = require('it-is').style('colour')
, split = require('..')
exports ['emit mapper exceptions as error events'] = function (test) {
var s = split(JSON.parse)
, caughtError = false
, rows = []
s.on('error', function (err) {
caughtError = true
})
s.on('data', function (row) { rows.push(row) })
s.write('{"a":1}\n{"')
it(caughtError).equal(false)
it(rows).deepEqual([ { a: 1 } ])
s.write('b":2}\n{"c":}\n')
it(caughtError).equal(true)
it(rows).deepEqual([ { a: 1 }, { b: 2 } ])
s.end()
test.done()
}
exports ['mapper error events on trailing chunks'] = function (test) {
var s = split(JSON.parse)
, caughtError = false
, rows = []
s.on('error', function (err) {
caughtError = true
})
s.on('data', function (row) { rows.push(row) })
s.write('{"a":1}\n{"')
it(caughtError).equal(false)
it(rows).deepEqual([ { a: 1 } ])
s.write('b":2}\n{"c":}')
it(caughtError).equal(false)
it(rows).deepEqual([ { a: 1 }, { b: 2 } ])
s.end()
it(caughtError).equal(true)
it(rows).deepEqual([ { a: 1 }, { b: 2 } ])
test.done()
}