@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
39 lines (38 loc) • 1.34 kB
TypeScript
export declare function mockStringId(id: string): void;
export declare function unmockStringId(): void;
/**
* Generate cryptographically-secure string id.
* Powered by `nanoid`.
*/
export declare function stringId(length?: number, alphabet?: string): string;
/**
* Generate a string id of Base62 alphabet (same as "alphanumeric": A-Za-z0-9)
*
* Length is 16 (non-configurable currently).
*/
export declare const stringIdBase62: () => string;
/**
* Generate a string id of Base64 alphabet: A-Za-z0-9+/
*
* Default length is 16.
* Length should be dividable by 4 (otherwise unexpected length will be produced).
*
* Dividable by 4 lengths produce ids with no padding `=` characters, which is optimal.
*/
export declare function stringIdBase64(size?: number): string;
/**
* Generate a string id of Base64url alphabet: A-Za-z0-9-_
*
* Default length is 16.
* Length should be dividable by 4 (otherwise unexpected length will be produced).
*
* Base64url always produces strings without a padding character `=`, by design.
*/
export declare function stringIdBase64Url(size?: number): string;
/**
* Generate cryptographically-secure string id with non-ambiguous characters only,
* e.g. missing O and 0, I and 1 and l etc.
*
* Default length is 16.
*/
export declare function stringIdNonAmbiguous(size?: number): string;