@xylabs/hex 2.13.14 → 2.13.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/address.d.cts +2 -2
- package/dist/browser/address.d.cts.map +1 -1
- package/dist/browser/address.d.mts +2 -2
- package/dist/browser/address.d.mts.map +1 -1
- package/dist/browser/address.d.ts +2 -2
- package/dist/browser/address.d.ts.map +1 -1
- package/dist/browser/hash.d.cts +0 -2
- package/dist/browser/hash.d.cts.map +1 -1
- package/dist/browser/hash.d.mts +0 -2
- package/dist/browser/hash.d.mts.map +1 -1
- package/dist/browser/hash.d.ts +0 -2
- package/dist/browser/hash.d.ts.map +1 -1
- package/dist/browser/hex/as.d.cts +5 -0
- package/dist/browser/hex/as.d.cts.map +1 -0
- package/dist/browser/hex/as.d.mts +5 -0
- package/dist/browser/hex/as.d.mts.map +1 -0
- package/dist/browser/hex/as.d.ts +5 -0
- package/dist/browser/hex/as.d.ts.map +1 -0
- package/dist/browser/hex/from.d.cts +7 -0
- package/dist/browser/hex/from.d.cts.map +1 -0
- package/dist/browser/hex/from.d.mts +7 -0
- package/dist/browser/hex/from.d.mts.map +1 -0
- package/dist/browser/hex/from.d.ts +7 -0
- package/dist/browser/hex/from.d.ts.map +1 -0
- package/dist/browser/hex/index.d.cts +8 -0
- package/dist/browser/hex/index.d.cts.map +1 -0
- package/dist/browser/hex/index.d.mts +8 -0
- package/dist/browser/hex/index.d.mts.map +1 -0
- package/dist/browser/hex/index.d.ts +8 -0
- package/dist/browser/hex/index.d.ts.map +1 -0
- package/dist/browser/hex/is.d.cts +3 -0
- package/dist/browser/hex/is.d.cts.map +1 -0
- package/dist/browser/hex/is.d.mts +3 -0
- package/dist/browser/hex/is.d.mts.map +1 -0
- package/dist/browser/hex/is.d.ts +3 -0
- package/dist/browser/hex/is.d.ts.map +1 -0
- package/dist/browser/hex/legacy.d.cts +4 -0
- package/dist/browser/hex/legacy.d.cts.map +1 -0
- package/dist/browser/hex/legacy.d.mts +4 -0
- package/dist/browser/hex/legacy.d.mts.map +1 -0
- package/dist/browser/hex/legacy.d.ts +4 -0
- package/dist/browser/hex/legacy.d.ts.map +1 -0
- package/dist/browser/hex/model.d.cts +7 -0
- package/dist/browser/hex/model.d.cts.map +1 -0
- package/dist/browser/hex/model.d.mts +7 -0
- package/dist/browser/hex/model.d.mts.map +1 -0
- package/dist/browser/hex/model.d.ts +7 -0
- package/dist/browser/hex/model.d.ts.map +1 -0
- package/dist/browser/hex/nibble.d.cts +3 -0
- package/dist/browser/hex/nibble.d.cts.map +1 -0
- package/dist/browser/hex/nibble.d.mts +3 -0
- package/dist/browser/hex/nibble.d.mts.map +1 -0
- package/dist/browser/hex/nibble.d.ts +3 -0
- package/dist/browser/hex/nibble.d.ts.map +1 -0
- package/dist/browser/hex/regex.d.cts +3 -0
- package/dist/browser/hex/regex.d.cts.map +1 -0
- package/dist/browser/hex/regex.d.mts +3 -0
- package/dist/browser/hex/regex.d.mts.map +1 -0
- package/dist/browser/hex/regex.d.ts +3 -0
- package/dist/browser/hex/regex.d.ts.map +1 -0
- package/dist/browser/index.cjs +107 -61
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +107 -61
- package/dist/browser/index.js.map +1 -1
- package/dist/node/address.d.cts +2 -2
- package/dist/node/address.d.cts.map +1 -1
- package/dist/node/address.d.mts +2 -2
- package/dist/node/address.d.mts.map +1 -1
- package/dist/node/address.d.ts +2 -2
- package/dist/node/address.d.ts.map +1 -1
- package/dist/node/hash.d.cts +0 -2
- package/dist/node/hash.d.cts.map +1 -1
- package/dist/node/hash.d.mts +0 -2
- package/dist/node/hash.d.mts.map +1 -1
- package/dist/node/hash.d.ts +0 -2
- package/dist/node/hash.d.ts.map +1 -1
- package/dist/node/hex/as.d.cts +5 -0
- package/dist/node/hex/as.d.cts.map +1 -0
- package/dist/node/hex/as.d.mts +5 -0
- package/dist/node/hex/as.d.mts.map +1 -0
- package/dist/node/hex/as.d.ts +5 -0
- package/dist/node/hex/as.d.ts.map +1 -0
- package/dist/node/hex/from.d.cts +7 -0
- package/dist/node/hex/from.d.cts.map +1 -0
- package/dist/node/hex/from.d.mts +7 -0
- package/dist/node/hex/from.d.mts.map +1 -0
- package/dist/node/hex/from.d.ts +7 -0
- package/dist/node/hex/from.d.ts.map +1 -0
- package/dist/node/hex/index.d.cts +8 -0
- package/dist/node/hex/index.d.cts.map +1 -0
- package/dist/node/hex/index.d.mts +8 -0
- package/dist/node/hex/index.d.mts.map +1 -0
- package/dist/node/hex/index.d.ts +8 -0
- package/dist/node/hex/index.d.ts.map +1 -0
- package/dist/node/hex/is.d.cts +3 -0
- package/dist/node/hex/is.d.cts.map +1 -0
- package/dist/node/hex/is.d.mts +3 -0
- package/dist/node/hex/is.d.mts.map +1 -0
- package/dist/node/hex/is.d.ts +3 -0
- package/dist/node/hex/is.d.ts.map +1 -0
- package/dist/node/hex/legacy.d.cts +4 -0
- package/dist/node/hex/legacy.d.cts.map +1 -0
- package/dist/node/hex/legacy.d.mts +4 -0
- package/dist/node/hex/legacy.d.mts.map +1 -0
- package/dist/node/hex/legacy.d.ts +4 -0
- package/dist/node/hex/legacy.d.ts.map +1 -0
- package/dist/node/hex/model.d.cts +7 -0
- package/dist/node/hex/model.d.cts.map +1 -0
- package/dist/node/hex/model.d.mts +7 -0
- package/dist/node/hex/model.d.mts.map +1 -0
- package/dist/node/hex/model.d.ts +7 -0
- package/dist/node/hex/model.d.ts.map +1 -0
- package/dist/node/hex/nibble.d.cts +3 -0
- package/dist/node/hex/nibble.d.cts.map +1 -0
- package/dist/node/hex/nibble.d.mts +3 -0
- package/dist/node/hex/nibble.d.mts.map +1 -0
- package/dist/node/hex/nibble.d.ts +3 -0
- package/dist/node/hex/nibble.d.ts.map +1 -0
- package/dist/node/hex/regex.d.cts +3 -0
- package/dist/node/hex/regex.d.cts.map +1 -0
- package/dist/node/hex/regex.d.mts +3 -0
- package/dist/node/hex/regex.d.mts.map +1 -0
- package/dist/node/hex/regex.d.ts +3 -0
- package/dist/node/hex/regex.d.ts.map +1 -0
- package/dist/node/index.cjs +117 -65
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +107 -61
- package/dist/node/index.js.map +1 -1
- package/package.json +2 -2
- package/src/address.ts +18 -10
- package/src/hash.ts +13 -17
- package/src/hex/as.ts +20 -0
- package/src/hex/from.ts +52 -0
- package/src/hex/index.ts +7 -0
- package/src/hex/is.ts +21 -0
- package/src/hex/legacy.ts +8 -0
- package/src/hex/model.ts +7 -0
- package/src/hex/nibble.ts +11 -0
- package/src/hex/regex.ts +2 -0
- package/dist/browser/hex.d.cts +0 -15
- package/dist/browser/hex.d.cts.map +0 -1
- package/dist/browser/hex.d.mts +0 -15
- package/dist/browser/hex.d.mts.map +0 -1
- package/dist/browser/hex.d.ts +0 -15
- package/dist/browser/hex.d.ts.map +0 -1
- package/dist/node/hex.d.cts +0 -15
- package/dist/node/hex.d.cts.map +0 -1
- package/dist/node/hex.d.mts +0 -15
- package/dist/node/hex.d.mts.map +0 -1
- package/dist/node/hex.d.ts +0 -15
- package/dist/node/hex.d.ts.map +0 -1
- package/src/hex.ts +0 -88
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/assert.ts","../../src/hex.ts","../../src/address.ts","../../src/hash.ts"],"sourcesContent":["export * from './address'\nexport * from './hash'\nexport * from './hex'\n","export type AssertCallback = (value: unknown, message: string) => string | boolean\n\nexport type AssertConfig = string | AssertCallback | boolean\n\nexport const assertError = (value: unknown, assert: AssertConfig | undefined, defaultMessage: string) => {\n if (assert) {\n const assertString = typeof assert === 'string' ? assert : typeof assert === 'boolean' ? defaultMessage : assert(value, defaultMessage)\n if (assertString) {\n throw Error(assertString === true ? defaultMessage : assertString)\n }\n }\n return undefined\n}\n","import { isArrayBuffer } from '@xylabs/arraybuffer'\n\nimport { AssertConfig, assertError } from './assert'\n\nexport const hexRegex = /^[0-9a-f]+$/i\nexport const hexRegexWithPrefix = /0x[0-9a-f]+$/i\n\nexport type Hex = string\n\nexport const hexFrom = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join('')\n}\n\n//determine the number of octets for a given number of bits\nexport const bitsToOctets = (value: number): number => {\n const octets = value >> 2\n if (value !== octets << 2) throw Error('Bits for octets must multiple of 8')\n return octets\n}\n\n//determine the number of octets for a given number of bits\nexport const octetsToBits = (value: number): number => {\n return value << 2\n}\n\n//are the number of bit a round octet (factor of 8)?\nexport const isRoundOctet = (value: number) => {\n return (value >> 2) << 2 === value\n}\n\nexport const isHex = (value: unknown, bitLength?: number): value is Hex => {\n //Is it a string?\n if (typeof value !== 'string') return false\n\n //If a bitLength specified, does it conform?\n if (bitLength !== undefined && value.length !== bitsToOctets(bitLength)) return false\n\n //Does it only has hex values?\n return hexRegex.test(value)\n}\n\nexport const toHex = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join('')\n}\n\nexport function asHex(value: unknown): Hex | undefined\nexport function asHex(value: unknown, bitLength?: number): Hex | undefined\nexport function asHex(value: unknown, assert: AssertConfig): Hex\nexport function asHex(value: unknown, bitLength: number | undefined, assert?: AssertConfig): Hex\nexport function asHex(value: unknown, assertOrBitLength?: AssertConfig | number, assertOnly?: AssertConfig): Hex | undefined {\n const bitLength = typeof assertOrBitLength === 'number' ? assertOrBitLength : undefined\n const assert = typeof assertOrBitLength !== 'number' ? assertOrBitLength : assertOnly\n\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string':\n //remove the leading 0x if it is there\n stringValue = hexRegexWithPrefix.test(value) ? value.substring(2) : value\n break\n case 'number':\n if (value === Math.floor(value)) {\n stringValue = value.toString(16)\n } else {\n return assertError(value, assert, 'Numbers must be whole')\n }\n break\n case 'bigint':\n stringValue = value.toString(16)\n break\n case 'object':\n if (isArrayBuffer(value)) {\n stringValue = hexFrom(value)\n } else {\n return assertError(value, assert, 'Unsupported object')\n }\n break\n default:\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n\n //make it conform to the bit length if shorter\n if (stringValue && bitLength) {\n stringValue = stringValue.padStart(bitsToOctets(bitLength), '0')\n }\n\n return isHex(stringValue, bitLength) ? stringValue.toLowerCase() : assertError(value, assert, 'Unable to convert to Hash')\n}\n","import { AssertConfig, assertError } from './assert'\nimport { asHex, bitsToOctets, isHex } from './hex'\n\nexport const addressRegex = /0x[0-9a-f]+/i\n\nexport type Address = string\n\nexport const isAddress = (value: unknown, bitLength = 160): value is Address => {\n //Is it a string?\n if (typeof value !== 'string') return false\n\n //Does it only has hex values and leading 0x?\n if (!addressRegex.test(value)) return false\n\n const valueHex = value.substring(2)\n\n //If a bitLength specified, does it conform?\n if (bitLength !== undefined && valueHex.length !== bitsToOctets(bitLength)) return false\n\n return isHex(valueHex, bitLength)\n}\n\nexport function asAddress(value: unknown): Address | undefined\nexport function asAddress(value: unknown, assert: AssertConfig): Address\nexport function asAddress(value: unknown, bitLength: number): Address | undefined\nexport function asAddress(value: unknown, bitLength: number, assert: AssertConfig): Address\nexport function asAddress(value: unknown, assertOrBitLength?: AssertConfig | number, assertOnly?: AssertConfig): Address | undefined {\n const bitLength = typeof assertOrBitLength === 'number' ? assertOrBitLength : 160\n const assert = typeof assertOrBitLength !== 'number' ? assertOrBitLength : assertOnly\n\n const result = `0x${asHex(value, bitLength, assert)}`\n return isAddress(result, bitLength) ? result : assertError(value, assert, 'Resulting value is not an Address')\n}\n","import { AssertConfig, assertError } from './assert'\nimport { asHex, Hex, isHex, octetsToBits } from './hex'\n\nexport type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096\nexport const HashBitLength: HashBitLength[] = [32, 64, 128, 256, 512, 1024, 2048, 4096]\n\nexport const isHashBitLength = (value: unknown): value is HashBitLength => {\n return typeof value === 'number' && HashBitLength.includes(value as HashBitLength)\n}\n\nexport type Hash = Hex\nexport const isHash = (value: unknown, bitLength: HashBitLength = 256): value is Hash => {\n if (!isHex(value, bitLength)) return false\n\n const hex = asHex(value, bitLength)\n if (!hex) return false\n\n if (!isHashBitLength(octetsToBits(hex.length))) return false\n\n return true\n}\n\nexport function asHash(value: unknown): Hash | undefined\nexport function asHash(value: unknown, assert: AssertConfig): Hash\nexport function asHash(value: unknown, bitLength?: HashBitLength): Hash | undefined\nexport function asHash(value: unknown, bitLength: HashBitLength | undefined, assert: AssertConfig): Hash\nexport function asHash(value: unknown, assertOrBitLength?: AssertConfig | HashBitLength, assertOnly?: AssertConfig): Hash | undefined {\n const bitLength: HashBitLength = typeof assertOrBitLength === 'number' ? assertOrBitLength : 256\n const assert = typeof assertOrBitLength !== 'number' ? assertOrBitLength : assertOnly\n\n const result = asHex(value, bitLength, assert)\n return isHash(result, bitLength) ? result : assertError(value, assert, 'Resulting value is not a Hash')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,cAAc,CAAC,OAAgB,QAAkC,mBAA2B;AACvG,MAAI,QAAQ;AACV,UAAM,eAAe,OAAO,WAAW,WAAW,SAAS,OAAO,WAAW,YAAY,iBAAiB,OAAO,OAAO,cAAc;AACtI,QAAI,cAAc;AAChB,YAAM,MAAM,iBAAiB,OAAO,iBAAiB,YAAY;AAAA,IACnE;AAAA,EACF;AACA,SAAO;AACT;;;ACZA,yBAA8B;AAIvB,IAAM,WAAW;AACjB,IAAM,qBAAqB;AAI3B,IAAM,UAAU,CAAC,WAAwB;AAC9C,SAAO,CAAC,GAAG,IAAI,WAAW,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AACxF;AAGO,IAAM,eAAe,CAAC,UAA0B;AACrD,QAAM,SAAS,SAAS;AACxB,MAA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,OAAO,sBAAsB,WAAW,oBAAoB;AAC7F,QAAM,SAAS,OAAO,sBAAsB,WAAW,oBAAoB;AAE3E,QAAM,SAAS,MAAM,OAAO,WAAW,MAAM;AAC7C,SAAO,OAAO,QAAQ,SAAS,IAAI,SAAS,YAAY,OAAO,QAAQ,+BAA+B;AACxG;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/assert.ts","../../src/hex/from.ts","../../src/hex/nibble.ts","../../src/hex/regex.ts","../../src/hex/is.ts","../../src/hex/as.ts","../../src/hex/legacy.ts","../../src/address.ts","../../src/hash.ts"],"sourcesContent":["export * from './address'\nexport * from './hash'\nexport * from './hex'\n","export type AssertCallback = (value: unknown, message: string) => string | boolean\n\nexport type AssertConfig = string | AssertCallback | boolean\n\nexport const assertError = (value: unknown, assert: AssertConfig | undefined, defaultMessage: string) => {\n if (assert) {\n const assertString = typeof assert === 'string' ? assert : typeof assert === 'boolean' ? defaultMessage : assert(value, defaultMessage)\n if (assertString) {\n throw Error(assertString === true ? defaultMessage : assertString)\n }\n }\n return undefined\n}\n","import { isArrayBuffer } from '@xylabs/arraybuffer'\n\nimport { isHex } from './is'\nimport { HexConfig } from './model'\nimport { bitsToNibbles } from './nibble'\n\nexport const hexFromArrayBuffer = (buffer: ArrayBuffer, config?: HexConfig): string => {\n const unPadded = [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join('')\n return hexFromHexString(unPadded, config)\n}\n\nexport const hexFromBigInt = (value: bigint, config: HexConfig = {}): string => {\n const { bitLength } = config\n const unPadded = value.toString(16)\n const padded = bitLength === undefined ? unPadded : unPadded.padStart(bitsToNibbles(bitLength), '0')\n return hexFromHexString(padded, config)\n}\n\nexport const hexFromNumber = (value: number, config?: HexConfig): string => {\n return hexFromBigInt(BigInt(value), config)\n}\n\nexport const hexFromHexString = (value: string, config: HexConfig = {}): string => {\n const { prefix = false, byteSize = 8 } = config\n const nibbleBoundary = bitsToNibbles(byteSize)\n const unPadded = (value.startsWith('0x') ? value.substring(2) : value).toLowerCase()\n if (isHex(unPadded)) {\n const padded = unPadded.padStart(unPadded.length + (unPadded.length % nibbleBoundary), '0')\n return prefix ? `0x${padded}` : padded\n } else {\n throw Error('Received string is not a value hex')\n }\n}\n\nexport const hexFrom = (value: unknown, config?: HexConfig): string => {\n switch (typeof value) {\n case 'string':\n return hexFromHexString(value, config)\n case 'bigint':\n return hexFromBigInt(value, config)\n case 'number':\n return hexFromNumber(value, config)\n case 'object':\n if (isArrayBuffer(value)) {\n return hexFromArrayBuffer(value, config)\n } else {\n throw Error('Invalid type: object !== ArrayBuffer')\n }\n default:\n throw Error(`Invalid type: ${typeof value}`)\n }\n}\n","//determine the number of nibbles for a given number of bits\nexport const bitsToNibbles = (value: number): number => {\n const nibbles = value >> 2\n if (value !== nibbles << 2) throw Error('Bits for nibbles must multiple of 4')\n return nibbles\n}\n\n//determine the number of nibbles for a given number of bits\nexport const nibblesToBits = (value: number): number => {\n return value << 2\n}\n","export const hexRegex = /^[0-9a-f]+$/i\nexport const hexRegexWithPrefix = /0x[0-9a-f]+$/i\n","import { hexFromHexString } from './from'\nimport { Hex } from './model'\nimport { bitsToNibbles } from './nibble'\nimport { hexRegex } from './regex'\n\nexport const isHexZero = (value: string) => {\n return BigInt(hexFromHexString(value, { prefix: true })) === 0n\n}\n\nexport const isHex = (value: unknown, bitLength?: number): value is Hex => {\n //Is it a string?\n if (typeof value !== 'string') return false\n\n console.log(`BitLength: ${value.length << 2}|${bitLength}`)\n\n //If a bitLength specified, does it conform?\n if (bitLength !== undefined && value.length !== bitsToNibbles(bitLength)) return false\n\n //Does it only has hex values?\n return hexRegex.test(value)\n}\n","import { AssertConfig, assertError } from '../assert'\nimport { hexFromHexString } from './from'\nimport { isHex } from './is'\nimport { Hex } from './model'\n\nexport function asHex(value: unknown): Hex | undefined\nexport function asHex(value: unknown, assert: AssertConfig): Hex\nexport function asHex(value: unknown, assert?: AssertConfig): Hex | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string':\n stringValue = hexFromHexString(value)\n break\n default:\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n\n return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`)\n}\n","export const toHexLegacy = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join('')\n}\n\n/** @deprecated use toHexLegacy instead */\nexport const toHex = (buffer: ArrayBuffer) => {\n return toHexLegacy(buffer)\n}\n","import { AssertConfig, assertError } from './assert'\nimport { bitsToNibbles, HexConfig, hexFrom, hexFromHexString, isHex } from './hex'\n\nexport const addressRegex = /0x[0-9a-f]+/i\n\nexport type Address = string\n\nexport const toAddress = (value: unknown, config: HexConfig = {}) => {\n const { bitLength = 160, prefix = true } = config\n return hexFrom(value, { bitLength, prefix, ...config })\n}\n\nexport const isAddress = (value: unknown, bitLength = 160): value is Address => {\n //Is it a string?\n if (typeof value !== 'string') return false\n\n //Does it only has hex values and leading 0x?\n if (!addressRegex.test(value)) return false\n\n const valueHex = value.substring(2)\n\n //If a bitLength specified, does it conform?\n if (bitLength !== undefined && valueHex.length !== bitsToNibbles(bitLength)) return false\n\n return isHex(valueHex, bitLength)\n}\n\nexport function asAddress(value: unknown): Address | undefined\nexport function asAddress(value: unknown, assert: AssertConfig): Address\nexport function asAddress(value: unknown, assert?: AssertConfig): Address | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string':\n stringValue = hexFromHexString(value, { prefix: true })\n break\n default:\n return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined\n }\n return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`)\n}\n","import { AssertConfig, assertError } from './assert'\nimport { Hex, hexFromHexString, isHex } from './hex'\n\nexport type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096\nexport const HashBitLength: HashBitLength[] = [32, 64, 128, 256, 512, 1024, 2048, 4096]\n\nexport const isHashBitLength = (value: unknown): value is HashBitLength => {\n return typeof value === 'number' && HashBitLength.includes(value as HashBitLength)\n}\n\nexport type Hash = Hex\nexport const isHash = (value: unknown, bitLength: HashBitLength = 256): value is Hash => {\n return isHex(value, bitLength)\n}\n\nexport function asHash(value: unknown): Hash | undefined\nexport function asHash(value: unknown, assert: AssertConfig): Hash\nexport function asHash(value: unknown, assert?: AssertConfig): Hash | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string':\n stringValue = hexFromHexString(value)\n break\n default:\n return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined\n }\n return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,cAAc,CAAC,OAAgB,QAAkC,mBAA2B;AACvG,MAAI,QAAQ;AACV,UAAM,eAAe,OAAO,WAAW,WAAW,SAAS,OAAO,WAAW,YAAY,iBAAiB,OAAO,OAAO,cAAc;AACtI,QAAI,cAAc;AAChB,YAAM,MAAM,iBAAiB,OAAO,iBAAiB,YAAY;AAAA,IACnE;AAAA,EACF;AACA,SAAO;AACT;;;ACZA,yBAA8B;;;ACCvB,IAAM,gBAAgB,CAAC,UAA0B;AACtD,QAAM,UAAU,SAAS;AACzB,MAAI,UAAU,WAAW;AAAG,UAAM,MAAM,qCAAqC;AAC7E,SAAO;AACT;AAGO,IAAM,gBAAgB,CAAC,UAA0B;AACtD,SAAO,SAAS;AAClB;;;ACVO,IAAM,WAAW;AACjB,IAAM,qBAAqB;;;ACI3B,IAAM,YAAY,CAAC,UAAkB;AAC1C,SAAO,OAAO,iBAAiB,OAAO,EAAE,QAAQ,KAAK,CAAC,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aAAa,KAAK,KAAK;AAAG,WAAO;AAEtC,QAAM,WAAW,MAAM,UAAU,CAAC;AAGlC,MAAI,cAAc,UAAa,SAAS,WAAW,cAAc,SAAS;AAAG,WAAO;AAEpF,SAAO,MAAM,UAAU,SAAS;AAClC;AAIO,SAAS,UAAU,OAAgB,QAA4C;AACpF,MAAI,cAAkC;AAEtC,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AACH,oBAAc,iBAAiB,OAAO,EAAE,QAAQ,KAAK,CAAC;AACtD;AAAA,IACF;AACE,aAAO,SAAS,YAAY,OAAO,QAAQ,qBAAqB,OAAO,KAAK,GAAG,IAAI;AAAA,EACvF;AACA,SAAO,UAAU,WAAW,IAAI,cAAc,YAAY,OAAO,QAAQ,4BAA4B,KAAK,GAAG;AAC/G;;;ACpCO,IAAM,gBAAiC,CAAC,IAAI,IAAI,KAAK,KAAK,KAAK,MAAM,MAAM,IAAI;AAE/E,IAAM,kBAAkB,CAAC,UAA2C;AACzE,SAAO,OAAO,UAAU,YAAY,cAAc,SAAS,KAAsB;AACnF;AAGO,IAAM,SAAS,CAAC,OAAgB,YAA2B,QAAuB;AACvF,SAAO,MAAM,OAAO,SAAS;AAC/B;AAIO,SAAS,OAAO,OAAgB,QAAyC;AAC9E,MAAI,cAAkC;AAEtC,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AACH,oBAAc,iBAAiB,KAAK;AACpC;AAAA,IACF;AACE,aAAO,SAAS,YAAY,OAAO,QAAQ,qBAAqB,OAAO,KAAK,GAAG,IAAI;AAAA,EACvF;AACA,SAAO,OAAO,WAAW,IAAI,cAAc,YAAY,OAAO,QAAQ,wBAAwB,KAAK,GAAG;AACxG;","names":[]}
|
package/dist/browser/index.js
CHANGED
|
@@ -9,86 +9,128 @@ var assertError = (value, assert, defaultMessage) => {
|
|
|
9
9
|
return void 0;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// src/hex.ts
|
|
12
|
+
// src/hex/from.ts
|
|
13
13
|
import { isArrayBuffer } from "@xylabs/arraybuffer";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (value !== octets << 2)
|
|
22
|
-
throw Error("Bits for octets must multiple of 8");
|
|
23
|
-
return octets;
|
|
14
|
+
|
|
15
|
+
// src/hex/nibble.ts
|
|
16
|
+
var bitsToNibbles = (value) => {
|
|
17
|
+
const nibbles = value >> 2;
|
|
18
|
+
if (value !== nibbles << 2)
|
|
19
|
+
throw Error("Bits for nibbles must multiple of 4");
|
|
20
|
+
return nibbles;
|
|
24
21
|
};
|
|
25
|
-
var
|
|
22
|
+
var nibblesToBits = (value) => {
|
|
26
23
|
return value << 2;
|
|
27
24
|
};
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
|
|
26
|
+
// src/hex/regex.ts
|
|
27
|
+
var hexRegex = /^[0-9a-f]+$/i;
|
|
28
|
+
var hexRegexWithPrefix = /0x[0-9a-f]+$/i;
|
|
29
|
+
|
|
30
|
+
// src/hex/is.ts
|
|
31
|
+
var isHexZero = (value) => {
|
|
32
|
+
return BigInt(hexFromHexString(value, { prefix: true })) === 0n;
|
|
30
33
|
};
|
|
31
34
|
var isHex = (value, bitLength) => {
|
|
32
35
|
if (typeof value !== "string")
|
|
33
36
|
return false;
|
|
34
|
-
|
|
37
|
+
console.log(`BitLength: ${value.length << 2}|${bitLength}`);
|
|
38
|
+
if (bitLength !== void 0 && value.length !== bitsToNibbles(bitLength))
|
|
35
39
|
return false;
|
|
36
40
|
return hexRegex.test(value);
|
|
37
41
|
};
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
|
|
43
|
+
// src/hex/from.ts
|
|
44
|
+
var hexFromArrayBuffer = (buffer, config) => {
|
|
45
|
+
const unPadded = [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
46
|
+
return hexFromHexString(unPadded, config);
|
|
40
47
|
};
|
|
41
|
-
|
|
42
|
-
const bitLength =
|
|
43
|
-
const
|
|
44
|
-
|
|
48
|
+
var hexFromBigInt = (value, config = {}) => {
|
|
49
|
+
const { bitLength } = config;
|
|
50
|
+
const unPadded = value.toString(16);
|
|
51
|
+
const padded = bitLength === void 0 ? unPadded : unPadded.padStart(bitsToNibbles(bitLength), "0");
|
|
52
|
+
return hexFromHexString(padded, config);
|
|
53
|
+
};
|
|
54
|
+
var hexFromNumber = (value, config) => {
|
|
55
|
+
return hexFromBigInt(BigInt(value), config);
|
|
56
|
+
};
|
|
57
|
+
var hexFromHexString = (value, config = {}) => {
|
|
58
|
+
const { prefix = false, byteSize = 8 } = config;
|
|
59
|
+
const nibbleBoundary = bitsToNibbles(byteSize);
|
|
60
|
+
const unPadded = (value.startsWith("0x") ? value.substring(2) : value).toLowerCase();
|
|
61
|
+
if (isHex(unPadded)) {
|
|
62
|
+
const padded = unPadded.padStart(unPadded.length + unPadded.length % nibbleBoundary, "0");
|
|
63
|
+
return prefix ? `0x${padded}` : padded;
|
|
64
|
+
} else {
|
|
65
|
+
throw Error("Received string is not a value hex");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var hexFrom = (value, config) => {
|
|
45
69
|
switch (typeof value) {
|
|
46
70
|
case "string":
|
|
47
|
-
|
|
48
|
-
break;
|
|
49
|
-
case "number":
|
|
50
|
-
if (value === Math.floor(value)) {
|
|
51
|
-
stringValue = value.toString(16);
|
|
52
|
-
} else {
|
|
53
|
-
return assertError(value, assert, "Numbers must be whole");
|
|
54
|
-
}
|
|
55
|
-
break;
|
|
71
|
+
return hexFromHexString(value, config);
|
|
56
72
|
case "bigint":
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
return hexFromBigInt(value, config);
|
|
74
|
+
case "number":
|
|
75
|
+
return hexFromNumber(value, config);
|
|
59
76
|
case "object":
|
|
60
77
|
if (isArrayBuffer(value)) {
|
|
61
|
-
|
|
78
|
+
return hexFromArrayBuffer(value, config);
|
|
62
79
|
} else {
|
|
63
|
-
|
|
80
|
+
throw Error("Invalid type: object !== ArrayBuffer");
|
|
64
81
|
}
|
|
82
|
+
default:
|
|
83
|
+
throw Error(`Invalid type: ${typeof value}`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// src/hex/as.ts
|
|
88
|
+
function asHex(value, assert) {
|
|
89
|
+
let stringValue = void 0;
|
|
90
|
+
switch (typeof value) {
|
|
91
|
+
case "string":
|
|
92
|
+
stringValue = hexFromHexString(value);
|
|
65
93
|
break;
|
|
66
94
|
default:
|
|
67
95
|
return assertError(value, assert, `Unsupported type [${typeof value}]`);
|
|
68
96
|
}
|
|
69
|
-
|
|
70
|
-
stringValue = stringValue.padStart(bitsToOctets(bitLength), "0");
|
|
71
|
-
}
|
|
72
|
-
return isHex(stringValue, bitLength) ? stringValue.toLowerCase() : assertError(value, assert, "Unable to convert to Hash");
|
|
97
|
+
return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`);
|
|
73
98
|
}
|
|
74
99
|
|
|
100
|
+
// src/hex/legacy.ts
|
|
101
|
+
var toHexLegacy = (buffer) => {
|
|
102
|
+
return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
103
|
+
};
|
|
104
|
+
var toHex = (buffer) => {
|
|
105
|
+
return toHexLegacy(buffer);
|
|
106
|
+
};
|
|
107
|
+
|
|
75
108
|
// src/address.ts
|
|
76
109
|
var addressRegex = /0x[0-9a-f]+/i;
|
|
110
|
+
var toAddress = (value, config = {}) => {
|
|
111
|
+
const { bitLength = 160, prefix = true } = config;
|
|
112
|
+
return hexFrom(value, { bitLength, prefix, ...config });
|
|
113
|
+
};
|
|
77
114
|
var isAddress = (value, bitLength = 160) => {
|
|
78
115
|
if (typeof value !== "string")
|
|
79
116
|
return false;
|
|
80
117
|
if (!addressRegex.test(value))
|
|
81
118
|
return false;
|
|
82
119
|
const valueHex = value.substring(2);
|
|
83
|
-
if (bitLength !== void 0 && valueHex.length !==
|
|
120
|
+
if (bitLength !== void 0 && valueHex.length !== bitsToNibbles(bitLength))
|
|
84
121
|
return false;
|
|
85
122
|
return isHex(valueHex, bitLength);
|
|
86
123
|
};
|
|
87
|
-
function asAddress(value,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
124
|
+
function asAddress(value, assert) {
|
|
125
|
+
let stringValue = void 0;
|
|
126
|
+
switch (typeof value) {
|
|
127
|
+
case "string":
|
|
128
|
+
stringValue = hexFromHexString(value, { prefix: true });
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : void 0;
|
|
132
|
+
}
|
|
133
|
+
return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`);
|
|
92
134
|
}
|
|
93
135
|
|
|
94
136
|
// src/hash.ts
|
|
@@ -97,20 +139,18 @@ var isHashBitLength = (value) => {
|
|
|
97
139
|
return typeof value === "number" && HashBitLength.includes(value);
|
|
98
140
|
};
|
|
99
141
|
var isHash = (value, bitLength = 256) => {
|
|
100
|
-
|
|
101
|
-
return false;
|
|
102
|
-
const hex = asHex(value, bitLength);
|
|
103
|
-
if (!hex)
|
|
104
|
-
return false;
|
|
105
|
-
if (!isHashBitLength(octetsToBits(hex.length)))
|
|
106
|
-
return false;
|
|
107
|
-
return true;
|
|
142
|
+
return isHex(value, bitLength);
|
|
108
143
|
};
|
|
109
|
-
function asHash(value,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
144
|
+
function asHash(value, assert) {
|
|
145
|
+
let stringValue = void 0;
|
|
146
|
+
switch (typeof value) {
|
|
147
|
+
case "string":
|
|
148
|
+
stringValue = hexFromHexString(value);
|
|
149
|
+
break;
|
|
150
|
+
default:
|
|
151
|
+
return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : void 0;
|
|
152
|
+
}
|
|
153
|
+
return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`);
|
|
114
154
|
}
|
|
115
155
|
export {
|
|
116
156
|
HashBitLength,
|
|
@@ -118,16 +158,22 @@ export {
|
|
|
118
158
|
asAddress,
|
|
119
159
|
asHash,
|
|
120
160
|
asHex,
|
|
121
|
-
|
|
161
|
+
bitsToNibbles,
|
|
122
162
|
hexFrom,
|
|
163
|
+
hexFromArrayBuffer,
|
|
164
|
+
hexFromBigInt,
|
|
165
|
+
hexFromHexString,
|
|
166
|
+
hexFromNumber,
|
|
123
167
|
hexRegex,
|
|
124
168
|
hexRegexWithPrefix,
|
|
125
169
|
isAddress,
|
|
126
170
|
isHash,
|
|
127
171
|
isHashBitLength,
|
|
128
172
|
isHex,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
173
|
+
isHexZero,
|
|
174
|
+
nibblesToBits,
|
|
175
|
+
toAddress,
|
|
176
|
+
toHex,
|
|
177
|
+
toHexLegacy
|
|
132
178
|
};
|
|
133
179
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/assert.ts","../../src/hex.ts","../../src/address.ts","../../src/hash.ts"],"sourcesContent":["export type AssertCallback = (value: unknown, message: string) => string | boolean\n\nexport type AssertConfig = string | AssertCallback | boolean\n\nexport const assertError = (value: unknown, assert: AssertConfig | undefined, defaultMessage: string) => {\n if (assert) {\n const assertString = typeof assert === 'string' ? assert : typeof assert === 'boolean' ? defaultMessage : assert(value, defaultMessage)\n if (assertString) {\n throw Error(assertString === true ? defaultMessage : assertString)\n }\n }\n return undefined\n}\n","import { isArrayBuffer } from '@xylabs/arraybuffer'\n\nimport { AssertConfig, assertError } from './assert'\n\nexport const hexRegex = /^[0-9a-f]+$/i\nexport const hexRegexWithPrefix = /0x[0-9a-f]+$/i\n\nexport type Hex = string\n\nexport const hexFrom = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join('')\n}\n\n//determine the number of octets for a given number of bits\nexport const bitsToOctets = (value: number): number => {\n const octets = value >> 2\n if (value !== octets << 2) throw Error('Bits for octets must multiple of 8')\n return octets\n}\n\n//determine the number of octets for a given number of bits\nexport const octetsToBits = (value: number): number => {\n return value << 2\n}\n\n//are the number of bit a round octet (factor of 8)?\nexport const isRoundOctet = (value: number) => {\n return (value >> 2) << 2 === value\n}\n\nexport const isHex = (value: unknown, bitLength?: number): value is Hex => {\n //Is it a string?\n if (typeof value !== 'string') return false\n\n //If a bitLength specified, does it conform?\n if (bitLength !== undefined && value.length !== bitsToOctets(bitLength)) return false\n\n //Does it only has hex values?\n return hexRegex.test(value)\n}\n\nexport const toHex = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join('')\n}\n\nexport function asHex(value: unknown): Hex | undefined\nexport function asHex(value: unknown, bitLength?: number): Hex | undefined\nexport function asHex(value: unknown, assert: AssertConfig): Hex\nexport function asHex(value: unknown, bitLength: number | undefined, assert?: AssertConfig): Hex\nexport function asHex(value: unknown, assertOrBitLength?: AssertConfig | number, assertOnly?: AssertConfig): Hex | undefined {\n const bitLength = typeof assertOrBitLength === 'number' ? assertOrBitLength : undefined\n const assert = typeof assertOrBitLength !== 'number' ? assertOrBitLength : assertOnly\n\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string':\n //remove the leading 0x if it is there\n stringValue = hexRegexWithPrefix.test(value) ? value.substring(2) : value\n break\n case 'number':\n if (value === Math.floor(value)) {\n stringValue = value.toString(16)\n } else {\n return assertError(value, assert, 'Numbers must be whole')\n }\n break\n case 'bigint':\n stringValue = value.toString(16)\n break\n case 'object':\n if (isArrayBuffer(value)) {\n stringValue = hexFrom(value)\n } else {\n return assertError(value, assert, 'Unsupported object')\n }\n break\n default:\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n\n //make it conform to the bit length if shorter\n if (stringValue && bitLength) {\n stringValue = stringValue.padStart(bitsToOctets(bitLength), '0')\n }\n\n return isHex(stringValue, bitLength) ? stringValue.toLowerCase() : assertError(value, assert, 'Unable to convert to Hash')\n}\n","import { AssertConfig, assertError } from './assert'\nimport { asHex, bitsToOctets, isHex } from './hex'\n\nexport const addressRegex = /0x[0-9a-f]+/i\n\nexport type Address = string\n\nexport const isAddress = (value: unknown, bitLength = 160): value is Address => {\n //Is it a string?\n if (typeof value !== 'string') return false\n\n //Does it only has hex values and leading 0x?\n if (!addressRegex.test(value)) return false\n\n const valueHex = value.substring(2)\n\n //If a bitLength specified, does it conform?\n if (bitLength !== undefined && valueHex.length !== bitsToOctets(bitLength)) return false\n\n return isHex(valueHex, bitLength)\n}\n\nexport function asAddress(value: unknown): Address | undefined\nexport function asAddress(value: unknown, assert: AssertConfig): Address\nexport function asAddress(value: unknown, bitLength: number): Address | undefined\nexport function asAddress(value: unknown, bitLength: number, assert: AssertConfig): Address\nexport function asAddress(value: unknown, assertOrBitLength?: AssertConfig | number, assertOnly?: AssertConfig): Address | undefined {\n const bitLength = typeof assertOrBitLength === 'number' ? assertOrBitLength : 160\n const assert = typeof assertOrBitLength !== 'number' ? assertOrBitLength : assertOnly\n\n const result = `0x${asHex(value, bitLength, assert)}`\n return isAddress(result, bitLength) ? result : assertError(value, assert, 'Resulting value is not an Address')\n}\n","import { AssertConfig, assertError } from './assert'\nimport { asHex, Hex, isHex, octetsToBits } from './hex'\n\nexport type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096\nexport const HashBitLength: HashBitLength[] = [32, 64, 128, 256, 512, 1024, 2048, 4096]\n\nexport const isHashBitLength = (value: unknown): value is HashBitLength => {\n return typeof value === 'number' && HashBitLength.includes(value as HashBitLength)\n}\n\nexport type Hash = Hex\nexport const isHash = (value: unknown, bitLength: HashBitLength = 256): value is Hash => {\n if (!isHex(value, bitLength)) return false\n\n const hex = asHex(value, bitLength)\n if (!hex) return false\n\n if (!isHashBitLength(octetsToBits(hex.length))) return false\n\n return true\n}\n\nexport function asHash(value: unknown): Hash | undefined\nexport function asHash(value: unknown, assert: AssertConfig): Hash\nexport function asHash(value: unknown, bitLength?: HashBitLength): Hash | undefined\nexport function asHash(value: unknown, bitLength: HashBitLength | undefined, assert: AssertConfig): Hash\nexport function asHash(value: unknown, assertOrBitLength?: AssertConfig | HashBitLength, assertOnly?: AssertConfig): Hash | undefined {\n const bitLength: HashBitLength = typeof assertOrBitLength === 'number' ? assertOrBitLength : 256\n const assert = typeof assertOrBitLength !== 'number' ? assertOrBitLength : assertOnly\n\n const result = asHex(value, bitLength, assert)\n return isHash(result, bitLength) ? result : assertError(value, assert, 'Resulting value is not a Hash')\n}\n"],"mappings":";AAIO,IAAM,cAAc,CAAC,OAAgB,QAAkC,mBAA2B;AACvG,MAAI,QAAQ;AACV,UAAM,eAAe,OAAO,WAAW,WAAW,SAAS,OAAO,WAAW,YAAY,iBAAiB,OAAO,OAAO,cAAc;AACtI,QAAI,cAAc;AAChB,YAAM,MAAM,iBAAiB,OAAO,iBAAiB,YAAY;AAAA,IACnE;AAAA,EACF;AACA,SAAO;AACT;;;ACZA,SAAS,qBAAqB;AAIvB,IAAM,WAAW;AACjB,IAAM,qBAAqB;AAI3B,IAAM,UAAU,CAAC,WAAwB;AAC9C,SAAO,CAAC,GAAG,IAAI,WAAW,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AACxF;AAGO,IAAM,eAAe,CAAC,UAA0B;AACrD,QAAM,SAAS,SAAS;AACxB,MAAI,UAAU,UAAU;AAAG,UAAM,MAAM,oCAAoC;AAC3E,SAAO;AACT;AAGO,IAAM,eAAe,CAAC,UAA0B;AACrD,SAAO,SAAS;AAClB;AAGO,IAAM,eAAe,CAAC,UAAkB;AAC7C,SAAQ,SAAS,KAAM,MAAM;AAC/B;AAEO,IAAM,QAAQ,CAAC,OAAgB,cAAqC;AAEzE,MAAI,OAAO,UAAU;AAAU,WAAO;AAGtC,M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.ts","../../src/hex/regex.ts","../../src/hex/is.ts","../../src/hex/as.ts","../../src/hex/legacy.ts","../../src/address.ts","../../src/hash.ts"],"sourcesContent":["export type AssertCallback = (value: unknown, message: string) => string | boolean\n\nexport type AssertConfig = string | AssertCallback | boolean\n\nexport const assertError = (value: unknown, assert: AssertConfig | undefined, defaultMessage: string) => {\n if (assert) {\n const assertString = typeof assert === 'string' ? assert : typeof assert === 'boolean' ? defaultMessage : assert(value, defaultMessage)\n if (assertString) {\n throw Error(assertString === true ? defaultMessage : assertString)\n }\n }\n return undefined\n}\n","import { isArrayBuffer } from '@xylabs/arraybuffer'\n\nimport { isHex } from './is'\nimport { HexConfig } from './model'\nimport { bitsToNibbles } from './nibble'\n\nexport const hexFromArrayBuffer = (buffer: ArrayBuffer, config?: HexConfig): string => {\n const unPadded = [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join('')\n return hexFromHexString(unPadded, config)\n}\n\nexport const hexFromBigInt = (value: bigint, config: HexConfig = {}): string => {\n const { bitLength } = config\n const unPadded = value.toString(16)\n const padded = bitLength === undefined ? unPadded : unPadded.padStart(bitsToNibbles(bitLength), '0')\n return hexFromHexString(padded, config)\n}\n\nexport const hexFromNumber = (value: number, config?: HexConfig): string => {\n return hexFromBigInt(BigInt(value), config)\n}\n\nexport const hexFromHexString = (value: string, config: HexConfig = {}): string => {\n const { prefix = false, byteSize = 8 } = config\n const nibbleBoundary = bitsToNibbles(byteSize)\n const unPadded = (value.startsWith('0x') ? value.substring(2) : value).toLowerCase()\n if (isHex(unPadded)) {\n const padded = unPadded.padStart(unPadded.length + (unPadded.length % nibbleBoundary), '0')\n return prefix ? `0x${padded}` : padded\n } else {\n throw Error('Received string is not a value hex')\n }\n}\n\nexport const hexFrom = (value: unknown, config?: HexConfig): string => {\n switch (typeof value) {\n case 'string':\n return hexFromHexString(value, config)\n case 'bigint':\n return hexFromBigInt(value, config)\n case 'number':\n return hexFromNumber(value, config)\n case 'object':\n if (isArrayBuffer(value)) {\n return hexFromArrayBuffer(value, config)\n } else {\n throw Error('Invalid type: object !== ArrayBuffer')\n }\n default:\n throw Error(`Invalid type: ${typeof value}`)\n }\n}\n","//determine the number of nibbles for a given number of bits\nexport const bitsToNibbles = (value: number): number => {\n const nibbles = value >> 2\n if (value !== nibbles << 2) throw Error('Bits for nibbles must multiple of 4')\n return nibbles\n}\n\n//determine the number of nibbles for a given number of bits\nexport const nibblesToBits = (value: number): number => {\n return value << 2\n}\n","export const hexRegex = /^[0-9a-f]+$/i\nexport const hexRegexWithPrefix = /0x[0-9a-f]+$/i\n","import { hexFromHexString } from './from'\nimport { Hex } from './model'\nimport { bitsToNibbles } from './nibble'\nimport { hexRegex } from './regex'\n\nexport const isHexZero = (value: string) => {\n return BigInt(hexFromHexString(value, { prefix: true })) === 0n\n}\n\nexport const isHex = (value: unknown, bitLength?: number): value is Hex => {\n //Is it a string?\n if (typeof value !== 'string') return false\n\n console.log(`BitLength: ${value.length << 2}|${bitLength}`)\n\n //If a bitLength specified, does it conform?\n if (bitLength !== undefined && value.length !== bitsToNibbles(bitLength)) return false\n\n //Does it only has hex values?\n return hexRegex.test(value)\n}\n","import { AssertConfig, assertError } from '../assert'\nimport { hexFromHexString } from './from'\nimport { isHex } from './is'\nimport { Hex } from './model'\n\nexport function asHex(value: unknown): Hex | undefined\nexport function asHex(value: unknown, assert: AssertConfig): Hex\nexport function asHex(value: unknown, assert?: AssertConfig): Hex | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string':\n stringValue = hexFromHexString(value)\n break\n default:\n return assertError(value, assert, `Unsupported type [${typeof value}]`)\n }\n\n return isHex(stringValue) ? stringValue : assertError(value, assert, `Value is not Hex [${value}]`)\n}\n","export const toHexLegacy = (buffer: ArrayBuffer) => {\n return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join('')\n}\n\n/** @deprecated use toHexLegacy instead */\nexport const toHex = (buffer: ArrayBuffer) => {\n return toHexLegacy(buffer)\n}\n","import { AssertConfig, assertError } from './assert'\nimport { bitsToNibbles, HexConfig, hexFrom, hexFromHexString, isHex } from './hex'\n\nexport const addressRegex = /0x[0-9a-f]+/i\n\nexport type Address = string\n\nexport const toAddress = (value: unknown, config: HexConfig = {}) => {\n const { bitLength = 160, prefix = true } = config\n return hexFrom(value, { bitLength, prefix, ...config })\n}\n\nexport const isAddress = (value: unknown, bitLength = 160): value is Address => {\n //Is it a string?\n if (typeof value !== 'string') return false\n\n //Does it only has hex values and leading 0x?\n if (!addressRegex.test(value)) return false\n\n const valueHex = value.substring(2)\n\n //If a bitLength specified, does it conform?\n if (bitLength !== undefined && valueHex.length !== bitsToNibbles(bitLength)) return false\n\n return isHex(valueHex, bitLength)\n}\n\nexport function asAddress(value: unknown): Address | undefined\nexport function asAddress(value: unknown, assert: AssertConfig): Address\nexport function asAddress(value: unknown, assert?: AssertConfig): Address | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string':\n stringValue = hexFromHexString(value, { prefix: true })\n break\n default:\n return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined\n }\n return isAddress(stringValue) ? stringValue : assertError(value, assert, `Value is not an Address [${value}]`)\n}\n","import { AssertConfig, assertError } from './assert'\nimport { Hex, hexFromHexString, isHex } from './hex'\n\nexport type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096\nexport const HashBitLength: HashBitLength[] = [32, 64, 128, 256, 512, 1024, 2048, 4096]\n\nexport const isHashBitLength = (value: unknown): value is HashBitLength => {\n return typeof value === 'number' && HashBitLength.includes(value as HashBitLength)\n}\n\nexport type Hash = Hex\nexport const isHash = (value: unknown, bitLength: HashBitLength = 256): value is Hash => {\n return isHex(value, bitLength)\n}\n\nexport function asHash(value: unknown): Hash | undefined\nexport function asHash(value: unknown, assert: AssertConfig): Hash\nexport function asHash(value: unknown, assert?: AssertConfig): Hash | undefined {\n let stringValue: string | undefined = undefined\n\n switch (typeof value) {\n case 'string':\n stringValue = hexFromHexString(value)\n break\n default:\n return assert ? assertError(value, assert, `Unsupported type [${typeof value}]`) : undefined\n }\n return isHash(stringValue) ? stringValue : assertError(value, assert, `Value is not a Hash [${value}]`)\n}\n"],"mappings":";AAIO,IAAM,cAAc,CAAC,OAAgB,QAAkC,mBAA2B;AACvG,MAAI,QAAQ;AACV,UAAM,eAAe,OAAO,WAAW,WAAW,SAAS,OAAO,WAAW,YAAY,iBAAiB,OAAO,OAAO,cAAc;AACtI,QAAI,cAAc;AAChB,YAAM,MAAM,iBAAiB,OAAO,iBAAiB,YAAY;AAAA,IACnE;AAAA,EACF;AACA,SAAO;AACT;;;ACZA,SAAS,qBAAqB;;;ACCvB,IAAM,gBAAgB,CAAC,UAA0B;AACtD,QAAM,UAAU,SAAS;AACzB,MAAI,UAAU,WAAW;AAAG,UAAM,MAAM,qCAAqC;AAC7E,SAAO;AACT;AAGO,IAAM,gBAAgB,CAAC,UAA0B;AACtD,SAAO,SAAS;AAClB;;;ACVO,IAAM,WAAW;AACjB,IAAM,qBAAqB;;;ACI3B,IAAM,YAAY,CAAC,UAAkB;AAC1C,SAAO,OAAO,iBAAiB,OAAO,EAAE,QAAQ,KAAK,CAAC,CAAC,MAAM;AAC/D;AAEO,IAAM,QAAQ,CAAC,OAAgB,cAAqC;AAEzE,MAAI,OAAO,UAAU;AAAU,WAAO;AAEtC,UAAQ,IAAI,cAAc,MAAM,UAAU,CAAC,IAAI,SAAS,EAAE;AAG1D,MAAI,cAAc,UAAa,MAAM,WAAW,cAAc,SAAS;AAAG,WAAO;AAGjF,SAAO,SAAS,KAAK,KAAK;AAC5B;;;AHdO,IAAM,qBAAqB,CAAC,QAAqB,WAA+B;AACrF,QAAM,WAAW,CAAC,GAAG,IAAI,WAAW,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAChG,SAAO,iBAAiB,UAAU,MAAM;AAC1C;AAEO,I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;ACpCO,IAAM,gBAAiC,CAAC,IAAI,IAAI,KAAK,KAAK,KAAK,MAAM,MAAM,IAAI;AAE/E,IAAM,kBAAkB,CAAC,UAA2C;AACzE,SAAO,OAAO,UAAU,YAAY,cAAc,SAAS,KAAsB;AACnF;AAGO,IAAM,SAAS,CAAC,OAAgB,YAA2B,QAAuB;AACvF,SAAO,MAAM,OAAO,SAAS;AAC/B;AAIO,SAAS,OAAO,OAAgB,QAAyC;AAC9E,MAAI,cAAkC;AAEtC,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AACH,oBAAc,iBAAiB,KAAK;AACpC;AAAA,IACF;AACE,aAAO,SAAS,YAAY,OAAO,QAAQ,qBAAqB,OAAO,KAAK,GAAG,IAAI;AAAA,EACvF;AACA,SAAO,OAAO,WAAW,IAAI,cAAc,YAAY,OAAO,QAAQ,wBAAwB,KAAK,GAAG;AACxG;","names":[]}
|
package/dist/node/address.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AssertConfig } from './assert';
|
|
2
|
+
import { HexConfig } from './hex';
|
|
2
3
|
export declare const addressRegex: RegExp;
|
|
3
4
|
export type Address = string;
|
|
5
|
+
export declare const toAddress: (value: unknown, config?: HexConfig) => string;
|
|
4
6
|
export declare const isAddress: (value: unknown, bitLength?: number) => value is string;
|
|
5
7
|
export declare function asAddress(value: unknown): Address | undefined;
|
|
6
8
|
export declare function asAddress(value: unknown, assert: AssertConfig): Address;
|
|
7
|
-
export declare function asAddress(value: unknown, bitLength: number): Address | undefined;
|
|
8
|
-
export declare function asAddress(value: unknown, bitLength: number, assert: AssertConfig): Address;
|
|
9
9
|
//# sourceMappingURL=address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,EAAiB,SAAS,EAAoC,MAAM,OAAO,CAAA;AAElF,eAAO,MAAM,YAAY,QAAiB,CAAA;AAE1C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B,eAAO,MAAM,SAAS,UAAW,OAAO,WAAU,SAAS,WAG1D,CAAA;AAED,eAAO,MAAM,SAAS,UAAW,OAAO,wCAavC,CAAA;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAA;AAC9D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAA"}
|
package/dist/node/address.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AssertConfig } from './assert';
|
|
2
|
+
import { HexConfig } from './hex';
|
|
2
3
|
export declare const addressRegex: RegExp;
|
|
3
4
|
export type Address = string;
|
|
5
|
+
export declare const toAddress: (value: unknown, config?: HexConfig) => string;
|
|
4
6
|
export declare const isAddress: (value: unknown, bitLength?: number) => value is string;
|
|
5
7
|
export declare function asAddress(value: unknown): Address | undefined;
|
|
6
8
|
export declare function asAddress(value: unknown, assert: AssertConfig): Address;
|
|
7
|
-
export declare function asAddress(value: unknown, bitLength: number): Address | undefined;
|
|
8
|
-
export declare function asAddress(value: unknown, bitLength: number, assert: AssertConfig): Address;
|
|
9
9
|
//# sourceMappingURL=address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,EAAiB,SAAS,EAAoC,MAAM,OAAO,CAAA;AAElF,eAAO,MAAM,YAAY,QAAiB,CAAA;AAE1C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B,eAAO,MAAM,SAAS,UAAW,OAAO,WAAU,SAAS,WAG1D,CAAA;AAED,eAAO,MAAM,SAAS,UAAW,OAAO,wCAavC,CAAA;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAA;AAC9D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAA"}
|
package/dist/node/address.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AssertConfig } from './assert';
|
|
2
|
+
import { HexConfig } from './hex';
|
|
2
3
|
export declare const addressRegex: RegExp;
|
|
3
4
|
export type Address = string;
|
|
5
|
+
export declare const toAddress: (value: unknown, config?: HexConfig) => string;
|
|
4
6
|
export declare const isAddress: (value: unknown, bitLength?: number) => value is string;
|
|
5
7
|
export declare function asAddress(value: unknown): Address | undefined;
|
|
6
8
|
export declare function asAddress(value: unknown, assert: AssertConfig): Address;
|
|
7
|
-
export declare function asAddress(value: unknown, bitLength: number): Address | undefined;
|
|
8
|
-
export declare function asAddress(value: unknown, bitLength: number, assert: AssertConfig): Address;
|
|
9
9
|
//# sourceMappingURL=address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,EAAiB,SAAS,EAAoC,MAAM,OAAO,CAAA;AAElF,eAAO,MAAM,YAAY,QAAiB,CAAA;AAE1C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B,eAAO,MAAM,SAAS,UAAW,OAAO,WAAU,SAAS,WAG1D,CAAA;AAED,eAAO,MAAM,SAAS,UAAW,OAAO,wCAavC,CAAA;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAA;AAC9D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAA"}
|
package/dist/node/hash.d.cts
CHANGED
|
@@ -7,6 +7,4 @@ export type Hash = Hex;
|
|
|
7
7
|
export declare const isHash: (value: unknown, bitLength?: HashBitLength) => value is string;
|
|
8
8
|
export declare function asHash(value: unknown): Hash | undefined;
|
|
9
9
|
export declare function asHash(value: unknown, assert: AssertConfig): Hash;
|
|
10
|
-
export declare function asHash(value: unknown, bitLength?: HashBitLength): Hash | undefined;
|
|
11
|
-
export declare function asHash(value: unknown, bitLength: HashBitLength | undefined, assert: AssertConfig): Hash;
|
|
12
10
|
//# sourceMappingURL=hash.d.ts.map
|
package/dist/node/hash.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,EAAE,GAAG,EAA2B,MAAM,OAAO,CAAA;AAEpD,MAAM,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAC1E,eAAO,MAAM,aAAa,EAAE,aAAa,EAA8C,CAAA;AAEvF,eAAO,MAAM,eAAe,UAAW,OAAO,2BAE7C,CAAA;AAED,MAAM,MAAM,IAAI,GAAG,GAAG,CAAA;AACtB,eAAO,MAAM,MAAM,UAAW,OAAO,cAAa,aAAa,oBAE9D,CAAA;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AACxD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA"}
|
package/dist/node/hash.d.mts
CHANGED
|
@@ -7,6 +7,4 @@ export type Hash = Hex;
|
|
|
7
7
|
export declare const isHash: (value: unknown, bitLength?: HashBitLength) => value is string;
|
|
8
8
|
export declare function asHash(value: unknown): Hash | undefined;
|
|
9
9
|
export declare function asHash(value: unknown, assert: AssertConfig): Hash;
|
|
10
|
-
export declare function asHash(value: unknown, bitLength?: HashBitLength): Hash | undefined;
|
|
11
|
-
export declare function asHash(value: unknown, bitLength: HashBitLength | undefined, assert: AssertConfig): Hash;
|
|
12
10
|
//# sourceMappingURL=hash.d.ts.map
|
package/dist/node/hash.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,EAAE,GAAG,EAA2B,MAAM,OAAO,CAAA;AAEpD,MAAM,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAC1E,eAAO,MAAM,aAAa,EAAE,aAAa,EAA8C,CAAA;AAEvF,eAAO,MAAM,eAAe,UAAW,OAAO,2BAE7C,CAAA;AAED,MAAM,MAAM,IAAI,GAAG,GAAG,CAAA;AACtB,eAAO,MAAM,MAAM,UAAW,OAAO,cAAa,aAAa,oBAE9D,CAAA;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AACxD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA"}
|
package/dist/node/hash.d.ts
CHANGED
|
@@ -7,6 +7,4 @@ export type Hash = Hex;
|
|
|
7
7
|
export declare const isHash: (value: unknown, bitLength?: HashBitLength) => value is string;
|
|
8
8
|
export declare function asHash(value: unknown): Hash | undefined;
|
|
9
9
|
export declare function asHash(value: unknown, assert: AssertConfig): Hash;
|
|
10
|
-
export declare function asHash(value: unknown, bitLength?: HashBitLength): Hash | undefined;
|
|
11
|
-
export declare function asHash(value: unknown, bitLength: HashBitLength | undefined, assert: AssertConfig): Hash;
|
|
12
10
|
//# sourceMappingURL=hash.d.ts.map
|
package/dist/node/hash.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAA;AACpD,OAAO,EAAE,GAAG,EAA2B,MAAM,OAAO,CAAA;AAEpD,MAAM,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAC1E,eAAO,MAAM,aAAa,EAAE,aAAa,EAA8C,CAAA;AAEvF,eAAO,MAAM,eAAe,UAAW,OAAO,2BAE7C,CAAA;AAED,MAAM,MAAM,IAAI,GAAG,GAAG,CAAA;AACtB,eAAO,MAAM,MAAM,UAAW,OAAO,cAAa,aAAa,oBAE9D,CAAA;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AACxD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hex/as.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAA;AAGrD,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAE7B,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,GAAG,SAAS,CAAA;AACtD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hex/as.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAA;AAGrD,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAE7B,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,GAAG,SAAS,CAAA;AACtD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../../src/hex/as.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAA;AAGrD,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAE7B,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,GAAG,SAAS,CAAA;AACtD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HexConfig } from './model';
|
|
2
|
+
export declare const hexFromArrayBuffer: (buffer: ArrayBuffer, config?: HexConfig) => string;
|
|
3
|
+
export declare const hexFromBigInt: (value: bigint, config?: HexConfig) => string;
|
|
4
|
+
export declare const hexFromNumber: (value: number, config?: HexConfig) => string;
|
|
5
|
+
export declare const hexFromHexString: (value: string, config?: HexConfig) => string;
|
|
6
|
+
export declare const hexFrom: (value: unknown, config?: HexConfig) => string;
|
|
7
|
+
//# sourceMappingURL=from.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from.d.ts","sourceRoot":"","sources":["../../../src/hex/from.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGnC,eAAO,MAAM,kBAAkB,WAAY,WAAW,WAAW,SAAS,KAAG,MAG5E,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAAU,SAAS,KAAQ,MAKrE,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAAW,SAAS,KAAG,MAEjE,CAAA;AAED,eAAO,MAAM,gBAAgB,UAAW,MAAM,WAAU,SAAS,KAAQ,MAUxE,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,OAAO,WAAW,SAAS,KAAG,MAiB5D,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HexConfig } from './model';
|
|
2
|
+
export declare const hexFromArrayBuffer: (buffer: ArrayBuffer, config?: HexConfig) => string;
|
|
3
|
+
export declare const hexFromBigInt: (value: bigint, config?: HexConfig) => string;
|
|
4
|
+
export declare const hexFromNumber: (value: number, config?: HexConfig) => string;
|
|
5
|
+
export declare const hexFromHexString: (value: string, config?: HexConfig) => string;
|
|
6
|
+
export declare const hexFrom: (value: unknown, config?: HexConfig) => string;
|
|
7
|
+
//# sourceMappingURL=from.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from.d.ts","sourceRoot":"","sources":["../../../src/hex/from.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGnC,eAAO,MAAM,kBAAkB,WAAY,WAAW,WAAW,SAAS,KAAG,MAG5E,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAAU,SAAS,KAAQ,MAKrE,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAAW,SAAS,KAAG,MAEjE,CAAA;AAED,eAAO,MAAM,gBAAgB,UAAW,MAAM,WAAU,SAAS,KAAQ,MAUxE,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,OAAO,WAAW,SAAS,KAAG,MAiB5D,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HexConfig } from './model';
|
|
2
|
+
export declare const hexFromArrayBuffer: (buffer: ArrayBuffer, config?: HexConfig) => string;
|
|
3
|
+
export declare const hexFromBigInt: (value: bigint, config?: HexConfig) => string;
|
|
4
|
+
export declare const hexFromNumber: (value: number, config?: HexConfig) => string;
|
|
5
|
+
export declare const hexFromHexString: (value: string, config?: HexConfig) => string;
|
|
6
|
+
export declare const hexFrom: (value: unknown, config?: HexConfig) => string;
|
|
7
|
+
//# sourceMappingURL=from.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from.d.ts","sourceRoot":"","sources":["../../../src/hex/from.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGnC,eAAO,MAAM,kBAAkB,WAAY,WAAW,WAAW,SAAS,KAAG,MAG5E,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAAU,SAAS,KAAQ,MAKrE,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAAW,SAAS,KAAG,MAEjE,CAAA;AAED,eAAO,MAAM,gBAAgB,UAAW,MAAM,WAAU,SAAS,KAAQ,MAUxE,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,OAAO,WAAW,SAAS,KAAG,MAiB5D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hex/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAA;AACpB,cAAc,QAAQ,CAAA;AACtB,cAAc,MAAM,CAAA;AACpB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hex/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAA;AACpB,cAAc,QAAQ,CAAA;AACtB,cAAc,MAAM,CAAA;AACpB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hex/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAA;AACpB,cAAc,QAAQ,CAAA;AACtB,cAAc,MAAM,CAAA;AACpB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/hex/is.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,UAAW,MAAM,YAEtC,CAAA;AAED,eAAO,MAAM,KAAK,UAAW,OAAO,cAAc,MAAM,oBAWvD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/hex/is.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,UAAW,MAAM,YAEtC,CAAA;AAED,eAAO,MAAM,KAAK,UAAW,OAAO,cAAc,MAAM,oBAWvD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../../src/hex/is.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,UAAW,MAAM,YAEtC,CAAA;AAED,eAAO,MAAM,KAAK,UAAW,OAAO,cAAc,MAAM,oBAWvD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/hex/legacy.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,WAAY,WAAW,WAE9C,CAAA;AAED,0CAA0C;AAC1C,eAAO,MAAM,KAAK,WAAY,WAAW,WAExC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/hex/legacy.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,WAAY,WAAW,WAE9C,CAAA;AAED,0CAA0C;AAC1C,eAAO,MAAM,KAAK,WAAY,WAAW,WAExC,CAAA"}
|