File tree 5 files changed +40
-28
lines changed
5 files changed +40
-28
lines changed Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -138,16 +138,22 @@ var patch = (function (json) {
138
138
139
139
function serializeExn ( x ) {
140
140
return ( function ( obj ) {
141
- return JSON . stringify ( obj , function ( _ , value ) {
141
+ var output = JSON . stringify ( obj , function ( _ , value ) {
142
142
if ( value === undefined ) {
143
143
return { RE_PRIVATE_NONE : true }
144
144
}
145
145
return value
146
- } )
147
- } ) ( x ) ;
146
+ } ) ;
147
+
148
+ if ( output === undefined ) {
149
+ // JSON.stringify will raise TypeError when it detects cylic objects
150
+ throw new TypeError ( "output is undefined" )
151
+ }
152
+ return output
153
+ } ) ( x ) ;
148
154
}
149
155
150
- function deserializeExn ( s ) {
156
+ function deserializeUnsafe ( s ) {
151
157
return patch ( JSON . parse ( s ) ) ;
152
158
}
153
159
@@ -160,7 +166,7 @@ export {
160
166
decodeArray ,
161
167
decodeBoolean ,
162
168
decodeNull ,
163
- deserializeExn ,
169
+ deserializeUnsafe ,
164
170
serializeExn ,
165
171
166
172
}
Original file line number Diff line number Diff line change @@ -138,16 +138,22 @@ var patch = (function (json) {
138
138
139
139
function serializeExn ( x ) {
140
140
return ( function ( obj ) {
141
- return JSON . stringify ( obj , function ( _ , value ) {
141
+ var output = JSON . stringify ( obj , function ( _ , value ) {
142
142
if ( value === undefined ) {
143
143
return { RE_PRIVATE_NONE : true }
144
144
}
145
145
return value
146
- } )
147
- } ) ( x ) ;
146
+ } ) ;
147
+
148
+ if ( output === undefined ) {
149
+ // JSON.stringify will raise TypeError when it detects cylic objects
150
+ throw new TypeError ( "output is undefined" )
151
+ }
152
+ return output
153
+ } ) ( x ) ;
148
154
}
149
155
150
- function deserializeExn ( s ) {
156
+ function deserializeUnsafe ( s ) {
151
157
return patch ( JSON . parse ( s ) ) ;
152
158
}
153
159
@@ -159,6 +165,6 @@ exports.decodeObject = decodeObject;
159
165
exports . decodeArray = decodeArray ;
160
166
exports . decodeBoolean = decodeBoolean ;
161
167
exports . decodeNull = decodeNull ;
162
- exports . deserializeExn = deserializeExn ;
168
+ exports . deserializeUnsafe = deserializeUnsafe ;
163
169
exports . serializeExn = serializeExn ;
164
170
/* No side effect */
You can’t perform that action at this time.
0 commit comments