import { Immutable } from './immutable'; /** * Immutable Array cannot be changed once created */ export declare class ImmutableArray implements Immutable { length: number; private readonly array; /** * The constructor of ImmutableArray * * @typedef T generic type parameter * @param {T[]} initialArray - Optional initial array * @param {() => void} onMutate - Optional callback invoked with the new ImmutableArray whenever a mutation is performed */ constructor(initialArray?: T[], onMutate?: (newArr: ImmutableArray) => void); /** * The function is called when the array is mutated * * @typedef T generic type parameter * @param {ImmutableArray} _newArr - The new array that was created. */ onMutate(_newArr: ImmutableArray): void; /** * Append items to the array and return a new ImmutableArray * * @param {T[]} items - The items to be appended to the array * @returns {ImmutableArray} - a new ImmutableArray with new items pushed. */ push(...items: T[]): ImmutableArray; /** * Remove the last item from the array and return a new ImmutableArray. * If the array is empty, a new ImmutableArray with the same (empty) contents is returned. * * @returns {ImmutableArray} - a new ImmutableArray with the last one popped */ pop(): ImmutableArray; /** * Update the item at the specified index and return a new ImmutableArray. * If the index is out of range, no change is made and a new ImmutableArray (same contents) is returned. * * @param {number} index - Index of the item to update. * @param {T} value - New value to set at the given index. * @returns {ImmutableArray} - a new ImmutableArray with updated item. */ set(index: number, value: T): ImmutableArray; /** * Set values from the provided array into this ImmutableArray one by one * * @param {T[]} values - Array of values to write into this array. * @returns {ImmutableArray} - a new ImmutableArray with updated items. */ setAll(values: T[]): ImmutableArray; /** * Clear the array and return a new ImmutableArray * * @returns {ImmutableArray} return a new ImmutableArray. */ clear(): ImmutableArray; /** * Performs a mutation on a copy of the internal array and returns a new ImmutableArray * * @param {(arr: T[]) => void} fn - (arr: T[]) => void * @returns {ImmutableArray} A new ImmutableArray */ withMutation(fn: (arr: T[]) => void): ImmutableArray; /** * Get item by index * * @param {number} index - index of the array items * @returns {T | undefined} The array item with the index */ get(index: number): T | undefined; /** * Join array elements into a string separated by the given separator. * * @param {string} [separator=','] - Separator to use between elements. * @returns {string} The joined string. */ join(separator?: string): string; /** * It returns an array of the values in the array * * @returns {T[]} An array of the values in the array. */ toArray(): T[]; }