@@ -3,15 +3,15 @@ import { YSONReviver } from "./types.js"
33const parseMap : YSONReviver < Map < any , any > > = x => {
44 if ( typeof x != "object" ) throw new Error ( "Map must be an object or entry array" )
55
6- if ( x instanceof Array ) { // Map entries
6+ if ( Array . isArray ( x ) ) { // Map entries
77 return new Map ( x as [ any , any ] [ ] )
88 }
99
1010 return new Map ( Object . entries ( x ) )
1111}
1212
1313const parseSet : YSONReviver < Set < any > > = x => {
14- if ( ! ( x instanceof Array ) ) throw new Error ( "Set must be an array" )
14+ if ( ! ( Array . isArray ( x ) ) ) throw new Error ( "Set must be an array" )
1515
1616 return new Set ( x )
1717}
@@ -29,13 +29,13 @@ const parseURL: YSONReviver<URL> = x => {
2929}
3030
3131const parseArrayBuffer : YSONReviver < ArrayBuffer > = x => {
32- if ( ! ( x instanceof Array ) ) throw new Error ( "ArrayBuffer must be an array" )
32+ if ( ! ( Array . isArray ( x ) ) ) throw new Error ( "ArrayBuffer must be an array" )
3333
3434 return new Uint8Array ( x as [ ] ) . buffer
3535}
3636
3737const parseDataView : YSONReviver < DataView > = x => {
38- if ( ! ( x instanceof Array ) ) throw new Error ( "DataView must be an array" )
38+ if ( ! ( Array . isArray ( x ) ) ) throw new Error ( "DataView must be an array" )
3939
4040 return new DataView ( new Uint8Array ( x as [ ] ) . buffer )
4141}
@@ -44,7 +44,7 @@ const typedArrays = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint1
4444type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array | Float32Array | Float64Array
4545
4646const parseTypedArray : YSONReviver < TypedArray > = ( x , { name } ) => {
47- if ( ! ( x instanceof Array ) ) throw new Error ( "TypedArray must be an array" )
47+ if ( ! Array . isArray ( x ) ) throw new Error ( "TypedArray must be an array" )
4848
4949 const typedArray = typedArrays . find ( typedArray => typedArray . name == name )
5050 if ( ! typedArray ) throw new Error ( "Unknown TypedArray" )
0 commit comments