File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 11'use strict'
2- const thru = require ( 'through2 ' )
2+ const { Transform } = require ( 'stream ' )
33const split = require ( 'split2' )
44
55function parse ( ) {
@@ -38,13 +38,17 @@ function parse () {
3838}
3939
4040function 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
5054module . exports = {
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments