1- 'use strict' ;
1+ 'use strict'
2+
3+ const StreamUtils = require ( '@tilfin/stream-utils' )
4+ const { assert } = require ( 'chai' )
25
36const fs = require ( 'fs' ) ;
4- const es = require ( 'event-stream' ) ;
57const through2 = require ( 'through2' ) ;
6- const chai = require ( 'chai' ) ;
7- const assert = chai . assert ;
88
99const JSONTransform = require ( '../lib/json_transform' ) ;
1010
@@ -30,13 +30,13 @@ describe('JSONTransform', () => {
3030 context ( 'passed 9 items JSON with count by 2 and expanding array' , ( ) => {
3131 it ( 'flush 5 items' , ( done ) => {
3232 const readStream = fs . createReadStream ( __dirname + '/fixtures/data/data_json.txt' ) ;
33- const jsonStream = new JSONTransform ( { expandArray : true , countBy : 2 } )
33+ const jsonStream = new JSONTransform ( { flatArray : true , countBy : 2 } )
3434 . on ( 'error' , function ( err ) {
3535 assert . ifError ( err ) ;
3636 done ( ) ;
3737 } ) ;
3838
39- const writeStream = es . writeArray ( function ( err , array ) {
39+ const writeStream = StreamUtils . writeArray ( function ( err , array ) {
4040 assert . deepEqual ( array [ 0 ] , [ { id : 1 } , { id : 2 } ] ) ;
4141 assert . deepEqual ( array [ 1 ] , [ { id : 3 } , { id : 4 } ] ) ;
4242 assert . deepEqual ( array [ 2 ] , [ { id : 5 } , { id : 6 } ] ) ;
@@ -52,7 +52,7 @@ describe('JSONTransform', () => {
5252 context ( 'highWaterMark is less than item count of 1 JSON line' , ( ) => {
5353 it ( 'reads rightly' , ( done ) => {
5454 const readStream = fs . createReadStream ( __dirname + '/fixtures/data/data_json.txt' ) ;
55- const jsonStream = new JSONTransform ( { highWaterMark : 7 , expandArray : true , countBy : 1 } )
55+ const jsonStream = new JSONTransform ( { highWaterMark : 7 , flatArray : true , countBy : 1 } )
5656 . on ( 'error' , function ( err ) {
5757 assert . ifError ( err ) ;
5858 done ( ) ;
@@ -70,7 +70,7 @@ describe('JSONTransform', () => {
7070 cb ( ) ;
7171 } ) ;
7272
73- const writeStream = es . writeArray ( function ( err , array ) {
73+ const writeStream = StreamUtils . writeArray ( function ( err , array ) {
7474 assert . equal ( array . length , 9 ) ;
7575 done ( ) ;
7676 } ) ;
@@ -84,7 +84,7 @@ describe('JSONTransform', () => {
8484 it ( `flush valid items through '${ errMsg } '` , ( done ) => {
8585 const readStream = fs . createReadStream ( __dirname + '/fixtures/data/multiline_json.txt' , { highWaterMark } ) ;
8686 const jsonStream = new JSONTransform ( )
87- const writeStream = es . writeArray ( function ( err , array ) {
87+ const writeStream = StreamUtils . writeArray ( function ( err , array ) {
8888 assert . deepEqual ( array [ 0 ] , { color : "red" , value : "#f00" } ) ;
8989 assert . deepEqual ( array [ 1 ] , { color : "green" , value : "#0f0" } ) ;
9090 assert . deepEqual ( array [ 2 ] , { color : "blue" , value : "#00f" } ) ;
0 commit comments