@esm-pack/bcrypt
Version:
bcrypt esm package build from bcrypt-ts
83 lines (82 loc) • 4.32 kB
TypeScript
/**
* utfx-embeddable (c) 2014 Daniel Wirtz <dcode@dcode.io>
* Released under the Apache License, Version 2.0
* see: https://github.com/dcodeIO/utfx for details
*/
export declare const MAX_CODEPOINT = 1114111;
/**
* Encodes UTF8 code points to UTF8 bytes.
* @param nextByte Code points source, either as a function returning the next code point
* respectively `null` if there are no more code points left or a single numeric code point.
* @param destination Bytes destination as a function successively called with the next byte
*/
export declare const encodeUTF8: (nextByte: number | (() => number | null), destination: (byte: number) => void) => void;
export declare class TruncatedError extends Error {
bytes: number[];
constructor(...args: number[]);
}
/**
* Decodes UTF8 bytes to UTF8 code points.
*
* @param nextByte Bytes source as a function returning the next byte respectively `null` if there
* are no more bytes left.
* @param destination Code points destination as a function successively called with each decoded code point.
* @throws {RangeError} If a starting byte is invalid in UTF8
* @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the
* remaining bytes.
*/
export declare const decodeUTF8: (nextByte: () => number | null, destination: (byte: number) => void) => void;
/**
* Converts UTF16 characters to UTF8 code points.
* @param nextByte Characters source as a function returning the next char code respectively
* `null` if there are no more characters left.
* @param destination Code points destination as a function successively called with each converted code
* point.
*/
export declare const UTF16toUTF8: (nextByte: () => number | null, destination: (byte: number) => void) => void;
/**
* Converts UTF8 code points to UTF16 characters.
*
* @param nextByte Code points source, either as a function returning the next code point
* respectively `null` if there are no more code points left or a single numeric code point.
* @param destination Characters destination as a function successively called with each converted char code.
* @throws {RangeError} If a code point is out of range
*/
export declare const UTF8toUTF16: (nextByte: (() => number | null) | number, destination: (byte: number) => void) => void;
/**
* Converts and encodes UTF16 characters to UTF8 bytes.
* @param nextByte Characters source as a function returning the next char code respectively `null`
* if there are no more characters left.
* @param destination Bytes destination as a function successively called with the next byte.
*/
export declare const encodeUTF16toUTF8: (nextByte: () => number | null, destination: (byte: number) => void) => void;
/**
* Decodes and converts UTF8 bytes to UTF16 characters.
* @param nextByte Bytes source as a function returning the next byte respectively `null` if there
* are no more bytes left.
* @param destination Characters destination as a function successively called with each converted char code.
* @throws {RangeError} If a starting byte is invalid in UTF8
* @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the remaining bytes.
*/
export declare const decodeUTF8toUTF16: (nextByte: () => number | null, destination: (byte: number) => void) => void;
/**
* Calculates the byte length of an UTF8 code point.
*
* @param codePoint UTF8 code point
* @returns Byte length
*/
export declare const calculateCodePoint: (codePoint: number) => number;
/**
* Calculates the number of UTF8 bytes required to store UTF8 code points.
* @param src Code points source as a function returning the next code point respectively
* `null` if there are no more code points left.
* @returns The number of UTF8 bytes required
*/
export declare const calculateUTF8: (src: () => number | null) => number;
/**
* Calculates the number of UTF8 code points respectively UTF8 bytes required to store UTF16 char codes.
* @param nextCharCode Characters source as a function returning the next char code respectively
* `null` if there are no more characters left.
* @returns The number of UTF8 code points at index 0 and the number of UTF8 bytes required at index 1.
*/
export declare const calculateUTF16asUTF8: (nextCharCode: () => number | null) => number[];