The type of the base characters
The brand type for the fractional index
Configuration options for the fractional indexing utility
Optional
Readonly
maxLength?: numberMaximum allowed length for generated keys.
Optional
Readonly
maxRetries?: numberMaximum number of retry attempts when generating keys.
Readonly
brand: XOptional
cache: FraciCacheOptional cache to improve performance by reusing computed values
A fractional indexing utility instance
// 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.