Skip to content

Commit 353ed0d

Browse files
committed
Replace through2 with Node stream.Transform
1 parent 4927f28 commit 353ed0d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

concatjson.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
const thru = require('through2')
2+
const { Transform } = require('stream')
33
const split = require('split2')
44

55
function parse () {
@@ -38,13 +38,17 @@ function parse () {
3838
}
3939

4040
function serialize () {
41-
return thru.obj((chunk, enc, cb) => {
41+
return new Serializer({ objectMode: true })
42+
}
43+
44+
class Serializer extends Transform {
45+
_transform (chunk, enc, cb) {
4246
try {
4347
return cb(null, JSON.stringify(chunk))
4448
} catch (err) {
4549
return cb(err)
4650
}
47-
})
51+
}
4852
}
4953

5054
module.exports = {

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"node": ">= 12.0.0"
2626
},
2727
"dependencies": {
28-
"split2": "^4.2.0",
29-
"through2": "^4.0.2"
28+
"split2": "^4.2.0"
3029
},
3130
"devDependencies": {
3231
"standard": "^17.1.0",

0 commit comments

Comments
 (0)