import { type MapFunction } from '../value'; /** * A bitwise set is limited to 32 values, the numbers 0-31. * * This is because Javascript performs bitwise calculations on 32-bit values. */ export declare const MAX_BITWISE_SET_SIZE = 32; /** * Enum or number value from 0 to 31 that denotes a specific item via index of the bit to measure. */ export type BitwiseEncodedSetIndex = number; /** * Set of values that are encoded into a single number. * * The number can include up to 32 unique boolean values. */ export type BitwiseEncodedSet = number; /** * Encodes a BitwiseEncodedSet from a set of values. */ export type BitwiseSetEncoder = (set: Set) => BitwiseEncodedSet; /** * Encodes a Set of bit indices into a single {@link BitwiseEncodedSet} number using bitwise OR. * * @param input - Set of indices (0-31) to encode * @returns A number with bits set at each index position */ export declare function encodeBitwiseSet(input: Set): BitwiseEncodedSet; /** * Decodes an BitwiseEncodedSet to a Set of values. */ export type BitwiseSetDecoder = (set: BitwiseEncodedSet) => Set; /** * Creates a decoder that converts a {@link BitwiseEncodedSet} number back into a Set of indices by checking each bit position up to `maxIndex`. * * @param maxIndex - The exclusive upper bound of indices to check * @returns A function that decodes an encoded number into a Set of active indices */ export declare function bitwiseSetDecoder(maxIndex: number): BitwiseSetDecoder; /** * Default decoder that checks all 32 bit positions. */ export declare const dencodeBitwiseSet: BitwiseSetDecoder; /** * Encodes and Decodes a BitwiseEncodedSet, depending on the input. */ export type BitwiseSetDencoder = BitwiseSetEncoder & BitwiseSetDecoder; /** * Creates a bidirectional encoder/decoder for {@link BitwiseEncodedSet}. * * Accepts either a Set (encodes to number) or a number (decodes to Set). * * @param maxIndex - Optional exclusive upper bound of indices for decoding; defaults to 32 * @returns A function that encodes Sets to numbers and decodes numbers to Sets */ export declare function bitwiseSetDencoder(maxIndex?: number): BitwiseSetDencoder; /** * Maps the input object to a set of index values. */ export type BitwiseObjectToSetFunction = MapFunction>; /** * Maps the input object from a set of index values. */ export type BitwiseObjectFromSetFunction = MapFunction, T>; /** * Encodes the input object to a BitwiseEncodedSet. */ export type BitwiseObjectEncoder = (object: T) => BitwiseEncodedSet; /** * Creates a {@link BitwiseObjectEncoder} that converts an object to a {@link BitwiseEncodedSet} number. * * Uses the provided `toSetFunction` to first map the object to a Set of indices, then encodes it. * * @param toSetFunction - Function that maps an object to a Set of bit indices * @returns An encoder function that produces a bitwise-encoded number from the object */ export declare function bitwiseObjectEncoder(toSetFunction: BitwiseObjectToSetFunction): BitwiseObjectEncoder; /** * Decodes an object from the input BitwiseEncodedSet. */ export type BitwiseObjectDecoder = (set: BitwiseEncodedSet) => T; /** * Creates a {@link BitwiseObjectDecoder} that converts a {@link BitwiseEncodedSet} number back into an object. * * @param fromSetFunction - Function that maps a Set of bit indices back to an object * @param maxIndex - Optional exclusive upper bound of indices for decoding; defaults to 32 * @returns A decoder function that produces an object from a bitwise-encoded number */ export declare function bitwiseObjectdecoder(fromSetFunction: BitwiseObjectFromSetFunction, maxIndex?: number): BitwiseObjectDecoder; /** * Encodes/Decodes an object. */ export type BitwiseObjectDencoder = BitwiseObjectEncoder & BitwiseObjectDecoder; export interface BitwiseObjectDencoderConfig { readonly toSetFunction: BitwiseObjectToSetFunction; readonly fromSetFunction: BitwiseObjectFromSetFunction; /** * The max index, exclusive */ readonly maxIndex?: number; } /** * Creates a bidirectional {@link BitwiseObjectDencoder} that encodes objects to numbers and decodes numbers back to objects. * * Accepts either a number (decodes to object) or an object (encodes to number). Returns 0 for null/undefined input. * * @param config - Configuration with `toSetFunction`, `fromSetFunction`, and optional `maxIndex` * @returns A function that encodes objects to numbers and decodes numbers to objects */ export declare function bitwiseObjectDencoder(config: BitwiseObjectDencoderConfig): BitwiseObjectDencoder;