UNPKG

4.27 kBSource Map (JSON)View Raw
1{"version":3,"file":"children-differ.esm.js","sources":["../src/consts.ts","../src/ChildrenDiffer.ts","../src/utils.ts","../src/index.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 {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","/*\negjs-children-differ\nCopyright (c) 2019-present NAVER Corp.\nMIT license\n*/\nimport ChildrenDiffer from \"./ChildrenDiffer\";\nexport default ChildrenDiffer;\nexport { diff } from \"./utils\";\nexport * from \"./types\";\n"],"names":["findKeyCallback","Map","undefined","childrenCount","el","__DIFF_KEY__","tslib_1","list","_super","ListDiffer","diff","prevList","listdiff"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAKA,AAAO,IAAMA,eAAe,GAAG,OAAOC,GAAP,KAAe,UAAf,GAC3BC,SAD2B,GAE1B;MACGC,aAAa,GAAG,CAApB;SAEO,UAACC,EAAD;WAAkBA,EAAU,CAACC,YAAX,KAA6BD,EAAU,CAACC,YAAX,GAA0B,EAAEF,aAAzD,CAAD;GAAxB;CAHA,EAFG;;ACGP;;;;;;;AAMA;;;EAA0DG,SAAA,eAAA,QAAA;;;;;;yBAIxD,CACEC,IADF;uBACE,EAAA;MAAAA,SAAA;;;WAEAC,WAAA,KAAA,EAAMD,IAAN,EAAYP,eAAZ;;;uBAEJ;EAT0DS,WAA1D;;ACdA;;;;;AAKA,AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgBC,KACdC,UACAJ;SAEOK,MAAQ,CAAID,QAAJ,EAAcJ,IAAd,EAAoBP,eAApB,CAAf;;;ACnDF;;;;;;;;;"}
\No newline at end of file