zcw-shared 1.20.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/algorithm/binarySearch.d.ts +3 -0
- package/dist/functions/algorithm/binarySearch.js +58 -0
- package/dist/functions/algorithm/binarySearch.js.map +1 -0
- package/dist/functions/algorithm/canJump.d.ts +2 -0
- package/dist/functions/algorithm/canJump.js +27 -0
- package/dist/functions/algorithm/canJump.js.map +1 -0
- package/dist/functions/algorithm/climbStairs.d.ts +2 -0
- package/dist/functions/algorithm/climbStairs.js +27 -0
- package/dist/functions/algorithm/climbStairs.js.map +1 -0
- package/dist/functions/algorithm/coinChange.d.ts +2 -0
- package/dist/functions/algorithm/coinChange.js +25 -0
- package/dist/functions/algorithm/coinChange.js.map +1 -0
- package/dist/functions/algorithm/combinationSum.d.ts +1 -0
- package/dist/functions/algorithm/combinationSum.js +24 -0
- package/dist/functions/algorithm/combinationSum.js.map +1 -0
- package/dist/functions/algorithm/editDistance.d.ts +2 -0
- package/dist/functions/algorithm/editDistance.js +96 -0
- package/dist/functions/algorithm/editDistance.js.map +1 -0
- package/dist/functions/algorithm/generateParenthesis.d.ts +1 -0
- package/dist/functions/algorithm/generateParenthesis.js +18 -0
- package/dist/functions/algorithm/generateParenthesis.js.map +1 -0
- package/dist/functions/algorithm/kmp.d.ts +2 -0
- package/dist/functions/algorithm/kmp.js +58 -0
- package/dist/functions/algorithm/kmp.js.map +1 -0
- package/dist/functions/algorithm/knapsack01.d.ts +2 -0
- package/dist/functions/algorithm/knapsack01.js +34 -0
- package/dist/functions/algorithm/knapsack01.js.map +1 -0
- package/dist/functions/algorithm/lengthOfLongestSubstring.d.ts +2 -0
- package/dist/functions/algorithm/lengthOfLongestSubstring.js +33 -0
- package/dist/functions/algorithm/lengthOfLongestSubstring.js.map +1 -0
- package/dist/functions/algorithm/longestCommonSubsequence.d.ts +2 -0
- package/dist/functions/algorithm/longestCommonSubsequence.js +37 -0
- package/dist/functions/algorithm/longestCommonSubsequence.js.map +1 -0
- package/dist/functions/algorithm/longestIncreasingSubsequence.d.ts +2 -0
- package/dist/functions/algorithm/longestIncreasingSubsequence.js +49 -0
- package/dist/functions/algorithm/longestIncreasingSubsequence.js.map +1 -0
- package/dist/functions/algorithm/maxArea.d.ts +1 -0
- package/dist/functions/algorithm/maxArea.js +19 -0
- package/dist/functions/algorithm/maxArea.js.map +1 -0
- package/dist/functions/algorithm/maxProfit.d.ts +2 -0
- package/dist/functions/algorithm/maxProfit.js +23 -0
- package/dist/functions/algorithm/maxProfit.js.map +1 -0
- package/dist/functions/algorithm/meetingRooms.d.ts +6 -0
- package/dist/functions/algorithm/meetingRooms.js +31 -0
- package/dist/functions/algorithm/meetingRooms.js.map +1 -0
- package/dist/functions/algorithm/mergeSort.d.ts +2 -0
- package/dist/functions/algorithm/mergeSort.js +72 -0
- package/dist/functions/algorithm/mergeSort.js.map +1 -0
- package/dist/functions/algorithm/minPathSum.d.ts +2 -0
- package/dist/functions/algorithm/minPathSum.js +39 -0
- package/dist/functions/algorithm/minPathSum.js.map +1 -0
- package/dist/functions/algorithm/minWindow.d.ts +1 -0
- package/dist/functions/algorithm/minWindow.js +40 -0
- package/dist/functions/algorithm/minWindow.js.map +1 -0
- package/dist/functions/algorithm/nQueens.d.ts +1 -0
- package/dist/functions/algorithm/nQueens.js +30 -0
- package/dist/functions/algorithm/nQueens.js.map +1 -0
- package/dist/functions/algorithm/numIslands.d.ts +2 -0
- package/dist/functions/algorithm/numIslands.js +59 -0
- package/dist/functions/algorithm/numIslands.js.map +1 -0
- package/dist/functions/algorithm/permutations.d.ts +1 -0
- package/dist/functions/algorithm/permutations.js +22 -0
- package/dist/functions/algorithm/permutations.js.map +1 -0
- package/dist/functions/algorithm/quickSort.d.ts +3 -0
- package/dist/functions/algorithm/quickSort.js +68 -0
- package/dist/functions/algorithm/quickSort.js.map +1 -0
- package/dist/functions/algorithm/rabinKarp.d.ts +1 -0
- package/dist/functions/algorithm/rabinKarp.js +40 -0
- package/dist/functions/algorithm/rabinKarp.js.map +1 -0
- package/dist/functions/algorithm/taskScheduler.d.ts +1 -0
- package/dist/functions/algorithm/taskScheduler.js +15 -0
- package/dist/functions/algorithm/taskScheduler.js.map +1 -0
- package/dist/functions/algorithm/threeSum.d.ts +2 -0
- package/dist/functions/algorithm/threeSum.js +56 -0
- package/dist/functions/algorithm/threeSum.js.map +1 -0
- package/dist/functions/algorithm/topologicalSort.d.ts +6 -0
- package/dist/functions/algorithm/topologicalSort.js +68 -0
- package/dist/functions/algorithm/topologicalSort.js.map +1 -0
- package/dist/functions/algorithm/trap.d.ts +2 -0
- package/dist/functions/algorithm/trap.js +51 -0
- package/dist/functions/algorithm/trap.js.map +1 -0
- package/dist/functions/array-object/chunk.d.ts +1 -0
- package/dist/functions/array-object/chunk.js +11 -0
- package/dist/functions/array-object/chunk.js.map +1 -0
- package/dist/functions/array-object/deepClone.d.ts +12 -0
- package/dist/functions/array-object/deepClone.js +131 -0
- package/dist/functions/array-object/deepClone.js.map +1 -0
- package/dist/functions/array-object/evolve.d.ts +3 -0
- package/dist/functions/array-object/evolve.js +15 -0
- package/dist/functions/array-object/evolve.js.map +1 -0
- package/dist/functions/array-object/flatten.d.ts +7 -0
- package/dist/functions/array-object/flatten.js +60 -0
- package/dist/functions/array-object/flatten.js.map +1 -0
- package/dist/functions/array-object/flattenObject.d.ts +5 -0
- package/dist/functions/array-object/flattenObject.js +102 -0
- package/dist/functions/array-object/flattenObject.js.map +1 -0
- package/dist/functions/array-object/groupBy.d.ts +1 -0
- package/dist/functions/array-object/groupBy.js +14 -0
- package/dist/functions/array-object/groupBy.js.map +1 -0
- package/dist/functions/array-object/omit.d.ts +1 -0
- package/dist/functions/array-object/omit.js +8 -0
- package/dist/functions/array-object/omit.js.map +1 -0
- package/dist/functions/array-object/pick.d.ts +1 -0
- package/dist/functions/array-object/pick.js +10 -0
- package/dist/functions/array-object/pick.js.map +1 -0
- package/dist/functions/array-object/shuffle.d.ts +1 -0
- package/dist/functions/array-object/shuffle.js +9 -0
- package/dist/functions/array-object/shuffle.js.map +1 -0
- package/dist/functions/array-object/sortBy.d.ts +1 -0
- package/dist/functions/array-object/sortBy.js +13 -0
- package/dist/functions/array-object/sortBy.js.map +1 -0
- package/dist/functions/array-object/unique.d.ts +10 -0
- package/dist/functions/array-object/unique.js +85 -0
- package/dist/functions/array-object/unique.js.map +1 -0
- package/dist/functions/async/cachedAsync.d.ts +27 -0
- package/dist/functions/async/cachedAsync.js +123 -0
- package/dist/functions/async/cachedAsync.js.map +1 -0
- package/dist/functions/async/promiseLimit.d.ts +10 -0
- package/dist/functions/async/promiseLimit.js +125 -0
- package/dist/functions/async/promiseLimit.js.map +1 -0
- package/dist/functions/async/retryWithBackoff.d.ts +12 -0
- package/dist/functions/async/retryWithBackoff.js +29 -0
- package/dist/functions/async/retryWithBackoff.js.map +1 -0
- package/dist/functions/browser/detectBrowser.d.ts +39 -0
- package/dist/functions/browser/detectBrowser.js +193 -0
- package/dist/functions/browser/detectBrowser.js.map +1 -0
- package/dist/functions/browser/detectOS.d.ts +5 -0
- package/dist/functions/browser/detectOS.js +20 -0
- package/dist/functions/browser/detectOS.js.map +1 -0
- package/dist/functions/browser/isMobile.d.ts +6 -0
- package/dist/functions/browser/isMobile.js +5 -0
- package/dist/functions/browser/isMobile.js.map +1 -0
- package/dist/functions/data-structures/AVLTree.d.ts +19 -0
- package/dist/functions/data-structures/AVLTree.js +197 -0
- package/dist/functions/data-structures/AVLTree.js.map +1 -0
- package/dist/functions/data-structures/BinarySearchTree.d.ts +19 -0
- package/dist/functions/data-structures/BinarySearchTree.js +150 -0
- package/dist/functions/data-structures/BinarySearchTree.js.map +1 -0
- package/dist/functions/data-structures/Graph.d.ts +19 -0
- package/dist/functions/data-structures/Graph.js +190 -0
- package/dist/functions/data-structures/Graph.js.map +1 -0
- package/dist/functions/data-structures/HashMap.d.ts +13 -0
- package/dist/functions/data-structures/HashMap.js +128 -0
- package/dist/functions/data-structures/HashMap.js.map +1 -0
- package/dist/functions/data-structures/Heap.d.ts +11 -0
- package/dist/functions/data-structures/Heap.js +91 -0
- package/dist/functions/data-structures/Heap.js.map +1 -0
- package/dist/functions/data-structures/LRUCache.d.ts +41 -0
- package/dist/functions/data-structures/LRUCache.js +182 -0
- package/dist/functions/data-structures/LRUCache.js.map +1 -0
- package/dist/functions/data-structures/LinkedList.d.ts +18 -0
- package/dist/functions/data-structures/LinkedList.js +135 -0
- package/dist/functions/data-structures/LinkedList.js.map +1 -0
- package/dist/functions/data-structures/PriorityQueue.d.ts +14 -0
- package/dist/functions/data-structures/PriorityQueue.js +77 -0
- package/dist/functions/data-structures/PriorityQueue.js.map +1 -0
- package/dist/functions/data-structures/Queue.d.ts +10 -0
- package/dist/functions/data-structures/Queue.js +27 -0
- package/dist/functions/data-structures/Queue.js.map +1 -0
- package/dist/functions/data-structures/Stack.d.ts +10 -0
- package/dist/functions/data-structures/Stack.js +27 -0
- package/dist/functions/data-structures/Stack.js.map +1 -0
- package/dist/functions/data-structures/Trie.d.ts +16 -0
- package/dist/functions/data-structures/Trie.js +127 -0
- package/dist/functions/data-structures/Trie.js.map +1 -0
- package/dist/functions/data-structures/UnionFind.d.ts +8 -0
- package/dist/functions/data-structures/UnionFind.js +53 -0
- package/dist/functions/data-structures/UnionFind.js.map +1 -0
- package/dist/functions/date/dateRange.d.ts +1 -0
- package/dist/functions/date/dateRange.js +18 -0
- package/dist/functions/date/dateRange.js.map +1 -0
- package/dist/functions/date/formatDate.d.ts +1 -0
- package/dist/functions/date/formatDate.js +21 -0
- package/dist/functions/date/formatDate.js.map +1 -0
- package/dist/functions/date/timeAgo.d.ts +1 -0
- package/dist/functions/date/timeAgo.js +49 -0
- package/dist/functions/date/timeAgo.js.map +1 -0
- package/dist/functions/design-tokens/buildTokens.d.ts +76 -0
- package/dist/functions/design-tokens/buildTokens.js +183 -0
- package/dist/functions/design-tokens/buildTokens.js.map +1 -0
- package/dist/functions/design-tokens/generateVariables.d.ts +7 -0
- package/dist/functions/design-tokens/generateVariables.js +135 -0
- package/dist/functions/design-tokens/generateVariables.js.map +1 -0
- package/dist/functions/design-tokens/mixColors.d.ts +1 -0
- package/dist/functions/design-tokens/mixColors.js +38 -0
- package/dist/functions/design-tokens/mixColors.js.map +1 -0
- package/dist/functions/design-tokens/parseDesignTokens.d.ts +10 -0
- package/dist/functions/design-tokens/parseDesignTokens.js +216 -0
- package/dist/functions/design-tokens/parseDesignTokens.js.map +1 -0
- package/dist/functions/file/formatFileSize.d.ts +1 -0
- package/dist/functions/file/formatFileSize.js +16 -0
- package/dist/functions/file/formatFileSize.js.map +1 -0
- package/dist/functions/file/getFileExtension.d.ts +5 -0
- package/dist/functions/file/getFileExtension.js +18 -0
- package/dist/functions/file/getFileExtension.js.map +1 -0
- package/dist/functions/functional/compose.d.ts +1 -0
- package/dist/functions/functional/compose.js +10 -0
- package/dist/functions/functional/compose.js.map +1 -0
- package/dist/functions/functional/cond.d.ts +1 -0
- package/dist/functions/functional/cond.js +15 -0
- package/dist/functions/functional/cond.js.map +1 -0
- package/dist/functions/functional/curry.d.ts +1 -0
- package/dist/functions/functional/curry.js +13 -0
- package/dist/functions/functional/curry.js.map +1 -0
- package/dist/functions/functional/curryAdvanced.d.ts +8 -0
- package/dist/functions/functional/curryAdvanced.js +87 -0
- package/dist/functions/functional/curryAdvanced.js.map +1 -0
- package/dist/functions/functional/flow.d.ts +1 -0
- package/dist/functions/functional/flow.js +14 -0
- package/dist/functions/functional/flow.js.map +1 -0
- package/dist/functions/functional/partial.d.ts +1 -0
- package/dist/functions/functional/partial.js +13 -0
- package/dist/functions/functional/partial.js.map +1 -0
- package/dist/functions/functional/pipe.d.ts +1 -0
- package/dist/functions/functional/pipe.js +10 -0
- package/dist/functions/functional/pipe.js.map +1 -0
- package/dist/functions/functional/tap.d.ts +1 -0
- package/dist/functions/functional/tap.js +14 -0
- package/dist/functions/functional/tap.js.map +1 -0
- package/dist/functions/functional/until.d.ts +1 -0
- package/dist/functions/functional/until.js +10 -0
- package/dist/functions/functional/until.js.map +1 -0
- package/dist/functions/math/average.d.ts +1 -0
- package/dist/functions/math/average.js +8 -0
- package/dist/functions/math/average.js.map +1 -0
- package/dist/functions/math/median.d.ts +1 -0
- package/dist/functions/math/median.js +14 -0
- package/dist/functions/math/median.js.map +1 -0
- package/dist/functions/math/percentile.d.ts +1 -0
- package/dist/functions/math/percentile.js +18 -0
- package/dist/functions/math/percentile.js.map +1 -0
- package/dist/functions/math/sum.d.ts +1 -0
- package/dist/functions/math/sum.js +4 -0
- package/dist/functions/math/sum.js.map +1 -0
- package/dist/functions/number/clamp.d.ts +1 -0
- package/dist/functions/number/clamp.js +7 -0
- package/dist/functions/number/clamp.js.map +1 -0
- package/dist/functions/number/formatNumber.d.ts +8 -0
- package/dist/functions/number/formatNumber.js +16 -0
- package/dist/functions/number/formatNumber.js.map +1 -0
- package/dist/functions/number/random.d.ts +4 -0
- package/dist/functions/number/random.js +9 -0
- package/dist/functions/number/random.js.map +1 -0
- package/dist/functions/number/range.d.ts +1 -0
- package/dist/functions/number/range.js +18 -0
- package/dist/functions/number/range.js.map +1 -0
- package/dist/functions/patterns/EventEmitter.d.ts +32 -0
- package/dist/functions/patterns/EventEmitter.js +108 -0
- package/dist/functions/patterns/EventEmitter.js.map +1 -0
- package/dist/functions/patterns/adapter.d.ts +8 -0
- package/dist/functions/patterns/adapter.js +14 -0
- package/dist/functions/patterns/adapter.js.map +1 -0
- package/dist/functions/patterns/builder.d.ts +9 -0
- package/dist/functions/patterns/builder.js +28 -0
- package/dist/functions/patterns/builder.js.map +1 -0
- package/dist/functions/patterns/chainOfResponsibility.d.ts +9 -0
- package/dist/functions/patterns/chainOfResponsibility.js +19 -0
- package/dist/functions/patterns/chainOfResponsibility.js.map +1 -0
- package/dist/functions/patterns/command.d.ts +15 -0
- package/dist/functions/patterns/command.js +49 -0
- package/dist/functions/patterns/command.js.map +1 -0
- package/dist/functions/patterns/decorator.d.ts +10 -0
- package/dist/functions/patterns/decorator.js +72 -0
- package/dist/functions/patterns/decorator.js.map +1 -0
- package/dist/functions/patterns/factory.d.ts +8 -0
- package/dist/functions/patterns/factory.js +25 -0
- package/dist/functions/patterns/factory.js.map +1 -0
- package/dist/functions/patterns/observer.d.ts +19 -0
- package/dist/functions/patterns/observer.js +89 -0
- package/dist/functions/patterns/observer.js.map +1 -0
- package/dist/functions/patterns/prototype.d.ts +4 -0
- package/dist/functions/patterns/prototype.js +30 -0
- package/dist/functions/patterns/prototype.js.map +1 -0
- package/dist/functions/patterns/proxy.d.ts +8 -0
- package/dist/functions/patterns/proxy.js +41 -0
- package/dist/functions/patterns/proxy.js.map +1 -0
- package/dist/functions/patterns/singleton.d.ts +11 -0
- package/dist/functions/patterns/singleton.js +32 -0
- package/dist/functions/patterns/singleton.js.map +1 -0
- package/dist/functions/patterns/strategy.d.ts +12 -0
- package/dist/functions/patterns/strategy.js +34 -0
- package/dist/functions/patterns/strategy.js.map +1 -0
- package/dist/functions/patterns/templateMethod.d.ts +8 -0
- package/dist/functions/patterns/templateMethod.js +19 -0
- package/dist/functions/patterns/templateMethod.js.map +1 -0
- package/dist/functions/patterns/usePluginSystem.d.ts +11 -0
- package/dist/functions/patterns/usePluginSystem.js +34 -0
- package/dist/functions/patterns/usePluginSystem.js.map +1 -0
- package/dist/functions/performance/debounce.d.ts +5 -0
- package/dist/functions/performance/debounce.js +12 -0
- package/dist/functions/performance/debounce.js.map +1 -0
- package/dist/functions/performance/memoize.d.ts +1 -0
- package/dist/functions/performance/memoize.js +13 -0
- package/dist/functions/performance/memoize.js.map +1 -0
- package/dist/functions/performance/once.d.ts +1 -0
- package/dist/functions/performance/once.js +13 -0
- package/dist/functions/performance/once.js.map +1 -0
- package/dist/functions/performance/throttle.d.ts +1 -0
- package/dist/functions/performance/throttle.js +11 -0
- package/dist/functions/performance/throttle.js.map +1 -0
- package/dist/functions/performance/useCache.d.ts +18 -0
- package/dist/functions/performance/useCache.js +82 -0
- package/dist/functions/performance/useCache.js.map +1 -0
- package/dist/functions/platform/tencent-cloud/deploy.tcb.d.ts +13 -0
- package/dist/functions/platform/tencent-cloud/deploy.tcb.js +46 -0
- package/dist/functions/platform/tencent-cloud/deploy.tcb.js.map +1 -0
- package/dist/functions/platform/tencent-cloud/getSecret.d.ts +4 -0
- package/dist/functions/platform/tencent-cloud/getSecret.js +19 -0
- package/dist/functions/platform/tencent-cloud/getSecret.js.map +1 -0
- package/dist/functions/platform/uniapp/app-plus/buildAndroidApp.d.ts +27 -0
- package/dist/functions/platform/uniapp/app-plus/buildAndroidApp.js +287 -0
- package/dist/functions/platform/uniapp/app-plus/buildAndroidApp.js.map +1 -0
- package/dist/functions/platform/uniapp/build.d.ts +21 -0
- package/dist/functions/platform/uniapp/build.js +83 -0
- package/dist/functions/platform/uniapp/build.js.map +1 -0
- package/dist/functions/platform/uniapp/detectAndroidProjectStructure.d.ts +11 -0
- package/dist/functions/platform/uniapp/detectAndroidProjectStructure.js +30 -0
- package/dist/functions/platform/uniapp/detectAndroidProjectStructure.js.map +1 -0
- package/dist/functions/platform/uniapp/detectProjectType.d.ts +20 -0
- package/dist/functions/platform/uniapp/detectProjectType.js +68 -0
- package/dist/functions/platform/uniapp/detectProjectType.js.map +1 -0
- package/dist/functions/platform/uniapp/parseManifest.d.ts +18 -0
- package/dist/functions/platform/uniapp/parseManifest.js +49 -0
- package/dist/functions/platform/uniapp/parseManifest.js.map +1 -0
- package/dist/functions/platform/uniapp/waitForPages.d.ts +7 -0
- package/dist/functions/platform/uniapp/waitForPages.js +20 -0
- package/dist/functions/platform/uniapp/waitForPages.js.map +1 -0
- package/dist/functions/principles/MyPromise.d.ts +32 -0
- package/dist/functions/principles/MyPromise.js +254 -0
- package/dist/functions/principles/MyPromise.js.map +1 -0
- package/dist/functions/principles/functionBind.d.ts +4 -0
- package/dist/functions/principles/functionBind.js +33 -0
- package/dist/functions/principles/functionBind.js.map +1 -0
- package/dist/functions/principles/myInstanceof.d.ts +5 -0
- package/dist/functions/principles/myInstanceof.js +56 -0
- package/dist/functions/principles/myInstanceof.js.map +1 -0
- package/dist/functions/principles/myNew.d.ts +3 -0
- package/dist/functions/principles/myNew.js +19 -0
- package/dist/functions/principles/myNew.js.map +1 -0
- package/dist/functions/promise/sleep.d.ts +5 -0
- package/dist/functions/promise/sleep.js +6 -0
- package/dist/functions/promise/sleep.js.map +1 -0
- package/dist/functions/promise/timeout.d.ts +6 -0
- package/dist/functions/promise/timeout.js +12 -0
- package/dist/functions/promise/timeout.js.map +1 -0
- package/dist/functions/storage/useLocalStorage.d.ts +8 -0
- package/dist/functions/storage/useLocalStorage.js +101 -0
- package/dist/functions/storage/useLocalStorage.js.map +1 -0
- package/dist/functions/storage/useSessionStorage.d.ts +8 -0
- package/dist/functions/storage/useSessionStorage.js +101 -0
- package/dist/functions/storage/useSessionStorage.js.map +1 -0
- package/dist/functions/storage/useStorage.d.ts +13 -0
- package/dist/functions/storage/useStorage.js +62 -0
- package/dist/functions/storage/useStorage.js.map +1 -0
- package/dist/functions/storage/useStorageWithIndexedDB.d.ts +8 -0
- package/dist/functions/storage/useStorageWithIndexedDB.js +132 -0
- package/dist/functions/storage/useStorageWithIndexedDB.js.map +1 -0
- package/dist/functions/tencent-cloud/upload.cos.d.ts +20 -0
- package/dist/functions/tencent-cloud/upload.cos.js +119 -0
- package/dist/functions/tencent-cloud/upload.cos.js.map +1 -0
- package/dist/functions/tree/buildTree.d.ts +7 -0
- package/dist/functions/tree/buildTree.js +27 -0
- package/dist/functions/tree/buildTree.js.map +1 -0
- package/dist/functions/tree/filterTree.d.ts +4 -0
- package/dist/functions/tree/filterTree.js +21 -0
- package/dist/functions/tree/filterTree.js.map +1 -0
- package/dist/functions/tree/findNode.d.ts +4 -0
- package/dist/functions/tree/findNode.js +21 -0
- package/dist/functions/tree/findNode.js.map +1 -0
- package/dist/functions/tree/flattenTree.d.ts +6 -0
- package/dist/functions/tree/flattenTree.js +21 -0
- package/dist/functions/tree/flattenTree.js.map +1 -0
- package/dist/functions/url/buildQueryString.d.ts +5 -0
- package/dist/functions/url/buildQueryString.js +15 -0
- package/dist/functions/url/buildQueryString.js.map +1 -0
- package/dist/functions/url/parseUrl.d.ts +11 -0
- package/dist/functions/url/parseUrl.js +34 -0
- package/dist/functions/url/parseUrl.js.map +1 -0
- package/dist/functions/utils/cachedAsync.d.ts +27 -0
- package/dist/functions/utils/cachedAsync.js +123 -0
- package/dist/functions/utils/cachedAsync.js.map +1 -0
- package/dist/functions/utils/createI18n.d.ts +2 -0
- package/dist/functions/utils/createI18n.js +97 -0
- package/dist/functions/utils/createI18n.js.map +1 -0
- package/dist/functions/utils/createReactive.d.ts +10 -0
- package/dist/functions/utils/createReactive.js +50 -0
- package/dist/functions/utils/createReactive.js.map +1 -0
- package/dist/functions/utils/diff.d.ts +25 -0
- package/dist/functions/utils/diff.js +316 -0
- package/dist/functions/utils/diff.js.map +1 -0
- package/dist/functions/utils/errorManager.d.ts +63 -0
- package/dist/functions/utils/errorManager.js +199 -0
- package/dist/functions/utils/errorManager.js.map +1 -0
- package/dist/functions/utils/formatString.d.ts +5 -0
- package/dist/functions/utils/formatString.js +9 -0
- package/dist/functions/utils/formatString.js.map +1 -0
- package/dist/functions/utils/i18n.d.ts +27 -0
- package/dist/functions/utils/i18n.js +119 -0
- package/dist/functions/utils/i18n.js.map +1 -0
- package/dist/functions/utils/permission.d.ts +40 -0
- package/dist/functions/utils/permission.js +189 -0
- package/dist/functions/utils/permission.js.map +1 -0
- package/dist/functions/utils/pinia.d.ts +52 -0
- package/dist/functions/utils/pinia.js +183 -0
- package/dist/functions/utils/pinia.js.map +1 -0
- package/dist/functions/utils/useAltool.d.ts +39 -0
- package/dist/functions/utils/useAltool.js +350 -0
- package/dist/functions/utils/useAltool.js.map +1 -0
- package/dist/functions/utils/vueDiff.d.ts +38 -0
- package/dist/functions/utils/vueDiff.js +333 -0
- package/dist/functions/utils/vueDiff.js.map +1 -0
- package/dist/functions/validation/isEmail.d.ts +1 -0
- package/dist/functions/validation/isEmail.js +8 -0
- package/dist/functions/validation/isEmail.js.map +1 -0
- package/dist/functions/validation/isIdCard.d.ts +1 -0
- package/dist/functions/validation/isIdCard.js +49 -0
- package/dist/functions/validation/isIdCard.js.map +1 -0
- package/dist/functions/validation/isIpAddress.d.ts +1 -0
- package/dist/functions/validation/isIpAddress.js +15 -0
- package/dist/functions/validation/isIpAddress.js.map +1 -0
- package/dist/functions/validation/isPhone.d.ts +1 -0
- package/dist/functions/validation/isPhone.js +12 -0
- package/dist/functions/validation/isPhone.js.map +1 -0
- package/dist/functions/validation/isUrl.d.ts +5 -0
- package/dist/functions/validation/isUrl.js +33 -0
- package/dist/functions/validation/isUrl.js.map +1 -0
- package/dist/hooks/usePermission.d.ts +7 -0
- package/dist/hooks/usePermission.js +123 -0
- package/dist/hooks/usePermission.js.map +1 -0
- package/dist/reactive/createReactive.d.ts +10 -0
- package/dist/reactive/createReactive.js +50 -0
- package/dist/reactive/createReactive.js.map +1 -0
- package/dist/reactive/createReactiveErrorManager.d.ts +63 -0
- package/dist/reactive/createReactiveErrorManager.js +199 -0
- package/dist/reactive/createReactiveErrorManager.js.map +1 -0
- package/dist/reactive/createReactiveI18n.d.ts +27 -0
- package/dist/reactive/createReactiveI18n.js +119 -0
- package/dist/reactive/createReactiveI18n.js.map +1 -0
- package/dist/reactive/createReactivePermission.d.ts +40 -0
- package/dist/reactive/createReactivePermission.js +189 -0
- package/dist/reactive/createReactivePermission.js.map +1 -0
- package/dist/reactive/createReactivePinia.d.ts +52 -0
- package/dist/reactive/createReactivePinia.js +183 -0
- package/dist/reactive/createReactivePinia.js.map +1 -0
- package/dist/reactive/useReactiveCookie.d.ts +19 -0
- package/dist/reactive/useReactiveCookie.js +84 -0
- package/dist/reactive/useReactiveCookie.js.map +1 -0
- package/dist/vue-hooks/browser/useBattery.d.ts +16 -0
- package/dist/vue-hooks/browser/useBattery.js +70 -0
- package/dist/vue-hooks/browser/useBattery.js.map +1 -0
- package/dist/vue-hooks/browser/useBluetooth.d.ts +25 -0
- package/dist/vue-hooks/browser/useBluetooth.js +72 -0
- package/dist/vue-hooks/browser/useBluetooth.js.map +1 -0
- package/dist/vue-hooks/browser/useCamera.d.ts +21 -0
- package/dist/vue-hooks/browser/useCamera.js +52 -0
- package/dist/vue-hooks/browser/useCamera.js.map +1 -0
- package/dist/vue-hooks/browser/useClipboard.d.ts +18 -0
- package/dist/vue-hooks/browser/useClipboard.js +33 -0
- package/dist/vue-hooks/browser/useClipboard.js.map +1 -0
- package/dist/vue-hooks/browser/useFullscreen.d.ts +20 -0
- package/dist/vue-hooks/browser/useFullscreen.js +73 -0
- package/dist/vue-hooks/browser/useFullscreen.js.map +1 -0
- package/dist/vue-hooks/browser/useGamepad.d.ts +25 -0
- package/dist/vue-hooks/browser/useGamepad.js +69 -0
- package/dist/vue-hooks/browser/useGamepad.js.map +1 -0
- package/dist/vue-hooks/browser/useGeolocation.d.ts +24 -0
- package/dist/vue-hooks/browser/useGeolocation.js +85 -0
- package/dist/vue-hooks/browser/useGeolocation.js.map +1 -0
- package/dist/vue-hooks/browser/useMediaSession.d.ts +19 -0
- package/dist/vue-hooks/browser/useMediaSession.js +71 -0
- package/dist/vue-hooks/browser/useMediaSession.js.map +1 -0
- package/dist/vue-hooks/browser/useMicrophone.d.ts +23 -0
- package/dist/vue-hooks/browser/useMicrophone.js +66 -0
- package/dist/vue-hooks/browser/useMicrophone.js.map +1 -0
- package/dist/vue-hooks/browser/useNetwork.d.ts +23 -0
- package/dist/vue-hooks/browser/useNetwork.js +57 -0
- package/dist/vue-hooks/browser/useNetwork.js.map +1 -0
- package/dist/vue-hooks/browser/useOrientation.d.ts +22 -0
- package/dist/vue-hooks/browser/useOrientation.js +54 -0
- package/dist/vue-hooks/browser/useOrientation.js.map +1 -0
- package/dist/vue-hooks/browser/usePageVisibility.d.ts +15 -0
- package/dist/vue-hooks/browser/usePageVisibility.js +25 -0
- package/dist/vue-hooks/browser/usePageVisibility.js.map +1 -0
- package/dist/vue-hooks/browser/useScreenOrientation.d.ts +24 -0
- package/dist/vue-hooks/browser/useScreenOrientation.js +67 -0
- package/dist/vue-hooks/browser/useScreenOrientation.js.map +1 -0
- package/dist/vue-hooks/browser/useScreenWakeLock.d.ts +15 -0
- package/dist/vue-hooks/browser/useScreenWakeLock.js +57 -0
- package/dist/vue-hooks/browser/useScreenWakeLock.js.map +1 -0
- package/dist/vue-hooks/browser/useShare.d.ts +21 -0
- package/dist/vue-hooks/browser/useShare.js +39 -0
- package/dist/vue-hooks/browser/useShare.js.map +1 -0
- package/dist/vue-hooks/browser/useVibration.d.ts +17 -0
- package/dist/vue-hooks/browser/useVibration.js +40 -0
- package/dist/vue-hooks/browser/useVibration.js.map +1 -0
- package/dist/vue-hooks/dom/useClickOutside.d.ts +9 -0
- package/dist/vue-hooks/dom/useClickOutside.js +16 -0
- package/dist/vue-hooks/dom/useClickOutside.js.map +1 -0
- package/dist/vue-hooks/dom/useDraggable.d.ts +33 -0
- package/dist/vue-hooks/dom/useDraggable.js +163 -0
- package/dist/vue-hooks/dom/useDraggable.js.map +1 -0
- package/dist/vue-hooks/dom/useEventListener.d.ts +11 -0
- package/dist/vue-hooks/dom/useEventListener.js +18 -0
- package/dist/vue-hooks/dom/useEventListener.js.map +1 -0
- package/dist/vue-hooks/dom/useResizable.d.ts +50 -0
- package/dist/vue-hooks/dom/useResizable.js +178 -0
- package/dist/vue-hooks/dom/useResizable.js.map +1 -0
- package/dist/vue-hooks/history/useDebouncedRefHistory.d.ts +17 -0
- package/dist/vue-hooks/history/useDebouncedRefHistory.js +46 -0
- package/dist/vue-hooks/history/useDebouncedRefHistory.js.map +1 -0
- package/dist/vue-hooks/history/useManualRefHistory.d.ts +26 -0
- package/dist/vue-hooks/history/useManualRefHistory.js +80 -0
- package/dist/vue-hooks/history/useManualRefHistory.js.map +1 -0
- package/dist/vue-hooks/history/useRefHistory.d.ts +15 -0
- package/dist/vue-hooks/history/useRefHistory.js +41 -0
- package/dist/vue-hooks/history/useRefHistory.js.map +1 -0
- package/dist/vue-hooks/state/createGlobalState.d.ts +2 -0
- package/dist/vue-hooks/state/createGlobalState.js +11 -0
- package/dist/vue-hooks/state/createGlobalState.js.map +1 -0
- package/dist/vue-hooks/state/createInjectionState.d.ts +10 -0
- package/dist/vue-hooks/state/createInjectionState.js +20 -0
- package/dist/vue-hooks/state/createInjectionState.js.map +1 -0
- package/dist/vue-hooks/state/createSharedComposable.d.ts +2 -0
- package/dist/vue-hooks/state/createSharedComposable.js +13 -0
- package/dist/vue-hooks/state/createSharedComposable.js.map +1 -0
- package/dist/vue-hooks/state/injectLocal.d.ts +8 -0
- package/dist/vue-hooks/state/injectLocal.js +12 -0
- package/dist/vue-hooks/state/injectLocal.js.map +1 -0
- package/dist/vue-hooks/state/provideLocal.d.ts +7 -0
- package/dist/vue-hooks/state/provideLocal.js +7 -0
- package/dist/vue-hooks/state/provideLocal.js.map +1 -0
- package/dist/vue-hooks/state/useAsyncState.d.ts +27 -0
- package/dist/vue-hooks/state/useAsyncState.js +46 -0
- package/dist/vue-hooks/state/useAsyncState.js.map +1 -0
- package/dist/vue-hooks/state/useCounter.d.ts +17 -0
- package/dist/vue-hooks/state/useCounter.js +44 -0
- package/dist/vue-hooks/state/useCounter.js.map +1 -0
- package/dist/vue-hooks/state/useToggle.d.ts +13 -0
- package/dist/vue-hooks/state/useToggle.js +23 -0
- package/dist/vue-hooks/state/useToggle.js.map +1 -0
- package/dist/vue-hooks/time/useInterval.d.ts +16 -0
- package/dist/vue-hooks/time/useInterval.js +33 -0
- package/dist/vue-hooks/time/useInterval.js.map +1 -0
- package/dist/vue-hooks/time/useTimeout.d.ts +17 -0
- package/dist/vue-hooks/time/useTimeout.js +40 -0
- package/dist/vue-hooks/time/useTimeout.js.map +1 -0
- package/dist/vue-hooks/worker/useWebWorker.d.ts +25 -0
- package/dist/vue-hooks/worker/useWebWorker.js +207 -0
- package/dist/vue-hooks/worker/useWebWorker.js.map +1 -0
- package/dist/vue-hooks/worker/useWorkerFunction.d.ts +26 -0
- package/dist/vue-hooks/worker/useWorkerFunction.js +191 -0
- package/dist/vue-hooks/worker/useWorkerFunction.js.map +1 -0
- package/dist/vue-hooks/worker/useWorkerPool.d.ts +33 -0
- package/dist/vue-hooks/worker/useWorkerPool.js +247 -0
- package/dist/vue-hooks/worker/useWorkerPool.js.map +1 -0
- package/package.json +175 -60
- package/references/browser.d.ts +12 -0
- package/references/device.d.ts +340 -0
- package/references/dom.d.ts +31 -6
- package/references/node.d.ts +2 -0
- package/references/tencent-cloud.d.ts +38 -0
- package/references/xlsx.d.ts +51 -0
- package/types/algorithm-visual.d.ts +79 -0
- package/types/algorithm.d.ts +85 -0
- package/types/reactive.d.ts +67 -0
- package/types/tencent-cloud.d.ts +29 -0
- package/types/vue.d.ts +22 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export function topologicalSort(numCourses, prerequisites) {
|
|
2
|
+
const graph = Array.from({ length: numCourses }, () => []);
|
|
3
|
+
const inDegree = Array(numCourses).fill(0);
|
|
4
|
+
for (const [course, prereq] of prerequisites) {
|
|
5
|
+
graph[prereq].push(course);
|
|
6
|
+
inDegree[course]++;
|
|
7
|
+
}
|
|
8
|
+
const queue = [];
|
|
9
|
+
for (let i = 0; i < numCourses; i++) {
|
|
10
|
+
if (inDegree[i] === 0) {
|
|
11
|
+
queue.push(i);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const order = [];
|
|
15
|
+
while (queue.length > 0) {
|
|
16
|
+
const course = queue.shift();
|
|
17
|
+
order.push(course);
|
|
18
|
+
for (const next of graph[course]) {
|
|
19
|
+
inDegree[next]--;
|
|
20
|
+
if (inDegree[next] === 0) {
|
|
21
|
+
queue.push(next);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
canFinish: order.length === numCourses,
|
|
27
|
+
order: order.length === numCourses ? order : []
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function topologicalSortDFS(numCourses, prerequisites) {
|
|
31
|
+
const graph = Array.from({ length: numCourses }, () => []);
|
|
32
|
+
for (const [course, prereq] of prerequisites) {
|
|
33
|
+
graph[prereq].push(course);
|
|
34
|
+
}
|
|
35
|
+
const visited = Array(numCourses).fill(false);
|
|
36
|
+
const visiting = Array(numCourses).fill(false);
|
|
37
|
+
const order = [];
|
|
38
|
+
let hasCycle = false;
|
|
39
|
+
function dfs(course) {
|
|
40
|
+
if (visiting[course]) {
|
|
41
|
+
hasCycle = true;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (visited[course])
|
|
45
|
+
return;
|
|
46
|
+
visiting[course] = true;
|
|
47
|
+
for (const next of graph[course]) {
|
|
48
|
+
dfs(next);
|
|
49
|
+
if (hasCycle)
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
visiting[course] = false;
|
|
53
|
+
visited[course] = true;
|
|
54
|
+
order.push(course);
|
|
55
|
+
}
|
|
56
|
+
for (let i = 0; i < numCourses; i++) {
|
|
57
|
+
if (!visited[i]) {
|
|
58
|
+
dfs(i);
|
|
59
|
+
if (hasCycle)
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
canFinish: !hasCycle,
|
|
65
|
+
order: hasCycle ? [] : order.reverse()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=topologicalSort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topologicalSort.js","sourceRoot":"","sources":["../../../src/functions/algorithm/topologicalSort.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,eAAe,CAC7B,UAAkB,EAClB,aAAyB;IAGzB,MAAM,KAAK,GAAe,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IACtE,MAAM,QAAQ,GAAa,KAAK,CAAC,UAAU,CAAC,CAAC,I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L,SAAS,EAAE,CAAC,QAAQ;QACpB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE;KACvC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export function trap(height) {
|
|
2
|
+
if (height.length === 0)
|
|
3
|
+
return 0;
|
|
4
|
+
let left = 0;
|
|
5
|
+
let right = height.length - 1;
|
|
6
|
+
let leftMax = 0;
|
|
7
|
+
let rightMax = 0;
|
|
8
|
+
let water = 0;
|
|
9
|
+
while (left < right) {
|
|
10
|
+
if (height[left] < height[right]) {
|
|
11
|
+
if (height[left] >= leftMax) {
|
|
12
|
+
leftMax = height[left];
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
water += leftMax - height[left];
|
|
16
|
+
}
|
|
17
|
+
left++;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (height[right] >= rightMax) {
|
|
21
|
+
rightMax = height[right];
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
water += rightMax - height[right];
|
|
25
|
+
}
|
|
26
|
+
right--;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return water;
|
|
30
|
+
}
|
|
31
|
+
export function trapDP(height) {
|
|
32
|
+
if (height.length === 0)
|
|
33
|
+
return 0;
|
|
34
|
+
const n = height.length;
|
|
35
|
+
const leftMax = Array(n).fill(0);
|
|
36
|
+
const rightMax = Array(n).fill(0);
|
|
37
|
+
leftMax[0] = height[0];
|
|
38
|
+
for (let i = 1; i < n; i++) {
|
|
39
|
+
leftMax[i] = Math.max(leftMax[i - 1], height[i]);
|
|
40
|
+
}
|
|
41
|
+
rightMax[n - 1] = height[n - 1];
|
|
42
|
+
for (let i = n - 2; i >= 0; i--) {
|
|
43
|
+
rightMax[i] = Math.max(rightMax[i + 1], height[i]);
|
|
44
|
+
}
|
|
45
|
+
let water = 0;
|
|
46
|
+
for (let i = 0; i < n; i++) {
|
|
47
|
+
water += Math.min(leftMax[i], rightMax[i]) - height[i];
|
|
48
|
+
}
|
|
49
|
+
return water;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=trap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trap.js","sourceRoot":"","sources":["../../../src/functions/algorithm/trap.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,IAAI,CAAC,MAAgB;IACnC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAA;IAEjC,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;IAC7B,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,OAAO,IAAI,GAAG,KAAK,EAAE,CAAC;QACpB,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACjC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;gBAC5B,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;YACxB,CAAC;iBAAM,CAAC;gBACN,KAAK,IAAI,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;YACjC,CAAC;YACD,IAAI,EAAE,CAAA;QACR,CAAC;aAAM,CAAC;YACN,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;gBAC9B,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;YAC1B,CAAC;iBAAM,CAAC;gBACN,KAAK,IAAI,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;YACnC,CAAC;YACD,KAAK,EAAE,CAAA;QACT,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAKD,MAAM,UAAU,M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CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function chunk<T>(array: T[], size: number): T[][];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function chunk(array, size) {
|
|
2
|
+
if (size <= 0) {
|
|
3
|
+
throw new Error('Chunk size must be greater than 0');
|
|
4
|
+
}
|
|
5
|
+
const result = [];
|
|
6
|
+
for (let i = 0; i < array.length; i += size) {
|
|
7
|
+
result.push(array.slice(i, i + size));
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=chunk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/functions/array-object/chunk.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,KAAK,CAAI,KAAU,EAAE,IAAY;IAC/C,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IACtD,CAAC;IAED,MAAM,MAAM,GAAU,EAAE,CAAA;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACvC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface DeepCloneOptions {
|
|
2
|
+
includeNonEnumerable?: boolean;
|
|
3
|
+
includeSymbol?: boolean;
|
|
4
|
+
includePrototype?: boolean;
|
|
5
|
+
customClone?: (value: any, defaultClone: (v: any) => any) => any;
|
|
6
|
+
}
|
|
7
|
+
export declare function deepClone<T>(value: T, options?: DeepCloneOptions): T;
|
|
8
|
+
export declare function deepCloneJSON<T>(value: T): T;
|
|
9
|
+
export interface DeepCloneStructuredDeps {
|
|
10
|
+
structuredClone?: <T>(value: T) => T;
|
|
11
|
+
}
|
|
12
|
+
export declare function deepCloneStructured<T>(value: T, deps: DeepCloneStructuredDeps): T;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export function deepClone(value, options = {}) {
|
|
2
|
+
const cache = new WeakMap();
|
|
3
|
+
function clone(val) {
|
|
4
|
+
if (val === null || typeof val !== 'object') {
|
|
5
|
+
return val;
|
|
6
|
+
}
|
|
7
|
+
if (cache.has(val)) {
|
|
8
|
+
return cache.get(val);
|
|
9
|
+
}
|
|
10
|
+
if (options.customClone) {
|
|
11
|
+
const customResult = options.customClone(val, clone);
|
|
12
|
+
if (customResult !== undefined) {
|
|
13
|
+
return customResult;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const type = Object.prototype.toString.call(val);
|
|
17
|
+
if (type === '[object Date]') {
|
|
18
|
+
return new Date(val.getTime());
|
|
19
|
+
}
|
|
20
|
+
if (type === '[object RegExp]') {
|
|
21
|
+
const pattern = val.source;
|
|
22
|
+
const flags = val.flags;
|
|
23
|
+
return new RegExp(pattern, flags);
|
|
24
|
+
}
|
|
25
|
+
if (val instanceof Error) {
|
|
26
|
+
const errorCopy = new val.constructor(val.message);
|
|
27
|
+
errorCopy.stack = val.stack;
|
|
28
|
+
errorCopy.name = val.name;
|
|
29
|
+
return errorCopy;
|
|
30
|
+
}
|
|
31
|
+
if (type === '[object Map]') {
|
|
32
|
+
const mapCopy = new Map();
|
|
33
|
+
cache.set(val, mapCopy);
|
|
34
|
+
val.forEach((value, key) => {
|
|
35
|
+
mapCopy.set(clone(key), clone(value));
|
|
36
|
+
});
|
|
37
|
+
return mapCopy;
|
|
38
|
+
}
|
|
39
|
+
if (type === '[object Set]') {
|
|
40
|
+
const setCopy = new Set();
|
|
41
|
+
cache.set(val, setCopy);
|
|
42
|
+
val.forEach(value => {
|
|
43
|
+
setCopy.add(clone(value));
|
|
44
|
+
});
|
|
45
|
+
return setCopy;
|
|
46
|
+
}
|
|
47
|
+
if (type === '[object WeakMap]') {
|
|
48
|
+
return new WeakMap();
|
|
49
|
+
}
|
|
50
|
+
if (type === '[object WeakSet]') {
|
|
51
|
+
return new WeakSet();
|
|
52
|
+
}
|
|
53
|
+
if (type === '[object ArrayBuffer]') {
|
|
54
|
+
const buffer = val;
|
|
55
|
+
const copy = new ArrayBuffer(buffer.byteLength);
|
|
56
|
+
new Uint8Array(copy).set(new Uint8Array(buffer));
|
|
57
|
+
return copy;
|
|
58
|
+
}
|
|
59
|
+
if (ArrayBuffer.isView(val) && !(val instanceof DataView)) {
|
|
60
|
+
const typedArray = val;
|
|
61
|
+
const TypedArrayConstructor = typedArray.constructor;
|
|
62
|
+
const copy = new TypedArrayConstructor(typedArray.length);
|
|
63
|
+
copy.set(typedArray);
|
|
64
|
+
return copy;
|
|
65
|
+
}
|
|
66
|
+
if (type === '[object DataView]') {
|
|
67
|
+
const dataView = val;
|
|
68
|
+
const bufferCopy = clone(dataView.buffer);
|
|
69
|
+
return new DataView(bufferCopy, dataView.byteOffset, dataView.byteLength);
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(val)) {
|
|
72
|
+
const arrCopy = [];
|
|
73
|
+
cache.set(val, arrCopy);
|
|
74
|
+
for (let i = 0; i < val.length; i++) {
|
|
75
|
+
arrCopy[i] = clone(val[i]);
|
|
76
|
+
}
|
|
77
|
+
return arrCopy;
|
|
78
|
+
}
|
|
79
|
+
let objCopy;
|
|
80
|
+
if (options.includePrototype) {
|
|
81
|
+
objCopy = Object.create(Object.getPrototypeOf(val));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
objCopy = {};
|
|
85
|
+
}
|
|
86
|
+
cache.set(val, objCopy);
|
|
87
|
+
for (const key in val) {
|
|
88
|
+
if (Object.prototype.hasOwnProperty.call(val, key)) {
|
|
89
|
+
objCopy[key] = clone(val[key]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (options.includeNonEnumerable) {
|
|
93
|
+
const propertyNames = Object.getOwnPropertyNames(val);
|
|
94
|
+
for (const key of propertyNames) {
|
|
95
|
+
if (!objCopy.hasOwnProperty(key)) {
|
|
96
|
+
const descriptor = Object.getOwnPropertyDescriptor(val, key);
|
|
97
|
+
if (descriptor) {
|
|
98
|
+
Object.defineProperty(objCopy, key, {
|
|
99
|
+
...descriptor,
|
|
100
|
+
value: clone(descriptor.value)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (options.includeSymbol) {
|
|
107
|
+
const symbols = Object.getOwnPropertySymbols(val);
|
|
108
|
+
for (const symbol of symbols) {
|
|
109
|
+
const descriptor = Object.getOwnPropertyDescriptor(val, symbol);
|
|
110
|
+
if (descriptor) {
|
|
111
|
+
Object.defineProperty(objCopy, symbol, {
|
|
112
|
+
...descriptor,
|
|
113
|
+
value: clone(descriptor.value)
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return objCopy;
|
|
119
|
+
}
|
|
120
|
+
return clone(value);
|
|
121
|
+
}
|
|
122
|
+
export function deepCloneJSON(value) {
|
|
123
|
+
return JSON.parse(JSON.stringify(value));
|
|
124
|
+
}
|
|
125
|
+
export function deepCloneStructured(value, deps) {
|
|
126
|
+
if (deps.structuredClone) {
|
|
127
|
+
return deps.structuredClone(value);
|
|
128
|
+
}
|
|
129
|
+
return deepClone(value);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=deepClone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepClone.js","sourceRoot":"","sources":["../../../src/functions/array-object/deepClone.ts"],"names":[],"mappings":"AA0CA,MAAM,UAAU,SAAS,CAAI,KAAQ,EAAE,UAA4B,EAAE;IAEnE,MAAM,KAAK,GAAG,IAAI,OAAO,EAAY,CAAA;IAErC,SAAS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OAAO,KAAK,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC;AAiBD,MAAM,UAAU,aAAa,CAAI,KAAQ;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;AAC1C,CAAC;AAsBD,MAAM,UAAU,mBAAmB,CAAI,KAAQ,EAAE,IAA6B;IAE5E,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAGD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function evolve(transformations) {
|
|
2
|
+
return (obj) => {
|
|
3
|
+
if (!obj || typeof obj !== 'object')
|
|
4
|
+
return obj;
|
|
5
|
+
const result = { ...obj };
|
|
6
|
+
for (const key in transformations) {
|
|
7
|
+
if (obj.hasOwnProperty(key) && transformations[key]) {
|
|
8
|
+
const transform = transformations[key];
|
|
9
|
+
result[key] = transform(obj[key]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=evolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evolve.js","sourceRoot":"","sources":["../../../src/functions/array-object/evolve.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,MAAM,CACpB,eAMC;IAED,OAAO,CAAC,GAAM,EAAO,EAAE;QACrB,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAA;QAE/C,MAAM,MAAM,GAAQ,EAAE,GAAG,GAAG,EAAE,CAAA;QAE9B,KAAK,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;YAClC,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpD,MAAM,SAAS,GAAG,eAAe,CAAC,GAAG,CAAa,CAAA;gBAClD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;YACnC,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function flatten<T>(arr: any[], depth?: number): T[];
|
|
2
|
+
export declare function flattenReduce<T>(arr: any[], depth?: number): T[];
|
|
3
|
+
export declare function flattenIterative<T>(arr: any[]): T[];
|
|
4
|
+
export declare function flattenGenerator(arr: any[]): Generator<any>;
|
|
5
|
+
export declare function flattenWithGenerator<T>(arr: any[]): T[];
|
|
6
|
+
export declare function flattenToString(arr: any[]): number[];
|
|
7
|
+
export declare function flattenNative<T>(arr: any[], depth?: number): T[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function flatten(arr, depth = Infinity) {
|
|
2
|
+
const result = [];
|
|
3
|
+
function flattenHelper(items, currentDepth) {
|
|
4
|
+
for (const item of items) {
|
|
5
|
+
if (Array.isArray(item) && currentDepth > 0) {
|
|
6
|
+
flattenHelper(item, currentDepth - 1);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
result.push(item);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
flattenHelper(arr, depth);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
export function flattenReduce(arr, depth = Infinity) {
|
|
17
|
+
if (depth <= 0) {
|
|
18
|
+
return arr.slice();
|
|
19
|
+
}
|
|
20
|
+
return arr.reduce((acc, item) => {
|
|
21
|
+
if (Array.isArray(item)) {
|
|
22
|
+
return acc.concat(flattenReduce(item, depth - 1));
|
|
23
|
+
}
|
|
24
|
+
return acc.concat(item);
|
|
25
|
+
}, []);
|
|
26
|
+
}
|
|
27
|
+
export function flattenIterative(arr) {
|
|
28
|
+
const stack = [...arr];
|
|
29
|
+
const result = [];
|
|
30
|
+
while (stack.length) {
|
|
31
|
+
const item = stack.pop();
|
|
32
|
+
if (Array.isArray(item)) {
|
|
33
|
+
stack.push(...item);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
result.unshift(item);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
export function* flattenGenerator(arr) {
|
|
42
|
+
for (const item of arr) {
|
|
43
|
+
if (Array.isArray(item)) {
|
|
44
|
+
yield* flattenGenerator(item);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
yield item;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function flattenWithGenerator(arr) {
|
|
52
|
+
return [...flattenGenerator(arr)];
|
|
53
|
+
}
|
|
54
|
+
export function flattenToString(arr) {
|
|
55
|
+
return arr.toString().split(',').map(Number);
|
|
56
|
+
}
|
|
57
|
+
export function flattenNative(arr, depth = Infinity) {
|
|
58
|
+
return arr.flat(depth);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=flatten.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.js","sourceRoot":"","sources":["../../../src/functions/array-object/flatten.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,OAAO,CAAI,GAAU,EAAE,QAAgB,QAAQ;IAC7D,MAAM,MAAM,GAAQ,EAAE,CAAA;IAEtB,SAAS,aAAa,CAAC,KAAY,EAAE,YAAoB;QACvD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;gBAC5C,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,CAAC,CAAC,CAAA;YACvC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,C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EAAE,CAAC;YACxB,KAAK,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAA;QACZ,CAAC;IACH,CAAC;AACH,CAAC;AAKD,MAAM,UAAU,oBAAoB,CAAI,GAAU;IAChD,OAAO,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAA;AACnC,CAAC;AAKD,MAAM,UAAU,eAAe,CAAC,GAAU;IACxC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC;AAKD,MAAM,UAAU,aAAa,CAAI,GAAU,EAAE,QAAgB,QAAQ;IACnE,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function flattenObject(obj: Record<string, any>, prefix?: string): Record<string, any>;
|
|
2
|
+
export declare function flattenObjectWithArray(obj: Record<string, any>, prefix?: string): Record<string, any>;
|
|
3
|
+
export declare function unflattenObject(obj: Record<string, any>): Record<string, any>;
|
|
4
|
+
export declare function flattenObjectKeepArray(obj: Record<string, any>, prefix?: string): Record<string, any>;
|
|
5
|
+
export declare function flattenObjectDeep(obj: any, prefix?: string): Record<string, any>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export function flattenObject(obj, prefix = '') {
|
|
2
|
+
const result = {};
|
|
3
|
+
for (const key in obj) {
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
5
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
6
|
+
const value = obj[key];
|
|
7
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
8
|
+
Object.assign(result, flattenObject(value, newKey));
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
result[newKey] = value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
export function flattenObjectWithArray(obj, prefix = '') {
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const key in obj) {
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
21
|
+
const newKey = prefix ? `${prefix}[${key}]` : key;
|
|
22
|
+
const value = obj[key];
|
|
23
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
24
|
+
Object.assign(result, flattenObjectWithArray(value, newKey));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
result[newKey] = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
export function unflattenObject(obj) {
|
|
34
|
+
const result = {};
|
|
35
|
+
for (const key in obj) {
|
|
36
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
37
|
+
const keys = key.split('.');
|
|
38
|
+
let current = result;
|
|
39
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
40
|
+
const k = keys[i];
|
|
41
|
+
if (!(k in current)) {
|
|
42
|
+
current[k] = {};
|
|
43
|
+
}
|
|
44
|
+
current = current[k];
|
|
45
|
+
}
|
|
46
|
+
current[keys[keys.length - 1]] = obj[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
export function flattenObjectKeepArray(obj, prefix = '') {
|
|
52
|
+
const result = {};
|
|
53
|
+
for (const key in obj) {
|
|
54
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
55
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
56
|
+
const value = obj[key];
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
result[newKey] = value;
|
|
59
|
+
}
|
|
60
|
+
else if (value !== null && typeof value === 'object') {
|
|
61
|
+
Object.assign(result, flattenObjectKeepArray(value, newKey));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
result[newKey] = value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
export function flattenObjectDeep(obj, prefix = '') {
|
|
71
|
+
const result = {};
|
|
72
|
+
if (Array.isArray(obj)) {
|
|
73
|
+
obj.forEach((item, index) => {
|
|
74
|
+
const newKey = prefix ? `${prefix}.${index}` : String(index);
|
|
75
|
+
if (item !== null && typeof item === 'object') {
|
|
76
|
+
Object.assign(result, flattenObjectDeep(item, newKey));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
result[newKey] = item;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else if (obj !== null && typeof obj === 'object') {
|
|
84
|
+
for (const key in obj) {
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
86
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
87
|
+
const value = obj[key];
|
|
88
|
+
if (value !== null && typeof value === 'object') {
|
|
89
|
+
Object.assign(result, flattenObjectDeep(value, newKey));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
result[newKey] = value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
result[prefix] = obj;
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=flattenObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenObject.js","sourceRoot":"","sources":["../../../src/functions/array-object/flattenObject.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,aAAa,CAC3B,GAAwB,EACxB,SAAiB,EAAE;IAEnB,MAAM,MAAM,GAAwB,EAAE,CAAA;IAEtC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,SA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G,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnD,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACtB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;gBACnD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;gBAChD,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;gBAEtB,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAChD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;gBACzD,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAA;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAA;IACtB,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function groupBy<T>(array: T[], keyOrFn: keyof T | ((item: T) => string | number)): Record<string, T[]>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function groupBy(array, keyOrFn) {
|
|
2
|
+
const result = {};
|
|
3
|
+
for (const item of array) {
|
|
4
|
+
const key = typeof keyOrFn === 'function'
|
|
5
|
+
? String(keyOrFn(item))
|
|
6
|
+
: String(item[keyOrFn]);
|
|
7
|
+
if (!result[key]) {
|
|
8
|
+
result[key] = [];
|
|
9
|
+
}
|
|
10
|
+
result[key].push(item);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=groupBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groupBy.js","sourceRoot":"","sources":["../../../src/functions/array-object/groupBy.ts"],"names":[],"mappings":"AAwBA,MAAM,UAAU,OAAO,CACrB,KAAU,EACV,OAAiD;IAEjD,MAAM,MAAM,GAAwB,EAAE,CAAA;IAEtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,OAAO,OAAO,KAAK,UAAU;YACvC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACjB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;QAClB,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../../../src/functions/array-object/omit.ts"],"names":[],"mappings":"AAoBA,MAAM,UAAU,IAAI,CAClB,GAAM,EACN,IAAS;IAET,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAS,CAAA;IAEhC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;IAED,OAAO,MAAoB,CAAA;AAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../../src/functions/array-object/pick.ts"],"names":[],"mappings":"AAoBA,MAAM,UAAU,IAAI,CAClB,GAAM,EACN,IAAS;IAET,MAAM,MAAM,GAAG,EAAgB,CAAA;IAE/B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;YACf,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function shuffle<T>(array: T[]): T[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function shuffle(array) {
|
|
2
|
+
const result = [...array];
|
|
3
|
+
for (let i = result.length - 1; i > 0; i--) {
|
|
4
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
5
|
+
[result[i], result[j]] = [result[j], result[i]];
|
|
6
|
+
}
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=shuffle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shuffle.js","sourceRoot":"","sources":["../../../src/functions/array-object/shuffle.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,OAAO,CAAI,KAAU;IACnC,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;IAEzB,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAC5C;QAAA,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sortBy<T>(array: T[], keyOrFn: keyof T | ((item: T) => any), order?: 'asc' | 'desc'): T[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function sortBy(array, keyOrFn, order = 'asc') {
|
|
2
|
+
const sorted = [...array].sort((a, b) => {
|
|
3
|
+
const aValue = typeof keyOrFn === 'function' ? keyOrFn(a) : a[keyOrFn];
|
|
4
|
+
const bValue = typeof keyOrFn === 'function' ? keyOrFn(b) : b[keyOrFn];
|
|
5
|
+
if (aValue < bValue)
|
|
6
|
+
return order === 'asc' ? -1 : 1;
|
|
7
|
+
if (aValue > bValue)
|
|
8
|
+
return order === 'asc' ? 1 : -1;
|
|
9
|
+
return 0;
|
|
10
|
+
});
|
|
11
|
+
return sorted;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=sortBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortBy.js","sourceRoot":"","sources":["../../../src/functions/array-object/sortBy.ts"],"names":[],"mappings":"AAyBA,MAAM,UAAU,MAAM,CACpB,KAAU,EACV,OAAqC,EACrC,QAAwB,KAAK;IAE7B,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QACtE,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAEtE,IAAI,MAAM,GAAG,MAAM;YAAE,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACpD,IAAI,MAAM,GAAG,MAAM;YAAE,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACpD,OAAO,CAAC,CAAA;IACV,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function unique<T>(arr: T[]): T[];
|
|
2
|
+
export declare function uniqueLoop<T>(arr: T[]): T[];
|
|
3
|
+
export declare function uniqueIndexOf<T>(arr: T[]): T[];
|
|
4
|
+
export declare function uniqueIncludes<T>(arr: T[]): T[];
|
|
5
|
+
export declare function uniqueFilter<T>(arr: T[]): T[];
|
|
6
|
+
export declare function uniqueReduce<T>(arr: T[]): T[];
|
|
7
|
+
export declare function uniqueMap<T>(arr: T[]): T[];
|
|
8
|
+
export declare function uniqueBy<T extends Record<string, any>>(arr: T[], key: keyof T): T[];
|
|
9
|
+
export declare function uniqueWith<T, K>(arr: T[], fn: (item: T) => K): T[];
|
|
10
|
+
export declare function uniqueAndSort(arr: number[]): number[];
|