How to use the nanoid/async 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 terascope / teraslice / packages / elasticsearch-store / src / utils / model.ts View on Github external
export async function makeId(len = 12): Promise {
    const id = await nanoid(len);
    const result = badIdRegex.exec(id);
    if (result && result[0].length) {
        const chars = generate('1234567890abcdef', result[0].length);
        return id.replace(badIdRegex, chars);
    }
    return id;
}
github terascope / teraslice / packages / data-access / src / utils / misc.ts View on Github external
export async function makeId(len = 12): Promise {
    const id = await nanoid(len);
    const result = badIdRegex.exec(id);
    if (result && result[0].length) {
        const chars = generate('1234567890abcdef', result[0].length);
        return id.replace(badIdRegex, chars);
    }
    return id;
}

nanoid

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

MIT
Latest version published 3 months ago

Package Health Score

85 / 100
Full package analysis