diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/split2 | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/split2')
| -rw-r--r-- | node_modules/split2/.README.md.un~ | bin | 33830 -> 0 bytes | |||
| -rw-r--r-- | node_modules/split2/.index.js.un~ | bin | 108894 -> 0 bytes | |||
| -rw-r--r-- | node_modules/split2/.npmignore | 7 | ||||
| -rw-r--r-- | node_modules/split2/.package.json.un~ | bin | 6123 -> 0 bytes | |||
| -rw-r--r-- | node_modules/split2/.test.js.un~ | bin | 96451 -> 0 bytes | |||
| -rw-r--r-- | node_modules/split2/.travis.yml | 3 | ||||
| -rw-r--r-- | node_modules/split2/LICENSE | 13 | ||||
| -rw-r--r-- | node_modules/split2/README.md | 74 | ||||
| -rw-r--r-- | node_modules/split2/index.js | 83 | ||||
| -rw-r--r-- | node_modules/split2/package.json | 30 | ||||
| -rw-r--r-- | node_modules/split2/test.js | 149 |
11 files changed, 0 insertions, 359 deletions
diff --git a/node_modules/split2/.README.md.un~ b/node_modules/split2/.README.md.un~ Binary files differdeleted file mode 100644 index 8e126090..00000000 --- a/node_modules/split2/.README.md.un~ +++ /dev/null diff --git a/node_modules/split2/.index.js.un~ b/node_modules/split2/.index.js.un~ Binary files differdeleted file mode 100644 index b5c967a4..00000000 --- a/node_modules/split2/.index.js.un~ +++ /dev/null diff --git a/node_modules/split2/.npmignore b/node_modules/split2/.npmignore deleted file mode 100644 index 73734ed3..00000000 --- a/node_modules/split2/.npmignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules/ -build/ -libleveldb.so -libleveldb.a -test-data/ -_benchdb_* -*.sw* diff --git a/node_modules/split2/.package.json.un~ b/node_modules/split2/.package.json.un~ Binary files differdeleted file mode 100644 index e9f0aec3..00000000 --- a/node_modules/split2/.package.json.un~ +++ /dev/null diff --git a/node_modules/split2/.test.js.un~ b/node_modules/split2/.test.js.un~ Binary files differdeleted file mode 100644 index cce9293a..00000000 --- a/node_modules/split2/.test.js.un~ +++ /dev/null diff --git a/node_modules/split2/.travis.yml b/node_modules/split2/.travis.yml deleted file mode 100644 index 6e5919de..00000000 --- a/node_modules/split2/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - "0.10" diff --git a/node_modules/split2/LICENSE b/node_modules/split2/LICENSE deleted file mode 100644 index ed176567..00000000 --- a/node_modules/split2/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2014, Matteo Collina <hello@matteocollina.com> - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/split2/README.md b/node_modules/split2/README.md deleted file mode 100644 index 66fc9590..00000000 --- a/node_modules/split2/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# Split2(matcher, mapper, options) - -[](http://travis-ci.org/mcollina/split2) - -Break up a stream and reassemble it so that each line is a chunk. -`split2` is inspired by [@dominictarr](https://github.com/dominictarr) [`split`](https://github.com/dominictarr) module, -and it is totally API compatible with it. -However, it is based on [`through2`](https://github.com/rvagg/through2) by [@rvagg](https://github.com/rvagg) and it is fully based on Stream2. - -`matcher` may be a `String`, or a `RegExp`. Example, read every line in a file ... - -``` js - fs.createReadStream(file) - .pipe(split2()) - .on('data', function (line) { - //each chunk now is a seperate line! - }) - -``` - -`split` takes the same arguments as `string.split` except it defaults to '/\r?\n/' instead of ',', and the optional `limit` paremeter is ignored. -[String#split](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/split) - -`split` takes an optional options object on it's third argument, which -is directly passed as a -[Transform](http://nodejs.org/api/stream.html#stream_class_stream_transform_1) -option. - -Calling `.destroy` will make the stream emit `close`. Use this to perform cleanup logic - -``` js -var splitFile = function(filename) { - var file = fs.createReadStream(filename) - - return file - .pipe(split2()) - .on('close', function() { - // destroy the file stream in case the split stream was destroyed - file.destroy() - }) -} - -var stream = splitFile('my-file.txt') - -stream.destroy() // will destroy the input file stream -``` - -# NDJ - Newline Delimited Json - -`split2` accepts a function which transforms each line. - -``` js -fs.createReadStream(file) - .pipe(split2(JSON.parse)) - .on('data', function (obj) { - //each chunk now is a a js object - }) -``` - -# License - -Copyright (c) 2014, Matteo Collina <hello@matteocollina.com> - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/split2/index.js b/node_modules/split2/index.js deleted file mode 100644 index b9682e04..00000000 --- a/node_modules/split2/index.js +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright (c) 2014, Matteo Collina <hello@matteocollina.com> - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -'use strict'; - -var through = require('through2') - -function transform(chunk, enc, cb) { - var list = chunk.toString('utf8').split(this.matcher) - , remaining = list.pop() - , i - - if (list.length >= 1) { - push(this, this.mapper((this._last + list.shift()))) - } else { - remaining = this._last + remaining - } - - for (i = 0; i < list.length; i++) { - push(this, this.mapper(list[i])) - } - - this._last = remaining - - cb() -} - -function flush(cb) { - if (this._last) - push(this, this.mapper(this._last)) - - cb() -} - -function push(self, val) { - if (val !== undefined) - self.push(val) -} - -function noop(incoming) { - return incoming -} - -function split(matcher, mapper, options) { - - if (typeof matcher === 'object' && !(matcher instanceof RegExp)) { - options = matcher - matcher = null - } - - if (typeof matcher === 'function') { - mapper = matcher - matcher = null - } - - options = options || {} - - var stream = through(options, transform, flush) - - // this stream is in objectMode only in the readable part - stream._readableState.objectMode = true; - - stream._last = '' - stream.matcher = matcher || /\r?\n/ - stream.mapper = mapper || noop - - return stream -} - -module.exports = split diff --git a/node_modules/split2/package.json b/node_modules/split2/package.json deleted file mode 100644 index f4d22fe8..00000000 --- a/node_modules/split2/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "split2", - "version": "0.2.1", - "description": "split a Text Stream into a Line Stream, using Stream 2", - "main": "index.js", - "scripts": { - "test": "tap test.js" - }, - "pre-commit": [ - "test" - ], - "website": "https://github.com/mcollina/split2", - "repository": { - "type": "git", - "url": "https://github.com/mcollina/split2.git" - }, - "bugs": { - "url": "http://github.com/mcollina/split2/issues" - }, - "author": "Matteo Collina <hello@matteocollina.com>", - "license": "ISC", - "devDependencies": { - "tap": "~0.4.12", - "pre-commit": "0.0.9", - "callback-stream": "~1.0.2" - }, - "dependencies": { - "through2": "~0.6.1" - } -} diff --git a/node_modules/split2/test.js b/node_modules/split2/test.js deleted file mode 100644 index d227d4ac..00000000 --- a/node_modules/split2/test.js +++ /dev/null @@ -1,149 +0,0 @@ - -var test = require('tap').test - , split = require('./') - , callback = require('callback-stream') - , strcb = callback.bind(null, { decodeStrings: false }) - , objcb = callback.bind(null, { objectMode: true }) - -test('split two lines on end', function(t) { - t.plan(1) - - var input = split() - - input.pipe(strcb(function(err, list) { - t.deepEqual(list, ['hello', 'world']) - })) - - input.end('hello\nworld') -}) - -test('split two lines on two writes', function(t) { - t.plan(1) - - var input = split() - - input.pipe(strcb(function(err, list) { - t.deepEqual(list, ['hello', 'world']) - })) - - input.write('hello') - input.write('\nworld') - input.end() -}) - -test('accumulate multiple writes', function(t) { - t.plan(1) - - var input = split() - - input.pipe(strcb(function(err, list) { - t.deepEqual(list, ['helloworld']) - })) - - input.write('hello') - input.write('world') - input.end() -}) - -test('split using a custom string matcher', function(t) { - t.plan(1) - - var input = split('~') - - input.pipe(strcb(function(err, list) { - t.deepEqual(list, ['hello', 'world']) - })) - - input.end('hello~world') -}) - -test('split using a custom regexp matcher', function(t) { - t.plan(1) - - var input = split(/~/) - - input.pipe(strcb(function(err, list) { - t.deepEqual(list, ['hello', 'world']) - })) - - input.end('hello~world') -}) - -test('support an option argument', function(t) { - t.plan(2) - - var input = split({ highWatermark: 2 }) - - input.pipe(strcb(function(err, list) { - t.notOk(err, 'no errors') - t.deepEqual(list, ['hello', 'world']) - })) - - input.end('hello\nworld') -}) - -test('support a mapper function', function(t) { - t.plan(2) - - var a = { a: '42' } - , b = { b: '24' } - var input = split(JSON.parse) - - input.pipe(objcb(function(err, list) { - t.notOk(err, 'no errors') - t.deepEqual(list, [a, b]) - })) - - input.write(JSON.stringify(a)) - input.write('\n') - input.end(JSON.stringify(b)) -}) - -test('split lines windows-style', function(t) { - t.plan(1) - - var input = split() - - input.pipe(strcb(function(err, list) { - t.deepEqual(list, ['hello', 'world']) - })) - - input.end('hello\r\nworld') -}) - -test('splits a buffer', function(t) { - t.plan(1) - - var input = split() - - input.pipe(strcb(function(err, list) { - t.deepEqual(list, ['hello', 'world']) - })) - - input.end(new Buffer('hello\nworld')) -}) - -test('do not end on undefined', function(t) { - t.plan(1) - - var input = split(function(line) {}) - - input.pipe(strcb(function(err, list) { - t.deepEqual(list, []) - })) - - input.end(new Buffer('hello\nworld')) -}) - -test('has destroy method', function(t) { - t.plan(1) - - var input = split(function(line) {}) - - input.on('close', function() { - t.ok(true, 'close emitted') - t.end() - }) - - input.destroy() -})
\ No newline at end of file |
