campfire.js
    Preparing search index...

    Function ids

    • Returns a function that generates random alphanumeric IDs with an optional prefix. Each generated ID is unique within the scope of the returned function.

      Useful for creating unique HTML element IDs, form field IDs, or any scenario where you need to generate multiple unique identifiers.

      Note: This function is not suitable for generating IDs that require high entropy or cryptographic security.

      Parameters

      • prefix: string = 'cf-'

        The prefix to use. Defaults to 'cf-'.

      Returns () => string

      A function that generates a unique ID.

      const genId = ids();
      console.log(genId()) // cf-k9yh28
      const todoId = ids('todo');
      console.log(todoId()) // todo-hv9p4y