@trezoa/codecs-core
Advanced tools
+13
-10
@@ -34,5 +34,7 @@ 'use strict'; | ||
| const slice = offset === 0 && data.length === bytes.length ? data : data.slice(offset, offset + bytes.length); | ||
| if (slice.length !== bytes.length) return false; | ||
| return bytes.every((b, i) => b === slice[i]); | ||
| return bytesEqual(slice, bytes); | ||
| } | ||
| function bytesEqual(bytes1, bytes2) { | ||
| return bytes1.length === bytes2.length && bytes1.every((value, index) => value === bytes2[index]); | ||
| } | ||
| function getEncodedSize(value, encoder) { | ||
@@ -112,3 +114,3 @@ return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value); | ||
| function addEncoderSentinel(encoder, sentinel) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -128,3 +130,3 @@ if (findSentinelIndex(encoderBytes, sentinel) >= 0) { | ||
| return offset; | ||
| }; | ||
| }); | ||
| if (isFixedSize(encoder)) { | ||
@@ -141,3 +143,3 @@ return createEncoder({ ...encoder, fixedSize: encoder.fixedSize + sentinel.length, write }); | ||
| function addDecoderSentinel(decoder, sentinel) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const candidateBytes = offset === 0 ? bytes : bytes.slice(offset); | ||
@@ -155,3 +157,3 @@ const sentinelIndex = findSentinelIndex(candidateBytes, sentinel); | ||
| return [decoder.decode(preSentinelBytes), offset + preSentinelBytes.length + sentinel.length]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(decoder)) { | ||
@@ -207,3 +209,3 @@ return createDecoder({ ...decoder, fixedSize: decoder.fixedSize + sentinel.length, read }); | ||
| function addEncoderSizePrefix(encoder, prefix) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -213,3 +215,3 @@ offset = prefix.write(encoderBytes.length, bytes, offset); | ||
| return offset + encoderBytes.length; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(encoder)) { | ||
@@ -232,3 +234,3 @@ return createEncoder({ ...encoder, fixedSize: prefix.fixedSize + encoder.fixedSize, write }); | ||
| function addDecoderSizePrefix(decoder, prefix) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const [bigintSize, decoderOffset] = prefix.read(bytes, offset); | ||
@@ -242,3 +244,3 @@ const size = Number(bigintSize); | ||
| return [decoder.decode(bytes), offset + size]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(decoder)) { | ||
@@ -495,2 +497,3 @@ return createDecoder({ ...decoder, fixedSize: prefix.fixedSize + decoder.fixedSize, read }); | ||
| exports.assertIsVariableSize = assertIsVariableSize; | ||
| exports.bytesEqual = bytesEqual; | ||
| exports.combineCodec = combineCodec; | ||
@@ -497,0 +500,0 @@ exports.containsBytes = containsBytes; |
+13
-11
@@ -32,5 +32,7 @@ import { TrezoaError, TREZOA_ERROR__CODECS__EXPECTED_FIXED_LENGTH, TREZOA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH, TREZOA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH, TREZOA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH, TREZOA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH, TREZOA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY, TREZOA_ERROR__CODECS__INVALID_BYTE_LENGTH, TREZOA_ERROR__CODECS__OFFSET_OUT_OF_RANGE, TREZOA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY, TREZOA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH, TREZOA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES, TREZOA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL } from '@trezoa/errors'; | ||
| const slice = offset === 0 && data.length === bytes.length ? data : data.slice(offset, offset + bytes.length); | ||
| if (slice.length !== bytes.length) return false; | ||
| return bytes.every((b, i) => b === slice[i]); | ||
| return bytesEqual(slice, bytes); | ||
| } | ||
| function bytesEqual(bytes1, bytes2) { | ||
| return bytes1.length === bytes2.length && bytes1.every((value, index) => value === bytes2[index]); | ||
| } | ||
| function getEncodedSize(value, encoder) { | ||
@@ -110,3 +112,3 @@ return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value); | ||
| function addEncoderSentinel(encoder, sentinel) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -126,3 +128,3 @@ if (findSentinelIndex(encoderBytes, sentinel) >= 0) { | ||
| return offset; | ||
| }; | ||
| }); | ||
| if (isFixedSize(encoder)) { | ||
@@ -139,3 +141,3 @@ return createEncoder({ ...encoder, fixedSize: encoder.fixedSize + sentinel.length, write }); | ||
| function addDecoderSentinel(decoder, sentinel) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const candidateBytes = offset === 0 ? bytes : bytes.slice(offset); | ||
@@ -153,3 +155,3 @@ const sentinelIndex = findSentinelIndex(candidateBytes, sentinel); | ||
| return [decoder.decode(preSentinelBytes), offset + preSentinelBytes.length + sentinel.length]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(decoder)) { | ||
@@ -205,3 +207,3 @@ return createDecoder({ ...decoder, fixedSize: decoder.fixedSize + sentinel.length, read }); | ||
| function addEncoderSizePrefix(encoder, prefix) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -211,3 +213,3 @@ offset = prefix.write(encoderBytes.length, bytes, offset); | ||
| return offset + encoderBytes.length; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(encoder)) { | ||
@@ -230,3 +232,3 @@ return createEncoder({ ...encoder, fixedSize: prefix.fixedSize + encoder.fixedSize, write }); | ||
| function addDecoderSizePrefix(decoder, prefix) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const [bigintSize, decoderOffset] = prefix.read(bytes, offset); | ||
@@ -240,3 +242,3 @@ const size = Number(bigintSize); | ||
| return [decoder.decode(bytes), offset + size]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(decoder)) { | ||
@@ -482,4 +484,4 @@ return createDecoder({ ...decoder, fixedSize: prefix.fixedSize + decoder.fixedSize, read }); | ||
| export { addCodecSentinel, addCodecSizePrefix, addDecoderSentinel, addDecoderSizePrefix, addEncoderSentinel, addEncoderSizePrefix, assertByteArrayHasEnoughBytesForCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayOffsetIsNotOutOfRange, assertIsFixedSize, assertIsVariableSize, combineCodec, containsBytes, createCodec, createDecoder, createDecoderThatConsumesEntireByteArray, createEncoder, fixBytes, fixCodecSize, fixDecoderSize, fixEncoderSize, getEncodedSize, isFixedSize, isVariableSize, mergeBytes, offsetCodec, offsetDecoder, offsetEncoder, padBytes, padLeftCodec, padLeftDecoder, padLeftEncoder, padRightCodec, padRightDecoder, padRightEncoder, resizeCodec, resizeDecoder, resizeEncoder, reverseCodec, reverseDecoder, reverseEncoder, transformCodec, transformDecoder, transformEncoder }; | ||
| export { addCodecSentinel, addCodecSizePrefix, addDecoderSentinel, addDecoderSizePrefix, addEncoderSentinel, addEncoderSizePrefix, assertByteArrayHasEnoughBytesForCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayOffsetIsNotOutOfRange, assertIsFixedSize, assertIsVariableSize, bytesEqual, combineCodec, containsBytes, createCodec, createDecoder, createDecoderThatConsumesEntireByteArray, createEncoder, fixBytes, fixCodecSize, fixDecoderSize, fixEncoderSize, getEncodedSize, isFixedSize, isVariableSize, mergeBytes, offsetCodec, offsetDecoder, offsetEncoder, padBytes, padLeftCodec, padLeftDecoder, padLeftEncoder, padRightCodec, padRightDecoder, padRightEncoder, resizeCodec, resizeDecoder, resizeEncoder, reverseCodec, reverseDecoder, reverseEncoder, transformCodec, transformDecoder, transformEncoder }; | ||
| //# sourceMappingURL=index.browser.mjs.map | ||
| //# sourceMappingURL=index.browser.mjs.map |
+13
-11
@@ -32,5 +32,7 @@ import { TrezoaError, TREZOA_ERROR__CODECS__EXPECTED_FIXED_LENGTH, TREZOA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH, TREZOA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH, TREZOA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH, TREZOA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH, TREZOA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY, TREZOA_ERROR__CODECS__INVALID_BYTE_LENGTH, TREZOA_ERROR__CODECS__OFFSET_OUT_OF_RANGE, TREZOA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY, TREZOA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH, TREZOA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES, TREZOA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL } from '@trezoa/errors'; | ||
| const slice = offset === 0 && data.length === bytes.length ? data : data.slice(offset, offset + bytes.length); | ||
| if (slice.length !== bytes.length) return false; | ||
| return bytes.every((b, i) => b === slice[i]); | ||
| return bytesEqual(slice, bytes); | ||
| } | ||
| function bytesEqual(bytes1, bytes2) { | ||
| return bytes1.length === bytes2.length && bytes1.every((value, index) => value === bytes2[index]); | ||
| } | ||
| function getEncodedSize(value, encoder) { | ||
@@ -110,3 +112,3 @@ return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value); | ||
| function addEncoderSentinel(encoder, sentinel) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -126,3 +128,3 @@ if (findSentinelIndex(encoderBytes, sentinel) >= 0) { | ||
| return offset; | ||
| }; | ||
| }); | ||
| if (isFixedSize(encoder)) { | ||
@@ -139,3 +141,3 @@ return createEncoder({ ...encoder, fixedSize: encoder.fixedSize + sentinel.length, write }); | ||
| function addDecoderSentinel(decoder, sentinel) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const candidateBytes = offset === 0 ? bytes : bytes.slice(offset); | ||
@@ -153,3 +155,3 @@ const sentinelIndex = findSentinelIndex(candidateBytes, sentinel); | ||
| return [decoder.decode(preSentinelBytes), offset + preSentinelBytes.length + sentinel.length]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(decoder)) { | ||
@@ -205,3 +207,3 @@ return createDecoder({ ...decoder, fixedSize: decoder.fixedSize + sentinel.length, read }); | ||
| function addEncoderSizePrefix(encoder, prefix) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -211,3 +213,3 @@ offset = prefix.write(encoderBytes.length, bytes, offset); | ||
| return offset + encoderBytes.length; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(encoder)) { | ||
@@ -230,3 +232,3 @@ return createEncoder({ ...encoder, fixedSize: prefix.fixedSize + encoder.fixedSize, write }); | ||
| function addDecoderSizePrefix(decoder, prefix) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const [bigintSize, decoderOffset] = prefix.read(bytes, offset); | ||
@@ -240,3 +242,3 @@ const size = Number(bigintSize); | ||
| return [decoder.decode(bytes), offset + size]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(decoder)) { | ||
@@ -482,4 +484,4 @@ return createDecoder({ ...decoder, fixedSize: prefix.fixedSize + decoder.fixedSize, read }); | ||
| export { addCodecSentinel, addCodecSizePrefix, addDecoderSentinel, addDecoderSizePrefix, addEncoderSentinel, addEncoderSizePrefix, assertByteArrayHasEnoughBytesForCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayOffsetIsNotOutOfRange, assertIsFixedSize, assertIsVariableSize, combineCodec, containsBytes, createCodec, createDecoder, createDecoderThatConsumesEntireByteArray, createEncoder, fixBytes, fixCodecSize, fixDecoderSize, fixEncoderSize, getEncodedSize, isFixedSize, isVariableSize, mergeBytes, offsetCodec, offsetDecoder, offsetEncoder, padBytes, padLeftCodec, padLeftDecoder, padLeftEncoder, padRightCodec, padRightDecoder, padRightEncoder, resizeCodec, resizeDecoder, resizeEncoder, reverseCodec, reverseDecoder, reverseEncoder, transformCodec, transformDecoder, transformEncoder }; | ||
| export { addCodecSentinel, addCodecSizePrefix, addDecoderSentinel, addDecoderSizePrefix, addEncoderSentinel, addEncoderSizePrefix, assertByteArrayHasEnoughBytesForCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayOffsetIsNotOutOfRange, assertIsFixedSize, assertIsVariableSize, bytesEqual, combineCodec, containsBytes, createCodec, createDecoder, createDecoderThatConsumesEntireByteArray, createEncoder, fixBytes, fixCodecSize, fixDecoderSize, fixEncoderSize, getEncodedSize, isFixedSize, isVariableSize, mergeBytes, offsetCodec, offsetDecoder, offsetEncoder, padBytes, padLeftCodec, padLeftDecoder, padLeftEncoder, padRightCodec, padRightDecoder, padRightEncoder, resizeCodec, resizeDecoder, resizeEncoder, reverseCodec, reverseDecoder, reverseEncoder, transformCodec, transformDecoder, transformEncoder }; | ||
| //# sourceMappingURL=index.native.mjs.map | ||
| //# sourceMappingURL=index.native.mjs.map |
+13
-10
@@ -34,5 +34,7 @@ 'use strict'; | ||
| const slice = offset === 0 && data.length === bytes.length ? data : data.slice(offset, offset + bytes.length); | ||
| if (slice.length !== bytes.length) return false; | ||
| return bytes.every((b, i) => b === slice[i]); | ||
| return bytesEqual(slice, bytes); | ||
| } | ||
| function bytesEqual(bytes1, bytes2) { | ||
| return bytes1.length === bytes2.length && bytes1.every((value, index) => value === bytes2[index]); | ||
| } | ||
| function getEncodedSize(value, encoder) { | ||
@@ -112,3 +114,3 @@ return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value); | ||
| function addEncoderSentinel(encoder, sentinel) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -128,3 +130,3 @@ if (findSentinelIndex(encoderBytes, sentinel) >= 0) { | ||
| return offset; | ||
| }; | ||
| }); | ||
| if (isFixedSize(encoder)) { | ||
@@ -141,3 +143,3 @@ return createEncoder({ ...encoder, fixedSize: encoder.fixedSize + sentinel.length, write }); | ||
| function addDecoderSentinel(decoder, sentinel) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const candidateBytes = offset === 0 ? bytes : bytes.slice(offset); | ||
@@ -155,3 +157,3 @@ const sentinelIndex = findSentinelIndex(candidateBytes, sentinel); | ||
| return [decoder.decode(preSentinelBytes), offset + preSentinelBytes.length + sentinel.length]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(decoder)) { | ||
@@ -207,3 +209,3 @@ return createDecoder({ ...decoder, fixedSize: decoder.fixedSize + sentinel.length, read }); | ||
| function addEncoderSizePrefix(encoder, prefix) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -213,3 +215,3 @@ offset = prefix.write(encoderBytes.length, bytes, offset); | ||
| return offset + encoderBytes.length; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(encoder)) { | ||
@@ -232,3 +234,3 @@ return createEncoder({ ...encoder, fixedSize: prefix.fixedSize + encoder.fixedSize, write }); | ||
| function addDecoderSizePrefix(decoder, prefix) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const [bigintSize, decoderOffset] = prefix.read(bytes, offset); | ||
@@ -242,3 +244,3 @@ const size = Number(bigintSize); | ||
| return [decoder.decode(bytes), offset + size]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(decoder)) { | ||
@@ -495,2 +497,3 @@ return createDecoder({ ...decoder, fixedSize: prefix.fixedSize + decoder.fixedSize, read }); | ||
| exports.assertIsVariableSize = assertIsVariableSize; | ||
| exports.bytesEqual = bytesEqual; | ||
| exports.combineCodec = combineCodec; | ||
@@ -497,0 +500,0 @@ exports.containsBytes = containsBytes; |
+13
-11
@@ -32,5 +32,7 @@ import { TrezoaError, TREZOA_ERROR__CODECS__EXPECTED_FIXED_LENGTH, TREZOA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH, TREZOA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH, TREZOA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH, TREZOA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH, TREZOA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY, TREZOA_ERROR__CODECS__INVALID_BYTE_LENGTH, TREZOA_ERROR__CODECS__OFFSET_OUT_OF_RANGE, TREZOA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY, TREZOA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH, TREZOA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES, TREZOA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL } from '@trezoa/errors'; | ||
| const slice = offset === 0 && data.length === bytes.length ? data : data.slice(offset, offset + bytes.length); | ||
| if (slice.length !== bytes.length) return false; | ||
| return bytes.every((b, i) => b === slice[i]); | ||
| return bytesEqual(slice, bytes); | ||
| } | ||
| function bytesEqual(bytes1, bytes2) { | ||
| return bytes1.length === bytes2.length && bytes1.every((value, index) => value === bytes2[index]); | ||
| } | ||
| function getEncodedSize(value, encoder) { | ||
@@ -110,3 +112,3 @@ return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value); | ||
| function addEncoderSentinel(encoder, sentinel) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -126,3 +128,3 @@ if (findSentinelIndex(encoderBytes, sentinel) >= 0) { | ||
| return offset; | ||
| }; | ||
| }); | ||
| if (isFixedSize(encoder)) { | ||
@@ -139,3 +141,3 @@ return createEncoder({ ...encoder, fixedSize: encoder.fixedSize + sentinel.length, write }); | ||
| function addDecoderSentinel(decoder, sentinel) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const candidateBytes = offset === 0 ? bytes : bytes.slice(offset); | ||
@@ -153,3 +155,3 @@ const sentinelIndex = findSentinelIndex(candidateBytes, sentinel); | ||
| return [decoder.decode(preSentinelBytes), offset + preSentinelBytes.length + sentinel.length]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(decoder)) { | ||
@@ -205,3 +207,3 @@ return createDecoder({ ...decoder, fixedSize: decoder.fixedSize + sentinel.length, read }); | ||
| function addEncoderSizePrefix(encoder, prefix) { | ||
| const write = (value, bytes, offset) => { | ||
| const write = ((value, bytes, offset) => { | ||
| const encoderBytes = encoder.encode(value); | ||
@@ -211,3 +213,3 @@ offset = prefix.write(encoderBytes.length, bytes, offset); | ||
| return offset + encoderBytes.length; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(encoder)) { | ||
@@ -230,3 +232,3 @@ return createEncoder({ ...encoder, fixedSize: prefix.fixedSize + encoder.fixedSize, write }); | ||
| function addDecoderSizePrefix(decoder, prefix) { | ||
| const read = (bytes, offset) => { | ||
| const read = ((bytes, offset) => { | ||
| const [bigintSize, decoderOffset] = prefix.read(bytes, offset); | ||
@@ -240,3 +242,3 @@ const size = Number(bigintSize); | ||
| return [decoder.decode(bytes), offset + size]; | ||
| }; | ||
| }); | ||
| if (isFixedSize(prefix) && isFixedSize(decoder)) { | ||
@@ -482,4 +484,4 @@ return createDecoder({ ...decoder, fixedSize: prefix.fixedSize + decoder.fixedSize, read }); | ||
| export { addCodecSentinel, addCodecSizePrefix, addDecoderSentinel, addDecoderSizePrefix, addEncoderSentinel, addEncoderSizePrefix, assertByteArrayHasEnoughBytesForCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayOffsetIsNotOutOfRange, assertIsFixedSize, assertIsVariableSize, combineCodec, containsBytes, createCodec, createDecoder, createDecoderThatConsumesEntireByteArray, createEncoder, fixBytes, fixCodecSize, fixDecoderSize, fixEncoderSize, getEncodedSize, isFixedSize, isVariableSize, mergeBytes, offsetCodec, offsetDecoder, offsetEncoder, padBytes, padLeftCodec, padLeftDecoder, padLeftEncoder, padRightCodec, padRightDecoder, padRightEncoder, resizeCodec, resizeDecoder, resizeEncoder, reverseCodec, reverseDecoder, reverseEncoder, transformCodec, transformDecoder, transformEncoder }; | ||
| export { addCodecSentinel, addCodecSizePrefix, addDecoderSentinel, addDecoderSizePrefix, addEncoderSentinel, addEncoderSizePrefix, assertByteArrayHasEnoughBytesForCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayOffsetIsNotOutOfRange, assertIsFixedSize, assertIsVariableSize, bytesEqual, combineCodec, containsBytes, createCodec, createDecoder, createDecoderThatConsumesEntireByteArray, createEncoder, fixBytes, fixCodecSize, fixDecoderSize, fixEncoderSize, getEncodedSize, isFixedSize, isVariableSize, mergeBytes, offsetCodec, offsetDecoder, offsetEncoder, padBytes, padLeftCodec, padLeftDecoder, padLeftEncoder, padRightCodec, padRightDecoder, padRightEncoder, resizeCodec, resizeDecoder, resizeEncoder, reverseCodec, reverseDecoder, reverseEncoder, transformCodec, transformDecoder, transformEncoder }; | ||
| //# sourceMappingURL=index.node.mjs.map | ||
| //# sourceMappingURL=index.node.mjs.map |
@@ -93,2 +93,16 @@ import { ReadonlyUint8Array } from './readonly-uint8array'; | ||
| export declare function containsBytes(data: ReadonlyUint8Array | Uint8Array, bytes: ReadonlyUint8Array | Uint8Array, offset: number): boolean; | ||
| /** | ||
| * Returns true if and only if the provided `bytes1` and `bytes2` byte arrays are equal. | ||
| * | ||
| * @param bytes1 - The first byte array to compare. | ||
| * @param bytes2 - The second byte array to compare. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const bytes1 = new Uint8Array([0x01, 0x02, 0x03, 0x04]); | ||
| * const bytes2 = new Uint8Array([0x01, 0x02, 0x03, 0x04]); | ||
| * bytesEqual(bytes1, bytes2); // true | ||
| * ``` | ||
| */ | ||
| export declare function bytesEqual(bytes1: ReadonlyUint8Array | Uint8Array, bytes2: ReadonlyUint8Array | Uint8Array): boolean; | ||
| //# sourceMappingURL=bytes.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,GAAI,YAAY,UAAU,EAAE,KAAG,UAkBrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;AACxE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAAC;AAQxF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,kBAAkB,GAAG,UAAU,EAAE,QAAQ,MAAM,KAAG,kBAAkB,GAAG,UAC1B,CAAC;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CACzB,IAAI,EAAE,kBAAkB,GAAG,UAAU,EACrC,KAAK,EAAE,kBAAkB,GAAG,UAAU,EACtC,MAAM,EAAE,MAAM,GACf,OAAO,CAIT"} | ||
| {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,GAAI,YAAY,UAAU,EAAE,KAAG,UAkBrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;AACxE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAAC;AAQxF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,kBAAkB,GAAG,UAAU,EAAE,QAAQ,MAAM,KAAG,kBAAkB,GAAG,UAC1B,CAAC;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CACzB,IAAI,EAAE,kBAAkB,GAAG,UAAU,EACrC,KAAK,EAAE,kBAAkB,GAAG,UAAU,EACtC,MAAM,EAAE,MAAM,GACf,OAAO,CAGT;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,UAAU,EAAE,MAAM,EAAE,kBAAkB,GAAG,UAAU,GAAG,OAAO,CAEpH"} |
| /** | ||
| * This package contains the core types and functions for encoding and decoding data structures on Trezoa. It can be used standalone, but it is also exported as part of Kit [`@trezoa/kit`](https://github.com/trezoa.xyz/kit/tree/main/packages/kit). | ||
| * This package contains the core types and functions for encoding and decoding data structures on Trezoa. It can be used standalone, but it is also exported as part of Kit [`@trezoa/kit`](https://github.com/trezoa-xyz/kit/tree/main/packages/kit). | ||
| * | ||
| * This package is also part of the [`@trezoa/codecs` package](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs) which acts as an entry point for all codec packages as well as for their documentation. | ||
| * This package is also part of the [`@trezoa/codecs` package](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs) which acts as an entry point for all codec packages as well as for their documentation. | ||
| * | ||
| * ## Composing codecs | ||
| * | ||
| * The easiest way to create your own codecs is to compose the [various codecs](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs) offered by this library. For instance, here’s how you would define a codec for a `Person` object that contains a `name` string attribute and an `age` number stored in 4 bytes. | ||
| * The easiest way to create your own codecs is to compose the [various codecs](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs) offered by this library. For instance, here’s how you would define a codec for a `Person` object that contains a `name` string attribute and an `age` number stored in 4 bytes. | ||
| * | ||
@@ -29,10 +29,10 @@ * ```ts | ||
| * | ||
| * - [`@trezoa/codecs-numbers`](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs-numbers) for number codecs. | ||
| * - [`@trezoa/codecs-strings`](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs-strings) for string codecs. | ||
| * - [`@trezoa/codecs-data-structures`](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs-data-structures) for many data structure codecs such as objects, arrays, tuples, sets, maps, enums, discriminated unions, booleans, etc. | ||
| * - [`@trezoa/options`](https://github.com/trezoa.xyz/kit/tree/main/packages/options) for a Rust-like `Option` type and associated codec. | ||
| * - [`@trezoa/codecs-numbers`](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs-numbers) for number codecs. | ||
| * - [`@trezoa/codecs-strings`](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs-strings) for string codecs. | ||
| * - [`@trezoa/codecs-data-structures`](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs-data-structures) for many data structure codecs such as objects, arrays, tuples, sets, maps, enums, discriminated unions, booleans, etc. | ||
| * - [`@trezoa/options`](https://github.com/trezoa-xyz/kit/tree/main/packages/options) for a Rust-like `Option` type and associated codec. | ||
| * | ||
| * You may also be interested in some of the helpers of this `@trezoa/codecs-core` library such as `transformCodec`, `fixCodecSize` or `reverseCodec` that create new codecs from existing ones. | ||
| * | ||
| * Note that all of these libraries are included in the [`@trezoa/codecs` package](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs) as well as the main `@trezoa/kit` package for your convenience. | ||
| * Note that all of these libraries are included in the [`@trezoa/codecs` package](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs) as well as the main `@trezoa/kit` package for your convenience. | ||
| * | ||
@@ -651,3 +651,3 @@ * ## Composing encoders and decoders | ||
| * | ||
| * To read more about the available codecs and how to use them, check out the documentation of the main [`@trezoa/codecs` package](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs). | ||
| * To read more about the available codecs and how to use them, check out the documentation of the main [`@trezoa/codecs` package](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs). | ||
| * | ||
@@ -654,0 +654,0 @@ * @packageDocumentation |
+11
-14
| { | ||
| "name": "@trezoa/codecs-core", | ||
| "version": "5.0.0", | ||
| "version": "5.1.0", | ||
| "description": "Core types and helpers for encoding and decoding byte arrays on Trezoa", | ||
| "homepage": "https://www.trezoa.com/api#trezoacodecs-core", | ||
| "homepage": "https://www.trezoakit.com/api#trezoacodecs-core", | ||
| "exports": { | ||
@@ -36,6 +36,3 @@ "edge-light": { | ||
| "files": [ | ||
| "./dist/", | ||
| "NOTICE", | ||
| "LICENSE", | ||
| "README.md" | ||
| "./dist/" | ||
| ], | ||
@@ -48,10 +45,10 @@ "sideEffects": false, | ||
| ], | ||
| "author": "Trezoa-team Maintainers <maintainers@trezoa.xyz>", | ||
| "author": "Trezoa Team Maintainers <maintainers@trezoa.com>", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/trezoa.xyz/kit" | ||
| "url": "https://github.com/trezoa-xyz/kit" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/trezoa.xyz/kit/issues" | ||
| "url": "https://github.com/trezoa-xyz/kit/issues" | ||
| }, | ||
@@ -63,3 +60,3 @@ "browserslist": [ | ||
| "dependencies": { | ||
| "@trezoa/errors": "^5.0.0" | ||
| "@trezoa/errors": "5.1.0" | ||
| }, | ||
@@ -77,3 +74,3 @@ "peerDependencies": { | ||
| "compile:typedefs": "tsc -p ./tsconfig.declarations.json", | ||
| "dev": "jest -c ../../node_modules/@trezoa/test-config/jest-dev.config.ts --rootDir . --watch", | ||
| "dev": "NODE_OPTIONS=\"--localstorage-file=$(mktemp)\" jest -c ../../node_modules/@trezoa/test-config/jest-dev.config.ts --rootDir . --watch", | ||
| "publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || (pnpm publish --tag ${PUBLISH_TAG:-canary} --access public --no-git-checks && (([ -n \"${GITHUB_OUTPUT:-}\" ] && echo 'published=true' >> \"$GITHUB_OUTPUT\") || true) && (([ \"$PUBLISH_TAG\" != \"canary\" ] && ../build-scripts/maybe-tag-latest.ts --token \"$GITHUB_TOKEN\" $npm_package_name@$npm_package_version) || true))", | ||
@@ -88,5 +85,5 @@ "publish-packages": "pnpm prepublishOnly && pnpm publish-impl", | ||
| "test:typecheck": "tsc --noEmit", | ||
| "test:unit:browser": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@trezoa/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
| "test:unit:node": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@trezoa/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
| "test:unit:browser": "NODE_OPTIONS=\"--localstorage-file=$(mktemp)\" TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@trezoa/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
| "test:unit:node": "NODE_OPTIONS=\"--localstorage-file=$(mktemp)\" TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@trezoa/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
| } | ||
| } | ||
| } |
+9
-9
@@ -14,9 +14,9 @@ [![npm][npm-image]][npm-url] | ||
| This package contains the core types and functions for encoding and decoding data structures on Trezoa. It can be used standalone, but it is also exported as part of Kit [`@trezoa/kit`](https://github.com/trezoa.xyz/kit/tree/main/packages/kit). | ||
| This package contains the core types and functions for encoding and decoding data structures on Trezoa. It can be used standalone, but it is also exported as part of Kit [`@trezoa/kit`](https://github.com/trezoa-xyz/kit/tree/main/packages/kit). | ||
| This package is also part of the [`@trezoa/codecs` package](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs) which acts as an entry point for all codec packages as well as for their documentation. | ||
| This package is also part of the [`@trezoa/codecs` package](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs) which acts as an entry point for all codec packages as well as for their documentation. | ||
| ## Composing codecs | ||
| The easiest way to create your own codecs is to compose the [various codecs](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs) offered by this library. For instance, here’s how you would define a codec for a `Person` object that contains a `name` string attribute and an `age` number stored in 4 bytes. | ||
| The easiest way to create your own codecs is to compose the [various codecs](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs) offered by this library. For instance, here’s how you would define a codec for a `Person` object that contains a `name` string attribute and an `age` number stored in 4 bytes. | ||
@@ -42,10 +42,10 @@ ```ts | ||
| - [`@trezoa/codecs-numbers`](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs-numbers) for number codecs. | ||
| - [`@trezoa/codecs-strings`](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs-strings) for string codecs. | ||
| - [`@trezoa/codecs-data-structures`](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs-data-structures) for many data structure codecs such as objects, arrays, tuples, sets, maps, enums, discriminated unions, booleans, etc. | ||
| - [`@trezoa/options`](https://github.com/trezoa.xyz/kit/tree/main/packages/options) for a Rust-like `Option` type and associated codec. | ||
| - [`@trezoa/codecs-numbers`](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs-numbers) for number codecs. | ||
| - [`@trezoa/codecs-strings`](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs-strings) for string codecs. | ||
| - [`@trezoa/codecs-data-structures`](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs-data-structures) for many data structure codecs such as objects, arrays, tuples, sets, maps, enums, discriminated unions, booleans, etc. | ||
| - [`@trezoa/options`](https://github.com/trezoa-xyz/kit/tree/main/packages/options) for a Rust-like `Option` type and associated codec. | ||
| You may also be interested in some of the helpers of this `@trezoa/codecs-core` library such as `transformCodec`, `fixCodecSize` or `reverseCodec` that create new codecs from existing ones. | ||
| Note that all of these libraries are included in the [`@trezoa/codecs` package](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs) as well as the main `@trezoa/kit` package for your convenience. | ||
| Note that all of these libraries are included in the [`@trezoa/codecs` package](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs) as well as the main `@trezoa/kit` package for your convenience. | ||
@@ -664,2 +664,2 @@ ## Composing encoders and decoders | ||
| To read more about the available codecs and how to use them, check out the documentation of the main [`@trezoa/codecs` package](https://github.com/trezoa.xyz/kit/tree/main/packages/codecs). | ||
| To read more about the available codecs and how to use them, check out the documentation of the main [`@trezoa/codecs` package](https://github.com/trezoa-xyz/kit/tree/main/packages/codecs). |
-79
| NOTICE | ||
| ================================================================================ | ||
| Trezoa Codecs Core - Fork Notice | ||
| ================================================================================ | ||
| This software is a fork of the original @solana/codecs-core package, which was | ||
| created and is maintained by Solana Labs, Inc. and contributors. | ||
| Original Project Information: | ||
| - Original Name: @solana/codecs-core | ||
| - Original Repository: https://github.com/anza-xyz/kit/tree/main/packages/codecs-core | ||
| - Original Copyright: Copyright (c) 2023 Solana Labs, Inc. | ||
| - Original License: MIT License | ||
| Fork Information: | ||
| - Fork Name: @trezoa/codecs-core | ||
| - Fork Repository: https://github.com/trezoa.xyz/kit/tree/main/packages/codecs-core | ||
| - Fork Maintainer: Trezoa-team | ||
| - Fork Date: November 29, 2025 | ||
| ================================================================================ | ||
| Legal Compliance Notice | ||
| ================================================================================ | ||
| This fork is created in compliance with the MIT License terms of the original | ||
| work. The original copyright notice and license terms are preserved in the | ||
| LICENSE file as required. | ||
| Modifications Made: | ||
| - Updated package naming from @solana/* to @trezoa/* | ||
| - Updated repository URLs and maintainer information | ||
| - Updated error handling references from Solana to Trezoa naming conventions | ||
| - Updated documentation and examples to reflect Trezoa ecosystem | ||
| - Updated dependency references to use Trezoa equivalents | ||
| The core functionality, algorithms, and structure of the original codebase | ||
| remain largely unchanged. This fork is intended to provide codec functionality | ||
| within the Trezoa ecosystem while maintaining compatibility with the original | ||
| design principles. | ||
| ================================================================================ | ||
| Attribution and Acknowledgments | ||
| ================================================================================ | ||
| We acknowledge and thank the original authors and contributors of the | ||
| @solana/codecs-core package: | ||
| - Solana Labs, Inc. - Original creators and maintainers | ||
| - All contributors to the original Solana Kit project | ||
| - The broader Solana developer community | ||
| Their work has provided the foundation for this Trezoa ecosystem adaptation. | ||
| ================================================================================ | ||
| License Information | ||
| ================================================================================ | ||
| This software is distributed under the same MIT License as the original work. | ||
| See the LICENSE file for the complete license terms. | ||
| For questions about this fork, please contact: maintainers@trezoa.xyz | ||
| For questions about the original work, please contact: maintainers@solanalabs.com | ||
| ================================================================================ | ||
| Third-Party Dependencies | ||
| ================================================================================ | ||
| This package depends on @trezoa/errors, which is also a fork of the corresponding | ||
| Solana package. Please refer to that package's NOTICE file for additional | ||
| attribution information. | ||
| Original Solana packages and their Trezoa equivalents: | ||
| - @solana/errors → @trezoa/errors | ||
| - @solana/test-config → @trezoa/test-config | ||
| - @solana/kit → @trezoa/kit | ||
| - @solana/codecs → @trezoa/codecs | ||
| ================================================================================ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
937570
0.25%5288
0.49%43
-2.27%1
Infinity%1
Infinity%Updated