How to use the nanoid/url.replace function in nanoid

To help you get started, we’ve selected a few nanoid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DevExpress / testcafe-hammerhead / src / utils / generate-unique-id.ts View on Github external
// @ts-ignore
import nanoIdGenerate from 'nanoid/generate';
// @ts-ignore
import nanoIdAlphabet from 'nanoid/url';

const UNIQUE_ID_ALPHABET: string = nanoIdAlphabet.replace(/-|~/g, '');

const DEFAULT_ID_LENGTH = 9;

export default function (length?: number): string {
    return nanoIdGenerate(UNIQUE_ID_ALPHABET, length || DEFAULT_ID_LENGTH);
}

nanoid

A tiny (116 bytes), secure URL-friendly unique string ID generator

MIT
Latest version published 6 days ago

Package Health Score

91 / 100
Full package analysis