UNPKG

4.65 kBSource Map (JSON)View Raw
1{"version":3,"file":"children-differ.js","sources":["../src/consts.ts","../src/ChildrenDiffer.ts","../src/utils.ts","../src/index.ts","../src/index.umd.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","/*\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"],"names":["findKeyCallback","Map","undefined","childrenCount","el","__DIFF_KEY__","tslib_1","list","_super","ListDiffer","diff","prevList","listdiff","ChildrenDiffer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;;;;AAKA,IAAO,IAAMA,eAAe,GAAG,OAAOC,GAAP,KAAe,UAAf,GAC3BC,SAD2B,GAE1B;IACD,MAAIC,aAAa,GAAG,CAApB;IAEA,SAAO,UAACC,EAAD;IAAiB,WAACA,EAAU,CAACC,YAAX,KAA6BD,EAAU,CAACC,YAAX,GAA0B,EAAEF,aAAzD,CAAD;IAAwE,GAAhG;IACD,CAJC,EAFG;;ICGP;;;;;;;IAMA;;;IAA0DG,EAAAA,SAAA,eAAA,QAAA;IACxD;;;;;IAGA,yBAAA,CACEC,IADF;IACE,uBAAA,EAAA;IAAAA,MAAAA,SAAA;;;eAEAC,WAAA,KAAA,EAAMD,IAAN,EAAYP,eAAZ;IACD;;IACH,uBAAA;IATA,EAA0DS,WAA1D;;ICdA;;;;;AAKA,IAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,aAAgBC,KACdC,UACAJ;IAEA,SAAOK,eAAQ,CAAID,QAAJ,EAAcJ,IAAd,EAAoBP,eAApB,CAAf;IACD;;ICpDD;;;;;;ICAA;;;;;AAKA,IAECa,cAAsB,CAACH,IAAvB,GAA8BA,IAA9B;;;;;;;;"}
\No newline at end of file