{"version":3,"sources":["../../source/compare/compare.ts","../../source/schema/bigint/bigint.ts","../../source/schema/native/native.ts","../../source/schema/empty/empty.ts","../../source/schema/float/float.ts","../../source/schema/integer/integer.ts"],"names":["deepEqual","BUILT_IN_OBJECTS_SCHEMAS","BIGINT64_ARRAY_SCHEMA","BIGUINT64_ARRAY_SCHEMA","z","ARRAY_SCHEMA","validateArray","value","validateArrays","arrays","currentArray","EMPTY_ARRAY_SCHEMA","FLOAT32_ARRAY_SCHEMA","FLOAT64_ARRAY_SCHEMA","INT8_ARRAY_SCHEMA","INT16_ARRAY_SCHEMA","INT32_ARRAY_SCHEMA","UINT8_ARRAY_SCHEMA","UINT8_CLAMPED_ARRAY_SCHEMA","UINT16_ARRAY_SCHEMA","UINT32_ARRAY_SCHEMA","areArraysEqual","left","right","areArraysItemsSame"],"mappings":"AAAA,OAAOA,MAAe,4BCAtB,OAAS,4BAAAC,MAAgC,yCAKlC,IAAMC,EAAwBD,EAAyB,cACjDE,EAAyBF,EAAyB,eCN/D,OAAS,KAAAG,MAAS,MAEX,IAAMC,EAAeD,EAAE,MAAMA,EAAE,IAAI,CAAC,EAIpC,SAASE,EAAcC,EAA2C,CACxEF,EAAa,MAAME,CAAK,CACzB,CAEO,SAASC,KAAkBC,EAA0B,CAC3D,QAAWC,KAAgBD,EAC1BH,EAAcI,CAAY,CAE5B,CCZO,IAAMC,EAAqBN,EAAa,OAAO,CAAC,ECFvD,OAAS,4BAAAJ,MAAgC,yCAKlC,IAAMW,EAAuBX,EAAyB,aAChDY,EAAuBZ,EAAyB,aCN7D,OAAS,4BAAAA,MAAgC,yCAWlC,IAAMa,EAAoBb,EAAyB,UAC7Cc,EAAqBd,EAAyB,WAC9Ce,EAAqBf,EAAyB,WAQpD,IAAMgB,EAAqBhB,EAAyB,WAC9CiB,EAA6BjB,EAAyB,kBACtDkB,EAAsBlB,EAAyB,YAC/CmB,EAAsBnB,EAAyB,YLpBrD,SAASoB,EAA0BC,EAAgCC,EAA0C,CACnH,OAAAf,EAAec,EAAMC,CAAK,EAEnBD,EAAK,SAAWC,EAAM,OAASvB,EAAUsB,EAAMC,CAAK,EAAI,EAChE,CAKO,SAASC,EACfF,EACAC,EACU,CACV,OAAAf,EAAec,EAAMC,CAAK,EAEnBD,EAAK,SAAWC,EAAM,OAASvB,EAAWsB,EAAY,KAAK,EAAIC,EAAa,KAAK,CAAC,EAAI,EAC9F","sourcesContent":["import deepEqual from \"fast-deep-equal/es6/react\";\n\nimport { validateArrays } from \"../schema/schema.ts\";\n\nexport function areArraysEqual<ValueType>(left: ReadonlyArray<ValueType>, right: ReadonlyArray<ValueType>): boolean {\n\tvalidateArrays(left, right);\n\n\treturn left.length === right.length ? deepEqual(left, right) : false;\n}\n\n/**\n * Check whether the arrays has same items, but in a different order.\n */\nexport function areArraysItemsSame<ValueType>(\n\tleft: ReadonlyArray<ValueType>,\n\tright: ReadonlyArray<ValueType>,\n): boolean {\n\tvalidateArrays(left, right);\n\n\treturn left.length === right.length ? deepEqual((left as []).sort(), (right as []).sort()) : false;\n}\n","import { BUILT_IN_OBJECTS_SCHEMAS } from \"@terminal-nerds/snippets-type/built-in\";\n\nexport const BIGINT_ARRAY_TYPES = [\"signed\", \"unsigned\"] as const;\nexport type BigIntArrayType = (typeof BIGINT_ARRAY_TYPES)[number];\n\nexport const BIGINT64_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.BigInt64Array;\nexport const BIGUINT64_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.BigUint64Array;\n\nexport const BIGINT_ARRAY_SCHEMAS = {\n\tsigned: BIGINT64_ARRAY_SCHEMA,\n\tunsigned: BIGUINT64_ARRAY_SCHEMA,\n} as const;\n\nexport interface BigIntArrays {\n\tsigned: BigInt64Array;\n\tunsigned: BigUint64Array;\n}\n\nexport type BigIntArray<Type extends BigIntArrayType> = BigIntArrays[Type];\n\ntype BigIntArrayOptions<Type extends BigIntArrayType> = {\n\ttype: Type;\n};\n\nexport function validateBigIntArray<Type extends BigIntArrayType>(\n\tvalue: unknown,\n\toptions: BigIntArrayOptions<Type>,\n): asserts value is BigIntArray<Type> {\n\tconst { type } = options;\n\n\tBIGINT_ARRAY_SCHEMAS[type].parse(value);\n}\n\nexport function isBigIntArray<Type extends BigIntArrayType>(\n\tvalue: unknown,\n\toptions: BigIntArrayOptions<Type>,\n): value is BigIntArray<Type> {\n\tconst { type } = options;\n\n\treturn BIGINT_ARRAY_SCHEMAS[type].safeParse(value).success;\n}\n","import { z } from \"zod\";\n\nexport const ARRAY_SCHEMA = z.array(z.any());\n\nexport type AnyArray = ReadonlyArray<unknown>;\n\nexport function validateArray(value: unknown): asserts value is AnyArray {\n\tARRAY_SCHEMA.parse(value);\n}\n\nexport function validateArrays(...arrays: AnyArray[]): void {\n\tfor (const currentArray of arrays) {\n\t\tvalidateArray(currentArray);\n\t}\n}\n","import { ARRAY_SCHEMA, validateArray } from \"../native/native.ts\";\n\nexport const EMPTY_ARRAY_SCHEMA = ARRAY_SCHEMA.length(0);\n\nexport type EmptyArray = [];\n\nexport function validateEmptyArray(array: Array<unknown> | readonly unknown[]): asserts array is EmptyArray {\n\tEMPTY_ARRAY_SCHEMA.parse(array);\n}\n\nexport function isEmptyArray(array: Array<unknown> | readonly unknown[]): array is EmptyArray {\n\tvalidateArray(array);\n\n\treturn EMPTY_ARRAY_SCHEMA.safeParse(array).success;\n}\n","import { BUILT_IN_OBJECTS_SCHEMAS } from \"@terminal-nerds/snippets-type/built-in\";\n\nexport const FLOAT_ARRAY_BITS = [32, 64] as const;\nexport type FloatArrayBit = (typeof FLOAT_ARRAY_BITS)[number];\n\nexport const FLOAT32_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Float32Array;\nexport const FLOAT64_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Float64Array;\n\nexport const FLOAT_ARRAY_SCHEMAS = {\n\t32: FLOAT32_ARRAY_SCHEMA,\n\t64: FLOAT64_ARRAY_SCHEMA,\n} as const;\n\nexport type FloatArrays = {\n\t32: Float32Array;\n\t64: Float64Array;\n};\n\nexport type FloatArray<Bit extends FloatArrayBit> = FloatArrays[Bit];\n\nexport interface FloatArrayOptions<Bit extends FloatArrayBit> {\n\tbit: Bit;\n}\n\nexport function validateFloatArray<Bit extends FloatArrayBit>(\n\tvalue: unknown,\n\toptions: FloatArrayOptions<Bit>,\n): asserts value is FloatArray<Bit> {\n\tconst { bit } = options;\n\n\tFLOAT_ARRAY_SCHEMAS[bit].parse(value);\n}\n\nexport function isFloatArray<Bit extends FloatArrayBit>(\n\tvalue: unknown,\n\toptions: FloatArrayOptions<Bit>,\n): value is FloatArray<Bit> {\n\tconst { bit } = options;\n\n\treturn FLOAT_ARRAY_SCHEMAS[bit].safeParse(value).success;\n}\n","import { BUILT_IN_OBJECTS_SCHEMAS } from \"@terminal-nerds/snippets-type/built-in\";\n\nexport const INTEGER_ARRAY_TYPES = [\"signed\", \"unsigned\"] as const;\nexport type IntegerArrayType = (typeof INTEGER_ARRAY_TYPES)[number];\n\nexport const INTEGER_ARRAY_BITS = [8, 16, 32] as const;\nexport type IntegerArrayBit = (typeof INTEGER_ARRAY_BITS)[number];\n\nexport const INTEGER_ARRAY_CATEGORIES = [\"clamped\", \"standard\"] as const;\nexport type IntegerArrayCategory = (typeof INTEGER_ARRAY_CATEGORIES)[number];\n\nexport const INT8_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Int8Array;\nexport const INT16_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Int16Array;\nexport const INT32_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Int32Array;\n\nexport const INT_ARRAY_SCHEMAS = {\n\t8: { standard: INT8_ARRAY_SCHEMA },\n\t16: { standard: INT16_ARRAY_SCHEMA },\n\t32: { standard: INT32_ARRAY_SCHEMA },\n} as const;\n\nexport const UINT8_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Uint8Array;\nexport const UINT8_CLAMPED_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Uint8ClampedArray;\nexport const UINT16_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Uint16Array;\nexport const UINT32_ARRAY_SCHEMA = BUILT_IN_OBJECTS_SCHEMAS.Uint32Array;\n\nexport const UINT_ARRAY_SCHEMAS = {\n\t8: { standard: UINT8_ARRAY_SCHEMA, clamped: UINT8_CLAMPED_ARRAY_SCHEMA },\n\t16: { standard: UINT16_ARRAY_SCHEMA },\n\t32: { standard: UINT32_ARRAY_SCHEMA },\n} as const;\n\nexport const INTEGER_ARRAY_SCHEMAS = {\n\tsigned: INT_ARRAY_SCHEMAS,\n\tunsigned: UINT_ARRAY_SCHEMAS,\n} as const;\n\nexport interface IntegerArrays {\n\tsigned: {\n\t\t8: { standard: Int8Array };\n\t\t16: { standard: Int16Array };\n\t\t32: { standard: Int32Array };\n\t};\n\tunsigned: {\n\t\t8: { standard: Uint8Array; clamped: Uint8ClampedArray };\n\t\t16: { standard: Uint16Array };\n\t\t32: { standard: Uint32Array };\n\t};\n}\n\nexport type IntArray<Bit extends IntegerArrayBit> = IntegerArrays[\"signed\"][Bit][\"standard\"];\nexport type UintArray<Bit extends IntegerArrayBit, Category extends IntegerArrayCategory> = Bit extends 8\n\t? IntegerArrays[\"unsigned\"][8][Category]\n\t: IntegerArrays[\"unsigned\"][Bit][\"standard\"];\nexport type IntegerArray<\n\tType extends IntegerArrayType,\n\tBit extends IntegerArrayBit,\n\tCategory extends IntegerArrayCategory = Type extends \"unsigned\"\n\t\t? Bit extends 8\n\t\t\t? IntegerArrayCategory\n\t\t\t: \"standard\"\n\t\t: \"standard\",\n> = Type extends \"signed\" ? IntArray<Bit> : Type extends \"unsigned\" ? UintArray<Bit, Category> : never;\n\ntype IntArrayOptions<Type extends IntegerArrayType, Bit extends IntegerArrayBit> = {\n\ttype: Type;\n\tbit: Bit;\n};\n\ntype Uint8ArrayOptions<Clamped extends boolean | undefined = undefined> = {\n\ttype: \"unsigned\";\n\tclamped?: Clamped;\n\tbit: 8;\n};\n\nexport type IntegerArrayOptions<\n\tType extends IntegerArrayType,\n\tBit extends IntegerArrayBit,\n\tClamped extends boolean | undefined = undefined,\n> = Type extends \"unsigned\"\n\t? Bit extends 8\n\t\t? Uint8ArrayOptions<Type extends \"unsigned\" ? (Bit extends 8 ? Clamped : undefined) : undefined>\n\t\t: IntArrayOptions<Type, Bit>\n\t: IntArrayOptions<Type, Bit>;\n\nexport function isUnsigned(type: IntegerArrayType): type is \"unsigned\" {\n\treturn type === \"unsigned\";\n}\n\nexport function is8Bit(bit: IntegerArrayBit): bit is 8 {\n\treturn bit === 8;\n}\n\n/**\n * FIXME:\n * There's an unwanted case, where the passed options -`{ type: \"standard\", bit: 8 }`\n * the return value will be: `Uint8Array` | `Uint8ClampedArray`.\n * What is expected: it should pick one, and base it on the `clamped` optional key in options.\n */\nexport function validateIntegerArray<\n\tType extends IntegerArrayType,\n\tBit extends IntegerArrayBit,\n\tClamped extends boolean | undefined = undefined,\n>(\n\tvalue: unknown,\n\toptions: IntegerArrayOptions<Type, Bit, Clamped>,\n): asserts value is IntegerArray<Type, Bit, IntegerArrayCategory> {\n\tconst { type, bit } = options;\n\n\tif (isUnsigned(type) && is8Bit(bit)) {\n\t\tconst { clamped = false } = options as IntegerArrayOptions<\"unsigned\", 8, Clamped>;\n\n\t\tINTEGER_ARRAY_SCHEMAS[type][bit][clamped ? \"clamped\" : \"standard\"].parse(value);\n\t} else {\n\t\tINTEGER_ARRAY_SCHEMAS[type][bit][\"standard\"].parse(value);\n\t}\n}\n\n/**\n * FIXME:\n * There's an unwanted case, where the passed options -`{ type: \"standard\", bit: 8 }`\n * the return value will be: `Uint8Array` | `Uint8ClampedArray`.\n * What is expected: it should pick one, and base it on the `clamped` optional key in options.\n */\nexport function isIntegerArray<\n\tType extends IntegerArrayType,\n\tBit extends IntegerArrayBit,\n\tClamped extends boolean | undefined = undefined,\n>(\n\tvalue: unknown,\n\toptions: IntegerArrayOptions<Type, Bit, Clamped>,\n): value is IntegerArray<Type, Bit, IntegerArrayCategory> {\n\tconst { type, bit } = options;\n\n\tif (isUnsigned(type) && is8Bit(bit)) {\n\t\tconst { clamped = false } = options as IntegerArrayOptions<\"unsigned\", 8, Clamped>;\n\n\t\treturn INTEGER_ARRAY_SCHEMAS[type][bit][clamped ? \"clamped\" : \"standard\"].safeParse(value).success;\n\t} else {\n\t\treturn INTEGER_ARRAY_SCHEMAS[type][bit][\"standard\"].safeParse(value).success;\n\t}\n}\n"]}