Skip to main content
Module

x/sweetid/deps.ts>customAlphabet

Alphanumeric IDs, powered by Nano ID
Go to Latest
variable customAlphabet
import { customAlphabet } from "https://deno.land/x/sweetid@0.9.0/deps.ts";

Low-level function to change alphabet and ID size.

Alphabet must contain 256 symbols or less. Otherwise, the generator will not be secure.

Examples

import { customAlphabet } from "https://deno.land/x/nanoid/customAlphabet.ts";

const alphabet = '0123456789абвгдеё'; const nanoid = customAlphabet(alphabet, 5);

console.log(nanoid()); // => "8ё56а"

type

(alphabet: string, size: number) => unknown