fraci
    Preparing search index...

    Function fraci

    • We recommend using fraciBinary or fraciString directly to reduce bundle size whenever possible.

      Creates a fractional indexing utility with the specified configuration. This is the main factory function for creating a Fraci instance that can generate fractional indices between existing values.

      Type Parameters

      • const B extends FraciOptionsBase

        The type of the base characters

      • const X = unknown

        The brand type for the fractional index

      Parameters

      • options: FraciOptions<B> | B & { maxLength?: number; maxRetries?: number } & { brand: X }

        Configuration options for the fractional indexing utility

        • FraciOptions<B>
        • B & { maxLength?: number; maxRetries?: number } & { brand: X }
          • Optional ReadonlymaxLength?: number

            Maximum allowed length for generated keys.

            DEFAULT_MAX_LENGTH (50)
            
          • Optional ReadonlymaxRetries?: number

            Maximum number of retry attempts when generating keys.

            DEFAULT_MAX_RETRIES (5)
            
          • Readonlybrand: X
      • Optionalcache: FraciCache

        Optional cache to improve performance by reusing computed values

      Returns Fraci<FraciOptionsBaseToBase<B>, X>

      A fractional indexing utility instance

      When the digit or length base strings are invalid

      // Create a decimal-based fractional indexing utility
      const decimalFraci = fraci({
      brand: "exampleIndex",
      lengthBase: "abcdefghij"
      digitBase: "0123456789",
      });

      // Generate a key between null and null (first key)
      const [key1] = decimalFraci.generateKeyBetween(null, null);
      // Generate a key between key1 and null (key after key1)
      const [key2] = decimalFraci.generateKeyBetween(key1, null);
      // Generate a key between key1 and key2
      const [key3] = decimalFraci.generateKeyBetween(key1, key2);