@helios-lang/codec-utils
Advanced tools
Comparing version 0.1.22 to 0.1.23
{ | ||
"name": "@helios-lang/codec-utils", | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"description": "Primitive manipulation functions commonly used in encoding and decoding algorithms", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -16,11 +16,2 @@ /** | ||
/** | ||
* @typedef {string | number[] | {bytes: number[]}} ByteArrayLike | ||
*/ | ||
/** | ||
* Permissive conversion to bytes | ||
* @param {ByteArrayLike} b | ||
* @returns {number[]} | ||
*/ | ||
export function toBytes(b: ByteArrayLike): number[]; | ||
/** | ||
* Converts a list of uint8 bytes into its hexadecimal string representation. | ||
@@ -33,5 +24,2 @@ * @example | ||
export function bytesToHex(bytes: number[]): string; | ||
export type ByteArrayLike = string | number[] | { | ||
bytes: number[]; | ||
}; | ||
//# sourceMappingURL=base16.d.ts.map |
@@ -26,2 +26,6 @@ import { padBits } from "../bits/index.js" | ||
if (hex.startsWith("#")) { | ||
hex = hex.slice(1) | ||
} | ||
const bytes = [] | ||
@@ -49,23 +53,2 @@ | ||
/** | ||
* @typedef {string | number[] | {bytes: number[]}} ByteArrayLike | ||
*/ | ||
/** | ||
* Permissive conversion to bytes | ||
* @param {ByteArrayLike} b | ||
* @returns {number[]} | ||
*/ | ||
export function toBytes(b) { | ||
if (Array.isArray(b)) { | ||
return b | ||
} else if (typeof b == "string") { | ||
return hexToBytes(b) | ||
} else if (typeof b == "object" && "bytes" in b) { | ||
return b.bytes | ||
} else { | ||
throw new Error("not ByteArrayLike") | ||
} | ||
} | ||
/** | ||
* Converts a list of uint8 bytes into its hexadecimal string representation. | ||
@@ -72,0 +55,0 @@ * @example |
export * from "./bits/index.js"; | ||
export * from "./bytes/index.js"; | ||
export * from "./int/index.js"; | ||
export * from "./option/index.js"; | ||
export * from "./utf8/index.js"; | ||
export type Option<T> = import("./option/index.js").Option<T>; | ||
//# sourceMappingURL=index.d.ts.map |
export * from "./bits/index.js" | ||
export * from "./bytes/index.js" | ||
export * from "./int/index.js" | ||
export * from "./option/index.js" | ||
export * from "./utf8/index.js" | ||
/** | ||
* @template T | ||
* @typedef {import("./option/index.js").Option<T>} Option | ||
*/ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67327
63
2051