import { DiffResult, ListFormat } from "./types"; /** * A module that checks diff when values are added, removed, or changed in an array. * @ko 배열 또는 오브젝트에서 값이 추가되거나 삭제되거나 순서가 변경사항을 체크하는 모듈입니다. * @memberof eg */ declare class ListDiffer { private findKeyCallback?; private list; /** * @param - Initializing Data Array. 초기 설정할 데이터 배열. * @param - This callback function returns the key of the item. 아이템의 키를 반환하는 콜백 함수입니다. * @example * import ListDiffer from "@egjs/list-differ"; * // script => eg.ListDiffer * const differ = new ListDiffer([0, 1, 2, 3, 4, 5], e => e); * const result = differ.update([7, 8, 0, 4, 3, 6, 2, 1]); * // List before update * // [1, 2, 3, 4, 5] * console.log(result.prevList); * // Updated list * // [4, 3, 6, 2, 1] * console.log(result.list); * // Index array of values added to `list`. * // [0, 1, 5] * console.log(result.added); * // Index array of values removed in `prevList`. * // [5] * console.log(result.removed); * // An array of index pairs of `prevList` and `list` with different indexes from `prevList` and `list`. * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] * console.log(result.changed); * // The subset of `changed` and an array of index pairs that moved data directly. Indicate an array of absolute index pairs of `ordered`.(Formatted by: Array<[index of prevList, index of list]>) * // [[4, 3], [3, 4], [2, 6]] * console.log(result.pureChanged); * // An array of index pairs to be `ordered` that can synchronize `list` before adding data. (Formatted by: Array<[prevIndex, nextIndex]>) * // [[4, 1], [4, 2], [4, 3]] * console.log(result.ordered); * // An array of index pairs of `prevList` and `list` that have not been added/removed so data is preserved. * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] * console.log(result.maintained); */ constructor(list?: ListFormat, findKeyCallback?: (e: T, i: number, arr: T[]) => number | string); /** * Update list. * @ko 리스트를 업데이트를 합니다. * @param - List to update 업데이트할 리스트 * @return - Returns the results of an update from `prevList` to `list`. `prevList`에서 `list`로 업데이트한 결과를 반환한다. */ update(list: ListFormat): DiffResult; } export default ListDiffer;