UNPKG

iso-base

Version:
44 lines 1.48 kB
/** * * @param {number} value */ export function encodingLength(value: number): 8 | 1 | 2 | 3 | 4 | 5 | 6 | 7; /** * Encodes value into buffer starting at offset. * Returns Uint8Array, with the encoded varint written into it. * If Uint8Array is not provided, it will default to a new Uint8Array. * * @param {number} value * @param {Uint8Array} [buf] * @param {number} [offset] * @returns {[buf: Uint8Array, size: number]} - The buffer and the size of the encoded varint */ export function encode(value: number, buf?: Uint8Array, offset?: number): [buf: Uint8Array, size: number]; /** * Decodes buffer from position offset or default 0 and returns the decoded original integer. * * @param {Uint8Array} buf * @param {number} [offset] * @returns {[code: number, size: number]} - The decoded integer and the size of the encoded varint */ export function decode(buf: Uint8Array, offset?: number): [code: number, size: number]; /** * Tag a Uint8Array with a multicodec prefix * * @param {number} code * @param {Uint8Array} bytes */ export function tag(code: number, bytes: Uint8Array): Uint8Array<ArrayBuffer>; /** * Untag a Uint8Array with a multicodec prefix * * @param {number} code * @param {Uint8Array} taggedBytes */ export function untag(code: number, taggedBytes: Uint8Array): Uint8Array<ArrayBufferLike>; export namespace varint { export { encode }; export { decode }; export { encodingLength }; } //# sourceMappingURL=varint.d.ts.map