File tree Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ const {JSONParser} = require('@oresoftware/json-stream-parser');
23
23
24
24
console . log ( 'Running test' , __filename ) ;
25
25
26
+
26
27
const k = cp . spawn ( 'bash' ) ;
27
28
const foo = 'medicine' ;
28
29
@@ -35,8 +36,7 @@ k.stdin.end(`
35
36
{"foo":"$foo"} ∆∆
36
37
{"foo":"$foo"} ∆
37
38
∆{"foo":"$foo"}∆
38
-
39
- EOF
39
+ EOF
40
40
41
41
` ) ;
42
42
@@ -48,8 +48,14 @@ const to = setTimeout(() => {
48
48
49
49
let count = 0 ;
50
50
51
+ k . stdout . on ( 'data' , d => {
52
+ console . log ( 'XOKOEE' , String ( d ) ) ;
53
+ } ) ;
54
+
51
55
k . stdout . pipe ( new JSONParser ( { delimiter :'∆' } ) ) . on ( 'data' , d => {
52
56
57
+ console . log ( "HERE IS ONE:" , d ) ;
58
+
53
59
count ++ ;
54
60
55
61
if ( count > 3 ) {
Original file line number Diff line number Diff line change @@ -105,17 +105,22 @@ export class JSONParser<T = any> extends stream.Transform {
105
105
106
106
handleJSON ( o : string ) {
107
107
108
- if ( this . cleanFront ) {
109
- // sometimes there is some noise in the beginning of a line before the JSON starts
110
- const ib = o . indexOf ( '["' ) ;
111
- if ( ib !== 0 ) {
112
- const iz = o . indexOf ( '{"' ) ;
113
- if ( ib >= 0 || iz >= 0 ) {
114
- let i = Math . min ( ib , iz ) ;
115
- o = o . slice ( i ) ;
116
- }
117
- }
118
- }
108
+ // if (this.cleanFront) {
109
+ // // sometimes there is some noise in the beginning of a line before the JSON starts
110
+ // if (!((o[0] === '[' || o[0] === '{') && o[1] === '"')) {
111
+ // const ib = o.indexOf('["');
112
+ // const iz = o.indexOf('{"');
113
+ // if (ib >= 0 || iz >= 0) {
114
+ // let i = Math.min(ib, iz);
115
+ // if (!o.slice(0, i).match(this.delimiter)) {
116
+ // o = o.slice(i);
117
+ // }
118
+ //
119
+ // }
120
+ // }
121
+ // }
122
+
123
+ // console.log('ooooo:', o);
119
124
120
125
let json = null ;
121
126
You can’t perform that action at this time.
0 commit comments