New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ckb-lumos/codec

Package Overview
Dependencies
Maintainers
3
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckb-lumos/codec - npm Package Compare versions

Comparing version 0.19.0-alpha.1 to 0.19.0-alpha.3

lib/error.d.ts

2

lib/high-order/nested.d.ts

@@ -18,3 +18,3 @@ import { AnyCodec, Codec, PackParam, PackResult, UnpackParam, UnpackResult } from "../base";

/**
* a high-order codec that helps to organise multiple codecs together into a single object
* a high-order codec that helps to organize multiple codecs together into a single object
* @param codecShape

@@ -21,0 +21,0 @@ * @example

@@ -11,2 +11,6 @@ "use strict";

var _utils = require("../utils");
var _error = require("../error");
function createNullableCodec(codec) {

@@ -16,3 +20,3 @@ return {

if (packable == null) return packable;
return codec.pack(packable);
return (0, _utils.trackCodeExecuteError)(_error.CODEC_OPTIONAL_PATH, () => codec.pack(packable));
},

@@ -27,3 +31,3 @@ unpack: unpackable => {

/**
* a high-order codec that helps to organise multiple codecs together into a single object
* a high-order codec that helps to organize multiple codecs together into a single object
* @param codecShape

@@ -49,3 +53,3 @@ * @example

Object.assign(result, {
[key]: itemCodec.pack(packableObj[key])
[key]: (0, _utils.trackCodeExecuteError)(key, () => itemCodec.pack(packableObj[key]))
});

@@ -69,3 +73,3 @@ });

return {
pack: items => items.map(item => codec.pack(item)),
pack: items => items.map((item, index) => (0, _utils.trackCodeExecuteError)(index, () => codec.pack(item))),
unpack: items => items.map(item => codec.unpack(item))

@@ -72,0 +76,0 @@ };

@@ -12,3 +12,3 @@ /**

*/
import type { BytesCodec, Fixed, FixedBytesCodec, PackParam, UnpackResult } from "../base";
import { BytesCodec, Fixed, FixedBytesCodec, PackParam, UnpackResult } from "../base";
declare type NullableKeys<O extends Record<string, unknown>> = {

@@ -41,11 +41,56 @@ [K in keyof O]-?: [O[K] & (undefined | null)] extends [never] ? never : K;

}[keyof T]>;
/**
* The array is a fixed-size type: it has a fixed-size inner type and a fixed length.
* The size of an array is the size of inner type times the length.
* @param itemCodec the fixed-size array item codec
* @param itemCount
*/
export declare function array<T extends FixedBytesCodec>(itemCodec: T, itemCount: number): ArrayCodec<T> & Fixed;
/**
* Struct is a fixed-size type: all fields in struct are fixed-size and it has a fixed quantity of fields.
* The size of a struct is the sum of all fields' size.
* @param shape a object contains all fields' codec
* @param fields the shape's keys. It provide an order for serialization/deserialization.
*/
export declare function struct<T extends Record<string, FixedBytesCodec>>(shape: T, fields: (keyof T)[]): ObjectCodec<T> & Fixed;
/**
* Vector with fixed size item codec
* @param itemCodec fixed-size vector item codec
*/
export declare function fixvec<T extends FixedBytesCodec>(itemCodec: T): ArrayCodec<T>;
/**
* Vector with dynamic size item codec
* @param itemCodec the vector item codec. It can be fixed-size or dynamic-size.
* For example, you can create a recursive vector with this.
*/
export declare function dynvec<T extends BytesCodec>(itemCodec: T): ArrayCodec<T>;
/**
* General vector codec, if `itemCodec` is fixed size type, it will create a fixvec codec, otherwise a dynvec codec will be created.
* @param itemCodec
*/
export declare function vector<T extends BytesCodec>(itemCodec: T): ArrayCodec<T>;
/**
* Table is a dynamic-size type. It can be considered as a dynvec but the length is fixed.
* @param shape The table shape, item codec can be dynamic size
* @param fields the shape's keys. Also provide an order for pack/unpack.
*/
export declare function table<T extends Record<string, BytesCodec>>(shape: T, fields: (keyof T)[]): ObjectCodec<T>;
/**
* Union is a dynamic-size type.
* Serializing a union has two steps:
* - Serialize a item type id in bytes as a 32 bit unsigned integer in little-endian. The item type id is the index of the inner items, and it's starting at 0.
* - Serialize the inner item.
* @param itemCodec the union item record
* @param fields the list of itemCodec's keys. It's also provide an order for pack/unpack.
*/
export declare function union<T extends Record<string, BytesCodec>>(itemCodec: T, fields: (keyof T)[]): UnionCodec<T>;
/**
* Option is a dynamic-size type.
* Serializing an option depends on whether it is empty or not:
* - if it's empty, there is zero bytes (the size is 0).
* - if it's not empty, just serialize the inner item (the size is same as the inner item's size).
* @param itemCodec
*/
export declare function option<T extends BytesCodec>(itemCodec: T): OptionCodec<T>;
export {};
//# sourceMappingURL=layout.d.ts.map

