Skip to content

Commit 07bf92c

Browse files
committed
tmp
1 parent 090d28a commit 07bf92c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/main.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,25 @@ export class JSONParser<T = any> extends stream.Transform {
106106
sliceStr(o: string) {
107107

108108
const z = o.indexOf('∆˚ø');
109+
109110
if (z >= 0) {
110111
return o.slice(z);
111112
}
112113

113-
const ib = o.indexOf('["');
114-
const iz = o.indexOf('{"');
115-
if (ib > 0 && ib >= iz) {
116-
o = o.slice(ib);
117-
}
118-
else if (iz > 0 && iz >= ib) {
119-
o = o.slice(iz);
120-
}
114+
const i = [
115+
o.indexOf('["'),
116+
o.indexOf('{"'),
117+
o.indexOf('[['),
118+
o.indexOf('[[[')
119+
].reduce((a, b) => b > 0 && b < a ? b : a, 0);
120+
121121
// console.log('sliced json-stream string:', o);
122-
return o;
122+
123+
if (i <= 0) {
124+
return o;
125+
}
126+
127+
return o.slice(i);
123128
}
124129

125130
handleJSON(o: string) {

0 commit comments

Comments
 (0)