Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions concatjson.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
const thru = require('through2')
const { Transform } = require('stream')
const split = require('split2')

function parse () {
Expand Down Expand Up @@ -38,13 +38,17 @@ function parse () {
}

function serialize () {
return thru.obj((chunk, enc, cb) => {
return new Serializer({ objectMode: true })
}

class Serializer extends Transform {
_transform (chunk, enc, cb) {
try {
return cb(null, JSON.stringify(chunk))
} catch (err) {
return cb(err)
}
})
}
}

module.exports = {
Expand Down
107 changes: 63 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
"url": "https://github.com/manidlou/concatjson/issues"
},
"homepage": "https://github.com/manidlou/concatjson#readme",
"engines": {
"node": ">= 12.0.0"
},
"dependencies": {
"split2": "^2.1.1",
"through2": "^2.0.3"
"split2": "^4.2.0"
},
"devDependencies": {
"standard": "^8.6.0",
Expand Down