es-toolkit 1.38.0 → 1.39.0-dev.1308
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 +23 -1
- package/README.md +1 -0
- package/array.js +1 -0
- package/compat/each.d.ts +1 -0
- package/compat/each.js +1 -0
- package/compat/eachRight.d.ts +1 -0
- package/compat/eachRight.js +1 -0
- package/compat/extend.d.ts +1 -0
- package/compat/extend.js +1 -0
- package/compat/extendWith.d.ts +1 -0
- package/compat/extendWith.js +1 -0
- package/compat/first.d.ts +1 -0
- package/compat/first.js +1 -0
- package/compat.js +1 -0
- package/dist/_internal/compareValues.js +15 -0
- package/dist/array/at.js +19 -0
- package/dist/array/chunk.js +19 -0
- package/dist/array/compact.js +16 -0
- package/dist/array/countBy.js +15 -0
- package/dist/array/difference.js +10 -0
- package/dist/array/differenceBy.js +12 -0
- package/dist/array/differenceWith.js +13 -0
- package/dist/array/drop.js +10 -0
- package/dist/array/dropRight.js +13 -0
- package/dist/array/dropRightWhile.js +14 -0
- package/dist/array/dropWhile.js +13 -0
- package/dist/array/fill.js +15 -0
- package/dist/array/flatMap.js +11 -0
- package/dist/array/flatMapDeep.js +11 -0
- package/dist/array/flatten.js +23 -0
- package/dist/array/flattenDeep.js +11 -0
- package/dist/array/forEachRight.js +12 -0
- package/dist/array/groupBy.js +18 -0
- package/dist/array/head.js +9 -0
- package/dist/array/index.js +122 -271
- package/dist/array/initial.js +9 -0
- package/dist/array/intersection.js +12 -0
- package/dist/array/intersectionBy.js +10 -0
- package/dist/array/intersectionWith.js +13 -0
- package/dist/array/isSubset.js +11 -0
- package/dist/array/isSubsetWith.js +11 -0
- package/dist/array/keyBy.js +15 -0
- package/dist/array/last.js +9 -0
- package/dist/array/maxBy.js +22 -0
- package/dist/array/minBy.js +22 -0
- package/dist/array/orderBy.js +25 -0
- package/dist/array/partition.js +20 -0
- package/dist/array/pull.js +22 -0
- package/dist/array/pullAt.js +16 -0
- package/dist/array/remove.js +24 -0
- package/dist/array/sample.js +10 -0
- package/dist/array/sampleSize.js +24 -0
- package/dist/array/shuffle.js +14 -0
- package/dist/array/sortBy.js +11 -0
- package/dist/array/tail.js +9 -0
- package/dist/array/take.js +12 -0
- package/dist/array/takeRight.js +15 -0
- package/dist/array/takeRightWhile.js +14 -0
- package/dist/array/takeWhile.js +17 -0
- package/dist/array/toFilled.js +16 -0
- package/dist/array/union.js +11 -0
- package/dist/array/unionBy.js +11 -0
- package/dist/array/unionWith.js +11 -0
- package/dist/array/uniq.js +9 -0
- package/dist/array/uniqBy.js +17 -0
- package/dist/array/uniqWith.js +17 -0
- package/dist/array/unzip.js +22 -0
- package/dist/array/unzipWith.js +18 -0
- package/dist/array/windowed.js +20 -0
- package/dist/array/without.js +11 -0
- package/dist/array/xor.js +13 -0
- package/dist/array/xorBy.js +15 -0
- package/dist/array/xorWith.js +15 -0
- package/dist/array/zip.js +24 -0
- package/dist/array/zipObject.js +13 -0
- package/dist/array/zipWith.js +17 -0
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/MAX_ARRAY_LENGTH.js +7 -0
- package/dist/compat/_internal/MAX_SAFE_INTEGER.js +7 -0
- package/dist/compat/_internal/assignValue.js +14 -0
- package/dist/compat/_internal/compareValues.js +37 -0
- package/dist/compat/_internal/copyArray.js +14 -0
- package/dist/compat/_internal/decimalAdjust.js +23 -0
- package/dist/compat/_internal/flattenArrayLike.js +21 -0
- package/dist/compat/_internal/getSymbols.js +9 -0
- package/dist/compat/_internal/getSymbolsIn.js +16 -0
- package/dist/compat/_internal/getTag.js +12 -0
- package/dist/compat/_internal/isDeepKey.js +17 -0
- package/dist/compat/_internal/isIndex.js +20 -0
- package/dist/compat/_internal/isIterateeCall.js +21 -0
- package/dist/compat/_internal/isKey.js +20 -0
- package/dist/compat/_internal/isPrototype.js +11 -0
- package/dist/compat/_internal/mapToEntries.js +15 -0
- package/dist/compat/_internal/normalizeForCase.js +14 -0
- package/dist/compat/_internal/setToEntries.js +15 -0
- package/dist/{_chunk/isPlainObject-Xaozpc.js → compat/_internal/tags.js} +1 -37
- package/dist/compat/_internal/toArray.js +9 -0
- package/dist/compat/_internal/toKey.js +15 -0
- package/dist/compat/array/castArray.js +12 -0
- package/dist/compat/array/chunk.js +17 -0
- package/dist/compat/array/compact.js +15 -0
- package/dist/compat/array/concat.js +11 -0
- package/dist/compat/array/countBy.d.mts +22 -0
- package/dist/compat/array/countBy.d.ts +22 -0
- package/dist/compat/array/countBy.js +23 -0
- package/dist/compat/array/countBy.mjs +19 -0
- package/dist/compat/array/difference.js +24 -0
- package/dist/compat/array/differenceBy.js +24 -0
- package/dist/compat/array/differenceWith.js +23 -0
- package/dist/compat/array/drop.js +18 -0
- package/dist/compat/array/dropRight.js +18 -0
- package/dist/compat/array/dropRightWhile.js +40 -0
- package/dist/compat/array/dropWhile.js +41 -0
- package/dist/compat/array/every.js +64 -0
- package/dist/compat/array/fill.js +27 -0
- package/dist/compat/array/filter.js +37 -0
- package/dist/compat/array/find.js +30 -0
- package/dist/compat/array/findIndex.js +43 -0
- package/dist/compat/array/findLast.js +36 -0
- package/dist/compat/array/findLastIndex.js +43 -0
- package/dist/compat/array/flatMap.js +17 -0
- package/dist/compat/array/flatMapDeep.d.mts +67 -0
- package/dist/compat/array/flatMapDeep.d.ts +67 -0
- package/dist/compat/array/flatMapDeep.js +11 -0
- package/dist/compat/array/flatMapDeep.mjs +7 -0
- package/dist/compat/array/flatMapDepth.d.mts +71 -0
- package/dist/compat/array/flatMapDepth.d.ts +71 -0
- package/dist/compat/array/flatMapDepth.js +18 -0
- package/dist/compat/array/flatMapDepth.mjs +14 -0
- package/dist/compat/array/flatten.js +36 -0
- package/dist/compat/array/flattenDeep.js +11 -0
- package/dist/compat/array/flattenDepth.js +11 -0
- package/dist/compat/array/forEach.js +25 -0
- package/dist/compat/array/forEachRight.js +25 -0
- package/dist/compat/array/groupBy.js +19 -0
- package/dist/compat/array/head.js +16 -0
- package/dist/compat/array/includes.js +44 -0
- package/dist/compat/array/indexOf.js +26 -0
- package/dist/compat/array/initial.js +15 -0
- package/dist/compat/array/intersection.js +27 -0
- package/dist/compat/array/intersectionBy.js +40 -0
- package/dist/compat/array/intersectionWith.js +46 -0
- package/dist/compat/array/invokeMap.js +40 -0
- package/dist/compat/array/join.js +14 -0
- package/dist/compat/array/keyBy.js +23 -0
- package/dist/compat/array/last.js +16 -0
- package/dist/compat/array/lastIndexOf.js +26 -0
- package/dist/compat/array/map.js +25 -0
- package/dist/compat/array/nth.js +19 -0
- package/dist/compat/array/orderBy.js +82 -0
- package/dist/compat/array/partition.js +28 -0
- package/dist/compat/array/pull.js +11 -0
- package/dist/compat/array/pullAll.js +11 -0
- package/dist/compat/array/pullAllBy.js +26 -0
- package/dist/compat/array/pullAllWith.js +37 -0
- package/dist/compat/array/pullAt.js +38 -0
- package/dist/compat/array/reduce.js +37 -0
- package/dist/compat/array/reduceRight.js +43 -0
- package/dist/compat/array/reject.js +13 -0
- package/dist/compat/array/remove.js +12 -0
- package/dist/compat/array/reverse.js +12 -0
- package/dist/compat/array/sample.js +19 -0
- package/dist/compat/array/sampleSize.js +22 -0
- package/dist/compat/array/shuffle.js +28 -0
- package/dist/compat/array/size.js +17 -0
- package/dist/compat/array/slice.js +43 -0
- package/dist/compat/array/some.js +86 -0
- package/dist/compat/array/sortBy.js +20 -0
- package/dist/compat/array/sortedIndex.js +34 -0
- package/dist/compat/array/sortedIndexBy.js +62 -0
- package/dist/compat/array/sortedIndexOf.js +19 -0
- package/dist/compat/array/sortedLastIndex.js +35 -0
- package/dist/compat/array/sortedLastIndexBy.js +11 -0
- package/dist/compat/array/sortedLastIndexOf.js +19 -0
- package/dist/compat/array/tail.js +16 -0
- package/dist/compat/array/take.js +18 -0
- package/dist/compat/array/takeRight.js +18 -0
- package/dist/compat/array/takeRightWhile.js +19 -0
- package/dist/compat/array/takeWhile.js +19 -0
- package/dist/compat/array/union.js +15 -0
- package/dist/compat/array/unionBy.js +21 -0
- package/dist/compat/array/unionWith.js +20 -0
- package/dist/compat/array/uniq.js +15 -0
- package/dist/compat/array/uniqBy.js +16 -0
- package/dist/compat/array/uniqWith.js +16 -0
- package/dist/compat/array/unzip.js +18 -0
- package/dist/compat/array/unzipWith.js +25 -0
- package/dist/compat/array/without.js +15 -0
- package/dist/compat/array/xor.js +34 -0
- package/dist/compat/array/xorBy.js +27 -0
- package/dist/compat/array/xorWith.js +25 -0
- package/dist/compat/array/zip.js +15 -0
- package/dist/compat/array/zipObject.js +15 -0
- package/dist/compat/array/zipObjectDeep.js +27 -0
- package/dist/compat/array/zipWith.js +24 -0
- package/dist/compat/compat.d.mts +23 -15
- package/dist/compat/compat.d.ts +23 -15
- package/dist/compat/compat.js +595 -0
- package/dist/compat/compat.mjs +23 -15
- package/dist/compat/function/after.js +19 -0
- package/dist/compat/function/ary.js +17 -0
- package/dist/compat/function/attempt.js +14 -0
- package/dist/compat/function/before.js +24 -0
- package/dist/compat/function/bind.js +31 -0
- package/dist/compat/function/bindKey.js +31 -0
- package/dist/compat/function/curry.js +61 -0
- package/dist/compat/function/curryRight.js +68 -0
- package/dist/compat/function/debounce.js +50 -0
- package/dist/compat/function/defer.js +12 -0
- package/dist/compat/function/delay.js +14 -0
- package/dist/compat/function/flip.js +11 -0
- package/dist/compat/function/flow.js +16 -0
- package/dist/compat/function/flowRight.js +16 -0
- package/dist/compat/function/memoize.js +25 -0
- package/dist/compat/function/negate.js +14 -0
- package/dist/compat/function/nthArg.js +13 -0
- package/dist/compat/function/overArgs.d.mts +50 -0
- package/dist/compat/function/overArgs.d.ts +50 -0
- package/dist/compat/function/overArgs.js +24 -0
- package/dist/compat/function/overArgs.mjs +20 -0
- package/dist/compat/function/partial.js +12 -0
- package/dist/compat/function/partialRight.js +12 -0
- package/dist/compat/function/rearg.js +18 -0
- package/dist/compat/function/rest.js +15 -0
- package/dist/compat/function/spread.js +20 -0
- package/dist/compat/function/throttle.js +20 -0
- package/dist/compat/function/wrap.js +15 -0
- package/dist/compat/index.d.mts +23 -15
- package/dist/compat/index.d.ts +23 -15
- package/dist/compat/index.js +591 -5067
- package/dist/compat/index.mjs +23 -15
- package/dist/compat/math/add.js +26 -0
- package/dist/compat/math/ceil.js +11 -0
- package/dist/compat/math/clamp.js +17 -0
- package/dist/compat/math/divide.js +26 -0
- package/dist/compat/math/floor.js +11 -0
- package/dist/compat/math/inRange.js +32 -0
- package/dist/compat/math/max.js +22 -0
- package/dist/compat/math/maxBy.js +15 -0
- package/dist/compat/math/mean.js +12 -0
- package/dist/compat/math/meanBy.js +15 -0
- package/dist/compat/math/min.js +22 -0
- package/dist/compat/math/minBy.js +15 -0
- package/dist/compat/math/multiply.js +26 -0
- package/dist/compat/math/parseInt.js +12 -0
- package/dist/compat/math/random.js +74 -0
- package/dist/compat/math/range.js +30 -0
- package/dist/compat/math/rangeRight.js +30 -0
- package/dist/compat/math/round.js +11 -0
- package/dist/compat/math/subtract.js +26 -0
- package/dist/compat/math/sum.js +11 -0
- package/dist/compat/math/sumBy.js +29 -0
- package/dist/compat/object/assign.js +24 -0
- package/dist/compat/object/assignIn.js +24 -0
- package/dist/compat/object/assignInWith.js +34 -0
- package/dist/compat/object/assignWith.js +34 -0
- package/dist/compat/object/at.js +31 -0
- package/dist/compat/object/clone.js +164 -0
- package/dist/compat/object/cloneDeep.js +11 -0
- package/dist/compat/object/cloneDeepWith.js +39 -0
- package/dist/compat/object/cloneWith.js +18 -0
- package/dist/compat/object/create.js +22 -0
- package/dist/compat/object/defaults.js +31 -0
- package/dist/compat/object/defaultsDeep.d.mts +74 -0
- package/dist/compat/object/defaultsDeep.d.ts +74 -0
- package/dist/compat/object/defaultsDeep.js +47 -0
- package/dist/compat/object/defaultsDeep.mjs +43 -0
- package/dist/compat/object/findKey.d.mts +31 -8
- package/dist/compat/object/findKey.d.ts +31 -8
- package/dist/compat/object/findKey.js +17 -0
- package/dist/compat/object/findKey.mjs +3 -20
- package/dist/compat/object/findLastKey.d.mts +102 -0
- package/dist/compat/object/findLastKey.d.ts +102 -0
- package/dist/compat/object/findLastKey.js +17 -0
- package/dist/compat/object/findLastKey.mjs +13 -0
- package/dist/compat/object/forIn.js +20 -0
- package/dist/compat/object/forInRight.js +25 -0
- package/dist/compat/object/forOwn.js +23 -0
- package/dist/compat/object/forOwnRight.js +23 -0
- package/dist/compat/object/fromPairs.js +18 -0
- package/dist/compat/object/functions.js +14 -0
- package/dist/compat/object/functionsIn.js +20 -0
- package/dist/compat/object/get.js +72 -0
- package/dist/compat/object/has.js +38 -0
- package/dist/compat/object/hasIn.js +38 -0
- package/dist/compat/object/invertBy.js +31 -0
- package/dist/compat/object/keys.js +36 -0
- package/dist/compat/object/keysIn.js +57 -0
- package/dist/compat/object/mapKeys.js +24 -0
- package/dist/compat/object/mapValues.js +24 -0
- package/dist/compat/object/merge.js +12 -0
- package/dist/compat/object/mergeWith.js +92 -0
- package/dist/compat/object/omit.js +37 -0
- package/dist/compat/object/omitBy.js +30 -0
- package/dist/compat/object/pick.js +53 -0
- package/dist/compat/object/pickBy.js +30 -0
- package/dist/compat/object/property.js +13 -0
- package/dist/compat/object/propertyOf.js +13 -0
- package/dist/compat/object/result.js +28 -0
- package/dist/compat/object/set.js +11 -0
- package/dist/compat/object/setWith.js +18 -0
- package/dist/compat/object/toDefaulted.js +13 -0
- package/dist/compat/object/toPairs.js +26 -0
- package/dist/compat/object/toPairsIn.js +26 -0
- package/dist/compat/object/transform.js +34 -0
- package/dist/compat/object/unset.js +72 -0
- package/dist/compat/object/update.js +11 -0
- package/dist/compat/object/updateWith.js +48 -0
- package/dist/compat/object/values.js +9 -0
- package/dist/compat/object/valuesIn.js +17 -0
- package/dist/compat/predicate/conforms.js +15 -0
- package/dist/compat/predicate/conformsTo.js +24 -0
- package/dist/compat/predicate/isArguments.js +11 -0
- package/dist/compat/predicate/isArray.js +9 -0
- package/dist/compat/predicate/isArrayBuffer.js +11 -0
- package/dist/compat/predicate/isArrayLike.js +11 -0
- package/dist/compat/predicate/isArrayLikeObject.js +12 -0
- package/dist/compat/predicate/isBoolean.js +9 -0
- package/dist/compat/predicate/isBuffer.js +11 -0
- package/dist/compat/predicate/isDate.js +11 -0
- package/dist/compat/predicate/isElement.js +12 -0
- package/dist/compat/predicate/isEmpty.js +37 -0
- package/dist/compat/predicate/isEqualWith.js +27 -0
- package/dist/compat/predicate/isError.js +11 -0
- package/dist/compat/predicate/isFinite.js +9 -0
- package/dist/compat/predicate/isInteger.js +9 -0
- package/dist/compat/predicate/isMap.js +11 -0
- package/dist/compat/predicate/isMatch.js +11 -0
- package/dist/compat/predicate/isMatch.mjs +3 -98
- package/dist/compat/predicate/isMatchWith.d.mts +72 -0
- package/dist/compat/predicate/isMatchWith.d.ts +72 -0
- package/dist/compat/predicate/isMatchWith.js +156 -0
- package/dist/compat/predicate/isMatchWith.mjs +151 -0
- package/dist/compat/predicate/isNaN.js +9 -0
- package/dist/compat/predicate/isNative.js +21 -0
- package/dist/compat/predicate/isNil.js +9 -0
- package/dist/compat/predicate/isNumber.js +9 -0
- package/dist/compat/predicate/isObject.js +9 -0
- package/dist/compat/predicate/isObjectLike.js +9 -0
- package/dist/compat/predicate/isPlainObject.js +33 -0
- package/dist/compat/predicate/isRegExp.js +11 -0
- package/dist/compat/predicate/isSafeInteger.js +9 -0
- package/dist/compat/predicate/isSet.js +11 -0
- package/dist/compat/predicate/isString.js +9 -0
- package/dist/compat/predicate/isSymbol.js +9 -0
- package/dist/compat/predicate/isTypedArray.js +11 -0
- package/dist/compat/predicate/isWeakMap.js +11 -0
- package/dist/compat/predicate/isWeakSet.js +11 -0
- package/dist/compat/predicate/matches.js +15 -0
- package/dist/compat/predicate/matchesProperty.js +37 -0
- package/dist/compat/string/camelCase.js +12 -0
- package/dist/compat/string/deburr.js +12 -0
- package/dist/compat/string/endsWith.js +9 -0
- package/dist/compat/string/escape.js +12 -0
- package/dist/compat/string/escapeRegExp.js +12 -0
- package/dist/compat/string/kebabCase.js +12 -0
- package/dist/compat/string/lowerCase.js +12 -0
- package/dist/compat/string/lowerFirst.js +12 -0
- package/dist/compat/string/pad.js +12 -0
- package/dist/compat/string/padEnd.js +11 -0
- package/dist/compat/string/padStart.js +11 -0
- package/dist/compat/string/repeat.js +19 -0
- package/dist/compat/string/replace.js +14 -0
- package/dist/compat/string/snakeCase.js +12 -0
- package/dist/compat/string/split.js +11 -0
- package/dist/compat/string/startCase.js +26 -0
- package/dist/compat/string/startsWith.js +9 -0
- package/dist/compat/string/template.js +91 -0
- package/dist/compat/string/toLower.js +11 -0
- package/dist/compat/string/toUpper.js +11 -0
- package/dist/compat/string/trim.js +29 -0
- package/dist/compat/string/trimEnd.js +29 -0
- package/dist/compat/string/trimStart.js +29 -0
- package/dist/compat/string/truncate.d.mts +34 -0
- package/dist/compat/string/truncate.d.ts +34 -0
- package/dist/compat/string/truncate.js +52 -0
- package/dist/compat/string/truncate.mjs +48 -0
- package/dist/compat/string/unescape.js +12 -0
- package/dist/compat/string/upperCase.js +12 -0
- package/dist/compat/string/upperFirst.js +12 -0
- package/dist/compat/string/words.js +35 -0
- package/dist/compat/toolkit.js +14 -0
- package/dist/compat/util/bindAll.js +47 -0
- package/dist/compat/util/cond.js +30 -0
- package/dist/compat/util/constant.js +9 -0
- package/dist/compat/util/defaultTo.js +12 -0
- package/dist/compat/util/eq.js +9 -0
- package/dist/compat/util/gt.js +14 -0
- package/dist/compat/util/gte.js +14 -0
- package/dist/compat/util/invoke.js +52 -0
- package/dist/compat/util/iteratee.js +32 -0
- package/dist/compat/util/lt.js +14 -0
- package/dist/compat/util/lte.js +14 -0
- package/dist/compat/util/method.js +13 -0
- package/dist/compat/util/methodOf.js +13 -0
- package/dist/compat/util/now.js +9 -0
- package/dist/compat/util/over.js +17 -0
- package/dist/compat/util/overEvery.js +27 -0
- package/dist/compat/util/overSome.js +27 -0
- package/dist/compat/util/stubArray.js +9 -0
- package/dist/compat/util/stubFalse.js +9 -0
- package/dist/compat/util/stubObject.js +9 -0
- package/dist/compat/util/stubString.js +9 -0
- package/dist/compat/util/stubTrue.js +9 -0
- package/dist/compat/util/times.js +19 -0
- package/dist/compat/util/toArray.js +21 -0
- package/dist/compat/util/toFinite.js +19 -0
- package/dist/compat/util/toInteger.js +13 -0
- package/dist/compat/util/toLength.js +16 -0
- package/dist/compat/util/toNumber.js +14 -0
- package/dist/compat/util/toPath.js +72 -0
- package/dist/compat/util/toPlainObject.js +28 -0
- package/dist/compat/util/toSafeInteger.js +16 -0
- package/dist/compat/util/toString.js +22 -0
- package/dist/compat/util/uniqueId.js +11 -0
- package/dist/{_chunk/AbortError-Cg4ZQ1.js → error/AbortError.js} +2 -0
- package/dist/error/TimeoutError.js +12 -0
- package/dist/error/index.js +4 -8
- package/dist/function/after.js +18 -0
- package/dist/function/ary.js +11 -0
- package/dist/function/asyncNoop.js +7 -0
- package/dist/function/before.js +18 -0
- package/dist/function/curry.js +25 -0
- package/dist/function/curryRight.js +25 -0
- package/dist/function/debounce.js +67 -0
- package/dist/function/flow.js +15 -0
- package/dist/function/flowRight.js +11 -0
- package/dist/function/identity.js +9 -0
- package/dist/function/index.js +44 -153
- package/dist/function/memoize.js +20 -0
- package/dist/function/negate.js +9 -0
- package/dist/function/noop.js +7 -0
- package/dist/function/once.js +17 -0
- package/dist/function/partial.js +26 -0
- package/dist/function/partialRight.js +28 -0
- package/dist/function/rest.js +16 -0
- package/dist/function/retry.js +40 -0
- package/dist/function/spread.js +11 -0
- package/dist/function/throttle.js +27 -0
- package/dist/function/unary.js +11 -0
- package/dist/index.js +339 -188
- package/dist/math/clamp.js +12 -0
- package/dist/math/inRange.js +16 -0
- package/dist/math/index.js +28 -66
- package/dist/math/mean.js +11 -0
- package/dist/math/meanBy.js +12 -0
- package/dist/math/median.js +19 -0
- package/dist/math/medianBy.js +12 -0
- package/dist/{_chunk/randomInt-CF7bZK.js → math/random.js} +2 -5
- package/dist/math/randomInt.js +11 -0
- package/dist/math/range.js +21 -0
- package/dist/math/rangeRight.js +21 -0
- package/dist/math/round.js +13 -0
- package/dist/math/sum.js +13 -0
- package/dist/math/sumBy.js +13 -0
- package/dist/object/clone.js +49 -0
- package/dist/object/cloneDeep.js +11 -0
- package/dist/object/cloneDeepWith.js +160 -0
- package/dist/object/findKey.js +10 -0
- package/dist/object/flattenObject.js +30 -0
- package/dist/object/index.js +37 -182
- package/dist/object/invert.js +16 -0
- package/dist/object/mapKeys.js +16 -0
- package/dist/object/mapValues.js +16 -0
- package/dist/object/merge.js +36 -0
- package/dist/object/mergeWith.js +30 -0
- package/dist/object/omit.js +14 -0
- package/dist/object/omitBy.js +18 -0
- package/dist/object/pick.js +16 -0
- package/dist/object/pickBy.js +18 -0
- package/dist/object/toCamelCaseKeys.js +27 -0
- package/dist/object/toMerged.js +12 -0
- package/dist/object/toSnakeCaseKeys.js +27 -0
- package/dist/predicate/index.js +61 -125
- package/dist/predicate/isArrayBuffer.js +9 -0
- package/dist/predicate/isBlob.js +12 -0
- package/dist/predicate/isBoolean.js +9 -0
- package/dist/predicate/isBrowser.js +9 -0
- package/dist/predicate/isBuffer.js +9 -0
- package/dist/predicate/isDate.js +9 -0
- package/dist/predicate/isEqual.js +12 -0
- package/dist/{_chunk/isWeakSet-403Sh5.js → predicate/isEqualWith.js} +40 -115
- package/dist/predicate/isError.js +9 -0
- package/dist/predicate/isFile.js +14 -0
- package/dist/predicate/isFunction.js +9 -0
- package/dist/predicate/isJSON.js +18 -0
- package/dist/predicate/isJSONValue.js +48 -0
- package/dist/predicate/isLength.js +9 -0
- package/dist/predicate/isMap.js +9 -0
- package/dist/predicate/isNil.js +9 -0
- package/dist/predicate/isNode.js +9 -0
- package/dist/predicate/isNotNil.js +9 -0
- package/dist/predicate/isNull.js +9 -0
- package/dist/predicate/isPlainObject.js +19 -0
- package/dist/predicate/isPrimitive.js +9 -0
- package/dist/predicate/isPromise.js +9 -0
- package/dist/predicate/isRegExp.js +9 -0
- package/dist/predicate/isSet.js +9 -0
- package/dist/predicate/isString.js +9 -0
- package/dist/predicate/isSymbol.js +9 -0
- package/dist/predicate/isTypedArray.js +9 -0
- package/dist/predicate/isUndefined.js +9 -0
- package/dist/predicate/isWeakMap.js +9 -0
- package/dist/predicate/isWeakSet.js +9 -0
- package/dist/{_chunk/delay-_VMfFa.js → promise/delay.js} +3 -1
- package/dist/promise/index.js +9 -55
- package/dist/promise/mutex.js +20 -0
- package/dist/promise/semaphore.js +34 -0
- package/dist/promise/timeout.js +13 -0
- package/dist/promise/withTimeout.js +11 -0
- package/dist/string/camelCase.js +17 -0
- package/dist/string/capitalize.js +9 -0
- package/dist/string/constantCase.js +12 -0
- package/dist/string/deburr.js +49 -0
- package/dist/string/escape.js +16 -0
- package/dist/string/escapeRegExp.js +9 -0
- package/dist/string/index.js +40 -46
- package/dist/string/kebabCase.js +12 -0
- package/dist/string/lowerCase.js +12 -0
- package/dist/string/lowerFirst.js +9 -0
- package/dist/string/pad.js +9 -0
- package/dist/string/pascalCase.js +13 -0
- package/dist/string/reverseString.js +9 -0
- package/dist/string/snakeCase.js +12 -0
- package/dist/string/startCase.js +20 -0
- package/dist/string/trim.js +15 -0
- package/dist/string/trimEnd.js +29 -0
- package/dist/string/trimStart.js +26 -0
- package/dist/string/unescape.js +16 -0
- package/dist/string/upperCase.js +19 -0
- package/dist/string/upperFirst.js +9 -0
- package/dist/string/words.js +11 -0
- package/dist/util/attempt.js +14 -0
- package/dist/util/attemptAsync.js +15 -0
- package/dist/util/index.js +7 -30
- package/dist/util/invariant.js +15 -0
- package/error.js +1 -0
- package/function.js +1 -0
- package/math.js +1 -0
- package/object.js +1 -0
- package/package.json +26 -3
- package/predicate.js +1 -0
- package/promise.js +1 -0
- package/string.js +1 -0
- package/util.js +1 -0
- package/dist/_chunk/isPlainObject-DINLyA.js +0 -281
- package/dist/_chunk/noop-2IwLUk.js +0 -5
- package/dist/_chunk/range-DSpBDL.js +0 -59
- package/dist/_chunk/snakeCase-6cG1f4.js +0 -29
- package/dist/_chunk/unary-BVQ0iC.js +0 -188
- package/dist/_chunk/upperFirst-Cx78bs.js +0 -173
- package/dist/_chunk/zip-Cyyp17.js +0 -421
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
# es-toolkit Changelog
|
|
2
2
|
|
|
3
|
+
## Version v1.39.0
|
|
4
|
+
|
|
5
|
+
🎉 Released on June 5th, 2025. 🎉
|
|
6
|
+
|
|
7
|
+
We're thrilled to announce that `es-toolkit/compat` has achieved full compatibility with Lodash! 🎉
|
|
8
|
+
|
|
9
|
+
A huge thank you to all our contributors who made this possible.
|
|
10
|
+
|
|
11
|
+
- Introduced compatibility functions for [defaultsDeep](https://es-toolkit.slash.page/reference/compat/object/defaultsDeep.html), [isMatchWith](https://es-toolkit.slash.page/reference/compat/predicate/isMatchWith.html), [flatMapDepth](https://es-toolkit.slash.page/reference/compat/array/flatMapDepth.html), [flatMapDeep](https://es-toolkit.slash.page/reference/compat/array/flatMapDeep.html), [overArgs](https://es-toolkit.slash.page/reference/compat/function/overArgs.html), [findLastKey](https://es-toolkit.slash.page/reference/compat/object/findLastKey.html) and [truncate](https://es-toolkit.slash.page/reference/compat/string/truncate.html).
|
|
12
|
+
- Enhanced build system to support `es-toolkit/compat/*` module imports.
|
|
13
|
+
- Fixed special functions like `each` to ensure proper functionality.
|
|
14
|
+
- Fixed Deno compatibility issues for `defaultsDeep` function.
|
|
15
|
+
- Fixed import paths in Deno environment.
|
|
16
|
+
- Added benchmark comparing es-toolkit and lodash `identity` function performance.
|
|
17
|
+
- Improved documentation and test coverage for various functions.
|
|
18
|
+
|
|
19
|
+
We sincerely thank @raon0211, @dayongkr, @mreiden, @hwibaski, @shren207, @jiji-hoon96, and @myungjuice for their contributions. We appreciate your great efforts!
|
|
20
|
+
|
|
21
|
+
### ⭐️ Special Thanks to Our Amazing Contributors Who Made 100% Compatibility Possible ⭐️
|
|
22
|
+
|
|
23
|
+
@raon0211, @dayongkr, @D-Sketon, @mass2527, @ssi02014, @shren207, @chhw130, @haejunejung, @jsparkdev, @manudeli, @jgjgill, @hyesungoh, @kaehehehe, @filipsobol, @fvsch, @wondonghwi, @seungrodotlee, @bertyhell, @minchodang, @Jeong-Rae, @kangju2000, @juno7803, @wojtekmaj, @mattiacoll, @changwoolab, @po4tion, @gyumong, @choi2021, @mancuoj, @de-novo, @eunhyulkim, @kim-sung-jee, @gs18004, @Hanna922, @Na-hyunwoo, @aken-you, @tanggd, @ho991217, @piquark6046, @jiji-hoon96, @seonghun0828, @pkovzz, @nnnnoel, @noelkim-prestolabs, @minsoo-web, @hautest, @scato3, @l2hyunwoo, @WooWan, @VVSOGI, @k-jeonghee, @knott11, @lukaszkowalik2, @moonheekim0118, @sadobass, @minjongbaek, @umsungjun, @sossost, @sunrabbit123, @Seung-wan, @cruelladevil, @iDevGon, @oror-sine, @1eeminhyeong, @benzyminzy, @BlackWhite2000, @tooooo1, @L2HYUNN, @DonghyunKim98, @dasom-jo, @guesung, @uniqueeest, @KiKoS0, @myungjuice, @seung-juv, @Collection50, @nowethan, @coding-honey, @ariandel-dev, @apeltop, @jch1223, @yhay81, @milooy, @raviqqe, @youznn, @BinskLee, @YEONDG, @shinwonse, @willmanduffy, @vjo, @touhidrahman, @T3sT3ro, @belgattitude, @WISUNGWON, @anaclumos, @hsskey, @BasixKOR, @Kyujenius, @Dohun-choi, @dngur9801, @sanginchun, @westofsky, @DONG-8, @yhmpc, @pbstar, @MoXiaoluo, @uussong, @tuhm1, @tisou1, @spookyuser, @sa02045, @Hotanya, @nia3y, @mreiden, @kms0219kms, @IkumaTadokoro, @hansolbangul, @hainan-612, @hwibaski, @jeongshin, @HoberMin, @ohprettyhak, @gweesin, @FengBuPi, @kyvg, @evan-moon, @chldmsqls34, @kimpuro, @dogagenc, @Duck-98, @redd97, @faner11, @bhollis, @jaehunn, @babay123, @beomxtone, @ankitjha420, @shan-mx, @2skydev, @StyleShit, @confidential-nt, @siddsarkar, @seongminn, @healtheloper, @pnodet, @Gaic4o, @leeminhee119, @leehj322, @kristian240, @kingston, @kim-dongho, @jungwoo3490, @joris-gallot, @jonganebski, @jiwooproity, @moshuying, @jakvbs, @therealjamesjung, @SaeWooKKang and @HyeokjaeLee
|
|
24
|
+
|
|
3
25
|
## Version v1.38.0
|
|
4
26
|
|
|
5
|
-
Released on May
|
|
27
|
+
Released on May 18th, 2025.
|
|
6
28
|
|
|
7
29
|
- Added compatibility functions for [bindAll](https://es-toolkit.slash.page/reference/compat/util/bindAll.html), [setWith](https://es-toolkit.slash.page/reference/compat/object/setWith.html), [memoize](https://es-toolkit.slash.page/reference/function/memoize.html), [isNative](https://es-toolkit.slash.page/reference/compat/predicate/isNative.html), [invokeMap](https://es-toolkit.slash.page/reference/compat/array/invokeMap.html), [clone](https://es-toolkit.slash.page/reference/object/clone.html), [cloneWith](https://es-toolkit.slash.page/reference/compat/object/cloneWith.html), and [sortedLastIndexOf](https://es-toolkit.slash.page/reference/compat/array/sortedLastIndexOf.html).
|
|
8
30
|
- Enhanced [invariant](https://es-toolkit.slash.page/reference/util/invariant.html) function to accept Error instances and added [assert](https://es-toolkit.slash.page/reference/util/assert.html) alias.
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ es-toolkit is a state-of-the-art, high-performance JavaScript utility library wi
|
|
|
9
9
|
- es-toolkit offers a variety of everyday utility functions with modern implementations, such as [debounce](https://es-toolkit.slash.page/reference/function/debounce.html), [delay](https://es-toolkit.slash.page/reference/promise/delay.html), [chunk](https://es-toolkit.slash.page/reference/array/chunk.html), [sum](https://es-toolkit.slash.page/reference/math/sum.html), and [pick](https://es-toolkit.slash.page/reference/object/pick.html).
|
|
10
10
|
- Designed with performance in mind, es-toolkit achieves [2-3× better performance](https://es-toolkit.slash.page/performance.html) in modern JavaScript environments.
|
|
11
11
|
- es-toolkit supports tree shaking out of the box, and [reduces JavaScript code by up to 97%](https://es-toolkit.slash.page/bundle-size.html) compared to other libraries.
|
|
12
|
+
- es-toolkit offers a complete compatibility layer to seamlessly replace lodash, available as [es-toolkit/compat](https://es-toolkit.slash.page/compatibility.html).
|
|
12
13
|
- es-toolkit includes built-in TypeScript support, with straightforward yet robust types. It also provides useful type guards such as [isNotNil](https://es-toolkit.slash.page/reference/predicate/isNotNil.html).
|
|
13
14
|
- es-toolkit is utilized by several popular open-source libraries, such as [Storybook](https://github.com/storybookjs/storybook/blob/9d862798d666678cc4822e857c00bbd744169ced/code/core/package.json#L358) and [ink](https://github.com/vadimdemedes/ink/blob/2090ad9779be59dea71d173eb49785b7bd4495d0/package.json#L55).
|
|
14
15
|
- es-toolkit is battle-tested with 100% test coverage, ensuring reliability and robustness.
|
package/array.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/array');
|
package/compat/each.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { forEach as default } from '../dist/compat/array/forEach.js';
|
package/compat/each.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/compat/array/forEach.js').forEach;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { forEachRight as default } from '../dist/compat/array/forEachRight.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/compat/array/forEachRight.js').forEachRight;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { assignIn as default } from '../dist/compat/object/assignIn.js';
|
package/compat/extend.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/compat/object/assignIn.js').assignIn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { assignInWith as default } from '../dist/compat/object/assignInWith.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/compat/object/assignInWith.js').assignInWith;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { head as default } from '../dist/compat/array/head.js';
|
package/compat/first.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/compat/array/head.js').head;
|
package/compat.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/compat');
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function compareValues(a, b, order) {
|
|
6
|
+
if (a < b) {
|
|
7
|
+
return order === 'asc' ? -1 : 1;
|
|
8
|
+
}
|
|
9
|
+
if (a > b) {
|
|
10
|
+
return order === 'asc' ? 1 : -1;
|
|
11
|
+
}
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.compareValues = compareValues;
|
package/dist/array/at.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function at(arr, indices) {
|
|
6
|
+
const result = new Array(indices.length);
|
|
7
|
+
const length = arr.length;
|
|
8
|
+
for (let i = 0; i < indices.length; i++) {
|
|
9
|
+
let index = indices[i];
|
|
10
|
+
index = Number.isInteger(index) ? index : Math.trunc(index) || 0;
|
|
11
|
+
if (index < 0) {
|
|
12
|
+
index += length;
|
|
13
|
+
}
|
|
14
|
+
result[i] = arr[index];
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.at = at;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function chunk(arr, size) {
|
|
6
|
+
if (!Number.isInteger(size) || size <= 0) {
|
|
7
|
+
throw new Error('Size must be an integer greater than zero.');
|
|
8
|
+
}
|
|
9
|
+
const chunkLength = Math.ceil(arr.length / size);
|
|
10
|
+
const result = Array(chunkLength);
|
|
11
|
+
for (let index = 0; index < chunkLength; index++) {
|
|
12
|
+
const start = index * size;
|
|
13
|
+
const end = start + size;
|
|
14
|
+
result[index] = arr.slice(start, end);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.chunk = chunk;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function compact(arr) {
|
|
6
|
+
const result = [];
|
|
7
|
+
for (let i = 0; i < arr.length; i++) {
|
|
8
|
+
const item = arr[i];
|
|
9
|
+
if (item) {
|
|
10
|
+
result.push(item);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.compact = compact;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function countBy(arr, mapper) {
|
|
6
|
+
const result = {};
|
|
7
|
+
for (let i = 0; i < arr.length; i++) {
|
|
8
|
+
const item = arr[i];
|
|
9
|
+
const key = mapper(item);
|
|
10
|
+
result[key] = (result[key] ?? 0) + 1;
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.countBy = countBy;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function difference(firstArr, secondArr) {
|
|
6
|
+
const secondSet = new Set(secondArr);
|
|
7
|
+
return firstArr.filter(item => !secondSet.has(item));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.difference = difference;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function differenceBy(firstArr, secondArr, mapper) {
|
|
6
|
+
const mappedSecondSet = new Set(secondArr.map(item => mapper(item)));
|
|
7
|
+
return firstArr.filter(item => {
|
|
8
|
+
return !mappedSecondSet.has(mapper(item));
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.differenceBy = differenceBy;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function differenceWith(firstArr, secondArr, areItemsEqual) {
|
|
6
|
+
return firstArr.filter(firstItem => {
|
|
7
|
+
return secondArr.every(secondItem => {
|
|
8
|
+
return !areItemsEqual(firstItem, secondItem);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.differenceWith = differenceWith;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function dropRight(arr, itemsCount) {
|
|
6
|
+
itemsCount = Math.min(-itemsCount, 0);
|
|
7
|
+
if (itemsCount === 0) {
|
|
8
|
+
return arr.slice();
|
|
9
|
+
}
|
|
10
|
+
return arr.slice(0, itemsCount);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.dropRight = dropRight;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function dropRightWhile(arr, canContinueDropping) {
|
|
6
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
7
|
+
if (!canContinueDropping(arr[i], i, arr)) {
|
|
8
|
+
return arr.slice(0, i + 1);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.dropRightWhile = dropRightWhile;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function dropWhile(arr, canContinueDropping) {
|
|
6
|
+
const dropEndIndex = arr.findIndex((item, index, arr) => !canContinueDropping(item, index, arr));
|
|
7
|
+
if (dropEndIndex === -1) {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
return arr.slice(dropEndIndex);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.dropWhile = dropWhile;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function fill(array, value, start = 0, end = array.length) {
|
|
6
|
+
const length = array.length;
|
|
7
|
+
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|
8
|
+
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|
9
|
+
for (let i = finalStart; i < finalEnd; i++) {
|
|
10
|
+
array[i] = value;
|
|
11
|
+
}
|
|
12
|
+
return array;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.fill = fill;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const flatten = require('./flatten.js');
|
|
6
|
+
|
|
7
|
+
function flatMap(arr, iteratee, depth = 1) {
|
|
8
|
+
return flatten.flatten(arr.map(item => iteratee(item)), depth);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.flatMap = flatMap;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const flattenDeep = require('./flattenDeep.js');
|
|
6
|
+
|
|
7
|
+
function flatMapDeep(arr, iteratee) {
|
|
8
|
+
return flattenDeep.flattenDeep(arr.map((item) => iteratee(item)));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.flatMapDeep = flatMapDeep;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function flatten(arr, depth = 1) {
|
|
6
|
+
const result = [];
|
|
7
|
+
const flooredDepth = Math.floor(depth);
|
|
8
|
+
const recursive = (arr, currentDepth) => {
|
|
9
|
+
for (let i = 0; i < arr.length; i++) {
|
|
10
|
+
const item = arr[i];
|
|
11
|
+
if (Array.isArray(item) && currentDepth < flooredDepth) {
|
|
12
|
+
recursive(item, currentDepth + 1);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
result.push(item);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
recursive(arr, 0);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.flatten = flatten;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function forEachRight(arr, callback) {
|
|
6
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
7
|
+
const element = arr[i];
|
|
8
|
+
callback(element, i, arr);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.forEachRight = forEachRight;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
function groupBy(arr, getKeyFromItem) {
|
|
6
|
+
const result = {};
|
|
7
|
+
for (let i = 0; i < arr.length; i++) {
|
|
8
|
+
const item = arr[i];
|
|
9
|
+
const key = getKeyFromItem(item);
|
|
10
|
+
if (!Object.hasOwn(result, key)) {
|
|
11
|
+
result[key] = [];
|
|
12
|
+
}
|
|
13
|
+
result[key].push(item);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.groupBy = groupBy;
|