mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-12 21:03:32 -06:00
Initial commit
This commit is contained in:
BIN
node_modules/split2/.README.md.un~
generated
vendored
Normal file
BIN
node_modules/split2/.README.md.un~
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/split2/.index.js.un~
generated
vendored
Normal file
BIN
node_modules/split2/.index.js.un~
generated
vendored
Normal file
Binary file not shown.
7
node_modules/split2/.npmignore
generated
vendored
Normal file
7
node_modules/split2/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
node_modules/
|
||||
build/
|
||||
libleveldb.so
|
||||
libleveldb.a
|
||||
test-data/
|
||||
_benchdb_*
|
||||
*.sw*
|
BIN
node_modules/split2/.package.json.un~
generated
vendored
Normal file
BIN
node_modules/split2/.package.json.un~
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/split2/.test.js.un~
generated
vendored
Normal file
BIN
node_modules/split2/.test.js.un~
generated
vendored
Normal file
Binary file not shown.
3
node_modules/split2/.travis.yml
generated
vendored
Normal file
3
node_modules/split2/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
13
node_modules/split2/LICENSE
generated
vendored
Normal file
13
node_modules/split2/LICENSE
generated
vendored
Normal file
@@ -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.
|
74
node_modules/split2/README.md
generated
vendored
Normal file
74
node_modules/split2/README.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
# 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.
|
83
node_modules/split2/index.js
generated
vendored
Normal file
83
node_modules/split2/index.js
generated
vendored
Normal file
@@ -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
|
80
node_modules/split2/package.json
generated
vendored
Normal file
80
node_modules/split2/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"split2@^0.2.1",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/ldjson-stream"
|
||||
]
|
||||
],
|
||||
"_from": "split2@>=0.2.1 <0.3.0",
|
||||
"_id": "split2@0.2.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/split2",
|
||||
"_npmUser": {
|
||||
"email": "hello@matteocollina.com",
|
||||
"name": "matteo.collina"
|
||||
},
|
||||
"_npmVersion": "1.4.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "split2",
|
||||
"raw": "split2@^0.2.1",
|
||||
"rawSpec": "^0.2.1",
|
||||
"scope": null,
|
||||
"spec": ">=0.2.1 <0.3.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/ldjson-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/split2/-/split2-0.2.1.tgz",
|
||||
"_shasum": "02ddac9adc03ec0bb78c1282ec079ca6e85ae900",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "split2@^0.2.1",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/ldjson-stream",
|
||||
"author": {
|
||||
"email": "hello@matteocollina.com",
|
||||
"name": "Matteo Collina"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/mcollina/split2/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"through2": "~0.6.1"
|
||||
},
|
||||
"description": "split a Text Stream into a Line Stream, using Stream 2",
|
||||
"devDependencies": {
|
||||
"callback-stream": "~1.0.2",
|
||||
"pre-commit": "0.0.9",
|
||||
"tap": "~0.4.12"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "02ddac9adc03ec0bb78c1282ec079ca6e85ae900",
|
||||
"tarball": "https://registry.npmjs.org/split2/-/split2-0.2.1.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/mcollina/split2",
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "matteo.collina",
|
||||
"email": "hello@matteocollina.com"
|
||||
}
|
||||
],
|
||||
"name": "split2",
|
||||
"optionalDependencies": {},
|
||||
"pre-commit": [
|
||||
"test"
|
||||
],
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mcollina/split2.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test.js"
|
||||
},
|
||||
"version": "0.2.1",
|
||||
"website": "https://github.com/mcollina/split2"
|
||||
}
|
149
node_modules/split2/test.js
generated
vendored
Normal file
149
node_modules/split2/test.js
generated
vendored
Normal file
@@ -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()
|
||||
})
|
Reference in New Issue
Block a user