@vinicunca/perkakas 0.2.1 → 0.3.1
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/README.md +9 -0
- package/dist/commonjs/aria/index.js +17 -0
- package/dist/commonjs/aria/key-codes.js +25 -0
- package/dist/commonjs/array/all-pass.js +11 -0
- package/dist/commonjs/array/any-pass.js +11 -0
- package/dist/commonjs/array/chunk.js +17 -0
- package/dist/commonjs/array/compact.js +8 -0
- package/dist/commonjs/array/concat.js +11 -0
- package/dist/commonjs/array/count-by.js +22 -0
- package/dist/commonjs/array/difference-with.js +31 -0
- package/dist/commonjs/array/difference.js +32 -0
- package/dist/commonjs/array/drop-first-by.js +26 -0
- package/dist/commonjs/array/drop-last-while.js +16 -0
- package/dist/commonjs/array/drop-last.js +15 -0
- package/dist/commonjs/array/drop-while.js +16 -0
- package/dist/commonjs/array/drop.js +32 -0
- package/dist/commonjs/array/filter.js +41 -0
- package/dist/commonjs/array/find-index.js +46 -0
- package/dist/commonjs/array/find-last-index.js +24 -0
- package/dist/commonjs/array/find-last.js +24 -0
- package/dist/commonjs/array/find.js +38 -0
- package/dist/commonjs/array/first-by.js +22 -0
- package/dist/commonjs/array/first.js +26 -0
- package/dist/commonjs/array/flat-map-to-obj.js +25 -0
- package/dist/commonjs/array/flat-map.js +33 -0
- package/dist/commonjs/array/flatten-deep.js +48 -0
- package/dist/commonjs/array/flatten.js +32 -0
- package/dist/commonjs/array/for-each.js +40 -0
- package/dist/commonjs/array/group-by.js +33 -0
- package/dist/commonjs/array/has-at-least.js +11 -0
- package/dist/commonjs/array/index-by.js +24 -0
- package/dist/commonjs/array/index.js +81 -0
- package/dist/commonjs/array/intersection-with.js +31 -0
- package/dist/commonjs/array/intersection.js +32 -0
- package/dist/commonjs/array/join.js +11 -0
- package/dist/commonjs/array/last.js +11 -0
- package/dist/commonjs/array/length.js +11 -0
- package/dist/commonjs/array/map-to-obj.js +23 -0
- package/dist/commonjs/array/map.js +35 -0
- package/dist/commonjs/array/max-by.js +28 -0
- package/dist/commonjs/array/mean-by.js +26 -0
- package/dist/commonjs/array/merge-all.js +7 -0
- package/dist/commonjs/array/min-by.js +28 -0
- package/dist/commonjs/array/nth-by.js +12 -0
- package/dist/commonjs/array/only.js +14 -0
- package/dist/commonjs/array/partition.js +24 -0
- package/dist/commonjs/array/range.js +15 -0
- package/dist/commonjs/array/rank-by.js +17 -0
- package/dist/commonjs/array/reduce.js +19 -0
- package/dist/commonjs/array/reject.js +41 -0
- package/dist/commonjs/array/reverse.js +11 -0
- package/dist/commonjs/array/sample.js +34 -0
- package/dist/commonjs/array/shuffle.js +18 -0
- package/dist/commonjs/array/sort-by.js +52 -0
- package/dist/commonjs/array/sort.js +16 -0
- package/dist/commonjs/array/splice.js +13 -0
- package/dist/commonjs/array/split-at.js +13 -0
- package/dist/commonjs/array/split-when.js +17 -0
- package/dist/commonjs/array/sum-by.js +24 -0
- package/dist/commonjs/array/swap-indices.js +34 -0
- package/dist/commonjs/array/take-first-by.js +24 -0
- package/dist/commonjs/array/take-while.js +18 -0
- package/dist/commonjs/array/take.js +38 -0
- package/dist/commonjs/array/uniq-by.js +30 -0
- package/dist/commonjs/array/uniq-with.js +33 -0
- package/dist/commonjs/array/uniq.js +32 -0
- package/dist/commonjs/array/zip-obj.js +16 -0
- package/dist/commonjs/array/zip-with.js +23 -0
- package/dist/commonjs/array/zip.js +19 -0
- package/dist/commonjs/function/conditional.js +34 -0
- package/dist/commonjs/function/create-pipe.js +8 -0
- package/dist/commonjs/function/debounce.js +88 -0
- package/dist/commonjs/function/identity.js +7 -0
- package/dist/commonjs/function/index.js +25 -0
- package/dist/commonjs/function/noop.js +7 -0
- package/dist/commonjs/function/once.js +15 -0
- package/dist/commonjs/function/pipe.js +106 -0
- package/dist/commonjs/function/purry.js +20 -0
- package/dist/commonjs/function/sleep.js +9 -0
- package/dist/commonjs/guard/index.js +32 -0
- package/dist/commonjs/guard/is-array.js +7 -0
- package/dist/commonjs/guard/is-boolean.js +7 -0
- package/dist/commonjs/guard/is-date.js +7 -0
- package/dist/commonjs/guard/is-defined.js +13 -0
- package/dist/commonjs/guard/is-empty.js +19 -0
- package/dist/commonjs/guard/is-error.js +7 -0
- package/dist/commonjs/guard/is-function.js +7 -0
- package/dist/commonjs/guard/is-nil.js +7 -0
- package/dist/commonjs/guard/is-non-null.js +7 -0
- package/dist/commonjs/guard/is-not.js +9 -0
- package/dist/commonjs/guard/is-number.js +7 -0
- package/dist/commonjs/guard/is-object.js +11 -0
- package/dist/commonjs/guard/is-promise.js +7 -0
- package/dist/commonjs/guard/is-string.js +7 -0
- package/dist/commonjs/guard/is-symbol.js +7 -0
- package/dist/commonjs/guard/is-truthy.js +7 -0
- package/dist/commonjs/index.js +26 -0
- package/dist/commonjs/number/add.js +11 -0
- package/dist/commonjs/number/ceil.js +9 -0
- package/dist/commonjs/number/clamp.js +17 -0
- package/dist/commonjs/number/divide.js +11 -0
- package/dist/commonjs/number/floor.js +9 -0
- package/dist/commonjs/number/index.js +24 -0
- package/dist/commonjs/number/multiply.js +11 -0
- package/dist/commonjs/number/round.js +9 -0
- package/dist/commonjs/number/subtract.js +11 -0
- package/dist/commonjs/object/add-prop.js +14 -0
- package/dist/commonjs/object/clone.js +49 -0
- package/dist/commonjs/object/equals.js +71 -0
- package/dist/commonjs/object/for-each-obj.js +30 -0
- package/dist/commonjs/object/from-pairs.js +14 -0
- package/dist/commonjs/object/index.js +39 -0
- package/dist/commonjs/object/invert.js +15 -0
- package/dist/commonjs/object/keys.js +10 -0
- package/dist/commonjs/object/map-keys.js +16 -0
- package/dist/commonjs/object/map-values.js +16 -0
- package/dist/commonjs/object/merge-deep.js +31 -0
- package/dist/commonjs/object/merge.js +11 -0
- package/dist/commonjs/object/omit-by.js +20 -0
- package/dist/commonjs/object/omit.js +25 -0
- package/dist/commonjs/object/path-or.js +18 -0
- package/dist/commonjs/object/pick-by.js +20 -0
- package/dist/commonjs/object/pick.js +19 -0
- package/dist/commonjs/object/prop.js +7 -0
- package/dist/commonjs/object/set-path.js +26 -0
- package/dist/commonjs/object/set.js +14 -0
- package/dist/commonjs/object/swap-props.js +16 -0
- package/dist/commonjs/object/to-pairs.js +11 -0
- package/dist/commonjs/object/values.js +7 -0
- package/dist/commonjs/string/cases-types.js +2 -0
- package/dist/commonjs/string/cases.js +107 -0
- package/dist/commonjs/string/human-readable-file-size.js +16 -0
- package/dist/commonjs/string/index.js +21 -0
- package/dist/commonjs/string/random-string.js +10 -0
- package/dist/commonjs/string/slugify.js +13 -0
- package/dist/commonjs/string/string-to-path.js +18 -0
- package/dist/commonjs/type/index.js +17 -0
- package/dist/commonjs/type/type.js +13 -0
- package/dist/commonjs/utils/heap.js +43 -0
- package/dist/commonjs/utils/narrow.js +2 -0
- package/dist/commonjs/utils/paths.js +2 -0
- package/dist/commonjs/utils/purry-on.js +10 -0
- package/dist/commonjs/utils/purry-order-rules.js +66 -0
- package/dist/commonjs/utils/quick-select.js +31 -0
- package/dist/commonjs/utils/reduce-lazy.js +18 -0
- package/dist/commonjs/utils/swap-in-place.js +7 -0
- package/dist/commonjs/utils/to-lazy-indexed.js +7 -0
- package/dist/commonjs/utils/to-single.js +8 -0
- package/dist/commonjs/utils/types.js +2 -0
- package/dist/commonjs/utils/with-precision.js +23 -0
- package/dist/es/aria/index.js +1 -0
- package/dist/es/aria/key-codes.js +22 -0
- package/dist/es/array/all-pass.js +7 -0
- package/dist/es/array/any-pass.js +7 -0
- package/dist/es/array/chunk.js +13 -0
- package/dist/es/array/compact.js +4 -0
- package/dist/es/array/concat.js +7 -0
- package/dist/es/array/count-by.js +18 -0
- package/dist/es/array/difference-with.js +27 -0
- package/dist/es/array/difference.js +28 -0
- package/dist/es/array/drop-first-by.js +22 -0
- package/dist/es/array/drop-last-while.js +12 -0
- package/dist/es/array/drop-last.js +11 -0
- package/dist/es/array/drop-while.js +12 -0
- package/dist/es/array/drop.js +28 -0
- package/dist/es/array/filter.js +37 -0
- package/dist/es/array/find-index.js +42 -0
- package/dist/es/array/find-last-index.js +20 -0
- package/dist/es/array/find-last.js +20 -0
- package/dist/es/array/find.js +34 -0
- package/dist/es/array/first-by.js +18 -0
- package/dist/es/array/first.js +22 -0
- package/dist/es/array/flat-map-to-obj.js +21 -0
- package/dist/es/array/flat-map.js +29 -0
- package/dist/es/array/flatten-deep.js +44 -0
- package/dist/es/array/flatten.js +28 -0
- package/dist/es/array/for-each.js +36 -0
- package/dist/es/array/group-by.js +29 -0
- package/dist/es/array/has-at-least.js +7 -0
- package/dist/es/array/index-by.js +20 -0
- package/dist/es/array/index.js +65 -0
- package/dist/es/array/intersection-with.js +27 -0
- package/dist/es/array/intersection.js +28 -0
- package/dist/es/array/join.js +7 -0
- package/dist/es/array/last.js +7 -0
- package/dist/es/array/length.js +7 -0
- package/dist/es/array/map-to-obj.js +19 -0
- package/dist/es/array/map.js +31 -0
- package/dist/es/array/max-by.js +24 -0
- package/dist/es/array/mean-by.js +22 -0
- package/dist/es/array/merge-all.js +3 -0
- package/dist/es/array/min-by.js +24 -0
- package/dist/es/array/nth-by.js +8 -0
- package/dist/es/array/only.js +10 -0
- package/dist/es/array/partition.js +20 -0
- package/dist/es/array/range.js +11 -0
- package/dist/es/array/rank-by.js +13 -0
- package/dist/es/array/reduce.js +15 -0
- package/dist/es/array/reject.js +37 -0
- package/dist/es/array/reverse.js +7 -0
- package/dist/es/array/sample.js +30 -0
- package/dist/es/array/shuffle.js +14 -0
- package/dist/es/array/sort-by.js +48 -0
- package/dist/es/array/sort.js +12 -0
- package/dist/es/array/splice.js +9 -0
- package/dist/es/array/split-at.js +9 -0
- package/dist/es/array/split-when.js +13 -0
- package/dist/es/array/sum-by.js +20 -0
- package/dist/es/array/swap-indices.js +30 -0
- package/dist/es/array/take-first-by.js +20 -0
- package/dist/es/array/take-while.js +14 -0
- package/dist/es/array/take.js +34 -0
- package/dist/es/array/uniq-by.js +26 -0
- package/dist/es/array/uniq-with.js +29 -0
- package/dist/es/array/uniq.js +28 -0
- package/dist/es/array/zip-obj.js +12 -0
- package/dist/es/array/zip-with.js +19 -0
- package/dist/es/array/zip.js +15 -0
- package/dist/es/function/conditional.js +30 -0
- package/dist/es/function/create-pipe.js +4 -0
- package/dist/es/function/debounce.js +84 -0
- package/dist/es/function/identity.js +3 -0
- package/dist/es/function/index.js +9 -0
- package/dist/es/function/noop.js +3 -0
- package/dist/es/function/once.js +11 -0
- package/dist/es/function/pipe.js +102 -0
- package/dist/es/function/purry.js +16 -0
- package/dist/es/function/sleep.js +5 -0
- package/dist/es/guard/index.js +16 -0
- package/dist/es/guard/is-array.js +3 -0
- package/dist/es/guard/is-boolean.js +3 -0
- package/dist/es/guard/is-date.js +3 -0
- package/dist/es/guard/is-defined.js +9 -0
- package/dist/es/guard/is-empty.js +15 -0
- package/dist/es/guard/is-error.js +3 -0
- package/dist/es/guard/is-function.js +3 -0
- package/dist/es/guard/is-nil.js +3 -0
- package/dist/es/guard/is-non-null.js +3 -0
- package/dist/es/guard/is-not.js +5 -0
- package/dist/es/guard/is-number.js +3 -0
- package/dist/es/guard/is-object.js +7 -0
- package/dist/es/guard/is-promise.js +3 -0
- package/dist/es/guard/is-string.js +3 -0
- package/dist/es/guard/is-symbol.js +3 -0
- package/dist/es/guard/is-truthy.js +3 -0
- package/dist/es/index.js +9 -0
- package/dist/es/number/add.js +7 -0
- package/dist/es/number/ceil.js +5 -0
- package/dist/es/number/clamp.js +13 -0
- package/dist/es/number/divide.js +7 -0
- package/dist/es/number/floor.js +5 -0
- package/dist/es/number/index.js +8 -0
- package/dist/es/number/multiply.js +7 -0
- package/dist/es/number/round.js +5 -0
- package/dist/es/number/subtract.js +7 -0
- package/dist/es/object/add-prop.js +10 -0
- package/dist/es/object/clone.js +45 -0
- package/dist/es/object/equals.js +67 -0
- package/dist/es/object/for-each-obj.js +26 -0
- package/dist/es/object/from-pairs.js +10 -0
- package/dist/es/object/index.js +23 -0
- package/dist/es/object/invert.js +11 -0
- package/dist/es/object/keys.js +6 -0
- package/dist/es/object/map-keys.js +12 -0
- package/dist/es/object/map-values.js +12 -0
- package/dist/es/object/merge-deep.js +27 -0
- package/dist/es/object/merge.js +7 -0
- package/dist/es/object/omit-by.js +16 -0
- package/dist/es/object/omit.js +21 -0
- package/dist/es/object/path-or.js +14 -0
- package/dist/es/object/pick-by.js +16 -0
- package/dist/es/object/pick.js +15 -0
- package/dist/es/object/prop.js +3 -0
- package/dist/es/object/set-path.js +21 -0
- package/dist/es/object/set.js +10 -0
- package/dist/es/object/swap-props.js +12 -0
- package/dist/es/object/to-pairs.js +7 -0
- package/dist/es/object/values.js +3 -0
- package/dist/es/string/cases-types.js +1 -0
- package/dist/es/string/cases.js +93 -0
- package/dist/es/string/human-readable-file-size.js +12 -0
- package/dist/es/string/index.js +5 -0
- package/dist/es/string/random-string.js +6 -0
- package/dist/es/string/slugify.js +9 -0
- package/dist/es/string/string-to-path.js +14 -0
- package/dist/es/type/index.js +1 -0
- package/dist/es/type/type.js +9 -0
- package/dist/es/utils/heap.js +38 -0
- package/dist/es/utils/narrow.js +1 -0
- package/dist/es/utils/paths.js +1 -0
- package/dist/es/utils/purry-on.js +6 -0
- package/dist/es/utils/purry-order-rules.js +61 -0
- package/dist/es/utils/quick-select.js +27 -0
- package/dist/es/utils/reduce-lazy.js +14 -0
- package/dist/es/utils/swap-in-place.js +3 -0
- package/dist/es/utils/to-lazy-indexed.js +3 -0
- package/dist/es/utils/to-single.js +4 -0
- package/dist/es/utils/types.js +1 -0
- package/dist/es/utils/with-precision.js +19 -0
- package/dist/metadata.json +48311 -0
- package/dist/types/aria/index.d.ts +2 -0
- package/dist/types/aria/index.d.ts.map +1 -0
- package/dist/types/aria/key-codes.d.ts +26 -0
- package/dist/types/aria/key-codes.d.ts.map +1 -0
- package/dist/types/array/all-pass.d.ts +32 -0
- package/dist/types/array/all-pass.d.ts.map +1 -0
- package/dist/types/array/any-pass.d.ts +32 -0
- package/dist/types/array/any-pass.d.ts.map +1 -0
- package/dist/types/array/chunk.d.ts +29 -0
- package/dist/types/array/chunk.d.ts.map +1 -0
- package/dist/types/array/compact.d.ts +12 -0
- package/dist/types/array/compact.d.ts.map +1 -0
- package/dist/types/array/concat.d.ts +24 -0
- package/dist/types/array/concat.d.ts.map +1 -0
- package/dist/types/array/count-by.d.ts +20 -0
- package/dist/types/array/count-by.d.ts.map +1 -0
- package/dist/types/array/difference-with.d.ts +48 -0
- package/dist/types/array/difference-with.d.ts.map +1 -0
- package/dist/types/array/difference.d.ts +35 -0
- package/dist/types/array/difference.d.ts.map +1 -0
- package/dist/types/array/drop-first-by.d.ts +39 -0
- package/dist/types/array/drop-first-by.d.ts.map +1 -0
- package/dist/types/array/drop-last-while.d.ts +30 -0
- package/dist/types/array/drop-last-while.d.ts.map +1 -0
- package/dist/types/array/drop-last.d.ts +25 -0
- package/dist/types/array/drop-last.d.ts.map +1 -0
- package/dist/types/array/drop-while.d.ts +33 -0
- package/dist/types/array/drop-while.d.ts.map +1 -0
- package/dist/types/array/drop.d.ts +31 -0
- package/dist/types/array/drop.d.ts.map +1 -0
- package/dist/types/array/filter.d.ts +49 -0
- package/dist/types/array/filter.d.ts.map +1 -0
- package/dist/types/array/find-index.d.ts +67 -0
- package/dist/types/array/find-index.d.ts.map +1 -0
- package/dist/types/array/find-last-index.d.ts +43 -0
- package/dist/types/array/find-last-index.d.ts.map +1 -0
- package/dist/types/array/find-last.d.ts +45 -0
- package/dist/types/array/find-last.d.ts.map +1 -0
- package/dist/types/array/find.d.ts +59 -0
- package/dist/types/array/find.d.ts.map +1 -0
- package/dist/types/array/first-by.d.ts +57 -0
- package/dist/types/array/first-by.d.ts.map +1 -0
- package/dist/types/array/first.d.ts +35 -0
- package/dist/types/array/first.d.ts.map +1 -0
- package/dist/types/array/flat-map-to-obj.d.ts +50 -0
- package/dist/types/array/flat-map-to-obj.d.ts.map +1 -0
- package/dist/types/array/flat-map.d.ts +39 -0
- package/dist/types/array/flat-map.d.ts.map +1 -0
- package/dist/types/array/flatten-deep.d.ts +26 -0
- package/dist/types/array/flatten-deep.d.ts.map +1 -0
- package/dist/types/array/flatten.d.ts +23 -0
- package/dist/types/array/flatten.d.ts.map +1 -0
- package/dist/types/array/for-each.d.ts +57 -0
- package/dist/types/array/for-each.d.ts.map +1 -0
- package/dist/types/array/group-by.d.ts +36 -0
- package/dist/types/array/group-by.d.ts.map +1 -0
- package/dist/types/array/has-at-least.d.ts +47 -0
- package/dist/types/array/has-at-least.d.ts.map +1 -0
- package/dist/types/array/index-by.d.ts +34 -0
- package/dist/types/array/index-by.d.ts.map +1 -0
- package/dist/types/array/index.d.ts +66 -0
- package/dist/types/array/index.d.ts.map +1 -0
- package/dist/types/array/intersection-with.d.ts +54 -0
- package/dist/types/array/intersection-with.d.ts.map +1 -0
- package/dist/types/array/intersection.d.ts +30 -0
- package/dist/types/array/intersection.d.ts.map +1 -0
- package/dist/types/array/join.d.ts +45 -0
- package/dist/types/array/join.d.ts.map +1 -0
- package/dist/types/array/last.d.ts +24 -0
- package/dist/types/array/last.d.ts.map +1 -0
- package/dist/types/array/length.d.ts +14 -0
- package/dist/types/array/length.d.ts.map +1 -0
- package/dist/types/array/map-to-obj.d.ts +42 -0
- package/dist/types/array/map-to-obj.d.ts.map +1 -0
- package/dist/types/array/map.d.ts +62 -0
- package/dist/types/array/map.d.ts.map +1 -0
- package/dist/types/array/max-by.d.ts +39 -0
- package/dist/types/array/max-by.d.ts.map +1 -0
- package/dist/types/array/mean-by.d.ts +39 -0
- package/dist/types/array/mean-by.d.ts.map +1 -0
- package/dist/types/array/merge-all.d.ts +16 -0
- package/dist/types/array/merge-all.d.ts.map +1 -0
- package/dist/types/array/min-by.d.ts +39 -0
- package/dist/types/array/min-by.d.ts.map +1 -0
- package/dist/types/array/nth-by.d.ts +45 -0
- package/dist/types/array/nth-by.d.ts.map +1 -0
- package/dist/types/array/only.d.ts +36 -0
- package/dist/types/array/only.d.ts.map +1 -0
- package/dist/types/array/partition.d.ts +60 -0
- package/dist/types/array/partition.d.ts.map +1 -0
- package/dist/types/array/range.d.ts +22 -0
- package/dist/types/array/range.d.ts.map +1 -0
- package/dist/types/array/rank-by.d.ts +41 -0
- package/dist/types/array/rank-by.d.ts.map +1 -0
- package/dist/types/array/reduce.d.ts +35 -0
- package/dist/types/array/reduce.d.ts.map +1 -0
- package/dist/types/array/reject.d.ts +42 -0
- package/dist/types/array/reject.d.ts.map +1 -0
- package/dist/types/array/reverse.d.ts +25 -0
- package/dist/types/array/reverse.d.ts.map +1 -0
- package/dist/types/array/sample.d.ts +54 -0
- package/dist/types/array/sample.d.ts.map +1 -0
- package/dist/types/array/shuffle.d.ts +22 -0
- package/dist/types/array/shuffle.d.ts.map +1 -0
- package/dist/types/array/sort-by.d.ts +99 -0
- package/dist/types/array/sort-by.d.ts.map +1 -0
- package/dist/types/array/sort.d.ts +52 -0
- package/dist/types/array/sort.d.ts.map +1 -0
- package/dist/types/array/splice.d.ts +31 -0
- package/dist/types/array/splice.d.ts.map +1 -0
- package/dist/types/array/split-at.d.ts +26 -0
- package/dist/types/array/split-at.d.ts.map +1 -0
- package/dist/types/array/split-when.d.ts +24 -0
- package/dist/types/array/split-when.d.ts.map +1 -0
- package/dist/types/array/sum-by.d.ts +39 -0
- package/dist/types/array/sum-by.d.ts.map +1 -0
- package/dist/types/array/swap-indices.d.ts +68 -0
- package/dist/types/array/swap-indices.d.ts.map +1 -0
- package/dist/types/array/take-first-by.d.ts +43 -0
- package/dist/types/array/take-first-by.d.ts.map +1 -0
- package/dist/types/array/take-while.d.ts +24 -0
- package/dist/types/array/take-while.d.ts.map +1 -0
- package/dist/types/array/take.d.ts +30 -0
- package/dist/types/array/take.d.ts.map +1 -0
- package/dist/types/array/uniq-by.d.ts +22 -0
- package/dist/types/array/uniq-by.d.ts.map +1 -0
- package/dist/types/array/uniq-with.d.ts +44 -0
- package/dist/types/array/uniq-with.d.ts.map +1 -0
- package/dist/types/array/uniq.d.ts +24 -0
- package/dist/types/array/uniq.d.ts.map +1 -0
- package/dist/types/array/zip-obj.d.ts +26 -0
- package/dist/types/array/zip-obj.d.ts.map +1 -0
- package/dist/types/array/zip-with.d.ts +42 -0
- package/dist/types/array/zip-with.d.ts.map +1 -0
- package/dist/types/array/zip.d.ts +52 -0
- package/dist/types/array/zip.d.ts.map +1 -0
- package/dist/types/function/conditional.d.ts +108 -0
- package/dist/types/function/conditional.d.ts.map +1 -0
- package/dist/types/function/create-pipe.d.ts +19 -0
- package/dist/types/function/create-pipe.d.ts.map +1 -0
- package/dist/types/function/debounce.d.ts +92 -0
- package/dist/types/function/debounce.d.ts.map +1 -0
- package/dist/types/function/identity.d.ts +10 -0
- package/dist/types/function/identity.d.ts.map +1 -0
- package/dist/types/function/index.d.ts +10 -0
- package/dist/types/function/index.d.ts.map +1 -0
- package/dist/types/function/noop.d.ts +10 -0
- package/dist/types/function/noop.d.ts.map +1 -0
- package/dist/types/function/once.d.ts +13 -0
- package/dist/types/function/once.d.ts.map +1 -0
- package/dist/types/function/pipe.d.ts +32 -0
- package/dist/types/function/pipe.d.ts.map +1 -0
- package/dist/types/function/purry.d.ts +32 -0
- package/dist/types/function/purry.d.ts.map +1 -0
- package/dist/types/function/sleep.d.ts +12 -0
- package/dist/types/function/sleep.d.ts.map +1 -0
- package/dist/types/guard/index.d.ts +17 -0
- package/dist/types/guard/index.d.ts.map +1 -0
- package/dist/types/guard/is-array.d.ts +15 -0
- package/dist/types/guard/is-array.d.ts.map +1 -0
- package/dist/types/guard/is-boolean.d.ts +15 -0
- package/dist/types/guard/is-boolean.d.ts.map +1 -0
- package/dist/types/guard/is-date.d.ts +13 -0
- package/dist/types/guard/is-date.d.ts.map +1 -0
- package/dist/types/guard/is-defined.d.ts +22 -0
- package/dist/types/guard/is-defined.d.ts.map +1 -0
- package/dist/types/guard/is-empty.d.ts +19 -0
- package/dist/types/guard/is-empty.d.ts.map +1 -0
- package/dist/types/guard/is-error.d.ts +15 -0
- package/dist/types/guard/is-error.d.ts.map +1 -0
- package/dist/types/guard/is-function.d.ts +15 -0
- package/dist/types/guard/is-function.d.ts.map +1 -0
- package/dist/types/guard/is-nil.d.ts +14 -0
- package/dist/types/guard/is-nil.d.ts.map +1 -0
- package/dist/types/guard/is-non-null.d.ts +15 -0
- package/dist/types/guard/is-non-null.d.ts.map +1 -0
- package/dist/types/guard/is-not.d.ts +15 -0
- package/dist/types/guard/is-not.d.ts.map +1 -0
- package/dist/types/guard/is-number.d.ts +14 -0
- package/dist/types/guard/is-number.d.ts.map +1 -0
- package/dist/types/guard/is-object.d.ts +28 -0
- package/dist/types/guard/is-object.d.ts.map +1 -0
- package/dist/types/guard/is-promise.d.ts +14 -0
- package/dist/types/guard/is-promise.d.ts.map +1 -0
- package/dist/types/guard/is-string.d.ts +14 -0
- package/dist/types/guard/is-string.d.ts.map +1 -0
- package/dist/types/guard/is-symbol.d.ts +14 -0
- package/dist/types/guard/is-symbol.d.ts.map +1 -0
- package/dist/types/guard/is-truthy.d.ts +17 -0
- package/dist/types/guard/is-truthy.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/number/add.d.ts +29 -0
- package/dist/types/number/add.d.ts.map +1 -0
- package/dist/types/number/ceil.d.ts +35 -0
- package/dist/types/number/ceil.d.ts.map +1 -0
- package/dist/types/number/clamp.d.ts +38 -0
- package/dist/types/number/clamp.d.ts.map +1 -0
- package/dist/types/number/divide.d.ts +27 -0
- package/dist/types/number/divide.d.ts.map +1 -0
- package/dist/types/number/floor.d.ts +35 -0
- package/dist/types/number/floor.d.ts.map +1 -0
- package/dist/types/number/index.d.ts +9 -0
- package/dist/types/number/index.d.ts.map +1 -0
- package/dist/types/number/multiply.d.ts +27 -0
- package/dist/types/number/multiply.d.ts.map +1 -0
- package/dist/types/number/round.d.ts +35 -0
- package/dist/types/number/round.d.ts.map +1 -0
- package/dist/types/number/subtract.d.ts +29 -0
- package/dist/types/number/subtract.d.ts.map +1 -0
- package/dist/types/object/add-prop.d.ts +30 -0
- package/dist/types/object/add-prop.d.ts.map +1 -0
- package/dist/types/object/clone.d.ts +10 -0
- package/dist/types/object/clone.d.ts.map +1 -0
- package/dist/types/object/equals.d.ts +30 -0
- package/dist/types/object/equals.d.ts.map +1 -0
- package/dist/types/object/for-each-obj.d.ts +44 -0
- package/dist/types/object/for-each-obj.d.ts.map +1 -0
- package/dist/types/object/from-pairs.d.ts +38 -0
- package/dist/types/object/from-pairs.d.ts.map +1 -0
- package/dist/types/object/index.d.ts +24 -0
- package/dist/types/object/index.d.ts.map +1 -0
- package/dist/types/object/invert.d.ts +28 -0
- package/dist/types/object/invert.d.ts.map +1 -0
- package/dist/types/object/keys.d.ts +34 -0
- package/dist/types/object/keys.d.ts.map +1 -0
- package/dist/types/object/map-keys.d.ts +24 -0
- package/dist/types/object/map-keys.d.ts.map +1 -0
- package/dist/types/object/map-values.d.ts +25 -0
- package/dist/types/object/map-values.d.ts.map +1 -0
- package/dist/types/object/merge-deep.d.ts +32 -0
- package/dist/types/object/merge-deep.d.ts.map +1 -0
- package/dist/types/object/merge.d.ts +25 -0
- package/dist/types/object/merge.d.ts.map +1 -0
- package/dist/types/object/omit-by.d.ts +22 -0
- package/dist/types/object/omit-by.d.ts.map +1 -0
- package/dist/types/object/omit.d.ts +24 -0
- package/dist/types/object/omit.d.ts.map +1 -0
- package/dist/types/object/path-or.d.ts +76 -0
- package/dist/types/object/path-or.d.ts.map +1 -0
- package/dist/types/object/pick-by.d.ts +22 -0
- package/dist/types/object/pick-by.d.ts.map +1 -0
- package/dist/types/object/pick.d.ts +22 -0
- package/dist/types/object/pick.d.ts.map +1 -0
- package/dist/types/object/prop.d.ts +11 -0
- package/dist/types/object/prop.d.ts.map +1 -0
- package/dist/types/object/set-path.d.ts +29 -0
- package/dist/types/object/set-path.d.ts.map +1 -0
- package/dist/types/object/set.d.ts +26 -0
- package/dist/types/object/set.d.ts.map +1 -0
- package/dist/types/object/swap-props.d.ts +44 -0
- package/dist/types/object/swap-props.d.ts.map +1 -0
- package/dist/types/object/to-pairs.d.ts +33 -0
- package/dist/types/object/to-pairs.d.ts.map +1 -0
- package/dist/types/object/values.d.ts +20 -0
- package/dist/types/object/values.d.ts.map +1 -0
- package/dist/types/string/cases-types.d.ts +36 -0
- package/dist/types/string/cases-types.d.ts.map +1 -0
- package/dist/types/string/cases.d.ts +22 -0
- package/dist/types/string/cases.d.ts.map +1 -0
- package/dist/types/string/human-readable-file-size.d.ts +13 -0
- package/dist/types/string/human-readable-file-size.d.ts.map +1 -0
- package/dist/types/string/index.d.ts +6 -0
- package/dist/types/string/index.d.ts.map +1 -0
- package/dist/types/string/random-string.d.ts +10 -0
- package/dist/types/string/random-string.d.ts.map +1 -0
- package/dist/types/string/slugify.d.ts +12 -0
- package/dist/types/string/slugify.d.ts.map +1 -0
- package/dist/types/string/string-to-path.d.ts +11 -0
- package/dist/types/string/string-to-path.d.ts.map +1 -0
- package/dist/types/type/index.d.ts +2 -0
- package/dist/types/type/index.d.ts.map +1 -0
- package/dist/types/type/type.d.ts +19 -0
- package/dist/types/type/type.d.ts.map +1 -0
- package/dist/types/utils/heap.d.ts +24 -0
- package/dist/types/utils/heap.d.ts.map +1 -0
- package/dist/types/utils/narrow.d.ts +52 -0
- package/dist/types/utils/narrow.d.ts.map +1 -0
- package/dist/types/utils/paths.d.ts +9 -0
- package/dist/types/utils/paths.d.ts.map +1 -0
- package/dist/types/utils/purry-on.d.ts +7 -0
- package/dist/types/utils/purry-on.d.ts.map +1 -0
- package/dist/types/utils/purry-order-rules.d.ts +52 -0
- package/dist/types/utils/purry-order-rules.d.ts.map +1 -0
- package/dist/types/utils/quick-select.d.ts +18 -0
- package/dist/types/utils/quick-select.d.ts.map +1 -0
- package/dist/types/utils/reduce-lazy.d.ts +22 -0
- package/dist/types/utils/reduce-lazy.d.ts.map +1 -0
- package/dist/types/utils/swap-in-place.d.ts +5 -0
- package/dist/types/utils/swap-in-place.d.ts.map +1 -0
- package/dist/types/utils/to-lazy-indexed.d.ts +4 -0
- package/dist/types/utils/to-lazy-indexed.d.ts.map +1 -0
- package/dist/types/utils/to-single.d.ts +4 -0
- package/dist/types/utils/to-single.d.ts.map +1 -0
- package/dist/types/utils/types.d.ts +32 -0
- package/dist/types/utils/types.d.ts.map +1 -0
- package/dist/types/utils/with-precision.d.ts +2 -0
- package/dist/types/utils/with-precision.d.ts.map +1 -0
- package/package.json +34 -23
- package/dist/index.cjs +0 -2843
- package/dist/index.d.cts +0 -4175
- package/dist/index.d.ts +0 -4175
- package/dist/index.js +0 -2678
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -7
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Pred, PredIndexed } from '../utils/types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the index of the last element in the array where predicate is true, and -1 otherwise.
|
|
4
|
+
* @param array the array
|
|
5
|
+
* @param fn the predicate
|
|
6
|
+
* @signature
|
|
7
|
+
* P.findLastIndex(items, fn)
|
|
8
|
+
* P.findLastIndex.indexed(items, fn)
|
|
9
|
+
* @example
|
|
10
|
+
* P.findLastIndex([1, 3, 4, 6], n => n % 2 === 1) // => 1
|
|
11
|
+
* P.findLastIndex.indexed([1, 3, 4, 6], (n, i) => n % 2 === 1) // => 1
|
|
12
|
+
* @dataFirst
|
|
13
|
+
* @indexed
|
|
14
|
+
* @pipeable
|
|
15
|
+
* @category Array
|
|
16
|
+
*/
|
|
17
|
+
export declare function findLastIndex<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): number;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the index of the last element in the array where predicate is true, and -1 otherwise.
|
|
20
|
+
* @param fn the predicate
|
|
21
|
+
* @signature
|
|
22
|
+
* P.findLastIndex(fn)(items)
|
|
23
|
+
* P.findLastIndex.indexed(fn)(items)
|
|
24
|
+
* @example
|
|
25
|
+
* P.pipe(
|
|
26
|
+
* [1, 3, 4, 6],
|
|
27
|
+
* P.findLastIndex(n => n % 2 === 1)
|
|
28
|
+
* ) // => 1
|
|
29
|
+
* P.pipe(
|
|
30
|
+
* [1, 3, 4, 6],
|
|
31
|
+
* P.findLastIndex.indexed((n, i) => n % 2 === 1)
|
|
32
|
+
* ) // => 1
|
|
33
|
+
* @dataLast
|
|
34
|
+
* @indexed
|
|
35
|
+
* @pipeable
|
|
36
|
+
* @category Array
|
|
37
|
+
*/
|
|
38
|
+
export declare function findLastIndex<T>(fn: Pred<T, boolean>): (array: ReadonlyArray<T>) => number;
|
|
39
|
+
export declare namespace findLastIndex {
|
|
40
|
+
function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): number;
|
|
41
|
+
function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => number;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=find-last-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-last-index.d.ts","sourceRoot":"","sources":["../../../src/array/find-last-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAI7E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GACnB,MAAM,CAAC;AAEV;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GACnB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;AAkBvC,yBAAiB,aAAa,CAAC;IAC7B,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1B,MAAM,CAAC;IACV,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1B,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;CAKxC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Pred, PredIndexed } from '../utils/types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the value of the last element in the array where predicate is true, and undefined
|
|
4
|
+
* otherwise.
|
|
5
|
+
* @param array the array
|
|
6
|
+
* @param fn the predicate
|
|
7
|
+
* @signature
|
|
8
|
+
* P.findLast(items, fn)
|
|
9
|
+
* P.findLast.indexed(items, fn)
|
|
10
|
+
* @example
|
|
11
|
+
* P.findLast([1, 3, 4, 6], n => n % 2 === 1) // => 3
|
|
12
|
+
* P.findLast.indexed([1, 3, 4, 6], (n, i) => n % 2 === 1) // => 3
|
|
13
|
+
* @dataFirst
|
|
14
|
+
* @indexed
|
|
15
|
+
* @pipeable
|
|
16
|
+
* @category Array
|
|
17
|
+
*/
|
|
18
|
+
export declare function findLast<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): T | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the value of the last element in the array where predicate is true, and undefined
|
|
21
|
+
* otherwise.
|
|
22
|
+
* @param fn the predicate
|
|
23
|
+
* @signature
|
|
24
|
+
* P.findLast(fn)(items)
|
|
25
|
+
* P.findLast.indexed(fn)(items)
|
|
26
|
+
* @example
|
|
27
|
+
* P.pipe(
|
|
28
|
+
* [1, 3, 4, 6],
|
|
29
|
+
* P.findLast(n => n % 2 === 1)
|
|
30
|
+
* ) // => 3
|
|
31
|
+
* P.pipe(
|
|
32
|
+
* [1, 3, 4, 6],
|
|
33
|
+
* P.findLast.indexed((n, i) => n % 2 === 1)
|
|
34
|
+
* ) // => 3
|
|
35
|
+
* @dataLast
|
|
36
|
+
* @indexed
|
|
37
|
+
* @pipeable
|
|
38
|
+
* @category Array
|
|
39
|
+
*/
|
|
40
|
+
export declare function findLast<T = never>(fn: Pred<T, boolean>): (array: ReadonlyArray<T>) => T | undefined;
|
|
41
|
+
export declare namespace findLast {
|
|
42
|
+
function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): T | undefined;
|
|
43
|
+
function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => T | undefined;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=find-last.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-last.d.ts","sourceRoot":"","sources":["../../../src/array/find-last.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAI7E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GACnB,CAAC,GAAG,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAG,KAAK,EAChC,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GACnB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;AAkB9C,yBAAiB,QAAQ,CAAC;IACxB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1B,CAAC,GAAG,SAAS,CAAC;IACjB,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1B,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;CAK/C"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Pred, PredIndexed, PredIndexedOptional } from '../utils/types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the value of the first element in the array where predicate is true, and undefined otherwise.
|
|
4
|
+
* @param items the array
|
|
5
|
+
* @param fn the predicate
|
|
6
|
+
* @signature
|
|
7
|
+
* P.find(items, fn)
|
|
8
|
+
* P.find.indexed(items, fn)
|
|
9
|
+
* @example
|
|
10
|
+
* P.find([1, 3, 4, 6], n => n % 2 === 0) // => 4
|
|
11
|
+
* P.find.indexed([1, 3, 4, 6], (n, i) => n % 2 === 0) // => 4
|
|
12
|
+
* @dataFirst
|
|
13
|
+
* @indexed
|
|
14
|
+
* @pipeable
|
|
15
|
+
* @category Array
|
|
16
|
+
*/
|
|
17
|
+
export declare function find<T>(items: ReadonlyArray<T>, fn: Pred<T, boolean>): T | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the value of the first element in the array where predicate is true, and undefined otherwise.
|
|
20
|
+
* @param fn the predicate
|
|
21
|
+
* @signature
|
|
22
|
+
* P.find(fn)(items)
|
|
23
|
+
* P.find.indexed(fn)(items)
|
|
24
|
+
* @example
|
|
25
|
+
* P.pipe(
|
|
26
|
+
* [1, 3, 4, 6],
|
|
27
|
+
* P.find(n => n % 2 === 0)
|
|
28
|
+
* ) // => 4
|
|
29
|
+
* P.pipe(
|
|
30
|
+
* [1, 3, 4, 6],
|
|
31
|
+
* P.find.indexed((n, i) => n % 2 === 0)
|
|
32
|
+
* ) // => 4
|
|
33
|
+
* @dataLast
|
|
34
|
+
* @indexed
|
|
35
|
+
* @pipeable
|
|
36
|
+
* @category Array
|
|
37
|
+
*/
|
|
38
|
+
export declare function find<T = never>(fn: Pred<T, boolean>): (array: ReadonlyArray<T>) => T | undefined;
|
|
39
|
+
export declare namespace find {
|
|
40
|
+
function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): T | undefined;
|
|
41
|
+
function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => T | undefined;
|
|
42
|
+
const lazy: (<T>(fn: PredIndexedOptional<T, boolean>) => (value: T, index?: number | undefined, array?: T[] | undefined) => {
|
|
43
|
+
done: boolean;
|
|
44
|
+
hasNext: boolean;
|
|
45
|
+
next: T;
|
|
46
|
+
}) & {
|
|
47
|
+
single: true;
|
|
48
|
+
};
|
|
49
|
+
const lazyIndexed: ((fn: PredIndexedOptional<unknown, boolean>) => (value: unknown, index?: number | undefined, array?: unknown[] | undefined) => {
|
|
50
|
+
done: boolean;
|
|
51
|
+
hasNext: boolean;
|
|
52
|
+
next: unknown;
|
|
53
|
+
}) & {
|
|
54
|
+
readonly indexed: true;
|
|
55
|
+
} & {
|
|
56
|
+
single: true;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/array/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAM7E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GACnB,CAAC,GAAG,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAAC,CAAC,GAAG,KAAK,EAC5B,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GACnB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;AA6B9C,yBAAiB,IAAI,CAAC;IACpB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1B,CAAC,GAAG,SAAS,CAAC;IACjB,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1B,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAKvC,MAAM,IAAI;;;;;;KAAyB,CAAC;IAEpC,MAAM,WAAW;;;;;;;;KAAuC,CAAC;CACjE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { IterableContainer, NonEmptyArray } from '../utils/types';
|
|
2
|
+
import { type OrderRule } from '../utils/purry-order-rules';
|
|
3
|
+
type FirstBy<T extends IterableContainer> = (T extends readonly [unknown, ...ReadonlyArray<unknown>] ? never : T extends readonly [...ReadonlyArray<unknown>, unknown] ? never : undefined) | T[number];
|
|
4
|
+
/**
|
|
5
|
+
* Find the first element in the array that adheres to the order rules provided. This is a superset of what a typical `maxBy` or `minBy` function would do as it allows defining "tie-breaker" rules when values are equal, and allows comparing items using any logic. This function is equivalent to calling `P.first(P.sortBy(...))` but runs at *O(n)* instead of *O(nlogn)*.
|
|
6
|
+
*
|
|
7
|
+
* Use `nthBy` if you need an element other that the first, or `takeFirstBy` if you more than just the first element.
|
|
8
|
+
*
|
|
9
|
+
* @param data an array of items
|
|
10
|
+
* @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending ordeP.
|
|
11
|
+
* @returns the first element by the order criteria, or `undefined` if the array
|
|
12
|
+
* is empty. (The function provides strong typing if the input type assures the
|
|
13
|
+
* array isn't empty).
|
|
14
|
+
* @signature
|
|
15
|
+
* P.firstBy(...rules)(data);
|
|
16
|
+
* @example
|
|
17
|
+
* const max = P.pipe([1,2,3], P.firstBy([P.identity, "desc"])); // => 3;
|
|
18
|
+
* const min = P.pipe([1,2,3], P.firstBy([1,2,3])); // => 1;
|
|
19
|
+
*
|
|
20
|
+
* const data = [{ a: "a" }, { a: "aa" }, { a: "aaa" }] as const;
|
|
21
|
+
* const maxBy = P.pipe(data, P.firstBy([(item) => item.a.length, "desc"])); // => { a: "aaa" };
|
|
22
|
+
* const minBy = P.pipe(data, P.firstBy((item) => item.a.length)); // => { a: "a" };
|
|
23
|
+
*
|
|
24
|
+
* const data = [{type: "cat", size: 1}, {type: "cat", size: 2}, {type: "dog", size: 3}] as const;
|
|
25
|
+
* const multi = P.pipe(data, P.firstBy(P.prop('type'), [P.prop('size'), 'desc'])); // => {type: "cat", size: 2}
|
|
26
|
+
* @dataLast
|
|
27
|
+
* @category Array
|
|
28
|
+
*/
|
|
29
|
+
export declare function firstBy<T extends IterableContainer>(...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): (data: T) => FirstBy<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Find the first element in the array that adheres to the order rules provided. This is a superset of what a typical `maxBy` or `minBy` function would do as it allows defining "tie-breaker" rules when values are equal, and allows comparing items using any logic. This function is equivalent to calling `P.first(P.sortBy(...))` but runs at *O(n)* instead of *O(nlogn)*.
|
|
32
|
+
*
|
|
33
|
+
* Use `nthBy` if you need an element other that the first, or `takeFirstBy` if you more than just the first element.
|
|
34
|
+
*
|
|
35
|
+
* @param data an array of items
|
|
36
|
+
* @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending ordeP.
|
|
37
|
+
* @returns the first element by the order criteria, or `undefined` if the array
|
|
38
|
+
* is empty. (The function provides strong typing if the input type assures the
|
|
39
|
+
* array isn't empty).
|
|
40
|
+
* @signature
|
|
41
|
+
* P.firstBy(data, ...rules);
|
|
42
|
+
* @example
|
|
43
|
+
* const max = P.firstBy([1,2,3], [P.identity, "desc"]); // => 3;
|
|
44
|
+
* const min = P.firstBy([1,2,3], P.identity); // => 1;
|
|
45
|
+
*
|
|
46
|
+
* const data = [{ a: "a" }, { a: "aa" }, { a: "aaa" }] as const;
|
|
47
|
+
* const maxBy = P.firstBy(data, [(item) => item.a.length, "desc"]); // => { a: "aaa" };
|
|
48
|
+
* const minBy = P.firstBy(data, (item) => item.a.length); // => { a: "a" };
|
|
49
|
+
*
|
|
50
|
+
* const data = [{type: "cat", size: 1}, {type: "cat", size: 2}, {type: "dog", size: 3}] as const;
|
|
51
|
+
* const multi = P.firstBy(data, P.prop('type'), [P.prop('size'), 'desc']); // => {type: "cat", size: 2}
|
|
52
|
+
* @dataFirst
|
|
53
|
+
* @category Array
|
|
54
|
+
*/
|
|
55
|
+
export declare function firstBy<T extends IterableContainer>(data: T, ...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): FirstBy<T>;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=first-by.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-by.d.ts","sourceRoot":"","sources":["../../../src/array/first-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,4BAA4B,CAAC;AAG7E,KAAK,OAAO,CAAC,CAAC,SAAS,iBAAiB,IACpC,CAAC,CAAC,SAAS,SAAS,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,GACtD,KAAK,GACL,CAAC,SAAS,SAAS,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GACrD,KAAK,GACL,SAAS,CAAC,GACV,CAAC,CAAC,MAAM,CAAC,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,iBAAiB,EACjD,GAAG,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GACtD,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,iBAAiB,EACjD,IAAI,EAAE,CAAC,EACP,GAAG,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GACtD,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { IterableContainer } from '../utils/types';
|
|
2
|
+
type FirstOut<T extends IterableContainer> = T extends [] ? undefined : T extends readonly [unknown, ...Array<unknown>] ? T[0] : T extends readonly [...infer Pre, infer Last] ? Last | Pre[0] : T[0] | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Gets the first element of `array`.
|
|
5
|
+
* Note: In `pipe`, use `first()` form instead of `first`. Otherwise, the inferred type is lost.
|
|
6
|
+
* @param array the array
|
|
7
|
+
* @signature
|
|
8
|
+
* P.first(array)
|
|
9
|
+
* @example
|
|
10
|
+
* P.first([1, 2, 3]) // => 1
|
|
11
|
+
* P.first([]) // => undefined
|
|
12
|
+
* P.pipe(
|
|
13
|
+
* [1, 2, 4, 8, 16],
|
|
14
|
+
* P.filter(x => x > 3),
|
|
15
|
+
* P.first(),
|
|
16
|
+
* x => x + 1
|
|
17
|
+
* ); // => 5
|
|
18
|
+
*
|
|
19
|
+
* @category Array
|
|
20
|
+
* @pipeable
|
|
21
|
+
*/
|
|
22
|
+
export declare function first<T extends IterableContainer>(array: Readonly<T>): FirstOut<T>;
|
|
23
|
+
export declare function first<T extends IterableContainer>(): (array: Readonly<T>) => FirstOut<T>;
|
|
24
|
+
export declare namespace first {
|
|
25
|
+
function lazy<T>(): (value: T) => {
|
|
26
|
+
done: boolean;
|
|
27
|
+
hasNext: boolean;
|
|
28
|
+
next: T;
|
|
29
|
+
};
|
|
30
|
+
namespace lazy {
|
|
31
|
+
const single = true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=first.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first.d.ts","sourceRoot":"","sources":["../../../src/array/first.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,KAAK,QAAQ,CAAC,CAAC,SAAS,iBAAiB,IAAI,CAAC,SAAS,EAAE,GACrD,SAAS,GACT,CAAC,SAAS,SAAS,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,GAC7C,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,SAAS,SAAS,CAAC,GAAG,MAAM,GAAG,EAAE,MAAM,IAAI,CAAC,GAC3C,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GACb,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAEzB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAC/C,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GACjB,QAAQ,CAAC,CAAC,CAAC,CAAC;AACf,wBAAgB,KAAK,CAAC,CAAC,SAAS,iBAAiB,KAAK,CACpD,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KACf,QAAQ,CAAC,CAAC,CAAC,CAAC;AAUjB,yBAAiB,KAAK,CAAC;IACrB,SAAgB,IAAI,CAAC,CAAC,aACL,CAAC;;;;MAOjB;IACD,UAAiB,IAAI,CAAC;QACb,MAAM,MAAM,OAAO,CAAC;KAC5B;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map each element of an array into an object using a defined callback function and flatten the result.
|
|
3
|
+
* @param array The array to map.
|
|
4
|
+
* @param fn The mapping function, which should return an Array of key-value pairs, similar to Object.fromEntries
|
|
5
|
+
* @returns The new mapped object.
|
|
6
|
+
* @signature
|
|
7
|
+
* P.flatMapToObj(array, fn)
|
|
8
|
+
* P.flatMapToObj.indexed(array, fn)
|
|
9
|
+
* @example
|
|
10
|
+
* P.flatMapToObj([1, 2, 3], (x) =>
|
|
11
|
+
* x % 2 === 1 ? [[String(x), x]] : []
|
|
12
|
+
* ) // => {1: 1, 3: 3}
|
|
13
|
+
* P.flatMapToObj.indexed(['a', 'b'], (x, i) => [
|
|
14
|
+
* [x, i],
|
|
15
|
+
* [x + x, i + i],
|
|
16
|
+
* ]) // => {a: 0, aa: 0, b: 1, bb: 2}
|
|
17
|
+
* @dataFirst
|
|
18
|
+
* @indexed
|
|
19
|
+
* @category Array
|
|
20
|
+
*/
|
|
21
|
+
export declare function flatMapToObj<T, K extends keyof any, V>(array: ReadonlyArray<T>, fn: (element: T) => Array<[K, V]>): Record<K, V>;
|
|
22
|
+
/**
|
|
23
|
+
* Map each element of an array into an object using a defined callback function and flatten the result.
|
|
24
|
+
* @param fn The mapping function, which should return an Array of key-value pairs, similar to Object.fromEntries
|
|
25
|
+
* @returns The new mapped object.
|
|
26
|
+
* @signature
|
|
27
|
+
* P.flatMapToObj(fn)(array)
|
|
28
|
+
* P.flatMapToObj(fn)(array)
|
|
29
|
+
* @example
|
|
30
|
+
* P.pipe(
|
|
31
|
+
* [1, 2, 3],
|
|
32
|
+
* P.flatMapToObj(x => (x % 2 === 1 ? [[String(x), x]] : []))
|
|
33
|
+
* ) // => {1: 1, 3: 3}
|
|
34
|
+
* P.pipe(
|
|
35
|
+
* ['a', 'b'],
|
|
36
|
+
* P.flatMapToObj.indexed((x, i) => [
|
|
37
|
+
* [x, i],
|
|
38
|
+
* [x + x, i + i],
|
|
39
|
+
* ])
|
|
40
|
+
* ) // => {a: 0, aa: 0, b: 1, bb: 2}
|
|
41
|
+
* @dataLast
|
|
42
|
+
* @indexed
|
|
43
|
+
* @category Array
|
|
44
|
+
*/
|
|
45
|
+
export declare function flatMapToObj<T, K extends keyof any, V>(fn: (element: T) => Array<[K, V]>): (array: ReadonlyArray<T>) => Record<K, V>;
|
|
46
|
+
export declare namespace flatMapToObj {
|
|
47
|
+
function indexed<T, K extends keyof any, V>(array: ReadonlyArray<T>, fn: (element: T, index: number, array: ReadonlyArray<T>) => Array<[K, V]>): Record<K, V>;
|
|
48
|
+
function indexed<T, K extends keyof any, V>(fn: (element: T, index: number, array: ReadonlyArray<T>) => Array<[K, V]>): (array: ReadonlyArray<T>) => Record<K, V>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=flat-map-to-obj.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flat-map-to-obj.d.ts","sourceRoot":"","sources":["../../../src/array/flat-map-to-obj.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,EAAE,CAAC,EACpD,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAChC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEhB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,EAAE,CAAC,EACpD,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAChC,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAkB7C,yBAAiB,YAAY,CAAC;IAC5B,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,EAAE,CAAC,EAC/C,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACxE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChB,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,EAAE,CAAC,EAC/C,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACxE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAI9C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map each element of an array using a defined callback function and flatten the mapped result.
|
|
3
|
+
* @param array The array to map.
|
|
4
|
+
* @param fn The function mapper.
|
|
5
|
+
* @signature
|
|
6
|
+
* P.flatMap(array, fn)
|
|
7
|
+
* @example
|
|
8
|
+
* P.flatMap([1, 2, 3], x => [x, x * 10]) // => [1, 10, 2, 20, 3, 30]
|
|
9
|
+
* @dataFirst
|
|
10
|
+
* @pipeable
|
|
11
|
+
* @category Array
|
|
12
|
+
*/
|
|
13
|
+
export declare function flatMap<T, K>(array: ReadonlyArray<T>, fn: (input: T) => K | ReadonlyArray<K>): Array<K>;
|
|
14
|
+
/**
|
|
15
|
+
* Map each element of an array using a defined callback function and flatten the mapped result.
|
|
16
|
+
* @param fn The function mapper.
|
|
17
|
+
* @signature
|
|
18
|
+
* P.flatMap(fn)(array)
|
|
19
|
+
* @example
|
|
20
|
+
* P.pipe([1, 2, 3], P.flatMap(x => [x, x * 10])) // => [1, 10, 2, 20, 3, 30]
|
|
21
|
+
* @dataLast
|
|
22
|
+
* @pipeable
|
|
23
|
+
* @category Array
|
|
24
|
+
*/
|
|
25
|
+
export declare function flatMap<T, K>(fn: (input: T) => K | ReadonlyArray<K>): (array: ReadonlyArray<T>) => Array<K>;
|
|
26
|
+
export declare namespace flatMap {
|
|
27
|
+
function lazy<T, K>(fn: (input: T) => K | ReadonlyArray<K>): (value: T) => {
|
|
28
|
+
done: boolean;
|
|
29
|
+
hasMany: boolean;
|
|
30
|
+
hasNext: boolean;
|
|
31
|
+
next: K & any[];
|
|
32
|
+
} | {
|
|
33
|
+
done: boolean;
|
|
34
|
+
hasNext: boolean;
|
|
35
|
+
next: K | readonly K[];
|
|
36
|
+
hasMany?: never;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=flat-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flat-map.d.ts","sourceRoot":"","sources":["../../../src/array/flat-map.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GACrC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEZ;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GACrC,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;AAazC,yBAAiB,OAAO,CAAC;IACvB,SAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,WAChD,CAAC;;;;;;;;;;MAgBjB;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LazyResult } from '../utils/reduce-lazy';
|
|
2
|
+
type FlattenDeep<T> = T extends ReadonlyArray<infer K> ? FlattenDeep2<K> : T;
|
|
3
|
+
type FlattenDeep2<T> = T extends ReadonlyArray<infer K> ? FlattenDeep3<K> : T;
|
|
4
|
+
type FlattenDeep3<T> = T extends ReadonlyArray<infer K> ? FlattenDeep4<K> : T;
|
|
5
|
+
type FlattenDeep4<T> = T extends ReadonlyArray<infer K> ? K : T;
|
|
6
|
+
/**
|
|
7
|
+
* Recursively flattens `array`.
|
|
8
|
+
* Note: In `pipe`, use `flattenDeep()` form instead of `flattenDeep`. Otherwise, the inferred type is lost.
|
|
9
|
+
* @param items the target array
|
|
10
|
+
* @signature P.flattenDeep(array)
|
|
11
|
+
* @example
|
|
12
|
+
* P.flattenDeep([[1, 2], [[3], [4, 5]]]) // => [1, 2, 3, 4, 5]
|
|
13
|
+
* P.pipe(
|
|
14
|
+
* [[1, 2], [[3], [4, 5]]],
|
|
15
|
+
* P.flattenDeep(),
|
|
16
|
+
* ); // => [1, 2, 3, 4, 5]
|
|
17
|
+
* @category Array
|
|
18
|
+
* @pipeable
|
|
19
|
+
*/
|
|
20
|
+
export declare function flattenDeep<T>(items: ReadonlyArray<T>): Array<FlattenDeep<T>>;
|
|
21
|
+
export declare function flattenDeep<T>(): (items: ReadonlyArray<T>) => Array<FlattenDeep<T>>;
|
|
22
|
+
export declare namespace flattenDeep {
|
|
23
|
+
function lazy(): (value: any) => LazyResult<any>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=flatten-deep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten-deep.d.ts","sourceRoot":"","sources":["../../../src/array/flatten-deep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKvD,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC7E,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC9E,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC9E,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E,wBAAgB,WAAW,CAAC,CAAC,KAAK,CAChC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KACpB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAyB3B,yBAAiB,WAAW,CAAC;IAC3B,SAAgB,IAAI,YACH,GAAG,KAAG,WAAW,GAAG,CAAC,CAgBrC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LazyResult } from '../utils/reduce-lazy';
|
|
2
|
+
type Flatten<T> = T extends ReadonlyArray<infer K> ? K : T;
|
|
3
|
+
/**
|
|
4
|
+
* Flattens `array` a single level deep.
|
|
5
|
+
* Note: In `pipe`, use `flatten()` form instead of `flatten`. Otherwise, the inferred type is lost.
|
|
6
|
+
* @param items the target array
|
|
7
|
+
* @signature P.flatten(array)
|
|
8
|
+
* @example
|
|
9
|
+
* P.flatten([[1, 2], [3], [4, 5]]) // => [1, 2, 3, 4, 5]
|
|
10
|
+
* P.pipe(
|
|
11
|
+
* [[1, 2], [3], [4, 5]],
|
|
12
|
+
* P.flatten(),
|
|
13
|
+
* ); // => [1, 2, 3, 4, 5]
|
|
14
|
+
* @category Array
|
|
15
|
+
* @pipeable
|
|
16
|
+
*/
|
|
17
|
+
export declare function flatten<T>(items: ReadonlyArray<T>): Array<Flatten<T>>;
|
|
18
|
+
export declare function flatten<T>(): (items: ReadonlyArray<T>) => Array<Flatten<T>>;
|
|
19
|
+
export declare namespace flatten {
|
|
20
|
+
function lazy<T>(): (next: T) => LazyResult<any>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=flatten.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../../src/array/flatten.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKvD,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvE,wBAAgB,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAU7E,yBAAiB,OAAO,CAAC;IACvB,SAAgB,IAAI,CAAC,CAAC,YACN,CAAC,KAAG,WAAW,GAAG,CAAC,CAelC;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { LazyResult } from '../utils/reduce-lazy';
|
|
2
|
+
import type { Pred, PredIndexed, PredIndexedOptional } from '../utils/types';
|
|
3
|
+
/**
|
|
4
|
+
* Iterate an array using a defined callback function. The original array is returned instead of `void`.
|
|
5
|
+
* @param array The array.
|
|
6
|
+
* @param fn The callback function.
|
|
7
|
+
* @returns The original array
|
|
8
|
+
* @signature
|
|
9
|
+
* P.forEach(array, fn)
|
|
10
|
+
* P.forEach.indexed(array, fn)
|
|
11
|
+
* @example
|
|
12
|
+
* P.forEach([1, 2, 3], x => {
|
|
13
|
+
* console.log(x)
|
|
14
|
+
* }) // => [1, 2, 3]
|
|
15
|
+
* P.forEach.indexed([1, 2, 3], (x, i) => {
|
|
16
|
+
* console.log(x, i)
|
|
17
|
+
* }) // => [1, 2, 3]
|
|
18
|
+
* @dataFirst
|
|
19
|
+
* @indexed
|
|
20
|
+
* @pipeable
|
|
21
|
+
* @category Array
|
|
22
|
+
*/
|
|
23
|
+
export declare function forEach<T>(array: ReadonlyArray<T>, fn: Pred<T, void>): Array<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Iterate an array using a defined callback function. The original array is returned instead of `void`.
|
|
26
|
+
* @param fn the function mapper
|
|
27
|
+
* @signature
|
|
28
|
+
* P.forEach(fn)(array)
|
|
29
|
+
* P.forEach.indexed(fn)(array)
|
|
30
|
+
* @example
|
|
31
|
+
* P.pipe(
|
|
32
|
+
* [1, 2, 3],
|
|
33
|
+
* P.forEach(x => {
|
|
34
|
+
* console.log(x)
|
|
35
|
+
* })
|
|
36
|
+
* ) // => [1, 2, 3]
|
|
37
|
+
* P.pipe(
|
|
38
|
+
* [1, 2, 3],
|
|
39
|
+
* P.forEach.indexed((x, i) => {
|
|
40
|
+
* console.log(x, i)
|
|
41
|
+
* })
|
|
42
|
+
* ) // => [1, 2, 3]
|
|
43
|
+
* @dataLast
|
|
44
|
+
* @indexed
|
|
45
|
+
* @pipeable
|
|
46
|
+
* @category Array
|
|
47
|
+
*/
|
|
48
|
+
export declare function forEach<T>(fn: Pred<T, void>): (array: ReadonlyArray<T>) => Array<T>;
|
|
49
|
+
export declare namespace forEach {
|
|
50
|
+
function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, void>): Array<T>;
|
|
51
|
+
function indexed<T>(fn: PredIndexed<T, void>): (array: ReadonlyArray<T>) => Array<T>;
|
|
52
|
+
const lazy: <T>(fn: PredIndexedOptional<T, void>) => (value: T, index?: number | undefined, array?: readonly T[] | undefined) => LazyResult<T>;
|
|
53
|
+
const lazyIndexed: (<T>(fn: PredIndexedOptional<T, void>) => (value: T, index?: number | undefined, array?: readonly T[] | undefined) => LazyResult<T>) & {
|
|
54
|
+
readonly indexed: true;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=for-each.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for-each.d.ts","sourceRoot":"","sources":["../../../src/array/for-each.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAM7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,GAChB,KAAK,CAAC,CAAC,CAAC,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,GAChB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;AAqCzC,yBAAiB,OAAO,CAAC;IACvB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,GACvB,KAAK,CAAC,CAAC,CAAC,CAAC;IACZ,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,GACvB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;IAIlC,MAAM,IAAI,oIAAe,CAAC;IAC1B,MAAM,WAAW;;KAA6B,CAAC;CACvD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { NonEmptyArray, PredIndexed } from '../utils/types';
|
|
2
|
+
/**
|
|
3
|
+
* Splits a collection into sets, grouped by the result of running each value through `fn`.
|
|
4
|
+
* @param items the items to group
|
|
5
|
+
* @param fn the grouping function. When `undefined` is returned the item would
|
|
6
|
+
* be skipped and not grouped under any key.
|
|
7
|
+
* @signature
|
|
8
|
+
* P.groupBy(array, fn)
|
|
9
|
+
* P.groupBy.strict(array, fn)
|
|
10
|
+
* @example
|
|
11
|
+
* P.groupBy(['one', 'two', 'three'], x => x.length) // => {3: ['one', 'two'], 5: ['three']}
|
|
12
|
+
* P.groupBy.strict([{a: 'cat'}, {a: 'dog'}] as const, prop('a')) // => {cat: [{a: 'cat'}], dog: [{a: 'dog'}]} typed Partial<Record<'cat' | 'dog', NonEmptyArray<{a: 'cat' | 'dog'}>>>
|
|
13
|
+
* P.groupBy([0, 1], x => x % 2 === 0 ? 'even' : undefined) // => {even: [0]}
|
|
14
|
+
* @dataFirst
|
|
15
|
+
* @indexed
|
|
16
|
+
* @strict
|
|
17
|
+
* @category Array
|
|
18
|
+
*/
|
|
19
|
+
export declare function groupBy<T>(items: ReadonlyArray<T>, fn: (item: T) => PropertyKey | undefined): Record<PropertyKey, NonEmptyArray<T>>;
|
|
20
|
+
export declare function groupBy<T>(fn: (item: T) => PropertyKey | undefined): (array: ReadonlyArray<T>) => Record<PropertyKey, NonEmptyArray<T>>;
|
|
21
|
+
interface Strict {
|
|
22
|
+
<Value, Key extends PropertyKey = PropertyKey>(items: ReadonlyArray<Value>, fn: (item: Value) => Key | undefined): StrictOut<Value, Key>;
|
|
23
|
+
<Value, Key extends PropertyKey = PropertyKey>(fn: (item: Value) => Key | undefined): (items: ReadonlyArray<Value>) => StrictOut<Value, Key>;
|
|
24
|
+
readonly indexed: {
|
|
25
|
+
<Value, Key extends PropertyKey = PropertyKey>(fn: PredIndexed<Value, Key | undefined>): (items: ReadonlyArray<Value>) => StrictOut<Value, Key>;
|
|
26
|
+
<Value, Key extends PropertyKey = PropertyKey>(items: ReadonlyArray<Value>, fn: PredIndexed<Value, Key | undefined>): StrictOut<Value, Key>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
type StrictOut<Value, Key extends PropertyKey = PropertyKey> = string extends Key ? Record<Key, NonEmptyArray<Value>> : number extends Key ? Record<Key, NonEmptyArray<Value>> : symbol extends Key ? Record<Key, NonEmptyArray<Value>> : Partial<Record<Key, NonEmptyArray<Value>>>;
|
|
30
|
+
export declare namespace groupBy {
|
|
31
|
+
function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, PropertyKey | undefined>): Record<string, NonEmptyArray<T>>;
|
|
32
|
+
function indexed<T>(fn: PredIndexed<T, PropertyKey | undefined>): (array: ReadonlyArray<T>) => Record<string, NonEmptyArray<T>>;
|
|
33
|
+
const strict: Strict;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=group-by.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-by.d.ts","sourceRoot":"","sources":["../../../src/array/group-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAItF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,WAAW,GAAG,SAAS,GACvC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzC,wBAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,WAAW,GAAG,SAAS,GACvC,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAyCtE,UAAU,MAAM;IAEd,CAAC,KAAK,EAAE,GAAG,SAAS,WAAW,GAAG,WAAW,EAC3C,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,EAC3B,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,GAAG,GAAG,SAAS,GACnC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAGzB,CAAC,KAAK,EAAE,GAAG,SAAS,WAAW,GAAG,WAAW,EAC3C,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,GAAG,GAAG,SAAS,GACnC,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE1D,QAAQ,CAAC,OAAO,EAAE;QAEhB,CAAC,KAAK,EAAE,GAAG,SAAS,WAAW,GAAG,WAAW,EAC3C,EAAE,EAAE,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC,GACtC,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAG1D,CAAC,KAAK,EAAE,GAAG,SAAS,WAAW,GAAG,WAAW,EAC3C,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,EAC3B,EAAE,EAAE,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC,GACtC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KAC1B,CAAC;CACH;AAQD,KAAK,SAAS,CAAC,KAAK,EAAE,GAAG,SAAS,WAAW,GAAG,WAAW,IAGzD,MAAM,SAAS,GAAG,GACd,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,GACjC,MAAM,SAAS,GAAG,GAChB,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,GACjC,MAAM,SAAS,GAAG,GAChB,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,GAInC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnD,yBAAiB,OAAO,CAAC;IACvB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,GAC1C,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,GAC1C,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAK1D,MAAM,MAAM,EAAE,MAAgB,CAAC;CACvC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ReadonlyTuple } from 'type-fest';
|
|
2
|
+
type ArrayMinN<T, N extends number> = number extends N ? Array<T> : N extends 0 ? Array<T> : [...ReadonlyTuple<T, N>, ...Array<T>];
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the given array has at least the defined number of elements, and
|
|
5
|
+
* refines the output type accordingly so that those indices are defined when
|
|
6
|
+
* accessing the array even when using typescript's 'noUncheckedIndexAccess'.
|
|
7
|
+
*
|
|
8
|
+
* @param data the input array
|
|
9
|
+
* @param minimum the minimum number of elements the array must have
|
|
10
|
+
* @return true if the array's length is *at least* `minimum`.
|
|
11
|
+
* @signature
|
|
12
|
+
* P.hasAtLeast(data, minimum)
|
|
13
|
+
* @example
|
|
14
|
+
* P.hasAtLeast([], 4); // => false
|
|
15
|
+
*
|
|
16
|
+
* const data: number[] = [1,2,3,4];
|
|
17
|
+
* P.hasAtLeast(data, 1); // => true
|
|
18
|
+
* data[0]; // 1, with type `number`
|
|
19
|
+
* @dataFirst
|
|
20
|
+
* @category Array
|
|
21
|
+
*/
|
|
22
|
+
export declare function hasAtLeast<T, N extends number>(data: ReadonlyArray<T>, minimum: N): data is ArrayMinN<T, N>;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the given array has at least the defined number of elements, and
|
|
25
|
+
* refines the output type accordingly so that those indices are defined when
|
|
26
|
+
* accessing the array even when using typescript's 'noUncheckedIndexAccess'.
|
|
27
|
+
*
|
|
28
|
+
* @param data the input array
|
|
29
|
+
* @param minimum the minimum number of elements the array must have
|
|
30
|
+
* @return true if the array's length is *at least* `minimum`.
|
|
31
|
+
* @signature
|
|
32
|
+
* P.hasAtLeast(minimum)(data)
|
|
33
|
+
* @example
|
|
34
|
+
* P.pipe([], P.hasAtLeast(4)); // => false
|
|
35
|
+
*
|
|
36
|
+
* const data = [[1,2], [3], [4,5]];
|
|
37
|
+
* P.pipe(
|
|
38
|
+
* data,
|
|
39
|
+
* P.filter(P.hasAtLeast(2)),
|
|
40
|
+
* P.map(([, second]) => second),
|
|
41
|
+
* ); // => [2,5], with type `number[]`
|
|
42
|
+
* @dataLast
|
|
43
|
+
* @category Array
|
|
44
|
+
*/
|
|
45
|
+
export declare function hasAtLeast<N extends number>(minimum: N): <T>(data: ReadonlyArray<T>) => data is ArrayMinN<T, N>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=has-at-least.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-at-least.d.ts","sourceRoot":"","sources":["../../../src/array/has-at-least.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM/C,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,MAAM,SAAS,CAAC,GAEpD,KAAK,CAAC,CAAC,CAAC,GAGR,CAAC,SAAS,CAAC,GACP,KAAK,CAAC,CAAC,CAAC,GACR,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAC5C,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,OAAO,EAAE,CAAC,GACT,IAAI,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EACzC,OAAO,EAAE,CAAC,GACT,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PredIndexed } from '../utils/types';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a list of objects into an object indexing the objects by the given key.
|
|
4
|
+
* @param array the array
|
|
5
|
+
* @param fn the indexing function
|
|
6
|
+
* @signature
|
|
7
|
+
* P.indexBy(array, fn)
|
|
8
|
+
* @example
|
|
9
|
+
* P.indexBy(['one', 'two', 'three'], x => x.length) // => {3: 'two', 5: 'three'}
|
|
10
|
+
* @dataFirst
|
|
11
|
+
* @indexed
|
|
12
|
+
* @category Array
|
|
13
|
+
*/
|
|
14
|
+
export declare function indexBy<T>(array: ReadonlyArray<T>, fn: (item: T) => any): Record<string, T>;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a list of objects into an object indexing the objects by the given key.
|
|
17
|
+
* @param fn the indexing function
|
|
18
|
+
* @signature
|
|
19
|
+
* P.indexBy(fn)(array)
|
|
20
|
+
* @example
|
|
21
|
+
* P.pipe(
|
|
22
|
+
* ['one', 'two', 'three'],
|
|
23
|
+
* P.indexBy(x => x.length)
|
|
24
|
+
* ) // => {3: 'two', 5: 'three'}
|
|
25
|
+
* @dataLast
|
|
26
|
+
* @indexed
|
|
27
|
+
* @category Array
|
|
28
|
+
*/
|
|
29
|
+
export declare function indexBy<T>(fn: (item: T) => any): (array: ReadonlyArray<T>) => Record<string, T>;
|
|
30
|
+
export declare namespace indexBy {
|
|
31
|
+
function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, any>): Record<string, T>;
|
|
32
|
+
function indexed<T>(fn: PredIndexed<T, any>): (array: ReadonlyArray<T>) => Record<string, T>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index-by.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-by.d.ts","sourceRoot":"","sources":["../../../src/array/index-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAIvE;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,GACnB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAErB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,GACnB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAiBlD,yBAAiB,OAAO,CAAC;IACvB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,GACtB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACrB,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,GACtB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CAInD"}
|