The base configuration defining the encoding strategy
The brand type for the fractional index
Configuration options for the fractional indexing utility
Optional ReadonlymaxLength?: numberMaximum allowed length for generated keys.
Optional ReadonlymaxRetries?: numberMaximum number of retry attempts when generating keys.
Readonlybrand: XOptionalcache: FraciCacheOptional cache to improve performance by reusing computed values
A fractional indexing utility instance
Throws a FraciError 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);
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.