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/ldjson-stream | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/ldjson-stream')
| -rw-r--r-- | node_modules/ldjson-stream/.npmignore | 1 | ||||
| -rw-r--r-- | node_modules/ldjson-stream/index.js | 32 | ||||
| -rw-r--r-- | node_modules/ldjson-stream/package.json | 25 | ||||
| -rw-r--r-- | node_modules/ldjson-stream/readme.md | 55 | ||||
| -rw-r--r-- | node_modules/ldjson-stream/test.js | 35 |
5 files changed, 0 insertions, 148 deletions
diff --git a/node_modules/ldjson-stream/.npmignore b/node_modules/ldjson-stream/.npmignore deleted file mode 100644 index b512c09d..00000000 --- a/node_modules/ldjson-stream/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules
\ No newline at end of file diff --git a/node_modules/ldjson-stream/index.js b/node_modules/ldjson-stream/index.js deleted file mode 100644 index d827fb4f..00000000 --- a/node_modules/ldjson-stream/index.js +++ /dev/null @@ -1,32 +0,0 @@ -var through = require('through2') -var split = require('split2') -var EOL = require('os').EOL - -module.exports = parse -module.exports.serialize = serialize -module.exports.parse = parse - -function parse(opts) { - opts = opts || {} - opts.strict = opts.strict !== false - - function strict(row) { - if (row) return JSON.parse(row) - } - - function nonStrict(row) { - try { - if (row) return JSON.parse(row) - } catch(e) { - // ignore - } - } - - return opts.strict ? split(strict) : split(nonStrict) -} - -function serialize() { - return through.obj(function(obj, enc, cb) { - cb(null, JSON.stringify(obj) + EOL) - }) -} diff --git a/node_modules/ldjson-stream/package.json b/node_modules/ldjson-stream/package.json deleted file mode 100644 index ba64dbf0..00000000 --- a/node_modules/ldjson-stream/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "ldjson-stream", - "version": "1.2.1", - "description": "streaming line delimited json parser + serializer", - "main": "index.js", - "scripts": { - "test": "tape test.js" - }, - "author": "max ogden", - "license": "BSD", - "dependencies": { - "split2": "^0.2.1", - "through2": "^0.6.1" - }, - "devDependencies": { - "tape": "^2.13.3" - }, - "repository": { - "type": "git", - "url": "git://github.com/maxogden/ldjson-stream.git" - }, - "bugs": { - "url": "https://github.com/maxogden/ldjson-stream/issues" - } -} diff --git a/node_modules/ldjson-stream/readme.md b/node_modules/ldjson-stream/readme.md deleted file mode 100644 index d6a99c55..00000000 --- a/node_modules/ldjson-stream/readme.md +++ /dev/null @@ -1,55 +0,0 @@ -# ldjson-stream - -#### streaming line delimited json parser + serializer - -[](https://nodei.co/npm/ldjson-stream/) - -## usage - -``` -var ldj = require('ldjson-stream') -``` - -#### ldj.parse() - -returns a transform stream that accepts newline delimited json and emits objects - -example newline delimited json: - -`data.txt`: - -``` -{"foo": "bar"} -{"hello": "world"} -``` - -If you want to discard non-valid JSON messages, you can call `ldj.parse({strict: false})` - -usage: - -```js -fs.createReadStream('data.txt') - .pipe(ldj.parse()) - .on('data', function(obj) { - // obj is a javascript object - }) -``` - -#### ldj.serialize() - -returns a transform stream that accepts json objects and emits newline delimited json - -example usage: - -```js -var serialize = ldj.serialize() -serialize.on('data', function(line) { - // line is a line of stringified JSON with a newline delimiter at the end -}) -serialize.write({"foo": "bar"}) -serialize.end() -``` - -### license - -BSD diff --git a/node_modules/ldjson-stream/test.js b/node_modules/ldjson-stream/test.js deleted file mode 100644 index 9a2da0e1..00000000 --- a/node_modules/ldjson-stream/test.js +++ /dev/null @@ -1,35 +0,0 @@ -var test = require('tape') -var ldj = require('./') -var os = require('os') - -test('.parse', function(t) { - var parser = ldj.parse() - parser.on('data', function(obj) { - t.equal(obj.hello, 'world') - t.end() - }) - - parser.write('{"hello": "world"}\n') -}) - -test('.parse twice', function(t) { - var parser = ldj.parse() - parser.once('data', function(obj) { - t.equal(obj.hello, 'world') - parser.once('data', function(obj) { - t.equal(obj.hola, 'mundo') - t.end() - }) - }) - - parser.write('{"hello": "world"}\n{"hola": "mundo"}\n') -}) - -test('.serialize', function(t) { - var serializer = ldj.serialize() - serializer.on('data', function(data) { - t.equal(data, '{"hello":"world"}' + os.EOL) - t.end() - }) - serializer.write({hello: 'world'}) -}) |
