File tree Expand file tree Collapse file tree 5 files changed +40
-28
lines changed
Expand file tree Collapse file tree 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) {
138138
139139function serializeExn ( x ) {
140140 return ( function ( obj ) {
141- return JSON . stringify ( obj , function ( _ , value ) {
141+ var output = JSON . stringify ( obj , function ( _ , value ) {
142142 if ( value === undefined ) {
143143 return { RE_PRIVATE_NONE : true }
144144 }
145145 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 ) ;
148154}
149155
150- function deserializeExn ( s ) {
156+ function deserializeUnsafe ( s ) {
151157 return patch ( JSON . parse ( s ) ) ;
152158}
153159
@@ -160,7 +166,7 @@ export {
160166 decodeArray ,
161167 decodeBoolean ,
162168 decodeNull ,
163- deserializeExn ,
169+ deserializeUnsafe ,
164170 serializeExn ,
165171
166172}
Original file line number Diff line number Diff line change @@ -138,16 +138,22 @@ var patch = (function (json) {
138138
139139function serializeExn ( x ) {
140140 return ( function ( obj ) {
141- return JSON . stringify ( obj , function ( _ , value ) {
141+ var output = JSON . stringify ( obj , function ( _ , value ) {
142142 if ( value === undefined ) {
143143 return { RE_PRIVATE_NONE : true }
144144 }
145145 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 ) ;
148154}
149155
150- function deserializeExn ( s ) {
156+ function deserializeUnsafe ( s ) {
151157 return patch ( JSON . parse ( s ) ) ;
152158}
153159
@@ -159,6 +165,6 @@ exports.decodeObject = decodeObject;
159165exports . decodeArray = decodeArray ;
160166exports . decodeBoolean = decodeBoolean ;
161167exports . decodeNull = decodeNull ;
162- exports . deserializeExn = deserializeExn ;
168+ exports . deserializeUnsafe = deserializeUnsafe ;
163169exports . serializeExn = serializeExn ;
164170/* No side effect */
You can’t perform that action at this time.
0 commit comments