@@ -42,18 +42,6 @@ function getType(value): Types {
42
42
return Types . Primitive ;
43
43
}
44
44
45
- const stackItemOpen = [ ] ;
46
- stackItemOpen [ Types . Array ] = '[' ;
47
- stackItemOpen [ Types . Object ] = '{' ;
48
- stackItemOpen [ Types . ReadableString ] = '"' ;
49
- stackItemOpen [ Types . ReadableObject ] = '[' ;
50
-
51
- const stackItemEnd = [ ] ;
52
- stackItemEnd [ Types . Array ] = ']' ;
53
- stackItemEnd [ Types . Object ] = '}' ;
54
- stackItemEnd [ Types . ReadableString ] = '"' ;
55
- stackItemEnd [ Types . ReadableObject ] = ']' ;
56
-
57
45
function escapeString ( string ) {
58
46
// Modified code, original code by Douglas Crockford
59
47
// Original: https://github.com/douglascrockford/JSON-js/blob/master/json2.js
@@ -72,15 +60,11 @@ function escapeString(string) {
72
60
let primitiveToJSON : ( value : any ) => string ;
73
61
74
62
if ( global ?. JSON ?. stringify instanceof Function ) {
75
- let canSerializeBigInt = true ;
76
63
try {
77
64
if ( JSON . stringify ( global . BigInt ? global . BigInt ( '123' ) : '' ) !== '123' ) throw new Error ( ) ;
65
+ primitiveToJSON = JSON . stringify ;
78
66
} catch ( err ) {
79
- canSerializeBigInt = false ;
80
- }
81
- if ( canSerializeBigInt ) {
82
- primitiveToJSON = JSON . parse ;
83
- } else {
67
+ // Add support for bigint for primitiveToJSON
84
68
// eslint-disable-next-line no-confusing-arrow
85
69
primitiveToJSON = ( value ) => typeof value === 'bigint' ? String ( value ) : JSON . stringify ( value ) ;
86
70
}
@@ -126,7 +110,7 @@ function quoteString(string: string) {
126
110
return str ;
127
111
}
128
112
129
- function readAsPromised ( stream , size ?) {
113
+ function readAsPromised ( stream : Readable , size ?) {
130
114
const value = stream . read ( size ) ;
131
115
if ( value === null ) {
132
116
return new Promise ( ( resolve , reject ) => {
@@ -482,8 +466,6 @@ export class JsonStreamStringify extends Readable {
482
466
return true ;
483
467
}
484
468
485
- reading = false ;
486
- readMore = false ;
487
469
readState : ReadState = ReadState . NotReading ;
488
470
async _read ( size ?: number ) {
489
471
if ( this . readState === ReadState . Consumed ) return ;
0 commit comments