PromoCursed/node_modules/.cache/babel-loader/1351a567a18b9613b14e8af5c51025386417c3412cabd6bde2be07d13b937ff8.json
2024-08-20 23:25:37 +04:00

1 line
6.2 KiB
JSON

{"ast":null,"code":"/**\n * Get index with specific start index one by one. e.g.\n * min: 3, max: 9, start: 6\n *\n * Return index is:\n * [0]: 6\n * [1]: 7\n * [2]: 5\n * [3]: 8\n * [4]: 4\n * [5]: 9\n * [6]: 3\n */\nexport function getIndexByStartLoc(min, max, start, index) {\n var beforeCount = start - min;\n var afterCount = max - start;\n var balanceCount = Math.min(beforeCount, afterCount) * 2;\n\n // Balance\n if (index <= balanceCount) {\n var stepIndex = Math.floor(index / 2);\n if (index % 2) {\n return start + stepIndex + 1;\n }\n return start - stepIndex;\n }\n\n // One is out of range\n if (beforeCount > afterCount) {\n return start - (index - afterCount);\n }\n return start + (index - beforeCount);\n}\n\n/**\n * We assume that 2 list has only 1 item diff and others keeping the order.\n * So we can use dichotomy algorithm to find changed one.\n */\nexport function findListDiffIndex(originList, targetList, getKey) {\n var originLen = originList.length;\n var targetLen = targetList.length;\n var shortList;\n var longList;\n if (originLen === 0 && targetLen === 0) {\n return null;\n }\n if (originLen < targetLen) {\n shortList = originList;\n longList = targetList;\n } else {\n shortList = targetList;\n longList = originList;\n }\n var notExistKey = {\n __EMPTY_ITEM__: true\n };\n function getItemKey(item) {\n if (item !== undefined) {\n return getKey(item);\n }\n return notExistKey;\n }\n\n // Loop to find diff one\n var diffIndex = null;\n var multiple = Math.abs(originLen - targetLen) !== 1;\n for (var i = 0; i < longList.length; i += 1) {\n var shortKey = getItemKey(shortList[i]);\n var longKey = getItemKey(longList[i]);\n if (shortKey !== longKey) {\n diffIndex = i;\n multiple = multiple || shortKey !== getItemKey(longList[i + 1]);\n break;\n }\n }\n return diffIndex === null ? null : {\n index: diffIndex,\n multiple: multiple\n };\n}","map":{"version":3,"names":["getIndexByStartLoc","min","max","start","index","beforeCount","afterCount","balanceCount","Math","stepIndex","floor","findListDiffIndex","originList","targetList","getKey","originLen","length","targetLen","shortList","longList","notExistKey","__EMPTY_ITEM__","getItemKey","item","undefined","diffIndex","multiple","abs","i","shortKey","longKey"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-virtual-list/es/utils/algorithmUtil.js"],"sourcesContent":["/**\n * Get index with specific start index one by one. e.g.\n * min: 3, max: 9, start: 6\n *\n * Return index is:\n * [0]: 6\n * [1]: 7\n * [2]: 5\n * [3]: 8\n * [4]: 4\n * [5]: 9\n * [6]: 3\n */\nexport function getIndexByStartLoc(min, max, start, index) {\n var beforeCount = start - min;\n var afterCount = max - start;\n var balanceCount = Math.min(beforeCount, afterCount) * 2;\n\n // Balance\n if (index <= balanceCount) {\n var stepIndex = Math.floor(index / 2);\n if (index % 2) {\n return start + stepIndex + 1;\n }\n return start - stepIndex;\n }\n\n // One is out of range\n if (beforeCount > afterCount) {\n return start - (index - afterCount);\n }\n return start + (index - beforeCount);\n}\n\n/**\n * We assume that 2 list has only 1 item diff and others keeping the order.\n * So we can use dichotomy algorithm to find changed one.\n */\nexport function findListDiffIndex(originList, targetList, getKey) {\n var originLen = originList.length;\n var targetLen = targetList.length;\n var shortList;\n var longList;\n if (originLen === 0 && targetLen === 0) {\n return null;\n }\n if (originLen < targetLen) {\n shortList = originList;\n longList = targetList;\n } else {\n shortList = targetList;\n longList = originList;\n }\n var notExistKey = {\n __EMPTY_ITEM__: true\n };\n function getItemKey(item) {\n if (item !== undefined) {\n return getKey(item);\n }\n return notExistKey;\n }\n\n // Loop to find diff one\n var diffIndex = null;\n var multiple = Math.abs(originLen - targetLen) !== 1;\n for (var i = 0; i < longList.length; i += 1) {\n var shortKey = getItemKey(shortList[i]);\n var longKey = getItemKey(longList[i]);\n if (shortKey !== longKey) {\n diffIndex = i;\n multiple = multiple || shortKey !== getItemKey(longList[i + 1]);\n break;\n }\n }\n return diffIndex === null ? null : {\n index: diffIndex,\n multiple: multiple\n };\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;A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