afid
Version:
Random identifiers with some affordances for human usage.
33 lines (32 loc) • 1.39 kB
TypeScript
export interface AfidOptions {
length?: number;
start?: "random" | "letter" | "number";
prefix?: string;
suffix?: string;
segments?: number;
separator?: string;
}
/**
* Generate a short random identifier with affordances for human usage.
* Omits ambiguous characters and avoids forming words or too many
* sequences of one type of character.
*
* @remarks
* The identifiers are not securely generated and are typically short.
* Do not rely on them being secret or unguessable!
*
* @param options.length - (8) The number of random characters in the identifier (excluding prefix, suffix, separators).
* @param options.start - ('random') Whether the identifier should start with a letter, number, or randomly either.
* @param options.prefix - ('') A prefix to add to the identifier.
* @param options.suffix - ('') A suffix to include to the identifier.
* @param options.segments - (1) The number of groupings of characters, delimited by `options.separator` (excludes prefix/suffix).
* @param options.separator - ('-') The character to separate segments with (excludes prefix/suffix).
* @param length_or_options - The length directly, for convenience.
*
* @returns A random identifier.
*/
declare function afid(length_or_options?: number | AfidOptions): string;
declare const _default: typeof afid & {
version: string;
};
export default _default;