@@ -21,2 +21,6 @@ "use strict";

var _error = require("../error");
var _highOrder = require("../high-order");
/**

@@ -33,3 +37,11 @@ * | Type | Header | Body |

*/
/**
* The array is a fixed-size type: it has a fixed-size inner type and a fixed length.
* The size of an array is the size of inner type times the length.
* @param itemCodec the fixed-size array item codec
* @param itemCount
*/
function array(itemCodec, itemCount) {
const enhancedArrayCodec = (0, _highOrder.createArrayCodec)(itemCodec);
return (0, _base.createFixedBytesCodec)({

@@ -39,3 +51,3 @@ byteLength: itemCodec.byteLength * itemCount,

pack(items) {
const itemsBuf = items.map(item => itemCodec.pack(item));
const itemsBuf = enhancedArrayCodec.pack(items);
return (0, _bytes.concat)(...itemsBuf);

@@ -71,5 +83,13 @@ },

}
/**
* Struct is a fixed-size type: all fields in struct are fixed-size and it has a fixed quantity of fields.
* The size of a struct is the sum of all fields' size.
* @param shape a object contains all fields' codec
* @param fields the shape's keys. It provide an order for serialization/deserialization.
*/
function struct(shape, fields) {
checkShape(shape, fields);
const objectCodec = (0, _highOrder.createObjectCodec)(shape);
return (0, _base.createFixedBytesCodec)({

@@ -79,8 +99,5 @@ byteLength: fields.reduce((sum, field) => sum + shape[field].byteLength, 0),

pack(obj) {
const packed = objectCodec.pack(obj);
return fields.reduce((result, field) => {
const itemCodec = shape[field]; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const item = obj[field];
return (0, _bytes.concat)(result, itemCodec.pack(item));
return (0, _bytes.concat)(result, packed[field]);
}, Uint8Array.from([]));

@@ -105,7 +122,13 @@ },

}
/**
* Vector with fixed size item codec
* @param itemCodec fixed-size vector item codec
*/
function fixvec(itemCodec) {
return (0, _base.createBytesCodec)({
pack(items) {
return (0, _bytes.concat)(_number.Uint32LE.pack(items.length), items.reduce((buf, item) => (0, _bytes.concat)(buf, itemCodec.pack(item)), new ArrayBuffer(0)));
const arrayCodec = (0, _highOrder.createArrayCodec)(itemCodec);
return (0, _bytes.concat)(_number.Uint32LE.pack(items.length), arrayCodec.pack(items).reduce((buf, item) => (0, _bytes.concat)(buf, item), new ArrayBuffer(0)));
},

@@ -125,9 +148,14 @@

}
/**
* Vector with dynamic size item codec
* @param itemCodec the vector item codec. It can be fixed-size or dynamic-size.
* For example, you can create a recursive vector with this.
*/
function dynvec(itemCodec) {
return (0, _base.createBytesCodec)({
pack(obj) {
const packed = obj.reduce((result, item) => {
const packedItem = itemCodec.pack(item);
const arrayCodec = (0, _highOrder.createArrayCodec)(itemCodec);
const packed = arrayCodec.pack(obj).reduce((result, item) => {
const packedHeader = _number.Uint32LE.pack(result.offset);

@@ -137,4 +165,4 @@

header: (0, _bytes.concat)(result.header, packedHeader),
body: (0, _bytes.concat)(result.body, packedItem),
offset: result.offset + packedItem.byteLength
body: (0, _bytes.concat)(result.body, item),
offset: result.offset + item.byteLength
};

@@ -184,3 +212,8 @@ }, {

}
/**
* General vector codec, if `itemCodec` is fixed size type, it will create a fixvec codec, otherwise a dynvec codec will be created.
* @param itemCodec
*/
function vector(itemCodec) {

@@ -193,3 +226,9 @@ if ((0, _base.isFixedCodec)(itemCodec)) {

}
/**
* Table is a dynamic-size type. It can be considered as a dynvec but the length is fixed.
* @param shape The table shape, item codec can be dynamic size
* @param fields the shape's keys. Also provide an order for pack/unpack.
*/
function table(shape, fields) {

@@ -200,9 +239,7 @@ checkShape(shape, fields);

const headerLength = 4 + fields.length * 4;
const objectCodec = (0, _highOrder.createObjectCodec)(shape);
const packedObj = objectCodec.pack(obj);
const packed = fields.reduce((result, field) => {
const itemCodec = shape[field]; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const packedItem = packedObj[field];
const item = obj[field];
const packedItem = itemCodec.pack(item);
const packedOffset = _number.Uint32LE.pack(result.offset);

@@ -257,3 +294,12 @@

}
/**
* Union is a dynamic-size type.
* Serializing a union has two steps:
* - Serialize a item type id in bytes as a 32 bit unsigned integer in little-endian. The item type id is the index of the inner items, and it's starting at 0.
* - Serialize the inner item.
* @param itemCodec the union item record
* @param fields the list of itemCodec's keys. It's also provide an order for pack/unpack.
*/
function union(itemCodec, fields) {

@@ -263,6 +309,7 @@ return (0, _base.createBytesCodec)({

const type = obj.type;
const typeName = `Union(${fields.join(" | ")})`;
/* c8 ignore next */
if (typeof type !== "string") {
throw new Error(`Invalid type in union, type must be a string`);
throw new _error.CodecBaseParseError(`Invalid type in union, type must be a string`, typeName);
}

@@ -273,3 +320,3 @@

if (fieldIndex === -1) {
throw new Error(`Unknown union type: ${String(obj.type)}`);
throw new _error.CodecBaseParseError(`Unknown union type: ${String(obj.type)}`, typeName);
}

@@ -295,8 +342,18 @@

}
/**
* Option is a dynamic-size type.
* Serializing an option depends on whether it is empty or not:
* - if it's empty, there is zero bytes (the size is 0).
* - if it's not empty, just serialize the inner item (the size is same as the inner item's size).
* @param itemCodec
*/
function option(itemCodec) {
return (0, _base.createBytesCodec)({
pack(obj) {
const nullableCodec = (0, _highOrder.createNullableCodec)(itemCodec);
if (obj !== undefined && obj !== null) {
return itemCodec.pack(obj);
return nullableCodec.pack(obj);
} else {

@@ -303,0 +360,0 @@ return Uint8Array.from([]);

@@ -12,7 +12,9 @@ "use strict";

function assertNumberRange(value, min, max) {
var _error = require("../error");
function assertNumberRange(value, min, max, typeName) {
value = _bi.BI.from(value);
if (value.lt(min) || value.gt(max)) {
throw new Error(`Value must be between ${min.toString()} and ${max.toString()}, but got ${value.toString()}`);
throw new _error.CodecBaseParseError(`Value must be between ${min.toString()} and ${max.toString()}, but got ${value.toString()}`, typeName);
}

@@ -38,4 +40,12 @@ }

pack(biIsh) {
let endianType = littleEndian ? "LE" : "BE";
if (byteLength <= 1) {
endianType = "";
}
const typeName = `Uint${byteLength * 8}${endianType}`;
if (typeof biIsh === "number" && !Number.isSafeInteger(biIsh)) {
throw new Error(`${biIsh} is not a safe integer`);
throw new _error.CodecBaseParseError(`${biIsh} is not a safe integer`, typeName);
}

@@ -45,3 +55,3 @@

assertNumberRange(num, 0, max);
assertNumberRange(num, 0, max, typeName);
const result = new DataView(new ArrayBuffer(byteLength));

@@ -48,0 +58,0 @@

@@ -11,2 +11,3 @@ export declare function assertHexDecimal(str: string, byteLength?: number): void;

export declare function isObjectLike(x: unknown): x is Record<string, unknown>;
export declare function trackCodeExecuteError<T>(path: string | number | symbol, fn: () => T): T;
//# sourceMappingURL=utils.d.ts.map

@@ -12,2 +12,6 @@ "use strict";

exports.isObjectLike = isObjectLike;
exports.trackCodeExecuteError = trackCodeExecuteError;
var _error = require("./error");
const HEX_DECIMAL_REGEX = /^0x([0-9a-fA-F])+$/;

@@ -85,2 +89,12 @@ const HEX_DECIMAL_WITH_BYTELENGTH_REGEX_MAP = new Map();

}
function trackCodeExecuteError(path, fn) {
try {
return fn();
} catch (e) {
const readableError = (0, _error.isCodecExecuteError)(e) ? e : new _error.CodecExecuteError(e);
readableError.updateKey(path);
throw readableError;
}
}
//# sourceMappingURL=utils.js.map
{
"name": "@ckb-lumos/codec",
"version": "0.19.0-alpha.1",
"version": "0.19.0-alpha.3",
"description": "Make your own molecule binding in JavaScript(TypeScript)",
"author": "",
"homepage": "https://github.com/nervosnetwork/lumos#readme",
"homepage": "https://github.com/ckb-js/lumos#readme",
"license": "MIT",

@@ -19,3 +19,3 @@ "main": "lib/index.js",

"type": "git",
"url": "git+https://github.com/nervosnetwork/lumos.git"
"url": "git+https://github.com/ckb-js/lumos.git"
},

@@ -34,3 +34,3 @@ "scripts": {

"dependencies": {
"@ckb-lumos/bi": "^0.19.0-alpha.1"
"@ckb-lumos/bi": "^0.19.0-alpha.3"
},

@@ -41,3 +41,3 @@ "publishConfig": {

"bugs": {
"url": "https://github.com/nervosnetwork/lumos/issues"
"url": "https://github.com/ckb-js/lumos/issues"
},

@@ -53,5 +53,6 @@ "ava": {

"devDependencies": {
"escape-string-regexp": "^4.0.0",
"js-yaml": "^4.1.0"
},
"gitHead": "f244d81773326f206460014f8f305fcf08d88462"
"gitHead": "73af0bc3b396c40c2dbfe570d203f377f63aa993"
}

@@ -9,2 +9,4 @@ import {

} from "../base";
import { trackCodeExecuteError } from "../utils";
import { CODEC_OPTIONAL_PATH } from "../error";

@@ -23,3 +25,5 @@ export interface NullableCodec<C extends AnyCodec = AnyCodec> extends AnyCodec {

if (packable == null) return packable;
return codec.pack(packable);
return trackCodeExecuteError(CODEC_OPTIONAL_PATH, () =>
codec.pack(packable)
);
},

@@ -43,3 +47,3 @@ unpack: (unpackable) => {

/**
* a high-order codec that helps to organise multiple codecs together into a single object
* a high-order codec that helps to organize multiple codecs together into a single object
* @param codecShape

@@ -68,3 +72,7 @@ * @example

codecEntries.forEach(([key, itemCodec]) => {
Object.assign(result, { [key]: itemCodec.pack(packableObj[key]) });
Object.assign(result, {
[key]: trackCodeExecuteError(key, () =>
itemCodec.pack(packableObj[key])
),
});
});

@@ -95,3 +103,6 @@

return {
pack: (items) => items.map((item) => codec.pack(item)),
pack: (items) =>
items.map((item, index) =>
trackCodeExecuteError(index, () => codec.pack(item))
),
unpack: (items) => items.map((item) => codec.unpack(item)),

@@ -98,0 +109,0 @@ };

@@ -13,3 +13,3 @@ /**

import type {
import {
BytesCodec,

@@ -20,6 +20,14 @@ Fixed,

UnpackResult,
createBytesCodec,
createFixedBytesCodec,
isFixedCodec,
} from "../base";
import { createBytesCodec, createFixedBytesCodec, isFixedCodec } from "../base";
import { Uint32LE } from "../number";
import { concat } from "../bytes";
import { CodecBaseParseError } from "../error";
import {
createObjectCodec,
createArrayCodec,
createNullableCodec,
} from "../high-order";

@@ -58,2 +66,8 @@ type NullableKeys<O extends Record<string, unknown>> = {

/**
* The array is a fixed-size type: it has a fixed-size inner type and a fixed length.
* The size of an array is the size of inner type times the length.
* @param itemCodec the fixed-size array item codec
* @param itemCount
*/
export function array<T extends FixedBytesCodec>(

@@ -63,6 +77,7 @@ itemCodec: T,

): ArrayCodec<T> & Fixed {
const enhancedArrayCodec = createArrayCodec(itemCodec);
return createFixedBytesCodec({
byteLength: itemCodec.byteLength * itemCount,
pack(items) {
const itemsBuf = items.map((item) => itemCodec.pack(item));
const itemsBuf = enhancedArrayCodec.pack(items);
return concat(...itemsBuf);

@@ -100,2 +115,8 @@ },

/**
* Struct is a fixed-size type: all fields in struct are fixed-size and it has a fixed quantity of fields.
* The size of a struct is the sum of all fields' size.
* @param shape a object contains all fields' codec
* @param fields the shape's keys. It provide an order for serialization/deserialization.
*/
export function struct<T extends Record<string, FixedBytesCodec>>(

@@ -106,13 +127,11 @@ shape: T,

checkShape(shape, fields);
const objectCodec = createObjectCodec(shape);
return createFixedBytesCodec({
byteLength: fields.reduce((sum, field) => sum + shape[field].byteLength, 0),
pack(obj) {
const packed = objectCodec.pack(
obj as { [K in keyof T]: PackParam<T[K]> }
);
return fields.reduce((result, field) => {
const itemCodec = shape[field];
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const item = obj[field];
return concat(result, itemCodec.pack(item));
return concat(result, packed[field]);
}, Uint8Array.from([]));

@@ -139,11 +158,15 @@ },

/**
* Vector with fixed size item codec
* @param itemCodec fixed-size vector item codec
*/
export function fixvec<T extends FixedBytesCodec>(itemCodec: T): ArrayCodec<T> {
return createBytesCodec({
pack(items) {
const arrayCodec = createArrayCodec(itemCodec);
return concat(
Uint32LE.pack(items.length),
items.reduce(
(buf, item) => concat(buf, itemCodec.pack(item)),
new ArrayBuffer(0)
)
arrayCodec
.pack(items)
.reduce((buf, item) => concat(buf, item), new ArrayBuffer(0))
);

@@ -163,13 +186,18 @@ },

/**
* Vector with dynamic size item codec
* @param itemCodec the vector item codec. It can be fixed-size or dynamic-size.
* For example, you can create a recursive vector with this.
*/
export function dynvec<T extends BytesCodec>(itemCodec: T): ArrayCodec<T> {
return createBytesCodec({
pack(obj) {
const packed = obj.reduce(
const arrayCodec = createArrayCodec(itemCodec);
const packed = arrayCodec.pack(obj).reduce(
(result, item) => {
const packedItem = itemCodec.pack(item);
const packedHeader = Uint32LE.pack(result.offset);
return {
header: concat(result.header, packedHeader),
body: concat(result.body, packedItem),
offset: result.offset + packedItem.byteLength,
body: concat(result.body, item),
offset: result.offset + item.byteLength,
};

@@ -220,2 +248,6 @@ },

/**
* General vector codec, if `itemCodec` is fixed size type, it will create a fixvec codec, otherwise a dynvec codec will be created.
* @param itemCodec
*/
export function vector<T extends BytesCodec>(itemCodec: T): ArrayCodec<T> {

@@ -228,2 +260,7 @@ if (isFixedCodec(itemCodec)) {

/**
* Table is a dynamic-size type. It can be considered as a dynvec but the length is fixed.
* @param shape The table shape, item codec can be dynamic size
* @param fields the shape's keys. Also provide an order for pack/unpack.
*/
export function table<T extends Record<string, BytesCodec>>(

@@ -237,9 +274,9 @@ shape: T,

const headerLength = 4 + fields.length * 4;
const objectCodec = createObjectCodec(shape);
const packedObj = objectCodec.pack(
obj as { [K in keyof T]: PackParam<T[K]> }
);
const packed = fields.reduce(
(result, field) => {
const itemCodec = shape[field];
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const item = obj[field];
const packedItem = itemCodec.pack(item);
const packedItem = packedObj[field];
const packedOffset = Uint32LE.pack(result.offset);

@@ -296,2 +333,10 @@ return {

/**
* Union is a dynamic-size type.
* Serializing a union has two steps:
* - Serialize a item type id in bytes as a 32 bit unsigned integer in little-endian. The item type id is the index of the inner items, and it's starting at 0.
* - Serialize the inner item.
* @param itemCodec the union item record
* @param fields the list of itemCodec's keys. It's also provide an order for pack/unpack.
*/
export function union<T extends Record<string, BytesCodec>>(

@@ -304,6 +349,10 @@ itemCodec: T,

const type = obj.type;
const typeName = `Union(${fields.join(" | ")})`;
/* c8 ignore next */
if (typeof type !== "string") {
throw new Error(`Invalid type in union, type must be a string`);
throw new CodecBaseParseError(
`Invalid type in union, type must be a string`,
typeName
);
}

@@ -313,3 +362,6 @@

if (fieldIndex === -1) {
throw new Error(`Unknown union type: ${String(obj.type)}`);
throw new CodecBaseParseError(
`Unknown union type: ${String(obj.type)}`,
typeName
);
}

@@ -328,7 +380,15 @@ const packedFieldIndex = Uint32LE.pack(fieldIndex);

/**
* Option is a dynamic-size type.
* Serializing an option depends on whether it is empty or not:
* - if it's empty, there is zero bytes (the size is 0).
* - if it's not empty, just serialize the inner item (the size is same as the inner item's size).
* @param itemCodec
*/
export function option<T extends BytesCodec>(itemCodec: T): OptionCodec<T> {
return createBytesCodec({
pack(obj?) {
const nullableCodec = createNullableCodec(itemCodec);
if (obj !== undefined && obj !== null) {
return itemCodec.pack(obj);
return nullableCodec.pack(obj);
} else {

@@ -335,0 +395,0 @@ return Uint8Array.from([]);

import { BI, BIish } from "@ckb-lumos/bi";
import { createFixedBytesCodec, FixedBytesCodec } from "../base";
import { CodecBaseParseError } from "../error";
function assertNumberRange(value: BIish, min: BIish, max: BIish): void {
function assertNumberRange(
value: BIish,
min: BIish,
max: BIish,
typeName: string
): void {
value = BI.from(value);
if (value.lt(min) || value.gt(max)) {
throw new Error(
`Value must be between ${min.toString()} and ${max.toString()}, but got ${value.toString()}`
throw new CodecBaseParseError(
`Value must be between ${min.toString()} and ${max.toString()}, but got ${value.toString()}`,
typeName
);

@@ -35,8 +42,17 @@ }

pack(biIsh) {
let endianType: "LE" | "BE" | "" = littleEndian ? "LE" : "BE";
if (byteLength <= 1) {
endianType = "";
}
const typeName = `Uint${byteLength * 8}${endianType}`;
if (typeof biIsh === "number" && !Number.isSafeInteger(biIsh)) {
throw new Error(`${biIsh} is not a safe integer`);
throw new CodecBaseParseError(
`${biIsh} is not a safe integer`,
typeName
);
}
let num = BI.from(biIsh);
assertNumberRange(num, 0, max);
assertNumberRange(num, 0, max, typeName);

@@ -43,0 +59,0 @@ const result = new DataView(new ArrayBuffer(byteLength));

@@ -0,1 +1,7 @@

import {
CodecBaseParseError,
CodecExecuteError,
isCodecExecuteError,
} from "./error";
const HEX_DECIMAL_REGEX = /^0x([0-9a-fA-F])+$/;

@@ -82,1 +88,16 @@ const HEX_DECIMAL_WITH_BYTELENGTH_REGEX_MAP = new Map<number, RegExp>();

}
export function trackCodeExecuteError<T>(
path: string | number | symbol,
fn: () => T
): T {
try {
return fn();
} catch (e) {
const readableError = isCodecExecuteError(e)
? e
: new CodecExecuteError(e as CodecBaseParseError);
readableError.updateKey(path);
throw readableError;
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc