Function customAlphabet

  • Generate a unique ID based on a custom alphabet. This method uses the non-secure predictable random generator with bigger collision probability.

    Returns

    A random string generator.

    import { customAlphabet } from 'nanoid/non-secure'
    const nanoid = customAlphabet('0123456789абвгдеё', 5)
    model.id = //=> "8ё56а"

    Parameters

    • alphabet: string

      Alphabet used to generate the ID.

    • Optional defaultSize: number

      Size of the ID. The default size is 21.

    Returns ((size?: number) => string)

      • (size?: number): string
      • Parameters

        • Optional size: number

        Returns string

Generated using TypeDoc