Created
May 14, 2024 23:51
-
-
Save Suero152/7508faa894f12477a5c2fec7d3a974da to your computer and use it in GitHub Desktop.
A package patch to remove some Typebox BigInt usages so I can use it with Babel properly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/@sinclair/typebox/build/cjs/errors/errors.js b/node_modules/@sinclair/typebox/build/cjs/errors/errors.js | |
index b13e46b..090e803 100644 | |
--- a/node_modules/@sinclair/typebox/build/cjs/errors/errors.js | |
+++ b/node_modules/@sinclair/typebox/build/cjs/errors/errors.js | |
@@ -9,7 +9,7 @@ const extends_undefined_1 = require("../type/extends/extends-undefined"); | |
const function_1 = require("./function"); | |
const index_4 = require("../type/error/index"); | |
const index_5 = require("../value/deref/index"); | |
-const index_6 = require("../value/hash/index"); | |
+c | |
const index_7 = require("../type/symbols/index"); | |
const index_8 = require("../type/never/index"); | |
// ------------------------------------------------------------------ | |
@@ -149,18 +149,6 @@ function* FromArray(schema, references, path, value) { | |
for (let i = 0; i < value.length; i++) { | |
yield* Visit(schema.items, references, `${path}/${i}`, value[i]); | |
} | |
- // prettier-ignore | |
- if (schema.uniqueItems === true && !((function () { const set = new Set(); for (const element of value) { | |
- const hashed = (0, index_6.Hash)(element); | |
- if (set.has(hashed)) { | |
- return false; | |
- } | |
- else { | |
- set.add(hashed); | |
- } | |
- } return true; })())) { | |
- yield Create(ValueErrorType.ArrayUniqueItems, schema, path, value); | |
- } | |
// contains | |
if (!(IsDefined(schema.contains) || IsDefined(schema.minContains) || IsDefined(schema.maxContains))) { | |
return; | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/check/check.js b/node_modules/@sinclair/typebox/build/cjs/value/check/check.js | |
index a9deecb..5ac3b75 100644 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/check/check.js | |
+++ b/node_modules/@sinclair/typebox/build/cjs/value/check/check.js | |
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.Check = exports.ValueCheckUnknownTypeError = void 0; | |
const index_1 = require("../../system/index"); | |
const index_2 = require("../deref/index"); | |
-const index_3 = require("../hash/index"); | |
const index_4 = require("../../type/symbols/index"); | |
const index_5 = require("../../type/keyof/index"); | |
const index_6 = require("../../type/extends/index"); | |
@@ -59,18 +58,6 @@ function FromArray(schema, references, value) { | |
if (!value.every((value) => Visit(schema.items, references, value))) { | |
return false; | |
} | |
- // prettier-ignore | |
- if (schema.uniqueItems === true && !((function () { const set = new Set(); for (const element of value) { | |
- const hashed = (0, index_3.Hash)(element); | |
- if (set.has(hashed)) { | |
- return false; | |
- } | |
- else { | |
- set.add(hashed); | |
- } | |
- } return true; })())) { | |
- return false; | |
- } | |
// contains | |
if (!(IsDefined(schema.contains) || (0, index_10.IsNumber)(schema.minContains) || (0, index_10.IsNumber)(schema.maxContains))) { | |
return true; // exit | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/hash/hash.d.ts b/node_modules/@sinclair/typebox/build/cjs/value/hash/hash.d.ts | |
deleted file mode 100644 | |
index f6fdc27..0000000 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/hash/hash.d.ts | |
+++ /dev/null | |
@@ -1,7 +0,0 @@ | |
-import { TypeBoxError } from '../../type/error/index'; | |
-export declare class ValueHashError extends TypeBoxError { | |
- readonly value: unknown; | |
- constructor(value: unknown); | |
-} | |
-/** Creates a FNV1A-64 non cryptographic hash of the given value */ | |
-export declare function Hash(value: unknown): bigint; | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/hash/hash.js b/node_modules/@sinclair/typebox/build/cjs/value/hash/hash.js | |
deleted file mode 100644 | |
index 7c546d7..0000000 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/hash/hash.js | |
+++ /dev/null | |
@@ -1,152 +0,0 @@ | |
-"use strict"; | |
- | |
-Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.Hash = exports.ValueHashError = void 0; | |
-const index_1 = require("../guard/index"); | |
-const index_2 = require("../../type/error/index"); | |
-// ------------------------------------------------------------------ | |
-// Errors | |
-// ------------------------------------------------------------------ | |
-class ValueHashError extends index_2.TypeBoxError { | |
- constructor(value) { | |
- super(`Unable to hash value`); | |
- this.value = value; | |
- } | |
-} | |
-exports.ValueHashError = ValueHashError; | |
-// ------------------------------------------------------------------ | |
-// ByteMarker | |
-// ------------------------------------------------------------------ | |
-var ByteMarker; | |
-(function (ByteMarker) { | |
- ByteMarker[ByteMarker["Undefined"] = 0] = "Undefined"; | |
- ByteMarker[ByteMarker["Null"] = 1] = "Null"; | |
- ByteMarker[ByteMarker["Boolean"] = 2] = "Boolean"; | |
- ByteMarker[ByteMarker["Number"] = 3] = "Number"; | |
- ByteMarker[ByteMarker["String"] = 4] = "String"; | |
- ByteMarker[ByteMarker["Object"] = 5] = "Object"; | |
- ByteMarker[ByteMarker["Array"] = 6] = "Array"; | |
- ByteMarker[ByteMarker["Date"] = 7] = "Date"; | |
- ByteMarker[ByteMarker["Uint8Array"] = 8] = "Uint8Array"; | |
- ByteMarker[ByteMarker["Symbol"] = 9] = "Symbol"; | |
- ByteMarker[ByteMarker["BigInt"] = 10] = "BigInt"; | |
-})(ByteMarker || (ByteMarker = {})); | |
-// ------------------------------------------------------------------ | |
-// State | |
-// ------------------------------------------------------------------ | |
-let Accumulator = BigInt('14695981039346656037'); | |
-const [Prime, Size] = [BigInt('1099511628211'), BigInt('2') ** BigInt('64')]; | |
-const Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i)); | |
-const F64 = new Float64Array(1); | |
-const F64In = new DataView(F64.buffer); | |
-const F64Out = new Uint8Array(F64.buffer); | |
-// ------------------------------------------------------------------ | |
-// NumberToBytes | |
-// ------------------------------------------------------------------ | |
-function* NumberToBytes(value) { | |
- const byteCount = value === 0 ? 1 : Math.ceil(Math.floor(Math.log2(value) + 1) / 8); | |
- for (let i = 0; i < byteCount; i++) { | |
- yield (value >> (8 * (byteCount - 1 - i))) & 0xff; | |
- } | |
-} | |
-// ------------------------------------------------------------------ | |
-// Hashing Functions | |
-// ------------------------------------------------------------------ | |
-function ArrayType(value) { | |
- FNV1A64(ByteMarker.Array); | |
- for (const item of value) { | |
- Visit(item); | |
- } | |
-} | |
-function BooleanType(value) { | |
- FNV1A64(ByteMarker.Boolean); | |
- FNV1A64(value ? 1 : 0); | |
-} | |
-function BigIntType(value) { | |
- FNV1A64(ByteMarker.BigInt); | |
- F64In.setBigInt64(0, value); | |
- for (const byte of F64Out) { | |
- FNV1A64(byte); | |
- } | |
-} | |
-function DateType(value) { | |
- FNV1A64(ByteMarker.Date); | |
- Visit(value.getTime()); | |
-} | |
-function NullType(value) { | |
- FNV1A64(ByteMarker.Null); | |
-} | |
-function NumberType(value) { | |
- FNV1A64(ByteMarker.Number); | |
- F64In.setFloat64(0, value); | |
- for (const byte of F64Out) { | |
- FNV1A64(byte); | |
- } | |
-} | |
-function ObjectType(value) { | |
- FNV1A64(ByteMarker.Object); | |
- for (const key of globalThis.Object.getOwnPropertyNames(value).sort()) { | |
- Visit(key); | |
- Visit(value[key]); | |
- } | |
-} | |
-function StringType(value) { | |
- FNV1A64(ByteMarker.String); | |
- for (let i = 0; i < value.length; i++) { | |
- for (const byte of NumberToBytes(value.charCodeAt(i))) { | |
- FNV1A64(byte); | |
- } | |
- } | |
-} | |
-function SymbolType(value) { | |
- FNV1A64(ByteMarker.Symbol); | |
- Visit(value.description); | |
-} | |
-function Uint8ArrayType(value) { | |
- FNV1A64(ByteMarker.Uint8Array); | |
- for (let i = 0; i < value.length; i++) { | |
- FNV1A64(value[i]); | |
- } | |
-} | |
-function UndefinedType(value) { | |
- return FNV1A64(ByteMarker.Undefined); | |
-} | |
-function Visit(value) { | |
- if ((0, index_1.IsArray)(value)) | |
- return ArrayType(value); | |
- if ((0, index_1.IsBoolean)(value)) | |
- return BooleanType(value); | |
- if ((0, index_1.IsBigInt)(value)) | |
- return BigIntType(value); | |
- if ((0, index_1.IsDate)(value)) | |
- return DateType(value); | |
- if ((0, index_1.IsNull)(value)) | |
- return NullType(value); | |
- if ((0, index_1.IsNumber)(value)) | |
- return NumberType(value); | |
- if ((0, index_1.IsStandardObject)(value)) | |
- return ObjectType(value); | |
- if ((0, index_1.IsString)(value)) | |
- return StringType(value); | |
- if ((0, index_1.IsSymbol)(value)) | |
- return SymbolType(value); | |
- if ((0, index_1.IsUint8Array)(value)) | |
- return Uint8ArrayType(value); | |
- if ((0, index_1.IsUndefined)(value)) | |
- return UndefinedType(value); | |
- throw new ValueHashError(value); | |
-} | |
-function FNV1A64(byte) { | |
- Accumulator = Accumulator ^ Bytes[byte]; | |
- Accumulator = (Accumulator * Prime) % Size; | |
-} | |
-// ------------------------------------------------------------------ | |
-// Hash | |
-// ------------------------------------------------------------------ | |
-/** Creates a FNV1A-64 non cryptographic hash of the given value */ | |
-function Hash(value) { | |
- Accumulator = BigInt('14695981039346656037'); | |
- Visit(value); | |
- return Accumulator; | |
-} | |
-exports.Hash = Hash; | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/hash/index.d.ts b/node_modules/@sinclair/typebox/build/cjs/value/hash/index.d.ts | |
deleted file mode 100644 | |
index 6719163..0000000 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/hash/index.d.ts | |
+++ /dev/null | |
@@ -1 +0,0 @@ | |
-export * from './hash'; | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/hash/index.js b/node_modules/@sinclair/typebox/build/cjs/value/hash/index.js | |
deleted file mode 100644 | |
index 789dfc0..0000000 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/hash/index.js | |
+++ /dev/null | |
@@ -1,18 +0,0 @@ | |
-"use strict"; | |
- | |
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | |
- if (k2 === undefined) k2 = k; | |
- var desc = Object.getOwnPropertyDescriptor(m, k); | |
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | |
- desc = { enumerable: true, get: function() { return m[k]; } }; | |
- } | |
- Object.defineProperty(o, k2, desc); | |
-}) : (function(o, m, k, k2) { | |
- if (k2 === undefined) k2 = k; | |
- o[k2] = m[k]; | |
-})); | |
-var __exportStar = (this && this.__exportStar) || function(m, exports) { | |
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | |
-}; | |
-Object.defineProperty(exports, "__esModule", { value: true }); | |
-__exportStar(require("./hash"), exports); | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/index.d.ts b/node_modules/@sinclair/typebox/build/cjs/value/index.d.ts | |
index 92d78b2..7378ac6 100644 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/index.d.ts | |
+++ b/node_modules/@sinclair/typebox/build/cjs/value/index.d.ts | |
@@ -9,7 +9,6 @@ export * from './create/index'; | |
export * from './default/index'; | |
export * from './delta/index'; | |
export * from './equal/index'; | |
-export * from './hash/index'; | |
export * from './mutate/index'; | |
export * from './pointer/index'; | |
export * from './transform/index'; | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/index.js b/node_modules/@sinclair/typebox/build/cjs/value/index.js | |
index c08f53a..1f73e04 100644 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/index.js | |
+++ b/node_modules/@sinclair/typebox/build/cjs/value/index.js | |
@@ -38,7 +38,6 @@ __exportStar(require("./create/index"), exports); | |
__exportStar(require("./default/index"), exports); | |
__exportStar(require("./delta/index"), exports); | |
__exportStar(require("./equal/index"), exports); | |
-__exportStar(require("./hash/index"), exports); | |
__exportStar(require("./mutate/index"), exports); | |
__exportStar(require("./pointer/index"), exports); | |
__exportStar(require("./transform/index"), exports); | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/value/value.d.ts b/node_modules/@sinclair/typebox/build/cjs/value/value/value.d.ts | |
index a5d895c..7011a62 100644 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/value/value.d.ts | |
+++ b/node_modules/@sinclair/typebox/build/cjs/value/value/value.d.ts | |
@@ -45,8 +45,6 @@ export declare function Errors<T extends TSchema>(schema: T, value: unknown): Va | |
export declare function Equal<T>(left: T, right: unknown): right is T; | |
/** Returns edits to transform the current value into the next value */ | |
export declare function Diff(current: unknown, next: unknown): Edit[]; | |
-/** Returns a FNV1A-64 non cryptographic hash of the given value */ | |
-export declare function Hash(value: unknown): bigint; | |
/** Returns a new value with edits applied to the given value */ | |
export declare function Patch<T = any>(current: unknown, edits: Edit[]): T; | |
/** `[Mutable]` Performs a deep mutable value assignment while retaining internal references. */ | |
diff --git a/node_modules/@sinclair/typebox/build/cjs/value/value/value.js b/node_modules/@sinclair/typebox/build/cjs/value/value/value.js | |
index e1249c7..b1565cc 100644 | |
--- a/node_modules/@sinclair/typebox/build/cjs/value/value/value.js | |
+++ b/node_modules/@sinclair/typebox/build/cjs/value/value/value.js | |
@@ -1,10 +1,9 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.Mutate = exports.Patch = exports.Hash = exports.Diff = exports.Equal = exports.Errors = exports.Encode = exports.Default = exports.Decode = exports.Clone = exports.Convert = exports.Clean = exports.Check = exports.Create = exports.Cast = void 0; | |
+exports.Mutate = exports.Patch = exports.Diff = exports.Equal = exports.Errors = exports.Encode = exports.Default = exports.Decode = exports.Clone = exports.Convert = exports.Clean = exports.Check = exports.Create = exports.Cast = void 0; | |
const index_1 = require("../transform/index"); | |
const index_2 = require("../mutate/index"); | |
-const index_3 = require("../hash/index"); | |
const index_4 = require("../equal/index"); | |
const index_5 = require("../cast/index"); | |
const index_6 = require("../clone/index"); | |
@@ -82,11 +81,6 @@ function Diff(current, next) { | |
return (0, index_12.Diff)(current, next); | |
} | |
exports.Diff = Diff; | |
-/** Returns a FNV1A-64 non cryptographic hash of the given value */ | |
-function Hash(value) { | |
- return (0, index_3.Hash)(value); | |
-} | |
-exports.Hash = Hash; | |
/** Returns a new value with edits applied to the given value */ | |
function Patch(current, edits) { | |
return (0, index_12.Patch)(current, edits); | |
diff --git a/node_modules/@sinclair/typebox/build/esm/errors/errors.mjs b/node_modules/@sinclair/typebox/build/esm/errors/errors.mjs | |
index 4d6f5f7..98c4579 100644 | |
--- a/node_modules/@sinclair/typebox/build/esm/errors/errors.mjs | |
+++ b/node_modules/@sinclair/typebox/build/esm/errors/errors.mjs | |
@@ -5,7 +5,6 @@ import { ExtendsUndefinedCheck } from '../type/extends/extends-undefined.mjs'; | |
import { GetErrorFunction } from './function.mjs'; | |
import { TypeBoxError } from '../type/error/index.mjs'; | |
import { Deref } from '../value/deref/index.mjs'; | |
-import { Hash } from '../value/hash/index.mjs'; | |
import { Kind } from '../type/symbols/index.mjs'; | |
import { Never } from '../type/never/index.mjs'; | |
// ------------------------------------------------------------------ | |
@@ -145,18 +144,6 @@ function* FromArray(schema, references, path, value) { | |
for (let i = 0; i < value.length; i++) { | |
yield* Visit(schema.items, references, `${path}/${i}`, value[i]); | |
} | |
- // prettier-ignore | |
- if (schema.uniqueItems === true && !((function () { const set = new Set(); for (const element of value) { | |
- const hashed = Hash(element); | |
- if (set.has(hashed)) { | |
- return false; | |
- } | |
- else { | |
- set.add(hashed); | |
- } | |
- } return true; })())) { | |
- yield Create(ValueErrorType.ArrayUniqueItems, schema, path, value); | |
- } | |
// contains | |
if (!(IsDefined(schema.contains) || IsDefined(schema.minContains) || IsDefined(schema.maxContains))) { | |
return; | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/check/check.mjs b/node_modules/@sinclair/typebox/build/esm/value/check/check.mjs | |
index a0b1297..831dfc3 100644 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/check/check.mjs | |
+++ b/node_modules/@sinclair/typebox/build/esm/value/check/check.mjs | |
@@ -1,6 +1,5 @@ | |
import { TypeSystemPolicy } from '../../system/index.mjs'; | |
import { Deref } from '../deref/index.mjs'; | |
-import { Hash } from '../hash/index.mjs'; | |
import { Kind } from '../../type/symbols/index.mjs'; | |
import { KeyOfPattern } from '../../type/keyof/index.mjs'; | |
import { ExtendsUndefinedCheck } from '../../type/extends/index.mjs'; | |
@@ -55,18 +54,6 @@ function FromArray(schema, references, value) { | |
if (!value.every((value) => Visit(schema.items, references, value))) { | |
return false; | |
} | |
- // prettier-ignore | |
- if (schema.uniqueItems === true && !((function () { const set = new Set(); for (const element of value) { | |
- const hashed = Hash(element); | |
- if (set.has(hashed)) { | |
- return false; | |
- } | |
- else { | |
- set.add(hashed); | |
- } | |
- } return true; })())) { | |
- return false; | |
- } | |
// contains | |
if (!(IsDefined(schema.contains) || IsNumber(schema.minContains) || IsNumber(schema.maxContains))) { | |
return true; // exit | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/hash/hash.d.mts b/node_modules/@sinclair/typebox/build/esm/value/hash/hash.d.mts | |
deleted file mode 100644 | |
index 9609e22..0000000 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/hash/hash.d.mts | |
+++ /dev/null | |
@@ -1,7 +0,0 @@ | |
-import { TypeBoxError } from '../../type/error/index.mjs'; | |
-export declare class ValueHashError extends TypeBoxError { | |
- readonly value: unknown; | |
- constructor(value: unknown); | |
-} | |
-/** Creates a FNV1A-64 non cryptographic hash of the given value */ | |
-export declare function Hash(value: unknown): bigint; | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/hash/hash.mjs b/node_modules/@sinclair/typebox/build/esm/value/hash/hash.mjs | |
deleted file mode 100644 | |
index 98adb38..0000000 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/hash/hash.mjs | |
+++ /dev/null | |
@@ -1,147 +0,0 @@ | |
-import { IsArray, IsBoolean, IsBigInt, IsDate, IsNull, IsNumber, IsStandardObject, IsString, IsSymbol, IsUint8Array, IsUndefined } from '../guard/index.mjs'; | |
-import { TypeBoxError } from '../../type/error/index.mjs'; | |
-// ------------------------------------------------------------------ | |
-// Errors | |
-// ------------------------------------------------------------------ | |
-export class ValueHashError extends TypeBoxError { | |
- value; | |
- constructor(value) { | |
- super(`Unable to hash value`); | |
- this.value = value; | |
- } | |
-} | |
-// ------------------------------------------------------------------ | |
-// ByteMarker | |
-// ------------------------------------------------------------------ | |
-var ByteMarker; | |
-(function (ByteMarker) { | |
- ByteMarker[ByteMarker["Undefined"] = 0] = "Undefined"; | |
- ByteMarker[ByteMarker["Null"] = 1] = "Null"; | |
- ByteMarker[ByteMarker["Boolean"] = 2] = "Boolean"; | |
- ByteMarker[ByteMarker["Number"] = 3] = "Number"; | |
- ByteMarker[ByteMarker["String"] = 4] = "String"; | |
- ByteMarker[ByteMarker["Object"] = 5] = "Object"; | |
- ByteMarker[ByteMarker["Array"] = 6] = "Array"; | |
- ByteMarker[ByteMarker["Date"] = 7] = "Date"; | |
- ByteMarker[ByteMarker["Uint8Array"] = 8] = "Uint8Array"; | |
- ByteMarker[ByteMarker["Symbol"] = 9] = "Symbol"; | |
- ByteMarker[ByteMarker["BigInt"] = 10] = "BigInt"; | |
-})(ByteMarker || (ByteMarker = {})); | |
-// ------------------------------------------------------------------ | |
-// State | |
-// ------------------------------------------------------------------ | |
-let Accumulator = BigInt('14695981039346656037'); | |
-const [Prime, Size] = [BigInt('1099511628211'), BigInt('2') ** BigInt('64')]; | |
-const Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i)); | |
-const F64 = new Float64Array(1); | |
-const F64In = new DataView(F64.buffer); | |
-const F64Out = new Uint8Array(F64.buffer); | |
-// ------------------------------------------------------------------ | |
-// NumberToBytes | |
-// ------------------------------------------------------------------ | |
-function* NumberToBytes(value) { | |
- const byteCount = value === 0 ? 1 : Math.ceil(Math.floor(Math.log2(value) + 1) / 8); | |
- for (let i = 0; i < byteCount; i++) { | |
- yield (value >> (8 * (byteCount - 1 - i))) & 0xff; | |
- } | |
-} | |
-// ------------------------------------------------------------------ | |
-// Hashing Functions | |
-// ------------------------------------------------------------------ | |
-function ArrayType(value) { | |
- FNV1A64(ByteMarker.Array); | |
- for (const item of value) { | |
- Visit(item); | |
- } | |
-} | |
-function BooleanType(value) { | |
- FNV1A64(ByteMarker.Boolean); | |
- FNV1A64(value ? 1 : 0); | |
-} | |
-function BigIntType(value) { | |
- FNV1A64(ByteMarker.BigInt); | |
- F64In.setBigInt64(0, value); | |
- for (const byte of F64Out) { | |
- FNV1A64(byte); | |
- } | |
-} | |
-function DateType(value) { | |
- FNV1A64(ByteMarker.Date); | |
- Visit(value.getTime()); | |
-} | |
-function NullType(value) { | |
- FNV1A64(ByteMarker.Null); | |
-} | |
-function NumberType(value) { | |
- FNV1A64(ByteMarker.Number); | |
- F64In.setFloat64(0, value); | |
- for (const byte of F64Out) { | |
- FNV1A64(byte); | |
- } | |
-} | |
-function ObjectType(value) { | |
- FNV1A64(ByteMarker.Object); | |
- for (const key of globalThis.Object.getOwnPropertyNames(value).sort()) { | |
- Visit(key); | |
- Visit(value[key]); | |
- } | |
-} | |
-function StringType(value) { | |
- FNV1A64(ByteMarker.String); | |
- for (let i = 0; i < value.length; i++) { | |
- for (const byte of NumberToBytes(value.charCodeAt(i))) { | |
- FNV1A64(byte); | |
- } | |
- } | |
-} | |
-function SymbolType(value) { | |
- FNV1A64(ByteMarker.Symbol); | |
- Visit(value.description); | |
-} | |
-function Uint8ArrayType(value) { | |
- FNV1A64(ByteMarker.Uint8Array); | |
- for (let i = 0; i < value.length; i++) { | |
- FNV1A64(value[i]); | |
- } | |
-} | |
-function UndefinedType(value) { | |
- return FNV1A64(ByteMarker.Undefined); | |
-} | |
-function Visit(value) { | |
- if (IsArray(value)) | |
- return ArrayType(value); | |
- if (IsBoolean(value)) | |
- return BooleanType(value); | |
- if (IsBigInt(value)) | |
- return BigIntType(value); | |
- if (IsDate(value)) | |
- return DateType(value); | |
- if (IsNull(value)) | |
- return NullType(value); | |
- if (IsNumber(value)) | |
- return NumberType(value); | |
- if (IsStandardObject(value)) | |
- return ObjectType(value); | |
- if (IsString(value)) | |
- return StringType(value); | |
- if (IsSymbol(value)) | |
- return SymbolType(value); | |
- if (IsUint8Array(value)) | |
- return Uint8ArrayType(value); | |
- if (IsUndefined(value)) | |
- return UndefinedType(value); | |
- throw new ValueHashError(value); | |
-} | |
-function FNV1A64(byte) { | |
- Accumulator = Accumulator ^ Bytes[byte]; | |
- Accumulator = (Accumulator * Prime) % Size; | |
-} | |
-// ------------------------------------------------------------------ | |
-// Hash | |
-// ------------------------------------------------------------------ | |
-/** Creates a FNV1A-64 non cryptographic hash of the given value */ | |
-export function Hash(value) { | |
- Accumulator = BigInt('14695981039346656037'); | |
- Visit(value); | |
- return Accumulator; | |
-} | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/hash/index.d.mts b/node_modules/@sinclair/typebox/build/esm/value/hash/index.d.mts | |
deleted file mode 100644 | |
index cb66652..0000000 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/hash/index.d.mts | |
+++ /dev/null | |
@@ -1 +0,0 @@ | |
-export * from './hash.mjs'; | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/hash/index.mjs b/node_modules/@sinclair/typebox/build/esm/value/hash/index.mjs | |
deleted file mode 100644 | |
index cb66652..0000000 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/hash/index.mjs | |
+++ /dev/null | |
@@ -1 +0,0 @@ | |
-export * from './hash.mjs'; | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/index.d.mts b/node_modules/@sinclair/typebox/build/esm/value/index.d.mts | |
index 927dfb0..e1cc45a 100644 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/index.d.mts | |
+++ b/node_modules/@sinclair/typebox/build/esm/value/index.d.mts | |
@@ -9,7 +9,6 @@ export * from './create/index.mjs'; | |
export * from './default/index.mjs'; | |
export * from './delta/index.mjs'; | |
export * from './equal/index.mjs'; | |
-export * from './hash/index.mjs'; | |
export * from './mutate/index.mjs'; | |
export * from './pointer/index.mjs'; | |
export * from './transform/index.mjs'; | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/index.mjs b/node_modules/@sinclair/typebox/build/esm/value/index.mjs | |
index 7e70954..283adb3 100644 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/index.mjs | |
+++ b/node_modules/@sinclair/typebox/build/esm/value/index.mjs | |
@@ -18,7 +18,6 @@ export * from './create/index.mjs'; | |
export * from './default/index.mjs'; | |
export * from './delta/index.mjs'; | |
export * from './equal/index.mjs'; | |
-export * from './hash/index.mjs'; | |
export * from './mutate/index.mjs'; | |
export * from './pointer/index.mjs'; | |
export * from './transform/index.mjs'; | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/value/value.d.mts b/node_modules/@sinclair/typebox/build/esm/value/value/value.d.mts | |
index b042432..3101054 100644 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/value/value.d.mts | |
+++ b/node_modules/@sinclair/typebox/build/esm/value/value/value.d.mts | |
@@ -45,8 +45,6 @@ export declare function Errors<T extends TSchema>(schema: T, value: unknown): Va | |
export declare function Equal<T>(left: T, right: unknown): right is T; | |
/** Returns edits to transform the current value into the next value */ | |
export declare function Diff(current: unknown, next: unknown): Edit[]; | |
-/** Returns a FNV1A-64 non cryptographic hash of the given value */ | |
-export declare function Hash(value: unknown): bigint; | |
/** Returns a new value with edits applied to the given value */ | |
export declare function Patch<T = any>(current: unknown, edits: Edit[]): T; | |
/** `[Mutable]` Performs a deep mutable value assignment while retaining internal references. */ | |
diff --git a/node_modules/@sinclair/typebox/build/esm/value/value/value.mjs b/node_modules/@sinclair/typebox/build/esm/value/value/value.mjs | |
index 39f022c..85308e1 100644 | |
--- a/node_modules/@sinclair/typebox/build/esm/value/value/value.mjs | |
+++ b/node_modules/@sinclair/typebox/build/esm/value/value/value.mjs | |
@@ -1,6 +1,5 @@ | |
import { HasTransform, TransformDecode, TransformEncode, TransformDecodeCheckError, TransformEncodeCheckError } from '../transform/index.mjs'; | |
import { Mutate as MutateValue } from '../mutate/index.mjs'; | |
-import { Hash as HashValue } from '../hash/index.mjs'; | |
import { Equal as EqualValue } from '../equal/index.mjs'; | |
import { Cast as CastValue } from '../cast/index.mjs'; | |
import { Clone as CloneValue } from '../clone/index.mjs'; | |
@@ -66,10 +65,6 @@ export function Equal(left, right) { | |
export function Diff(current, next) { | |
return DiffValue(current, next); | |
} | |
-/** Returns a FNV1A-64 non cryptographic hash of the given value */ | |
-export function Hash(value) { | |
- return HashValue(value); | |
-} | |
/** Returns a new value with edits applied to the given value */ | |
export function Patch(current, edits) { | |
return PatchValue(current, edits); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment