es-toolkit 1.50.0 → 1.51.0-dev.2069
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/CHANGELOG.md +82 -0
- package/NOTICE +39 -0
- package/README.md +2 -2
- package/bigint.d.ts +1 -0
- package/bigint.js +1 -0
- package/dist/_internal/NonPlainObject.d.mts +8 -0
- package/dist/_internal/NonPlainObject.d.ts +8 -0
- package/dist/_internal/bigIntRangeLength.js +19 -0
- package/dist/_internal/bigIntRangeLength.mjs +19 -0
- package/dist/_internal/isMergeableValue.js +17 -0
- package/dist/_internal/isMergeableValue.mjs +17 -0
- package/dist/_internal/isUnsafeProperty.js +7 -4
- package/dist/_internal/isUnsafeProperty.mjs +7 -4
- package/dist/_internal/isUnsafeToWriteProperty.js +22 -0
- package/dist/_internal/isUnsafeToWriteProperty.mjs +22 -0
- package/dist/array/at.d.mts +1 -1
- package/dist/array/at.d.ts +1 -1
- package/dist/array/filterAsync.js +1 -1
- package/dist/array/filterAsync.mjs +1 -1
- package/dist/array/flatMapAsync.js +1 -1
- package/dist/array/flatMapAsync.mjs +1 -1
- package/dist/array/forEachAsync.js +1 -1
- package/dist/array/forEachAsync.mjs +1 -1
- package/dist/array/index.js +1 -1
- package/dist/array/index.mjs +1 -1
- package/dist/array/limitAsync.d.mts +4 -28
- package/dist/array/limitAsync.d.ts +4 -28
- package/dist/array/limitAsync.js +2 -39
- package/dist/array/limitAsync.mjs +3 -39
- package/dist/array/mapAsync.js +1 -1
- package/dist/array/mapAsync.mjs +1 -1
- package/dist/array/orderBy.d.mts +1 -1
- package/dist/array/orderBy.d.ts +1 -1
- package/dist/array/pullAt.d.mts +1 -1
- package/dist/array/pullAt.d.ts +1 -1
- package/dist/array/pullAt.js +1 -1
- package/dist/array/pullAt.mjs +1 -1
- package/dist/array/sortBy.d.mts +1 -1
- package/dist/array/sortBy.d.ts +1 -1
- package/dist/array/unzip.d.mts +3 -0
- package/dist/array/unzip.d.ts +3 -0
- package/dist/array/unzip.js +3 -0
- package/dist/array/unzip.mjs +3 -0
- package/dist/bigint/clamp.d.mts +37 -0
- package/dist/bigint/clamp.d.ts +37 -0
- package/dist/bigint/clamp.js +16 -0
- package/dist/bigint/clamp.mjs +16 -0
- package/dist/bigint/inRange.d.mts +37 -0
- package/dist/bigint/inRange.d.ts +37 -0
- package/dist/bigint/inRange.js +20 -0
- package/dist/bigint/inRange.mjs +20 -0
- package/dist/bigint/index.d.mts +14 -0
- package/dist/bigint/index.d.ts +14 -0
- package/dist/bigint/index.js +27 -0
- package/dist/bigint/index.mjs +14 -0
- package/dist/bigint/max.d.mts +21 -0
- package/dist/bigint/max.d.ts +21 -0
- package/dist/bigint/max.js +26 -0
- package/dist/bigint/max.mjs +26 -0
- package/dist/bigint/maxBy.d.mts +21 -0
- package/dist/bigint/maxBy.d.ts +21 -0
- package/dist/bigint/maxBy.js +34 -0
- package/dist/bigint/maxBy.mjs +34 -0
- package/dist/bigint/median.d.mts +22 -0
- package/dist/bigint/median.d.ts +22 -0
- package/dist/bigint/median.js +28 -0
- package/dist/bigint/median.mjs +28 -0
- package/dist/bigint/medianBy.d.mts +21 -0
- package/dist/bigint/medianBy.d.ts +21 -0
- package/dist/bigint/medianBy.js +24 -0
- package/dist/bigint/medianBy.mjs +24 -0
- package/dist/bigint/min.d.mts +18 -0
- package/dist/bigint/min.d.ts +18 -0
- package/dist/bigint/min.js +23 -0
- package/dist/bigint/min.mjs +23 -0
- package/dist/bigint/minBy.d.mts +21 -0
- package/dist/bigint/minBy.d.ts +21 -0
- package/dist/bigint/minBy.js +34 -0
- package/dist/bigint/minBy.mjs +34 -0
- package/dist/bigint/percentile.d.mts +23 -0
- package/dist/bigint/percentile.d.ts +23 -0
- package/dist/bigint/percentile.js +31 -0
- package/dist/bigint/percentile.mjs +31 -0
- package/dist/bigint/range.d.mts +45 -0
- package/dist/bigint/range.d.ts +45 -0
- package/dist/bigint/range.js +24 -0
- package/dist/bigint/range.mjs +24 -0
- package/dist/bigint/rangeRight.d.mts +43 -0
- package/dist/bigint/rangeRight.d.ts +43 -0
- package/dist/bigint/rangeRight.js +25 -0
- package/dist/bigint/rangeRight.mjs +25 -0
- package/dist/bigint/sum.d.mts +18 -0
- package/dist/bigint/sum.d.ts +18 -0
- package/dist/bigint/sum.js +22 -0
- package/dist/bigint/sum.mjs +22 -0
- package/dist/bigint/sumBy.d.mts +20 -0
- package/dist/bigint/sumBy.d.ts +20 -0
- package/dist/bigint/sumBy.js +24 -0
- package/dist/bigint/sumBy.mjs +24 -0
- package/dist/browser.global.js +6 -3
- package/dist/compat/_internal/normalizeZero.js +13 -0
- package/dist/compat/_internal/normalizeZero.mjs +13 -0
- package/dist/compat/_internal/toKey.js +1 -1
- package/dist/compat/_internal/toKey.mjs +1 -1
- package/dist/compat/_internal/unicodeSize.js +45 -0
- package/dist/compat/_internal/unicodeSize.mjs +45 -0
- package/dist/compat/array/chunk.js +1 -0
- package/dist/compat/array/chunk.mjs +1 -0
- package/dist/compat/array/difference.js +2 -1
- package/dist/compat/array/difference.mjs +2 -1
- package/dist/compat/array/differenceBy.js +3 -2
- package/dist/compat/array/differenceBy.mjs +3 -2
- package/dist/compat/array/drop.d.mts +1 -1
- package/dist/compat/array/drop.d.ts +1 -1
- package/dist/compat/array/dropRight.d.mts +2 -3
- package/dist/compat/array/dropRight.d.ts +2 -3
- package/dist/compat/array/dropRight.js +4 -4
- package/dist/compat/array/dropRight.mjs +4 -4
- package/dist/compat/array/every.js +9 -9
- package/dist/compat/array/every.mjs +9 -9
- package/dist/compat/array/fill.js +8 -2
- package/dist/compat/array/fill.mjs +8 -2
- package/dist/compat/array/find.js +14 -13
- package/dist/compat/array/find.mjs +14 -13
- package/dist/compat/array/findIndex.js +3 -19
- package/dist/compat/array/findIndex.mjs +3 -19
- package/dist/compat/array/findLast.js +3 -3
- package/dist/compat/array/findLast.mjs +3 -3
- package/dist/compat/array/flatMap.js +3 -8
- package/dist/compat/array/flatMap.mjs +3 -7
- package/dist/compat/array/flatMapDepth.js +1 -1
- package/dist/compat/array/flatMapDepth.mjs +1 -1
- package/dist/compat/array/forEach.js +1 -1
- package/dist/compat/array/forEach.mjs +1 -1
- package/dist/compat/array/includes.js +13 -13
- package/dist/compat/array/includes.mjs +13 -13
- package/dist/compat/array/indexOf.js +2 -1
- package/dist/compat/array/indexOf.mjs +2 -1
- package/dist/compat/array/intersection.js +3 -2
- package/dist/compat/array/intersection.mjs +3 -2
- package/dist/compat/array/intersectionBy.js +7 -11
- package/dist/compat/array/intersectionBy.mjs +7 -11
- package/dist/compat/array/intersectionWith.js +6 -18
- package/dist/compat/array/intersectionWith.mjs +6 -18
- package/dist/compat/array/last.js +1 -1
- package/dist/compat/array/last.mjs +1 -1
- package/dist/compat/array/lastIndexOf.js +3 -1
- package/dist/compat/array/lastIndexOf.mjs +3 -1
- package/dist/compat/array/map.js +3 -3
- package/dist/compat/array/map.mjs +3 -3
- package/dist/compat/array/orderBy.js +8 -6
- package/dist/compat/array/orderBy.mjs +8 -6
- package/dist/compat/array/partition.js +6 -6
- package/dist/compat/array/partition.mjs +6 -6
- package/dist/compat/array/pull.js +1 -1
- package/dist/compat/array/pull.mjs +1 -1
- package/dist/compat/array/pullAll.js +2 -0
- package/dist/compat/array/pullAll.mjs +2 -0
- package/dist/compat/array/remove.js +8 -4
- package/dist/compat/array/remove.mjs +8 -4
- package/dist/compat/array/reverse.js +1 -1
- package/dist/compat/array/reverse.mjs +1 -1
- package/dist/compat/array/sampleSize.js +2 -1
- package/dist/compat/array/sampleSize.mjs +2 -1
- package/dist/compat/array/size.js +2 -1
- package/dist/compat/array/size.mjs +2 -1
- package/dist/compat/array/some.js +2 -1
- package/dist/compat/array/some.mjs +2 -1
- package/dist/compat/array/takeRightWhile.js +2 -2
- package/dist/compat/array/takeRightWhile.mjs +2 -2
- package/dist/compat/array/takeWhile.js +2 -2
- package/dist/compat/array/takeWhile.mjs +2 -2
- package/dist/compat/array/unionBy.js +2 -1
- package/dist/compat/array/unionBy.mjs +2 -1
- package/dist/compat/array/uniqBy.js +4 -3
- package/dist/compat/array/uniqBy.mjs +4 -3
- package/dist/compat/array/unzip.d.mts +3 -0
- package/dist/compat/array/unzip.d.ts +3 -0
- package/dist/compat/array/unzip.js +3 -0
- package/dist/compat/array/unzip.mjs +3 -0
- package/dist/compat/array/unzipWith.js +1 -1
- package/dist/compat/array/unzipWith.mjs +1 -1
- package/dist/compat/array/zipObject.js +2 -0
- package/dist/compat/array/zipObject.mjs +2 -0
- package/dist/compat/compat.d.mts +3 -3
- package/dist/compat/compat.d.ts +3 -3
- package/dist/compat/compat.js +8 -4
- package/dist/compat/compat.mjs +8 -4
- package/dist/compat/function/curry.d.mts +1 -1
- package/dist/compat/function/curry.d.ts +1 -1
- package/dist/compat/function/debounce.js +1 -1
- package/dist/compat/function/debounce.mjs +1 -1
- package/dist/compat/function/flowRight.d.mts +1 -1
- package/dist/compat/function/flowRight.d.ts +1 -1
- package/dist/compat/function/partial.d.mts +1 -1
- package/dist/compat/function/partial.d.ts +1 -1
- package/dist/compat/function/rest.d.mts +1 -1
- package/dist/compat/function/rest.d.ts +1 -1
- package/dist/compat/function/rest.js +1 -1
- package/dist/compat/function/rest.mjs +1 -1
- package/dist/compat/index.d.mts +3 -3
- package/dist/compat/index.d.ts +3 -3
- package/dist/compat/index.js +6 -4
- package/dist/compat/index.mjs +5 -5
- package/dist/compat/math/maxBy.js +1 -1
- package/dist/compat/math/maxBy.mjs +1 -1
- package/dist/compat/math/meanBy.d.mts +4 -0
- package/dist/compat/math/meanBy.d.ts +4 -0
- package/dist/compat/math/meanBy.js +8 -3
- package/dist/compat/math/meanBy.mjs +8 -3
- package/dist/compat/math/minBy.js +1 -1
- package/dist/compat/math/minBy.mjs +1 -1
- package/dist/compat/object/cloneDeep.d.mts +5 -5
- package/dist/compat/object/cloneDeep.d.ts +5 -5
- package/dist/compat/object/cloneDeep.js +5 -5
- package/dist/compat/object/cloneDeep.mjs +5 -5
- package/dist/compat/object/cloneDeepWith.js +3 -1
- package/dist/compat/object/cloneDeepWith.mjs +3 -1
- package/dist/compat/object/cloneWith.d.mts +1 -1
- package/dist/compat/object/cloneWith.d.ts +1 -1
- package/dist/compat/object/cloneWith.js +1 -1
- package/dist/compat/object/cloneWith.mjs +1 -1
- package/dist/compat/object/entries.d.mts +1 -0
- package/dist/compat/object/entries.d.ts +1 -0
- package/dist/compat/object/entries.js +1 -0
- package/dist/compat/object/entries.mjs +1 -0
- package/dist/compat/object/entriesIn.d.mts +1 -0
- package/dist/compat/object/entriesIn.d.ts +1 -0
- package/dist/compat/object/entriesIn.js +1 -0
- package/dist/compat/object/entriesIn.mjs +1 -0
- package/dist/compat/object/omit.js +5 -5
- package/dist/compat/object/omit.mjs +5 -5
- package/dist/compat/object/transform.js +1 -1
- package/dist/compat/object/transform.mjs +1 -1
- package/dist/compat/object/updateWith.js +2 -2
- package/dist/compat/object/updateWith.mjs +2 -2
- package/dist/compat/predicate/isMatchWith.js +14 -5
- package/dist/compat/predicate/isMatchWith.mjs +14 -5
- package/dist/compat/string/template.js +2 -1
- package/dist/compat/string/template.mjs +2 -1
- package/dist/compat/string/words.js +17 -13
- package/dist/compat/string/words.mjs +17 -13
- package/dist/compat/util/iteratee.js +1 -3
- package/dist/compat/util/iteratee.mjs +1 -3
- package/dist/compat/util/toArray.d.mts +5 -5
- package/dist/compat/util/toArray.d.ts +5 -5
- package/dist/compat/util/toArray.js +9 -5
- package/dist/compat/util/toArray.mjs +9 -5
- package/dist/compat/util/toPath.js +11 -3
- package/dist/compat/util/toPath.mjs +11 -3
- package/dist/compat/util/toString.js +4 -1
- package/dist/compat/util/toString.mjs +4 -1
- package/dist/fp/array/at.d.mts +1 -1
- package/dist/fp/array/at.d.ts +1 -1
- package/dist/fp/array/orderBy.d.mts +1 -1
- package/dist/fp/array/orderBy.d.ts +1 -1
- package/dist/fp/array/sortBy.d.mts +1 -1
- package/dist/fp/array/sortBy.d.ts +1 -1
- package/dist/fp/array/unzip.d.mts +3 -0
- package/dist/fp/array/unzip.d.ts +3 -0
- package/dist/fp/array/unzip.js +3 -0
- package/dist/fp/array/unzip.mjs +3 -0
- package/dist/fp/iterator/chunk.d.mts +19 -0
- package/dist/fp/iterator/chunk.d.ts +19 -0
- package/dist/fp/iterator/chunk.js +24 -0
- package/dist/fp/iterator/chunk.mjs +24 -0
- package/dist/fp/iterator/count.d.mts +20 -0
- package/dist/fp/iterator/count.d.ts +20 -0
- package/dist/fp/iterator/count.js +25 -0
- package/dist/fp/iterator/count.mjs +25 -0
- package/dist/fp/iterator/drop.d.mts +20 -0
- package/dist/fp/iterator/drop.d.ts +20 -0
- package/dist/fp/iterator/drop.js +24 -0
- package/dist/fp/iterator/drop.mjs +24 -0
- package/dist/fp/iterator/dropWhile.d.mts +18 -0
- package/dist/fp/iterator/dropWhile.d.ts +18 -0
- package/dist/fp/iterator/dropWhile.js +23 -0
- package/dist/fp/iterator/dropWhile.mjs +23 -0
- package/dist/fp/iterator/every.d.mts +20 -0
- package/dist/fp/iterator/every.d.ts +20 -0
- package/dist/fp/iterator/every.js +24 -0
- package/dist/fp/iterator/every.mjs +24 -0
- package/dist/fp/iterator/filter.d.mts +37 -0
- package/dist/fp/iterator/filter.d.ts +37 -0
- package/dist/fp/iterator/filter.js +8 -0
- package/dist/fp/iterator/filter.mjs +8 -0
- package/dist/fp/iterator/find.d.mts +20 -0
- package/dist/fp/iterator/find.d.ts +20 -0
- package/dist/fp/iterator/find.js +24 -0
- package/dist/fp/iterator/find.mjs +24 -0
- package/dist/fp/iterator/flatMap.d.mts +20 -0
- package/dist/fp/iterator/flatMap.d.ts +20 -0
- package/dist/fp/iterator/flatMap.js +24 -0
- package/dist/fp/iterator/flatMap.mjs +24 -0
- package/dist/fp/iterator/forEach.d.mts +22 -0
- package/dist/fp/iterator/forEach.d.ts +22 -0
- package/dist/fp/iterator/forEach.js +26 -0
- package/dist/fp/iterator/forEach.mjs +26 -0
- package/dist/fp/iterator/head.d.mts +19 -0
- package/dist/fp/iterator/head.d.ts +19 -0
- package/dist/fp/iterator/head.js +24 -0
- package/dist/fp/iterator/head.mjs +24 -0
- package/dist/fp/iterator/index.d.mts +21 -0
- package/dist/fp/iterator/index.d.ts +21 -0
- package/dist/fp/iterator/index.js +41 -0
- package/dist/fp/iterator/index.mjs +21 -0
- package/dist/fp/iterator/map.d.mts +20 -0
- package/dist/fp/iterator/map.d.ts +20 -0
- package/dist/fp/iterator/map.js +24 -0
- package/dist/fp/iterator/map.mjs +24 -0
- package/dist/fp/iterator/partition.d.mts +22 -0
- package/dist/fp/iterator/partition.d.ts +22 -0
- package/dist/fp/iterator/partition.js +27 -0
- package/dist/fp/iterator/partition.mjs +27 -0
- package/dist/fp/iterator/reduce.d.mts +24 -0
- package/dist/fp/iterator/reduce.d.ts +24 -0
- package/dist/fp/iterator/reduce.js +28 -0
- package/dist/fp/iterator/reduce.mjs +28 -0
- package/dist/fp/iterator/scan.d.mts +21 -0
- package/dist/fp/iterator/scan.d.ts +21 -0
- package/dist/fp/iterator/scan.js +26 -0
- package/dist/fp/iterator/scan.mjs +26 -0
- package/dist/fp/iterator/some.d.mts +20 -0
- package/dist/fp/iterator/some.d.ts +20 -0
- package/dist/fp/iterator/some.js +24 -0
- package/dist/fp/iterator/some.mjs +24 -0
- package/dist/fp/iterator/take.d.mts +21 -0
- package/dist/fp/iterator/take.d.ts +21 -0
- package/dist/fp/iterator/take.js +25 -0
- package/dist/fp/iterator/take.mjs +25 -0
- package/dist/fp/iterator/takeWhile.d.mts +19 -0
- package/dist/fp/iterator/takeWhile.d.ts +19 -0
- package/dist/fp/iterator/takeWhile.js +24 -0
- package/dist/fp/iterator/takeWhile.mjs +24 -0
- package/dist/fp/iterator/toArray.d.mts +21 -0
- package/dist/fp/iterator/toArray.d.ts +21 -0
- package/dist/fp/iterator/toArray.js +25 -0
- package/dist/fp/iterator/toArray.mjs +25 -0
- package/dist/fp/iterator/uniqBy.d.mts +20 -0
- package/dist/fp/iterator/uniqBy.d.ts +20 -0
- package/dist/fp/iterator/uniqBy.js +25 -0
- package/dist/fp/iterator/uniqBy.mjs +25 -0
- package/dist/fp/iterator/zip.d.mts +20 -0
- package/dist/fp/iterator/zip.d.ts +20 -0
- package/dist/fp/iterator/zip.js +25 -0
- package/dist/fp/iterator/zip.mjs +25 -0
- package/dist/function/memoize.d.mts +3 -2
- package/dist/function/memoize.d.ts +3 -2
- package/dist/function/memoize.js +3 -2
- package/dist/function/memoize.mjs +3 -2
- package/dist/function/partial.d.mts +2 -2
- package/dist/function/partial.d.ts +2 -2
- package/dist/function/partialRight.d.mts +5 -5
- package/dist/function/partialRight.d.ts +5 -5
- package/dist/function/rest.d.mts +1 -1
- package/dist/function/rest.d.ts +1 -1
- package/dist/function/rest.js +1 -1
- package/dist/function/rest.mjs +1 -1
- package/dist/function/retry.d.mts +7 -4
- package/dist/function/retry.d.ts +7 -4
- package/dist/function/retry.js +4 -2
- package/dist/function/retry.mjs +1 -1
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +18 -4
- package/dist/index.mjs +12 -5
- package/dist/iterator/_internal/iterator.js +74 -0
- package/dist/iterator/_internal/iterator.mjs +74 -0
- package/dist/iterator/chunk.d.mts +21 -0
- package/dist/iterator/chunk.d.ts +21 -0
- package/dist/iterator/chunk.js +40 -0
- package/dist/iterator/chunk.mjs +40 -0
- package/dist/iterator/count.d.mts +18 -0
- package/dist/iterator/count.d.ts +18 -0
- package/dist/iterator/count.js +26 -0
- package/dist/iterator/count.mjs +26 -0
- package/dist/iterator/dropWhile.d.mts +20 -0
- package/dist/iterator/dropWhile.d.ts +20 -0
- package/dist/iterator/dropWhile.js +52 -0
- package/dist/iterator/dropWhile.mjs +52 -0
- package/dist/iterator/head.d.mts +21 -0
- package/dist/iterator/head.d.ts +21 -0
- package/dist/iterator/head.js +26 -0
- package/dist/iterator/head.mjs +26 -0
- package/dist/iterator/index.d.mts +12 -0
- package/dist/iterator/index.d.ts +12 -0
- package/dist/iterator/index.js +23 -0
- package/dist/iterator/index.mjs +12 -0
- package/dist/iterator/iterate.d.mts +20 -0
- package/dist/iterator/iterate.d.ts +20 -0
- package/dist/iterator/iterate.js +32 -0
- package/dist/iterator/iterate.mjs +32 -0
- package/dist/iterator/partition.d.mts +18 -0
- package/dist/iterator/partition.d.ts +18 -0
- package/dist/iterator/partition.js +36 -0
- package/dist/iterator/partition.mjs +36 -0
- package/dist/iterator/range.d.mts +42 -0
- package/dist/iterator/range.d.ts +42 -0
- package/dist/iterator/range.js +25 -0
- package/dist/iterator/range.mjs +25 -0
- package/dist/iterator/scan.d.mts +23 -0
- package/dist/iterator/scan.d.ts +23 -0
- package/dist/iterator/scan.js +47 -0
- package/dist/iterator/scan.mjs +47 -0
- package/dist/iterator/takeWhile.d.mts +20 -0
- package/dist/iterator/takeWhile.d.ts +20 -0
- package/dist/iterator/takeWhile.js +34 -0
- package/dist/iterator/takeWhile.mjs +34 -0
- package/dist/iterator/uniqBy.d.mts +22 -0
- package/dist/iterator/uniqBy.d.ts +22 -0
- package/dist/iterator/uniqBy.js +43 -0
- package/dist/iterator/uniqBy.mjs +43 -0
- package/dist/iterator/zip.d.mts +23 -0
- package/dist/iterator/zip.d.ts +23 -0
- package/dist/iterator/zip.js +45 -0
- package/dist/iterator/zip.mjs +45 -0
- package/dist/object/cloneDeepWith.d.mts +3 -1
- package/dist/object/cloneDeepWith.d.ts +3 -1
- package/dist/object/cloneDeepWith.js +3 -1
- package/dist/object/cloneDeepWith.mjs +3 -1
- package/dist/object/deepFreeze.d.mts +20 -0
- package/dist/object/deepFreeze.d.ts +20 -0
- package/dist/object/deepFreeze.js +29 -0
- package/dist/object/deepFreeze.mjs +29 -0
- package/dist/object/flattenObject.d.mts +16 -1
- package/dist/object/flattenObject.d.ts +16 -1
- package/dist/object/flattenObject.js +15 -6
- package/dist/object/flattenObject.mjs +15 -6
- package/dist/object/index.d.mts +7 -1
- package/dist/object/index.d.ts +7 -1
- package/dist/object/index.js +12 -0
- package/dist/object/index.mjs +7 -1
- package/dist/object/mapKeysAsync.d.mts +25 -0
- package/dist/object/mapKeysAsync.d.ts +25 -0
- package/dist/object/mapKeysAsync.js +32 -0
- package/dist/object/mapKeysAsync.mjs +32 -0
- package/dist/object/mapValuesAsync.d.mts +26 -0
- package/dist/object/mapValuesAsync.d.ts +26 -0
- package/dist/object/mapValuesAsync.js +32 -0
- package/dist/object/mapValuesAsync.mjs +32 -0
- package/dist/object/merge.js +2 -4
- package/dist/object/merge.mjs +1 -3
- package/dist/object/mergeWith.js +4 -4
- package/dist/object/mergeWith.mjs +4 -4
- package/dist/object/toCamelCaseKeys.d.mts +2 -6
- package/dist/object/toCamelCaseKeys.d.ts +2 -6
- package/dist/object/toConstantCaseKeys.d.mts +52 -0
- package/dist/object/toConstantCaseKeys.d.ts +52 -0
- package/dist/object/toConstantCaseKeys.js +66 -0
- package/dist/object/toConstantCaseKeys.mjs +66 -0
- package/dist/object/toKebabCaseKeys.d.mts +52 -0
- package/dist/object/toKebabCaseKeys.d.ts +52 -0
- package/dist/object/toKebabCaseKeys.js +66 -0
- package/dist/object/toKebabCaseKeys.mjs +66 -0
- package/dist/object/toMerged.js +4 -4
- package/dist/object/toMerged.mjs +4 -4
- package/dist/object/toPascalCaseKeys.d.mts +52 -0
- package/dist/object/toPascalCaseKeys.d.ts +52 -0
- package/dist/object/toPascalCaseKeys.js +66 -0
- package/dist/object/toPascalCaseKeys.mjs +66 -0
- package/dist/object/toSnakeCaseKeys.d.mts +2 -3
- package/dist/object/toSnakeCaseKeys.d.ts +2 -3
- package/dist/promise/index.d.mts +2 -1
- package/dist/promise/index.d.ts +2 -1
- package/dist/promise/index.js +2 -0
- package/dist/promise/index.mjs +2 -1
- package/dist/promise/limitAsync.d.mts +35 -0
- package/dist/promise/limitAsync.d.ts +35 -0
- package/dist/promise/limitAsync.js +46 -0
- package/dist/promise/limitAsync.mjs +46 -0
- package/dist/string/dedent.d.mts +37 -0
- package/dist/string/dedent.d.ts +37 -0
- package/dist/string/dedent.js +38 -0
- package/dist/string/dedent.mjs +38 -0
- package/dist/string/index.d.mts +2 -1
- package/dist/string/index.d.ts +2 -1
- package/dist/string/index.js +5 -3
- package/dist/string/index.mjs +5 -4
- package/dist/types/ToCamelCaseKeys.d.mts +24 -0
- package/dist/types/ToCamelCaseKeys.d.ts +24 -0
- package/dist/types/ToConstantCaseKeys.d.mts +21 -0
- package/dist/types/ToConstantCaseKeys.d.ts +21 -0
- package/dist/types/ToKebabCaseKeys.d.mts +23 -0
- package/dist/types/ToKebabCaseKeys.d.ts +23 -0
- package/dist/types/ToPascalCaseKeys.d.mts +24 -0
- package/dist/types/ToPascalCaseKeys.d.ts +24 -0
- package/dist/types/ToSnakeCaseKeys.d.mts +21 -0
- package/dist/types/ToSnakeCaseKeys.d.ts +21 -0
- package/dist/types/index.d.mts +6 -1
- package/dist/types/index.d.ts +6 -1
- package/fp/iterator.d.ts +1 -0
- package/fp/iterator.js +1 -0
- package/iterator.d.ts +1 -0
- package/iterator.js +1 -0
- package/package.json +70 -2
|
@@ -8,7 +8,7 @@ import { isString } from "../predicate/isString.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* The comparison uses SameValueZero to check for inclusion.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
11
|
+
* @param collection - The source to search in. It can be an array, an object, or a string.
|
|
12
12
|
* @param [target] - The value to search for in the source.
|
|
13
13
|
* @param [fromIndex=0] - The index to start searching from. If negative, it is treated as an offset from the end of the source.
|
|
14
14
|
* @returns `true` if the value is found in the source, `false` otherwise.
|
|
@@ -19,24 +19,24 @@ import { isString } from "../predicate/isString.mjs";
|
|
|
19
19
|
* includes('hello world', 'world'); // true
|
|
20
20
|
* includes('hello world', 'test'); // false
|
|
21
21
|
*/
|
|
22
|
-
function includes(
|
|
23
|
-
if (
|
|
22
|
+
function includes(collection, target, fromIndex, guard) {
|
|
23
|
+
if (collection == null) return false;
|
|
24
24
|
if (guard || !fromIndex) fromIndex = 0;
|
|
25
25
|
else fromIndex = toInteger(fromIndex);
|
|
26
|
-
if (isString(
|
|
27
|
-
if (fromIndex >
|
|
28
|
-
if (fromIndex < 0) fromIndex = Math.max(0,
|
|
29
|
-
return
|
|
26
|
+
if (isString(collection)) {
|
|
27
|
+
if (fromIndex > collection.length || target instanceof RegExp) return false;
|
|
28
|
+
if (fromIndex < 0) fromIndex = Math.max(0, collection.length + fromIndex);
|
|
29
|
+
return collection.includes(target, fromIndex);
|
|
30
30
|
}
|
|
31
|
-
if (Array.isArray(
|
|
32
|
-
if (isArrayLike(
|
|
33
|
-
if (fromIndex < 0) fromIndex = Math.max(0,
|
|
34
|
-
for (let i = fromIndex; i <
|
|
31
|
+
if (Array.isArray(collection)) return collection.includes(target, fromIndex);
|
|
32
|
+
if (isArrayLike(collection)) {
|
|
33
|
+
if (fromIndex < 0) fromIndex = Math.max(0, collection.length + fromIndex);
|
|
34
|
+
for (let i = fromIndex; i < collection.length; i++) if (eq(collection[i], target)) return true;
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
|
-
const keys = Object.keys(
|
|
37
|
+
const keys = Object.keys(collection);
|
|
38
38
|
if (fromIndex < 0) fromIndex = Math.max(0, keys.length + fromIndex);
|
|
39
|
-
for (let i = fromIndex; i < keys.length; i++) if (eq(Reflect.get(
|
|
39
|
+
for (let i = fromIndex; i < keys.length; i++) if (eq(Reflect.get(collection, keys[i]), target)) return true;
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
2
|
+
const require_toInteger = require("../util/toInteger.js");
|
|
2
3
|
//#region src/compat/array/indexOf.ts
|
|
3
4
|
/**
|
|
4
5
|
* Finds the index of the first occurrence of a value in an array.
|
|
@@ -20,7 +21,7 @@ const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
|
20
21
|
function indexOf(array, searchElement, fromIndex) {
|
|
21
22
|
if (!require_isArrayLike.isArrayLike(array)) return -1;
|
|
22
23
|
if (Number.isNaN(searchElement)) {
|
|
23
|
-
fromIndex = fromIndex ?? 0;
|
|
24
|
+
fromIndex = require_toInteger.toInteger(fromIndex ?? 0);
|
|
24
25
|
if (fromIndex < 0) fromIndex = Math.max(0, array.length + fromIndex);
|
|
25
26
|
for (let i = fromIndex; i < array.length; i++) if (Number.isNaN(array[i])) return i;
|
|
26
27
|
return -1;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
2
|
+
import { toInteger } from "../util/toInteger.mjs";
|
|
2
3
|
//#region src/compat/array/indexOf.ts
|
|
3
4
|
/**
|
|
4
5
|
* Finds the index of the first occurrence of a value in an array.
|
|
@@ -20,7 +21,7 @@ import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
|
20
21
|
function indexOf(array, searchElement, fromIndex) {
|
|
21
22
|
if (!isArrayLike(array)) return -1;
|
|
22
23
|
if (Number.isNaN(searchElement)) {
|
|
23
|
-
fromIndex = fromIndex ?? 0;
|
|
24
|
+
fromIndex = toInteger(fromIndex ?? 0);
|
|
24
25
|
if (fromIndex < 0) fromIndex = Math.max(0, array.length + fromIndex);
|
|
25
26
|
for (let i = fromIndex; i < array.length; i++) if (Number.isNaN(array[i])) return i;
|
|
26
27
|
return -1;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_intersection = require("../../array/intersection.js");
|
|
2
2
|
const require_uniq = require("../../array/uniq.js");
|
|
3
|
+
const require_toArray = require("../_internal/toArray.js");
|
|
3
4
|
const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
|
|
4
5
|
//#region src/compat/array/intersection.ts
|
|
5
6
|
/**
|
|
@@ -22,11 +23,11 @@ const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
|
|
|
22
23
|
function intersection(...arrays) {
|
|
23
24
|
if (arrays.length === 0) return [];
|
|
24
25
|
if (!require_isArrayLikeObject.isArrayLikeObject(arrays[0])) return [];
|
|
25
|
-
let result = require_uniq.uniq(
|
|
26
|
+
let result = require_uniq.uniq(require_toArray.toArray(arrays[0]));
|
|
26
27
|
for (let i = 1; i < arrays.length; i++) {
|
|
27
28
|
const array = arrays[i];
|
|
28
29
|
if (!require_isArrayLikeObject.isArrayLikeObject(array)) return [];
|
|
29
|
-
result = require_intersection.intersection(result,
|
|
30
|
+
result = require_intersection.intersection(result, require_toArray.toArray(array));
|
|
30
31
|
}
|
|
31
32
|
return result;
|
|
32
33
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { intersection as intersection$1 } from "../../array/intersection.mjs";
|
|
2
2
|
import { uniq } from "../../array/uniq.mjs";
|
|
3
|
+
import { toArray } from "../_internal/toArray.mjs";
|
|
3
4
|
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
|
|
4
5
|
//#region src/compat/array/intersection.ts
|
|
5
6
|
/**
|
|
@@ -22,11 +23,11 @@ import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
|
|
|
22
23
|
function intersection(...arrays) {
|
|
23
24
|
if (arrays.length === 0) return [];
|
|
24
25
|
if (!isArrayLikeObject(arrays[0])) return [];
|
|
25
|
-
let result = uniq(
|
|
26
|
+
let result = uniq(toArray(arrays[0]));
|
|
26
27
|
for (let i = 1; i < arrays.length; i++) {
|
|
27
28
|
const array = arrays[i];
|
|
28
29
|
if (!isArrayLikeObject(array)) return [];
|
|
29
|
-
result = intersection$1(result,
|
|
30
|
+
result = intersection$1(result, toArray(array));
|
|
30
31
|
}
|
|
31
32
|
return result;
|
|
32
33
|
}
|
|
@@ -4,7 +4,7 @@ const require_uniq = require("../../array/uniq.js");
|
|
|
4
4
|
const require_uniqBy = require("../../array/uniqBy.js");
|
|
5
5
|
const require_identity = require("../../function/identity.js");
|
|
6
6
|
const require_toArray = require("../_internal/toArray.js");
|
|
7
|
-
const
|
|
7
|
+
const require_iteratee = require("../util/iteratee.js");
|
|
8
8
|
const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
|
|
9
9
|
//#region src/compat/array/intersectionBy.ts
|
|
10
10
|
/**
|
|
@@ -38,22 +38,18 @@ const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
|
|
|
38
38
|
function intersectionBy(array, ...values) {
|
|
39
39
|
if (!require_isArrayLikeObject.isArrayLikeObject(array)) return [];
|
|
40
40
|
const lastValue = require_last.last(values);
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
41
|
+
const hasIteratee = !require_isArrayLikeObject.isArrayLikeObject(lastValue);
|
|
42
|
+
const count = hasIteratee ? values.length - 1 : values.length;
|
|
43
|
+
const mapper = hasIteratee ? require_iteratee.iteratee(lastValue) : require_identity.identity;
|
|
44
|
+
const iteratee$1 = typeof lastValue === "function" ? (item) => mapper(item) : mapper;
|
|
45
|
+
if (count <= 0) return require_uniqBy.uniqBy(require_toArray.toArray(array), iteratee$1);
|
|
44
46
|
let result = require_uniq.uniq(require_toArray.toArray(array));
|
|
45
47
|
for (let i = 0; i < count; ++i) {
|
|
46
48
|
const value = values[i];
|
|
47
49
|
if (!require_isArrayLikeObject.isArrayLikeObject(value)) return [];
|
|
48
|
-
|
|
50
|
+
result = require_intersectionBy.intersectionBy(result, require_toArray.toArray(value), iteratee$1);
|
|
49
51
|
}
|
|
50
52
|
return result;
|
|
51
53
|
}
|
|
52
|
-
function getIteratee(value) {
|
|
53
|
-
if (require_isArrayLikeObject.isArrayLikeObject(value)) return require_identity.identity;
|
|
54
|
-
if (typeof value === "function") return (item) => value(item);
|
|
55
|
-
if (typeof value === "string") return require_property.property(value);
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
54
|
//#endregion
|
|
59
55
|
exports.intersectionBy = intersectionBy;
|
|
@@ -4,7 +4,7 @@ import { uniq } from "../../array/uniq.mjs";
|
|
|
4
4
|
import { uniqBy } from "../../array/uniqBy.mjs";
|
|
5
5
|
import { identity } from "../../function/identity.mjs";
|
|
6
6
|
import { toArray } from "../_internal/toArray.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { iteratee } from "../util/iteratee.mjs";
|
|
8
8
|
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
|
|
9
9
|
//#region src/compat/array/intersectionBy.ts
|
|
10
10
|
/**
|
|
@@ -38,22 +38,18 @@ import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
|
|
|
38
38
|
function intersectionBy(array, ...values) {
|
|
39
39
|
if (!isArrayLikeObject(array)) return [];
|
|
40
40
|
const lastValue = last(values);
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
41
|
+
const hasIteratee = !isArrayLikeObject(lastValue);
|
|
42
|
+
const count = hasIteratee ? values.length - 1 : values.length;
|
|
43
|
+
const mapper = hasIteratee ? iteratee(lastValue) : identity;
|
|
44
|
+
const iteratee$1 = typeof lastValue === "function" ? (item) => mapper(item) : mapper;
|
|
45
|
+
if (count <= 0) return uniqBy(toArray(array), iteratee$1);
|
|
44
46
|
let result = uniq(toArray(array));
|
|
45
47
|
for (let i = 0; i < count; ++i) {
|
|
46
48
|
const value = values[i];
|
|
47
49
|
if (!isArrayLikeObject(value)) return [];
|
|
48
|
-
|
|
50
|
+
result = intersectionBy$1(result, toArray(value), iteratee$1);
|
|
49
51
|
}
|
|
50
52
|
return result;
|
|
51
53
|
}
|
|
52
|
-
function getIteratee(value) {
|
|
53
|
-
if (isArrayLikeObject(value)) return identity;
|
|
54
|
-
if (typeof value === "function") return (item) => value(item);
|
|
55
|
-
if (typeof value === "string") return property(value);
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
54
|
//#endregion
|
|
59
55
|
export { intersectionBy };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const require_intersectionWith = require("../../array/intersectionWith.js");
|
|
2
|
+
const require_uniq = require("../../array/uniq.js");
|
|
3
|
+
const require_uniqWith = require("../../array/uniqWith.js");
|
|
2
4
|
const require_eq = require("../util/eq.js");
|
|
5
|
+
const require_toArray = require("../_internal/toArray.js");
|
|
3
6
|
const require_last = require("./last.js");
|
|
4
|
-
const require_uniq = require("./uniq.js");
|
|
5
7
|
//#region src/compat/array/intersectionWith.ts
|
|
6
8
|
/**
|
|
7
9
|
* Returns the intersection of multiple arrays based on a custom equality function.
|
|
@@ -24,28 +26,14 @@ function intersectionWith(firstArr, ...otherArrs) {
|
|
|
24
26
|
let uniq$1 = require_uniq.uniq;
|
|
25
27
|
if (typeof _comparator === "function") {
|
|
26
28
|
comparator = _comparator;
|
|
27
|
-
uniq$1 =
|
|
29
|
+
uniq$1 = (arr) => require_uniqWith.uniqWith(arr, comparator);
|
|
28
30
|
otherArrs.pop();
|
|
29
31
|
}
|
|
30
|
-
let result = uniq$1(
|
|
32
|
+
let result = uniq$1(require_toArray.toArray(firstArr));
|
|
31
33
|
for (let i = 0; i < otherArrs.length; ++i) {
|
|
32
34
|
const otherArr = otherArrs[i];
|
|
33
35
|
if (otherArr == null) return [];
|
|
34
|
-
result = require_intersectionWith.intersectionWith(result,
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* This function is to preserve the sign of `-0`, which is a behavior in lodash.
|
|
40
|
-
*/
|
|
41
|
-
function uniqPreserve0(arr) {
|
|
42
|
-
const result = [];
|
|
43
|
-
const added = /* @__PURE__ */ new Set();
|
|
44
|
-
for (let i = 0; i < arr.length; i++) {
|
|
45
|
-
const item = arr[i];
|
|
46
|
-
if (added.has(item)) continue;
|
|
47
|
-
result.push(item);
|
|
48
|
-
added.add(item);
|
|
36
|
+
result = require_intersectionWith.intersectionWith(result, require_toArray.toArray(otherArr), comparator);
|
|
49
37
|
}
|
|
50
38
|
return result;
|
|
51
39
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { intersectionWith as intersectionWith$1 } from "../../array/intersectionWith.mjs";
|
|
2
|
+
import { uniq } from "../../array/uniq.mjs";
|
|
3
|
+
import { uniqWith } from "../../array/uniqWith.mjs";
|
|
2
4
|
import { eq } from "../util/eq.mjs";
|
|
5
|
+
import { toArray } from "../_internal/toArray.mjs";
|
|
3
6
|
import { last } from "./last.mjs";
|
|
4
|
-
import { uniq } from "./uniq.mjs";
|
|
5
7
|
//#region src/compat/array/intersectionWith.ts
|
|
6
8
|
/**
|
|
7
9
|
* Returns the intersection of multiple arrays based on a custom equality function.
|
|
@@ -24,28 +26,14 @@ function intersectionWith(firstArr, ...otherArrs) {
|
|
|
24
26
|
let uniq$1 = uniq;
|
|
25
27
|
if (typeof _comparator === "function") {
|
|
26
28
|
comparator = _comparator;
|
|
27
|
-
uniq$1 =
|
|
29
|
+
uniq$1 = (arr) => uniqWith(arr, comparator);
|
|
28
30
|
otherArrs.pop();
|
|
29
31
|
}
|
|
30
|
-
let result = uniq$1(
|
|
32
|
+
let result = uniq$1(toArray(firstArr));
|
|
31
33
|
for (let i = 0; i < otherArrs.length; ++i) {
|
|
32
34
|
const otherArr = otherArrs[i];
|
|
33
35
|
if (otherArr == null) return [];
|
|
34
|
-
result = intersectionWith$1(result,
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* This function is to preserve the sign of `-0`, which is a behavior in lodash.
|
|
40
|
-
*/
|
|
41
|
-
function uniqPreserve0(arr) {
|
|
42
|
-
const result = [];
|
|
43
|
-
const added = /* @__PURE__ */ new Set();
|
|
44
|
-
for (let i = 0; i < arr.length; i++) {
|
|
45
|
-
const item = arr[i];
|
|
46
|
-
if (added.has(item)) continue;
|
|
47
|
-
result.push(item);
|
|
48
|
-
added.add(item);
|
|
36
|
+
result = intersectionWith$1(result, toArray(otherArr), comparator);
|
|
49
37
|
}
|
|
50
38
|
return result;
|
|
51
39
|
}
|
|
@@ -25,7 +25,7 @@ const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
|
25
25
|
* // noElement will be undefined
|
|
26
26
|
*/
|
|
27
27
|
function last(array) {
|
|
28
|
-
if (!require_isArrayLike.isArrayLike(array)) return;
|
|
28
|
+
if (!require_isArrayLike.isArrayLike(array) || array.length === 0) return;
|
|
29
29
|
return require_last.last(require_toArray.toArray(array));
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
@@ -25,7 +25,7 @@ import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
|
25
25
|
* // noElement will be undefined
|
|
26
26
|
*/
|
|
27
27
|
function last(array) {
|
|
28
|
-
if (!isArrayLike(array)) return;
|
|
28
|
+
if (!isArrayLike(array) || array.length === 0) return;
|
|
29
29
|
return last$1(toArray(array));
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
@@ -8,8 +8,10 @@ function lastIndexOf(array, searchElement, fromIndex) {
|
|
|
8
8
|
if (fromIndex !== void 0) index = index < 0 ? Math.max(length + index, 0) : Math.min(index, length - 1);
|
|
9
9
|
if (Number.isNaN(searchElement)) {
|
|
10
10
|
for (let i = index; i >= 0; i--) if (Number.isNaN(array[i])) return i;
|
|
11
|
+
return -1;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
for (let i = index; i >= 0; i--) if (array[i] === searchElement) return i;
|
|
14
|
+
return -1;
|
|
13
15
|
}
|
|
14
16
|
//#endregion
|
|
15
17
|
exports.lastIndexOf = lastIndexOf;
|
|
@@ -8,8 +8,10 @@ function lastIndexOf(array, searchElement, fromIndex) {
|
|
|
8
8
|
if (fromIndex !== void 0) index = index < 0 ? Math.max(length + index, 0) : Math.min(index, length - 1);
|
|
9
9
|
if (Number.isNaN(searchElement)) {
|
|
10
10
|
for (let i = index; i >= 0; i--) if (Number.isNaN(array[i])) return i;
|
|
11
|
+
return -1;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
for (let i = index; i >= 0; i--) if (array[i] === searchElement) return i;
|
|
14
|
+
return -1;
|
|
13
15
|
}
|
|
14
16
|
//#endregion
|
|
15
17
|
export { lastIndexOf };
|
package/dist/compat/array/map.js
CHANGED
|
@@ -3,10 +3,10 @@ const require_range = require("../../math/range.js");
|
|
|
3
3
|
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
4
4
|
const require_iteratee = require("../util/iteratee.js");
|
|
5
5
|
//#region src/compat/array/map.ts
|
|
6
|
-
function map(collection, _iteratee) {
|
|
6
|
+
function map(collection, _iteratee = require_identity.identity) {
|
|
7
7
|
if (!collection) return [];
|
|
8
|
-
const keys = require_isArrayLike.isArrayLike(collection)
|
|
9
|
-
const iteratee$1 = require_iteratee.iteratee(_iteratee
|
|
8
|
+
const keys = require_isArrayLike.isArrayLike(collection) ? require_range.range(0, collection.length) : Object.keys(collection);
|
|
9
|
+
const iteratee$1 = require_iteratee.iteratee(_iteratee);
|
|
10
10
|
const result = new Array(keys.length);
|
|
11
11
|
for (let i = 0; i < keys.length; i++) {
|
|
12
12
|
const key = keys[i];
|
|
@@ -3,10 +3,10 @@ import { range } from "../../math/range.mjs";
|
|
|
3
3
|
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
4
4
|
import { iteratee } from "../util/iteratee.mjs";
|
|
5
5
|
//#region src/compat/array/map.ts
|
|
6
|
-
function map(collection, _iteratee) {
|
|
6
|
+
function map(collection, _iteratee = identity) {
|
|
7
7
|
if (!collection) return [];
|
|
8
|
-
const keys = isArrayLike(collection)
|
|
9
|
-
const iteratee$1 = iteratee(_iteratee
|
|
8
|
+
const keys = isArrayLike(collection) ? range(0, collection.length) : Object.keys(collection);
|
|
9
|
+
const iteratee$1 = iteratee(_iteratee);
|
|
10
10
|
const result = new Array(keys.length);
|
|
11
11
|
for (let i = 0; i < keys.length; i++) {
|
|
12
12
|
const key = keys[i];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
1
2
|
const require_toPath = require("../util/toPath.js");
|
|
2
3
|
const require_compareValues = require("../_internal/compareValues.js");
|
|
3
4
|
const require_isKey = require("../_internal/isKey.js");
|
|
@@ -36,26 +37,27 @@ const require_isKey = require("../_internal/isKey.js");
|
|
|
36
37
|
function orderBy(collection, criteria, orders, guard) {
|
|
37
38
|
if (collection == null) return [];
|
|
38
39
|
orders = guard ? void 0 : orders;
|
|
39
|
-
if (!Array.isArray(collection)) collection = Object.values(collection);
|
|
40
|
+
if (!Array.isArray(collection)) collection = require_isArrayLike.isArrayLike(collection) ? Array.from(collection) : Object.values(collection);
|
|
40
41
|
if (!Array.isArray(criteria)) criteria = criteria == null ? [null] : [criteria];
|
|
41
42
|
if (criteria.length === 0) criteria = [null];
|
|
42
43
|
if (!Array.isArray(orders)) orders = orders == null ? [] : [orders];
|
|
43
44
|
orders = orders.map((order) => String(order));
|
|
44
45
|
const getValueByNestedPath = (object, path) => {
|
|
45
46
|
let target = object;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
let index = 0;
|
|
48
|
+
for (; index < path.length && target != null; ++index) target = target[path[index]];
|
|
49
|
+
return index > 0 && index === path.length ? target : void 0;
|
|
48
50
|
};
|
|
49
51
|
const getValueByCriterion = (criterion, object) => {
|
|
50
|
-
if (
|
|
52
|
+
if (criterion == null) return object;
|
|
53
|
+
if (object == null) return;
|
|
51
54
|
if (typeof criterion === "object" && "key" in criterion) {
|
|
52
55
|
if (Object.hasOwn(object, criterion.key)) return object[criterion.key];
|
|
53
56
|
return getValueByNestedPath(object, criterion.path);
|
|
54
57
|
}
|
|
55
58
|
if (typeof criterion === "function") return criterion(object);
|
|
56
59
|
if (Array.isArray(criterion)) return getValueByNestedPath(object, criterion);
|
|
57
|
-
|
|
58
|
-
return object;
|
|
60
|
+
return object[criterion];
|
|
59
61
|
};
|
|
60
62
|
const preparedCriteria = criteria.map((criterion) => {
|
|
61
63
|
if (Array.isArray(criterion) && criterion.length === 1) criterion = criterion[0];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
1
2
|
import { toPath } from "../util/toPath.mjs";
|
|
2
3
|
import { compareValues } from "../_internal/compareValues.mjs";
|
|
3
4
|
import { isKey } from "../_internal/isKey.mjs";
|
|
@@ -36,26 +37,27 @@ import { isKey } from "../_internal/isKey.mjs";
|
|
|
36
37
|
function orderBy(collection, criteria, orders, guard) {
|
|
37
38
|
if (collection == null) return [];
|
|
38
39
|
orders = guard ? void 0 : orders;
|
|
39
|
-
if (!Array.isArray(collection)) collection = Object.values(collection);
|
|
40
|
+
if (!Array.isArray(collection)) collection = isArrayLike(collection) ? Array.from(collection) : Object.values(collection);
|
|
40
41
|
if (!Array.isArray(criteria)) criteria = criteria == null ? [null] : [criteria];
|
|
41
42
|
if (criteria.length === 0) criteria = [null];
|
|
42
43
|
if (!Array.isArray(orders)) orders = orders == null ? [] : [orders];
|
|
43
44
|
orders = orders.map((order) => String(order));
|
|
44
45
|
const getValueByNestedPath = (object, path) => {
|
|
45
46
|
let target = object;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
let index = 0;
|
|
48
|
+
for (; index < path.length && target != null; ++index) target = target[path[index]];
|
|
49
|
+
return index > 0 && index === path.length ? target : void 0;
|
|
48
50
|
};
|
|
49
51
|
const getValueByCriterion = (criterion, object) => {
|
|
50
|
-
if (
|
|
52
|
+
if (criterion == null) return object;
|
|
53
|
+
if (object == null) return;
|
|
51
54
|
if (typeof criterion === "object" && "key" in criterion) {
|
|
52
55
|
if (Object.hasOwn(object, criterion.key)) return object[criterion.key];
|
|
53
56
|
return getValueByNestedPath(object, criterion.path);
|
|
54
57
|
}
|
|
55
58
|
if (typeof criterion === "function") return criterion(object);
|
|
56
59
|
if (Array.isArray(criterion)) return getValueByNestedPath(object, criterion);
|
|
57
|
-
|
|
58
|
-
return object;
|
|
60
|
+
return object[criterion];
|
|
59
61
|
};
|
|
60
62
|
const preparedCriteria = criteria.map((criterion) => {
|
|
61
63
|
if (Array.isArray(criterion) && criterion.length === 1) criterion = criterion[0];
|
|
@@ -8,7 +8,7 @@ const require_iteratee = require("../util/iteratee.js");
|
|
|
8
8
|
* `predicate` returns falsy for. The predicate is invoked with one argument: (value).
|
|
9
9
|
*
|
|
10
10
|
* @template T
|
|
11
|
-
* @param
|
|
11
|
+
* @param collection - The array or object to iterate over.
|
|
12
12
|
* @param [predicate=identity] - The function invoked per iteration.
|
|
13
13
|
* @returns Returns the array of grouped elements.
|
|
14
14
|
*
|
|
@@ -25,14 +25,14 @@ const require_iteratee = require("../util/iteratee.js");
|
|
|
25
25
|
* partition([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);
|
|
26
26
|
* // => [[{ a: 2 }], [{ a: 1 }, { a: 3 }]]
|
|
27
27
|
*/
|
|
28
|
-
function partition(
|
|
29
|
-
if (!
|
|
30
|
-
const
|
|
28
|
+
function partition(collection, predicate = require_identity.identity) {
|
|
29
|
+
if (!collection) return [[], []];
|
|
30
|
+
const values = require_isArrayLike.isArrayLike(collection) ? collection : Object.values(collection);
|
|
31
31
|
predicate = require_iteratee.iteratee(predicate);
|
|
32
32
|
const matched = [];
|
|
33
33
|
const unmatched = [];
|
|
34
|
-
for (let i = 0; i <
|
|
35
|
-
const value =
|
|
34
|
+
for (let i = 0; i < values.length; i++) {
|
|
35
|
+
const value = values[i];
|
|
36
36
|
if (predicate(value)) matched.push(value);
|
|
37
37
|
else unmatched.push(value);
|
|
38
38
|
}
|
|
@@ -8,7 +8,7 @@ import { iteratee } from "../util/iteratee.mjs";
|
|
|
8
8
|
* `predicate` returns falsy for. The predicate is invoked with one argument: (value).
|
|
9
9
|
*
|
|
10
10
|
* @template T
|
|
11
|
-
* @param
|
|
11
|
+
* @param collection - The array or object to iterate over.
|
|
12
12
|
* @param [predicate=identity] - The function invoked per iteration.
|
|
13
13
|
* @returns Returns the array of grouped elements.
|
|
14
14
|
*
|
|
@@ -25,14 +25,14 @@ import { iteratee } from "../util/iteratee.mjs";
|
|
|
25
25
|
* partition([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);
|
|
26
26
|
* // => [[{ a: 2 }], [{ a: 1 }, { a: 3 }]]
|
|
27
27
|
*/
|
|
28
|
-
function partition(
|
|
29
|
-
if (!
|
|
30
|
-
const
|
|
28
|
+
function partition(collection, predicate = identity) {
|
|
29
|
+
if (!collection) return [[], []];
|
|
30
|
+
const values = isArrayLike(collection) ? collection : Object.values(collection);
|
|
31
31
|
predicate = iteratee(predicate);
|
|
32
32
|
const matched = [];
|
|
33
33
|
const unmatched = [];
|
|
34
|
-
for (let i = 0; i <
|
|
35
|
-
const value =
|
|
34
|
+
for (let i = 0; i < values.length; i++) {
|
|
35
|
+
const value = values[i];
|
|
36
36
|
if (predicate(value)) matched.push(value);
|
|
37
37
|
else unmatched.push(value);
|
|
38
38
|
}
|
|
@@ -13,7 +13,7 @@ import { pull as pull$1 } from "../../array/pull.mjs";
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* const numbers = [1, 2, 3, 4, 5, 2, 4];
|
|
16
|
-
* pull(numbers,
|
|
16
|
+
* pull(numbers, 2, 4);
|
|
17
17
|
* console.log(numbers); // [1, 3, 5]
|
|
18
18
|
*/
|
|
19
19
|
function pull(arr, ...valuesToRemove) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_pull = require("../../array/pull.js");
|
|
2
|
+
const require_isNil = require("../../predicate/isNil.js");
|
|
2
3
|
//#region src/compat/array/pullAll.ts
|
|
3
4
|
/**
|
|
4
5
|
* Removes all specified values from an array.
|
|
@@ -17,6 +18,7 @@ const require_pull = require("../../array/pull.js");
|
|
|
17
18
|
* console.log(numbers); // [1, 3, 5]
|
|
18
19
|
*/
|
|
19
20
|
function pullAll(arr, valuesToRemove = []) {
|
|
21
|
+
if (require_isNil.isNil(valuesToRemove)) return arr;
|
|
20
22
|
return require_pull.pull(arr, Array.from(valuesToRemove));
|
|
21
23
|
}
|
|
22
24
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pull } from "../../array/pull.mjs";
|
|
2
|
+
import { isNil } from "../../predicate/isNil.mjs";
|
|
2
3
|
//#region src/compat/array/pullAll.ts
|
|
3
4
|
/**
|
|
4
5
|
* Removes all specified values from an array.
|
|
@@ -17,6 +18,7 @@ import { pull } from "../../array/pull.mjs";
|
|
|
17
18
|
* console.log(numbers); // [1, 3, 5]
|
|
18
19
|
*/
|
|
19
20
|
function pullAll(arr, valuesToRemove = []) {
|
|
21
|
+
if (isNil(valuesToRemove)) return arr;
|
|
20
22
|
return pull(arr, Array.from(valuesToRemove));
|
|
21
23
|
}
|
|
22
24
|
//#endregion
|
|
@@ -12,22 +12,26 @@ const require_iteratee = require("../util/iteratee.js");
|
|
|
12
12
|
* @example
|
|
13
13
|
* // Using a predicate function
|
|
14
14
|
* const numbers = [1, 2, 3, 4, 5];
|
|
15
|
-
* remove(numbers, value => value % 2 === 0); // => [
|
|
15
|
+
* remove(numbers, value => value % 2 === 0); // => [2, 4]
|
|
16
|
+
* console.log(numbers); // => [1, 3, 5]
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* // Using a partial object
|
|
19
20
|
* const objects = [{ a: 1 }, { a: 2 }, { a: 3 }];
|
|
20
|
-
* remove(objects, { a: 1 }); // => [{ a:
|
|
21
|
+
* remove(objects, { a: 1 }); // => [{ a: 1 }]
|
|
22
|
+
* console.log(objects); // => [{ a: 2 }, { a: 3 }]
|
|
21
23
|
*
|
|
22
24
|
* @example
|
|
23
25
|
* // Using a property-value pair
|
|
24
26
|
* const objects = [{ a: 1 }, { a: 2 }, { a: 3 }];
|
|
25
|
-
* remove(objects, ['a', 1]); // => [{ a:
|
|
27
|
+
* remove(objects, ['a', 1]); // => [{ a: 1 }]
|
|
28
|
+
* console.log(objects); // => [{ a: 2 }, { a: 3 }]
|
|
26
29
|
*
|
|
27
30
|
* @example
|
|
28
31
|
* // Using a property key
|
|
29
32
|
* const objects = [{ a: 0 }, { a: 1 }];
|
|
30
|
-
* remove(objects, 'a'); // => [{ a:
|
|
33
|
+
* remove(objects, 'a'); // => [{ a: 1 }]
|
|
34
|
+
* console.log(objects); // => [{ a: 0 }]
|
|
31
35
|
*/
|
|
32
36
|
function remove(arr, shouldRemoveElement = require_identity.identity) {
|
|
33
37
|
return require_remove.remove(arr, require_iteratee.iteratee(shouldRemoveElement));
|
|
@@ -12,22 +12,26 @@ import { iteratee } from "../util/iteratee.mjs";
|
|
|
12
12
|
* @example
|
|
13
13
|
* // Using a predicate function
|
|
14
14
|
* const numbers = [1, 2, 3, 4, 5];
|
|
15
|
-
* remove(numbers, value => value % 2 === 0); // => [
|
|
15
|
+
* remove(numbers, value => value % 2 === 0); // => [2, 4]
|
|
16
|
+
* console.log(numbers); // => [1, 3, 5]
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* // Using a partial object
|
|
19
20
|
* const objects = [{ a: 1 }, { a: 2 }, { a: 3 }];
|
|
20
|
-
* remove(objects, { a: 1 }); // => [{ a:
|
|
21
|
+
* remove(objects, { a: 1 }); // => [{ a: 1 }]
|
|
22
|
+
* console.log(objects); // => [{ a: 2 }, { a: 3 }]
|
|
21
23
|
*
|
|
22
24
|
* @example
|
|
23
25
|
* // Using a property-value pair
|
|
24
26
|
* const objects = [{ a: 1 }, { a: 2 }, { a: 3 }];
|
|
25
|
-
* remove(objects, ['a', 1]); // => [{ a:
|
|
27
|
+
* remove(objects, ['a', 1]); // => [{ a: 1 }]
|
|
28
|
+
* console.log(objects); // => [{ a: 2 }, { a: 3 }]
|
|
26
29
|
*
|
|
27
30
|
* @example
|
|
28
31
|
* // Using a property key
|
|
29
32
|
* const objects = [{ a: 0 }, { a: 1 }];
|
|
30
|
-
* remove(objects, 'a'); // => [{ a:
|
|
33
|
+
* remove(objects, 'a'); // => [{ a: 1 }]
|
|
34
|
+
* console.log(objects); // => [{ a: 0 }]
|
|
31
35
|
*/
|
|
32
36
|
function remove(arr, shouldRemoveElement = identity) {
|
|
33
37
|
return remove$1(arr, iteratee(shouldRemoveElement));
|