summaryrefslogtreecommitdiff
path: root/node_modules/split2
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:50:21 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:50:21 +0800
commit0379526e20e1ff212df23e6326741aa9c06df204 (patch)
tree340143b0c4dc4280c88ba1591d137b53477005b3 /node_modules/split2
parent7aba14fb7c970c6e6af82c805db2aef6d70bfe2b (diff)
added doiuse plugin for postcss
Diffstat (limited to 'node_modules/split2')
-rw-r--r--node_modules/split2/.README.md.un~bin0 -> 33830 bytes
-rw-r--r--node_modules/split2/.index.js.un~bin0 -> 108894 bytes
-rw-r--r--node_modules/split2/.npmignore7
-rw-r--r--node_modules/split2/.package.json.un~bin0 -> 6123 bytes
-rw-r--r--node_modules/split2/.test.js.un~bin0 -> 96451 bytes
-rw-r--r--node_modules/split2/.travis.yml3
-rw-r--r--node_modules/split2/LICENSE13
-rw-r--r--node_modules/split2/README.md74
-rw-r--r--node_modules/split2/index.js83
-rw-r--r--node_modules/split2/package.json30
-rw-r--r--node_modules/split2/test.js149
11 files changed, 359 insertions, 0 deletions
diff --git a/node_modules/split2/.README.md.un~ b/node_modules/split2/.README.md.un~
new file mode 100644
index 00000000..8e126090
--- /dev/null
+++ b/node_modules/split2/.README.md.un~
Binary files differ
diff --git a/node_modules/split2/.index.js.un~ b/node_modules/split2/.index.js.un~
new file mode 100644
index 00000000..b5c967a4
--- /dev/null
+++ b/node_modules/split2/.index.js.un~
Binary files differ
diff --git a/node_modules/split2/.npmignore b/node_modules/split2/.npmignore
new file mode 100644
index 00000000..73734ed3
--- /dev/null
+++ b/node_modules/split2/.npmignore
@@ -0,0 +1,7 @@
+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~
new file mode 100644
index 00000000..e9f0aec3
--- /dev/null
+++ b/node_modules/split2/.package.json.un~
Binary files differ
diff --git a/node_modules/split2/.test.js.un~ b/node_modules/split2/.test.js.un~
new file mode 100644
index 00000000..cce9293a
--- /dev/null
+++ b/node_modules/split2/.test.js.un~
Binary files differ
diff --git a/node_modules/split2/.travis.yml b/node_modules/split2/.travis.yml
new file mode 100644
index 00000000..6e5919de
--- /dev/null
+++ b/node_modules/split2/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - "0.10"
diff --git a/node_modules/split2/LICENSE b/node_modules/split2/LICENSE
new file mode 100644
index 00000000..ed176567
--- /dev/null
+++ b/node_modules/split2/LICENSE
@@ -0,0 +1,13 @@
+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
new file mode 100644
index 00000000..66fc9590
--- /dev/null
+++ b/node_modules/split2/README.md
@@ -0,0 +1,74 @@
+# Split2(matcher, mapper, options)
+
+[![build status](https://secure.travis-ci.org/mcollina/split2.png)](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
new file mode 100644
index 00000000..b9682e04
--- /dev/null
+++ b/node_modules/split2/index.js
@@ -0,0 +1,83 @@
+/*
+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
new file mode 100644
index 00000000..f4d22fe8
--- /dev/null
+++ b/node_modules/split2/package.json
@@ -0,0 +1,30 @@
+{
+ "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
new file mode 100644
index 00000000..d227d4ac
--- /dev/null
+++ b/node_modules/split2/test.js
@@ -0,0 +1,149 @@
+
+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