8000 tmp · ORESoftware/json-parser@737f1dd · GitHub
[go: up one dir, main page]

Skip to content

Commit 737f1dd

Browse files
author
Alexander Mills
committed
tmp
1 parent 5d02704 commit 737f1dd

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

.r2g/tests/smoke-test.3.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {JSONParser} = require('@oresoftware/json-stream-parser');
2323

2424
console.log('Running test', __filename);
2525

26+
2627
const k = cp.spawn('bash');
2728
const foo = 'medicine';
2829

@@ -35,8 +36,7 @@ k.stdin.end(`
3536
{"foo":"$foo"} ∆∆
3637
{"foo":"$foo"} ∆
3738
∆{"foo":"$foo"}∆
38-
39-
EOF
39+
EOF
4040
4141
`);
4242

@@ -48,8 +48,14 @@ const to = setTimeout(() => {
4848

4949
let count = 0;
5050

51+
k.stdout.on('data', d => {
52+
console.log('XOKOEE',String(d));
53+
});
54+
5155
k.stdout.pipe(new JSONParser({delimiter:'∆'})).on('data', d => {
5256

57+
console.log("HERE IS ONE:", d);
58+
5359
count++;
5460

5561
if(count > 3){

src/main.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,22 @@ export class JSONParser<T = any> extends stream.Transform {
105105

106106
handleJSON(o: string) {
107107

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);
119124

120125
let json = null;
121126

0 commit comments

Comments
 (0)
0