UNPKG

3.93 kBSource Map (JSON)View Raw
1{"version":3,"file":"children-differ.min.js","sources":["../src/consts.ts","../src/ChildrenDiffer.ts","../src/index.umd.ts","../src/utils.ts"],"sourcesContent":["/*\negjs-children-differ\nCopyright (c) 2019-present NAVER Corp.\nMIT license\n*/\nexport const findKeyCallback = typeof Map === \"function\"\n ? undefined\n : (() => {\n let childrenCount = 0;\n\n return (el: Element) => (el as any).__DIFF_KEY__ || ((el as any).__DIFF_KEY__ = ++childrenCount);\n })();\n","/*\negjs-children-differ\nCopyright (c) 2019-present NAVER Corp.\nMIT license\n*/\nimport ListDiffer, { ListFormat } from \"@egjs/list-differ\";\nimport { findKeyCallback } from \"./consts\";\n\n/**\n * A module that checks diff when child are added, removed, or changed .\n * @ko 자식 노드들에서 자식 노드가 추가되거나 삭제되거나 순서가 변경된 사항을 체크하는 모듈입니다.\n * @memberof eg\n * @extends eg.ListDiffer\n */\nclass ChildrenDiffer<T extends Element = Element> extends ListDiffer<T> {\n /**\n * @param - Initializing Children <ko> 초기 설정할 자식 노드들</ko>\n */\n constructor(\n list: ListFormat<T> = [],\n ) {\n super(list, findKeyCallback);\n }\n}\nexport default ChildrenDiffer;\n","/*\negjs-children-differ\nCopyright (c) 2019-present NAVER Corp.\nMIT license\n*/\nimport ChildrenDiffer, { diff } from \"./index\";\n\n(ChildrenDiffer as any).diff = diff;\nexport default ChildrenDiffer;\n","/*\negjs-children-differ\nCopyright (c) 2019-present NAVER Corp.\nMIT license\n*/\nimport {diff as listdiff} from \"@egjs/list-differ\";\nimport { findKeyCallback } from \"./consts\";\nimport { ChildrenDiffResult } from \"./types\";\n\n\n/**\n *\n * @memberof eg.ChildrenDiffer\n * @static\n * @function\n * @param - Previous List <ko> 이전 목록 </ko>\n * @param - List to Update <ko> 업데이트 할 목록 </ko>\n * @return - Returns the diff between `prevList` and `list` <ko> `prevList`와 `list`의 다른 점을 반환한다.</ko>\n * @example\n * import { diff } from \"@egjs/children-differ\";\n * // script => eg.ChildrenDiffer.diff\n * const result = diff([0, 1, 2, 3, 4, 5], [7, 8, 0, 4, 3, 6, 2, 1]);\n * // List before update\n * // [1, 2, 3, 4, 5]\n * console.log(result.prevList);\n * // Updated list\n * // [4, 3, 6, 2, 1]\n * console.log(result.list);\n * // Index array of values added to `list`\n * // [0, 1, 5]\n * console.log(result.added);\n * // Index array of values removed in `prevList`\n * // [5]\n * console.log(result.removed);\n * // An array of index pairs of `prevList` and `list` with different indexes from `prevList` and `list`\n * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]]\n * console.log(result.changed);\n * // 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]>)\n * // [[4, 3], [3, 4], [2, 6]]\n * console.log(result.pureChanged);\n * // An array of index pairs to be `ordered` that can synchronize `list` before adding data. (Formatted by: Array<[prevIndex, nextIndex]>)\n * // [[4, 1], [4, 2], [4, 3]]\n * console.log(result.ordered);\n * // An array of index pairs of `prevList` and `list` that have not been added/removed so data is preserved\n * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]]\n * console.log(result.maintained);\n */\nexport function diff<T extends Element = Element>(\n prevList: T[],\n list: T[],\n): ChildrenDiffResult<T> {\n return listdiff<T>(prevList, list, findKeyCallback);\n}\n"],"names":["childrenCount","findKeyCallback","Map","undefined","el","__DIFF_KEY__","list","_super","tslib_1","ListDiffer","ChildrenDiffer","diff","prevList","listdiff"],"mappings":";;;;;;;;idAKO,IAGCA,EAHKC,EAAiC,mBAARC,SAClCC,GAEIH,EAAgB,EAEb,SAACI,UAAiBA,EAAWC,eAAkBD,EAAWC,eAAiBL,8BCSlFM,uBAAAA,MAEAC,YAAMD,EAAML,2IAP0CO,SAAAC,UCPzDC,EAAuBC,cCyCtBC,EACAN,UAEOO,OAAYD,EAAUN,EAAML"}
\No newline at end of file