@@ -8,25 +8,25 @@ import {
88 FLYTRAP_RESPONSE
99} from './constants'
1010
11- export function superJsonRegisterCustom ( ) {
11+ export function superJsonRegisterCustom ( superJsonInstance : typeof SuperJSON ) {
1212 // Fetch API classes
13- SuperJSON . registerCustom < any , string > (
13+ superJsonInstance . registerCustom < any , string > (
1414 {
1515 isApplicable : ( v ) : v is Headers => v instanceof Headers ,
1616 serialize : ( ) => FLYTRAP_HEADERS ,
1717 deserialize : ( ) => FLYTRAP_HEADERS
1818 } ,
1919 'Headers'
2020 )
21- SuperJSON . registerCustom < any , string > (
21+ superJsonInstance . registerCustom < any , string > (
2222 {
2323 isApplicable : ( v ) : v is Response => v instanceof Response ,
2424 serialize : ( ) => FLYTRAP_RESPONSE ,
2525 deserialize : ( ) => FLYTRAP_RESPONSE
2626 } ,
2727 'Response'
2828 )
29- SuperJSON . registerCustom < any , string > (
29+ superJsonInstance . registerCustom < any , string > (
3030 {
3131 isApplicable : ( v ) : v is Request => v instanceof Request ,
3232 serialize : ( ) => FLYTRAP_REQUEST ,
@@ -36,7 +36,7 @@ export function superJsonRegisterCustom() {
3636 )
3737
3838 // handle functions
39- SuperJSON . registerCustom < any , string > (
39+ superJsonInstance . registerCustom < any , string > (
4040 {
4141 isApplicable : ( v ) : v is Function => typeof v === 'function' ,
4242 serialize : ( ) => FLYTRAP_FUNCTION ,
@@ -46,7 +46,7 @@ export function superJsonRegisterCustom() {
4646 )
4747
4848 // handle DOM events
49- SuperJSON . registerCustom < any , string > (
49+ superJsonInstance . registerCustom < any , string > (
5050 {
5151 isApplicable : ( v ) : v is Event => {
5252 return typeof window !== 'undefined' ? v instanceof window . Event : false
@@ -64,7 +64,7 @@ export function superJsonRegisterCustom() {
6464 * @returns stringified object with cyclical dependencies removed
6565 */
6666export function stringify ( obj : any ) : string {
67- superJsonRegisterCustom ( )
67+ superJsonRegisterCustom ( SuperJSON )
6868
6969 const serialized = SuperJSON . serialize ( obj )
7070 if ( serialized . meta ?. referentialEqualities ) {
@@ -87,6 +87,6 @@ export function stringify(obj: any): string {
8787}
8888
8989export function parse < T = unknown > ( stringified : string ) : T {
90- superJsonRegisterCustom ( )
90+ superJsonRegisterCustom ( SuperJSON )
9191 return SuperJSON . parse < T > ( stringified )
9292}
0 commit comments