Skip to main content
Module

x/nanoid/mod.ts>customAlphabet

A NanoID implementation for Deno
Very Popular
Latest
variable customAlphabet
import { customAlphabet } from "https://deno.land/x/nanoid@v3.0.0/mod.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