@vinicunca/perkakas 0.3.1 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/array/all-pass.js +2 -2
- package/dist/commonjs/array/any-pass.js +2 -2
- package/dist/commonjs/array/chunk.js +3 -3
- package/dist/commonjs/array/concat.js +2 -2
- package/dist/commonjs/array/count-by.js +8 -6
- package/dist/commonjs/array/difference-with.js +5 -15
- package/dist/commonjs/array/difference.js +5 -15
- package/dist/commonjs/array/drop-first-by.js +1 -1
- package/dist/commonjs/array/drop-last-while.js +2 -2
- package/dist/commonjs/array/drop-last.js +3 -3
- package/dist/commonjs/array/drop-while.js +2 -2
- package/dist/commonjs/array/drop.js +5 -12
- package/dist/commonjs/array/filter.js +3 -16
- package/dist/commonjs/array/find-index.js +12 -25
- package/dist/commonjs/array/find-last-index.js +3 -3
- package/dist/commonjs/array/find-last.js +3 -3
- package/dist/commonjs/array/find.js +10 -22
- package/dist/commonjs/array/first.js +4 -10
- package/dist/commonjs/array/flat-map-to-obj.js +10 -9
- package/dist/commonjs/array/flat-map.js +5 -15
- package/dist/commonjs/array/flatten-deep.js +9 -19
- package/dist/commonjs/array/flatten.js +5 -17
- package/dist/commonjs/array/for-each.js +18 -22
- package/dist/commonjs/array/group-by.js +5 -5
- package/dist/commonjs/array/index-by.js +20 -7
- package/dist/commonjs/array/index.js +4 -0
- package/dist/commonjs/array/intersection-with.js +5 -15
- package/dist/commonjs/array/intersection.js +6 -16
- package/dist/commonjs/array/last.js +2 -2
- package/dist/commonjs/array/length.js +2 -2
- package/dist/commonjs/array/map-to-obj.js +8 -7
- package/dist/commonjs/array/map.js +11 -15
- package/dist/commonjs/array/max-by.js +6 -6
- package/dist/commonjs/array/mean-by.js +6 -6
- package/dist/commonjs/array/merge-all.js +5 -1
- package/dist/commonjs/array/min-by.js +6 -6
- package/dist/commonjs/array/only.js +3 -6
- package/dist/commonjs/array/partition.js +5 -5
- package/dist/commonjs/array/range.js +2 -2
- package/dist/commonjs/array/rank-by.js +1 -1
- package/dist/commonjs/array/reduce.js +3 -3
- package/dist/commonjs/array/reject.js +9 -22
- package/dist/commonjs/array/reverse.js +2 -2
- package/dist/commonjs/array/sample.js +1 -1
- package/dist/commonjs/array/shuffle.js +3 -3
- package/dist/commonjs/array/sort-by.js +5 -43
- package/dist/commonjs/array/sort.js +3 -3
- package/dist/commonjs/array/sorted-index-by.js +19 -0
- package/dist/commonjs/array/sorted-index-with.js +15 -0
- package/dist/commonjs/array/sorted-index.js +12 -0
- package/dist/commonjs/array/sorted-last-index-by.js +19 -0
- package/dist/commonjs/array/sorted-last-index.js +12 -0
- package/dist/commonjs/array/splice.js +3 -3
- package/dist/commonjs/array/split-at.js +3 -3
- package/dist/commonjs/array/split-when.js +6 -6
- package/dist/commonjs/array/sum-by.js +6 -6
- package/dist/commonjs/array/swap-indices.js +7 -7
- package/dist/commonjs/array/take-first-by.js +1 -1
- package/dist/commonjs/array/take-while.js +2 -2
- package/dist/commonjs/array/take.js +8 -21
- package/dist/commonjs/array/uniq-by.js +4 -11
- package/dist/commonjs/array/uniq-with.js +8 -18
- package/dist/commonjs/array/uniq.js +4 -11
- package/dist/commonjs/array/zip-obj.js +2 -2
- package/dist/commonjs/array/zip-with.js +4 -4
- package/dist/commonjs/array/zip.js +2 -2
- package/dist/commonjs/function/create-pipe.js +1 -1
- package/dist/commonjs/function/index.js +1 -0
- package/dist/commonjs/function/pipe.js +18 -24
- package/dist/commonjs/function/purry.js +8 -9
- package/dist/commonjs/function/times.js +18 -0
- package/dist/commonjs/guard/is-defined.js +1 -1
- package/dist/commonjs/guard/is-empty.js +4 -4
- package/dist/commonjs/guard/is-nil.js +1 -1
- package/dist/commonjs/guard/is-not.js +1 -3
- package/dist/commonjs/number/add.js +2 -2
- package/dist/commonjs/number/clamp.js +6 -6
- package/dist/commonjs/number/divide.js +2 -2
- package/dist/commonjs/number/multiply.js +2 -2
- package/dist/commonjs/number/subtract.js +2 -2
- package/dist/commonjs/object/add-prop.js +2 -2
- package/dist/commonjs/object/clone.js +5 -5
- package/dist/commonjs/object/equals.js +48 -52
- package/dist/commonjs/object/for-each-obj.js +9 -9
- package/dist/commonjs/object/from-pairs.js +6 -2
- package/dist/commonjs/object/invert.js +5 -3
- package/dist/commonjs/object/keys.js +3 -2
- package/dist/commonjs/object/map-keys.js +2 -2
- package/dist/commonjs/object/map-values.js +2 -2
- package/dist/commonjs/object/merge-deep.js +2 -2
- package/dist/commonjs/object/merge.js +2 -2
- package/dist/commonjs/object/omit-by.js +7 -6
- package/dist/commonjs/object/omit.js +2 -2
- package/dist/commonjs/object/path-or.js +6 -6
- package/dist/commonjs/object/pick-by.js +9 -8
- package/dist/commonjs/object/pick.js +7 -9
- package/dist/commonjs/object/set-path.js +14 -15
- package/dist/commonjs/object/set.js +2 -2
- package/dist/commonjs/object/swap-props.js +2 -2
- package/dist/commonjs/string/random-string.js +11 -5
- package/dist/commonjs/string/string-to-path.js +5 -5
- package/dist/commonjs/utils/binary-search-cutoff-index.js +19 -0
- package/dist/commonjs/utils/heap.js +1 -1
- package/dist/commonjs/utils/purry-order-rules.js +1 -1
- package/dist/commonjs/utils/quick-select.js +2 -2
- package/dist/commonjs/utils/reduce-lazy.js +9 -6
- package/dist/commonjs/utils/to-single.js +1 -2
- package/dist/es/array/all-pass.js +2 -2
- package/dist/es/array/any-pass.js +2 -2
- package/dist/es/array/chunk.js +3 -3
- package/dist/es/array/concat.js +2 -2
- package/dist/es/array/count-by.js +8 -6
- package/dist/es/array/difference-with.js +5 -15
- package/dist/es/array/difference.js +5 -15
- package/dist/es/array/drop-first-by.js +1 -1
- package/dist/es/array/drop-last-while.js +2 -2
- package/dist/es/array/drop-last.js +3 -3
- package/dist/es/array/drop-while.js +2 -2
- package/dist/es/array/drop.js +5 -12
- package/dist/es/array/filter.js +3 -16
- package/dist/es/array/find-index.js +12 -25
- package/dist/es/array/find-last-index.js +3 -3
- package/dist/es/array/find-last.js +3 -3
- package/dist/es/array/find.js +10 -22
- package/dist/es/array/first.js +4 -10
- package/dist/es/array/flat-map-to-obj.js +10 -9
- package/dist/es/array/flat-map.js +5 -15
- package/dist/es/array/flatten-deep.js +9 -19
- package/dist/es/array/flatten.js +5 -17
- package/dist/es/array/for-each.js +18 -22
- package/dist/es/array/group-by.js +5 -5
- package/dist/es/array/index-by.js +20 -7
- package/dist/es/array/index.js +4 -0
- package/dist/es/array/intersection-with.js +5 -15
- package/dist/es/array/intersection.js +6 -16
- package/dist/es/array/last.js +2 -2
- package/dist/es/array/length.js +2 -2
- package/dist/es/array/map-to-obj.js +8 -7
- package/dist/es/array/map.js +11 -15
- package/dist/es/array/max-by.js +6 -6
- package/dist/es/array/mean-by.js +6 -6
- package/dist/es/array/merge-all.js +5 -1
- package/dist/es/array/min-by.js +6 -6
- package/dist/es/array/only.js +3 -6
- package/dist/es/array/partition.js +5 -5
- package/dist/es/array/range.js +2 -2
- package/dist/es/array/rank-by.js +1 -1
- package/dist/es/array/reduce.js +3 -3
- package/dist/es/array/reject.js +9 -22
- package/dist/es/array/reverse.js +2 -2
- package/dist/es/array/sample.js +1 -1
- package/dist/es/array/shuffle.js +3 -3
- package/dist/es/array/sort-by.js +5 -43
- package/dist/es/array/sort.js +3 -3
- package/dist/es/array/sorted-index-by.js +15 -0
- package/dist/es/array/sorted-index-with.js +11 -0
- package/dist/es/array/sorted-index.js +8 -0
- package/dist/es/array/sorted-last-index-by.js +15 -0
- package/dist/es/array/sorted-last-index.js +8 -0
- package/dist/es/array/splice.js +3 -3
- package/dist/es/array/split-at.js +3 -3
- package/dist/es/array/split-when.js +6 -6
- package/dist/es/array/sum-by.js +6 -6
- package/dist/es/array/swap-indices.js +7 -7
- package/dist/es/array/take-first-by.js +1 -1
- package/dist/es/array/take-while.js +2 -2
- package/dist/es/array/take.js +8 -21
- package/dist/es/array/uniq-by.js +4 -11
- package/dist/es/array/uniq-with.js +8 -18
- package/dist/es/array/uniq.js +4 -11
- package/dist/es/array/zip-obj.js +2 -2
- package/dist/es/array/zip-with.js +4 -4
- package/dist/es/array/zip.js +2 -2
- package/dist/es/function/index.js +1 -0
- package/dist/es/function/pipe.js +18 -24
- package/dist/es/function/purry.js +8 -9
- package/dist/es/function/times.js +14 -0
- package/dist/es/guard/is-defined.js +1 -1
- package/dist/es/guard/is-empty.js +4 -4
- package/dist/es/guard/is-nil.js +1 -1
- package/dist/es/guard/is-not.js +1 -3
- package/dist/es/number/add.js +2 -2
- package/dist/es/number/clamp.js +6 -6
- package/dist/es/number/divide.js +2 -2
- package/dist/es/number/multiply.js +2 -2
- package/dist/es/number/subtract.js +2 -2
- package/dist/es/object/add-prop.js +2 -2
- package/dist/es/object/clone.js +5 -5
- package/dist/es/object/equals.js +48 -52
- package/dist/es/object/for-each-obj.js +9 -9
- package/dist/es/object/from-pairs.js +5 -1
- package/dist/es/object/invert.js +5 -3
- package/dist/es/object/keys.js +3 -2
- package/dist/es/object/map-keys.js +2 -2
- package/dist/es/object/map-values.js +2 -2
- package/dist/es/object/merge-deep.js +2 -2
- package/dist/es/object/merge.js +2 -2
- package/dist/es/object/omit-by.js +7 -6
- package/dist/es/object/omit.js +2 -2
- package/dist/es/object/path-or.js +6 -6
- package/dist/es/object/pick-by.js +9 -8
- package/dist/es/object/pick.js +7 -9
- package/dist/es/object/set-path.js +12 -13
- package/dist/es/object/set.js +2 -2
- package/dist/es/object/swap-props.js +2 -2
- package/dist/es/string/random-string.js +11 -5
- package/dist/es/string/string-to-path.js +5 -5
- package/dist/es/utils/binary-search-cutoff-index.js +15 -0
- package/dist/es/utils/heap.js +1 -1
- package/dist/es/utils/purry-order-rules.js +1 -1
- package/dist/es/utils/quick-select.js +2 -2
- package/dist/es/utils/reduce-lazy.js +9 -6
- package/dist/es/utils/to-single.js +1 -2
- package/dist/metadata.json +7915 -4373
- package/dist/types/array/count-by.d.ts.map +1 -1
- package/dist/types/array/difference-with.d.ts +2 -2
- package/dist/types/array/difference-with.d.ts.map +1 -1
- package/dist/types/array/difference.d.ts +2 -2
- package/dist/types/array/difference.d.ts.map +1 -1
- package/dist/types/array/drop.d.ts +2 -2
- package/dist/types/array/drop.d.ts.map +1 -1
- package/dist/types/array/filter.d.ts +5 -5
- package/dist/types/array/filter.d.ts.map +1 -1
- package/dist/types/array/find-index.d.ts +5 -20
- package/dist/types/array/find-index.d.ts.map +1 -1
- package/dist/types/array/find.d.ts +5 -12
- package/dist/types/array/find.d.ts.map +1 -1
- package/dist/types/array/first.d.ts +2 -5
- package/dist/types/array/first.d.ts.map +1 -1
- package/dist/types/array/flat-map-to-obj.d.ts +4 -4
- package/dist/types/array/flat-map-to-obj.d.ts.map +1 -1
- package/dist/types/array/flat-map.d.ts +2 -11
- package/dist/types/array/flat-map.d.ts.map +1 -1
- package/dist/types/array/flatten-deep.d.ts +15 -5
- package/dist/types/array/flatten-deep.d.ts.map +1 -1
- package/dist/types/array/flatten.d.ts +17 -2
- package/dist/types/array/flatten.d.ts.map +1 -1
- package/dist/types/array/for-each.d.ts +3 -3
- package/dist/types/array/for-each.d.ts.map +1 -1
- package/dist/types/array/group-by.d.ts.map +1 -1
- package/dist/types/array/index-by.d.ts +25 -6
- package/dist/types/array/index-by.d.ts.map +1 -1
- package/dist/types/array/index.d.ts +4 -0
- package/dist/types/array/index.d.ts.map +1 -1
- package/dist/types/array/intersection-with.d.ts +2 -2
- package/dist/types/array/intersection-with.d.ts.map +1 -1
- package/dist/types/array/intersection.d.ts +2 -2
- package/dist/types/array/intersection.d.ts.map +1 -1
- package/dist/types/array/last.d.ts +13 -4
- package/dist/types/array/last.d.ts.map +1 -1
- package/dist/types/array/map.d.ts +3 -3
- package/dist/types/array/map.d.ts.map +1 -1
- package/dist/types/array/max-by.d.ts.map +1 -1
- package/dist/types/array/mean-by.d.ts.map +1 -1
- package/dist/types/array/merge-all.d.ts +1 -1
- package/dist/types/array/merge-all.d.ts.map +1 -1
- package/dist/types/array/min-by.d.ts.map +1 -1
- package/dist/types/array/reduce.d.ts +2 -2
- package/dist/types/array/reduce.d.ts.map +1 -1
- package/dist/types/array/reject.d.ts +3 -3
- package/dist/types/array/reject.d.ts.map +1 -1
- package/dist/types/array/sort-by.d.ts +33 -33
- package/dist/types/array/sort-by.d.ts.map +1 -1
- package/dist/types/array/sort.d.ts.map +1 -1
- package/dist/types/array/sorted-index-by.d.ts +63 -0
- package/dist/types/array/sorted-index-by.d.ts.map +1 -0
- package/dist/types/array/sorted-index-with.d.ts +65 -0
- package/dist/types/array/sorted-index-with.d.ts.map +1 -0
- package/dist/types/array/sorted-index.d.ts +47 -0
- package/dist/types/array/sorted-index.d.ts.map +1 -0
- package/dist/types/array/sorted-last-index-by.d.ts +63 -0
- package/dist/types/array/sorted-last-index-by.d.ts.map +1 -0
- package/dist/types/array/sorted-last-index.d.ts +47 -0
- package/dist/types/array/sorted-last-index.d.ts.map +1 -0
- package/dist/types/array/sum-by.d.ts.map +1 -1
- package/dist/types/array/take.d.ts +2 -2
- package/dist/types/array/take.d.ts.map +1 -1
- package/dist/types/array/uniq-with.d.ts +3 -3
- package/dist/types/array/uniq-with.d.ts.map +1 -1
- package/dist/types/array/uniq.d.ts +15 -4
- package/dist/types/array/uniq.d.ts.map +1 -1
- package/dist/types/array/zip-obj.d.ts +2 -2
- package/dist/types/array/zip-obj.d.ts.map +1 -1
- package/dist/types/array/zip.d.ts.map +1 -1
- package/dist/types/function/conditional.d.ts.map +1 -1
- package/dist/types/function/index.d.ts +1 -0
- package/dist/types/function/index.d.ts.map +1 -1
- package/dist/types/function/noop.d.ts.map +1 -1
- package/dist/types/function/pipe.d.ts +21 -0
- package/dist/types/function/pipe.d.ts.map +1 -1
- package/dist/types/function/purry.d.ts +21 -6
- package/dist/types/function/purry.d.ts.map +1 -1
- package/dist/types/function/times.d.ts +29 -0
- package/dist/types/function/times.d.ts.map +1 -0
- package/dist/types/guard/is-empty.d.ts +15 -4
- package/dist/types/guard/is-empty.d.ts.map +1 -1
- package/dist/types/guard/is-not.d.ts +1 -1
- package/dist/types/guard/is-not.d.ts.map +1 -1
- package/dist/types/guard/is-object.d.ts +1 -1
- package/dist/types/guard/is-object.d.ts.map +1 -1
- package/dist/types/number/clamp.d.ts +7 -8
- package/dist/types/number/clamp.d.ts.map +1 -1
- package/dist/types/object/add-prop.d.ts +2 -2
- package/dist/types/object/add-prop.d.ts.map +1 -1
- package/dist/types/object/equals.d.ts +2 -2
- package/dist/types/object/equals.d.ts.map +1 -1
- package/dist/types/object/for-each-obj.d.ts +6 -6
- package/dist/types/object/for-each-obj.d.ts.map +1 -1
- package/dist/types/object/from-pairs.d.ts +9 -0
- package/dist/types/object/from-pairs.d.ts.map +1 -1
- package/dist/types/object/keys.d.ts +8 -4
- package/dist/types/object/keys.d.ts.map +1 -1
- package/dist/types/object/pick.d.ts +9 -9
- package/dist/types/object/pick.d.ts.map +1 -1
- package/dist/types/object/prop.d.ts.map +1 -1
- package/dist/types/object/set-path.d.ts +1 -1
- package/dist/types/object/set-path.d.ts.map +1 -1
- package/dist/types/object/to-pairs.d.ts +1 -1
- package/dist/types/object/to-pairs.d.ts.map +1 -1
- package/dist/types/string/random-string.d.ts +6 -2
- package/dist/types/string/random-string.d.ts.map +1 -1
- package/dist/types/string/string-to-path.d.ts.map +1 -1
- package/dist/types/type/type.d.ts.map +1 -1
- package/dist/types/utils/binary-search-cutoff-index.d.ts +2 -0
- package/dist/types/utils/binary-search-cutoff-index.d.ts.map +1 -0
- package/dist/types/utils/narrow.d.ts +1 -1
- package/dist/types/utils/narrow.d.ts.map +1 -1
- package/dist/types/utils/purry-on.d.ts +1 -1
- package/dist/types/utils/purry-on.d.ts.map +1 -1
- package/dist/types/utils/reduce-lazy.d.ts +2 -21
- package/dist/types/utils/reduce-lazy.d.ts.map +1 -1
- package/dist/types/utils/swap-in-place.d.ts.map +1 -1
- package/dist/types/utils/to-single.d.ts +4 -2
- package/dist/types/utils/to-single.d.ts.map +1 -1
- package/dist/types/utils/types.d.ts +2 -2
- package/dist/types/utils/types.d.ts.map +1 -1
- package/dist/types/utils/with-precision.d.ts.map +1 -1
- package/package.json +2 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LazyEvaluator } from '../function/pipe';
|
|
2
2
|
import type { IterableContainer, Pred, PredIndexed, PredIndexedOptional } from '../utils/types';
|
|
3
3
|
/**
|
|
4
4
|
* Map each element of an array using a defined callback function. If the input
|
|
@@ -52,8 +52,8 @@ type StrictOut<T extends IterableContainer, K> = {
|
|
|
52
52
|
export declare namespace map {
|
|
53
53
|
function indexed<T, K>(array: ReadonlyArray<T>, fn: PredIndexed<T, K>): Array<K>;
|
|
54
54
|
function indexed<T, K>(fn: PredIndexed<T, K>): (array: ReadonlyArray<T>) => Array<K>;
|
|
55
|
-
const lazy: <T, K>(fn: PredIndexedOptional<T, K>) =>
|
|
56
|
-
const lazyIndexed: (<T, K>(fn: PredIndexedOptional<T, K>) =>
|
|
55
|
+
const lazy: <T, K>(fn: PredIndexedOptional<T, K>) => LazyEvaluator<T, K>;
|
|
56
|
+
const lazyIndexed: (<T, K>(fn: PredIndexedOptional<T, K>) => LazyEvaluator<T, K>) & {
|
|
57
57
|
readonly indexed: true;
|
|
58
58
|
};
|
|
59
59
|
const strict: Strict;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/array/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/array/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EACV,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAMxB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CA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AI,MAAM,CAAC,GAAG,CAAC;CAC5B,CAAC;AAEF,yBAAiB,GAAG,CAAC;IACnB,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GACpB,KAAK,CAAC,CAAC,CAAC,CAAC;IACZ,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GACpB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;IAKlC,MAAM,IAAI,8DAAe,CAAC;IAC1B,MAAM,WAAW;;KAA6B,CAAC;IAE/C,MAAM,MAAM,EAAE,MAAY,CAAC;CACnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"max-by.d.ts","sourceRoot":"","sources":["../../../src/array/max-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"max-by.d.ts","sourceRoot":"","sources":["../../../src/array/max-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAqBvE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GACtB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GACtB,CAAC,GAAG,SAAS,CAAC;AAMjB,yBAAiB,KAAK,CAAC;IACrB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GACzB,CAAC,GAAG,SAAS,CAAC;IACjB,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GACzB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;CAI/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mean-by.d.ts","sourceRoot":"","sources":["../../../src/array/mean-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"mean-by.d.ts","sourceRoot":"","sources":["../../../src/array/mean-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAoBvE;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,MAAM,CAAC,CAAC,EACtB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GACtB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;AAEvC;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,MAAM,CAAC,CAAC,EACtB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GACtB,MAAM,CAAC;AAMV,yBAAiB,MAAM,CAAC;IACtB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GACzB,MAAM,CAAC;IAEV,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GACzB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;CAKxC"}
|
|
@@ -11,6 +11,6 @@ export declare function mergeAll<A>(array: readonly [A]): A;
|
|
|
11
11
|
export declare function mergeAll<A, B>(array: readonly [A, B]): A & B;
|
|
12
12
|
export declare function mergeAll<A, B, C>(array: readonly [A, B, C]): A & B & C;
|
|
13
13
|
export declare function mergeAll<A, B, C, D>(array: readonly [A, B, C, D]): A & B & C & D;
|
|
14
|
-
export declare function mergeAll<A, B, C, D, E>(array: [A, B, C, D, E]): A & B & C & D & E;
|
|
14
|
+
export declare function mergeAll<A, B, C, D, E>(array: readonly [A, B, C, D, E]): A & B & C & D & E;
|
|
15
15
|
export declare function mergeAll(array: ReadonlyArray<object>): object;
|
|
16
16
|
//# sourceMappingURL=merge-all.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-all.d.ts","sourceRoot":"","sources":["../../../src/array/merge-all.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACpD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC9D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACxE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EACjC,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GA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,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"min-by.d.ts","sourceRoot":"","sources":["../../../src/array/min-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"min-by.d.ts","sourceRoot":"","sources":["../../../src/array/min-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAqBvE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GACtB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GACtB,CAAC,GAAG,SAAS,CAAC;AAMjB,yBAAiB,KAAK,CAAC;IACrB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GACzB,CAAC,GAAG,SAAS,CAAC;IACjB,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GACzB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;CAI/C"}
|
|
@@ -29,7 +29,7 @@ export declare function reduce<T, K>(items: ReadonlyArray<T>, fn: (acc: K, item:
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function reduce<T, K>(fn: (acc: K, item: T) => K, initialValue: K): (items: ReadonlyArray<T>) => K;
|
|
31
31
|
export declare namespace reduce {
|
|
32
|
-
function indexed<T, K>(array: ReadonlyArray<T>, fn: (acc: K, item: T, index: number, items:
|
|
33
|
-
function indexed<T, K>(fn: (acc: K, item: T, index: number, items:
|
|
32
|
+
function indexed<T, K>(array: ReadonlyArray<T>, fn: (acc: K, item: T, index: number, items: ReadonlyArray<T>) => K, initialValue: K): K;
|
|
33
|
+
function indexed<T, K>(fn: (acc: K, item: T, index: number, items: ReadonlyArray<T>) => K, initialValue: K): (array: ReadonlyArray<T>) => K;
|
|
34
34
|
}
|
|
35
35
|
//# sourceMappingURL=reduce.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduce.d.ts","sourceRoot":"","sources":["../../../src/array/reduce.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EACzB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAC1B,YAAY,EAAE,CAAC,GACd,CAAC,CAAC;AAEL;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EACzB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAC1B,YAAY,EAAE,CAAC,GACd,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAmBlC,yBAAiB,MAAM,CAAC;IACtB,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"reduce.d.ts","sourceRoot":"","sources":["../../../src/array/reduce.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EACzB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAC1B,YAAY,EAAE,CAAC,GACd,CAAC,CAAC;AAEL;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EACzB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAC1B,YAAY,EAAE,CAAC,GACd,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAmBlC,yBAAiB,MAAM,CAAC;IACtB,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,EAClE,YAAY,EAAE,CAAC,GACd,CAAC,CAAC;IACL,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,EAClE,YAAY,EAAE,CAAC,GACd,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;CAInC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LazyEvaluator } from '../function/pipe';
|
|
2
2
|
import type { Pred, PredIndexed, PredIndexedOptional } from '../utils/types';
|
|
3
3
|
/**
|
|
4
4
|
* Reject the elements of an array that meet the condition specified in a callback function.
|
|
@@ -34,8 +34,8 @@ export declare function reject<T>(fn: Pred<T, boolean>): (items: ReadonlyArray<T
|
|
|
34
34
|
export declare namespace reject {
|
|
35
35
|
function indexed<T, K>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): Array<K>;
|
|
36
36
|
function indexed<T, K>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => Array<K>;
|
|
37
|
-
const lazy: <T>(fn: PredIndexedOptional<T, boolean>) =>
|
|
38
|
-
const lazyIndexed: (<T>(fn: PredIndexedOptional<T, boolean>) =>
|
|
37
|
+
const lazy: <T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T>;
|
|
38
|
+
const lazyIndexed: (<T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T>) & {
|
|
39
39
|
readonly indexed: true;
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reject.d.ts","sourceRoot":"","sources":["../../../src/array/reject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"reject.d.ts","sourceRoot":"","sources":["../../../src/array/reject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAM7E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GACnB,KAAK,CAAC,CAAC,CAAC,CAAC;AAEZ;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GACnB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;AAwBzC,yBAAiB,MAAM,CAAC;IACtB,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1B,KAAK,CAAC,CAAC,CAAC,CAAC;IACZ,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1B,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;IAKlC,MAAM,IAAI,8DAAe,CAAC;IAC1B,MAAM,WAAW;;KAA6B,CAAC;CACvD"}
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import type { IterableContainer, NonEmptyArray } from '../utils/types';
|
|
2
|
-
|
|
3
|
-
type Direction = (typeof ALL_DIRECTIONS)[number];
|
|
4
|
-
type ComparablePrimitive = boolean | number | string;
|
|
5
|
-
type Comparable = {
|
|
6
|
-
valueOf(): ComparablePrimitive;
|
|
7
|
-
} | ComparablePrimitive;
|
|
8
|
-
type SortProjection<T> = (x: T) => Comparable;
|
|
9
|
-
type SortPair<T> = readonly [
|
|
10
|
-
projector: SortProjection<T>,
|
|
11
|
-
direction: Direction
|
|
12
|
-
];
|
|
13
|
-
type SortRule<T> = SortPair<T> | SortProjection<T>;
|
|
2
|
+
import { type OrderRule } from '../utils/purry-order-rules';
|
|
14
3
|
/**
|
|
15
|
-
* Sorts the
|
|
16
|
-
* Sorting is based on a native `sort` function. It's not guaranteed to be stable.
|
|
4
|
+
* Sorts `data` using the provided ordering rules. The `sort` is done via the native `Array.prototype.sort` but is performed on a shallow copy of the array to avoid mutating the original data.
|
|
17
5
|
*
|
|
18
|
-
*
|
|
6
|
+
* To maintain the shape of more complex inputs (like non-empty arrays, tuples, etc...) use the `strict` variant.
|
|
19
7
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
8
|
+
* There are several other functions that take order rules and **bypass** the need to sort the array first (in *O(nlogn)* time):
|
|
9
|
+
* `firstBy` === `first(sortBy(data, ...rules))`, O(n).
|
|
10
|
+
* `takeFirstBy` === `take(sortBy(data, ...rules), k)`, O(nlogk).
|
|
11
|
+
* `dropFirstBy` === `drop(sortBy(data, ...rules), k)`, O(nlogk).
|
|
12
|
+
* `nthBy` === `sortBy(data, ...rules).at(k)`, O(n).
|
|
13
|
+
* `rankBy` === `sortedIndex(sortBy(data, ...rules), item)`, O(n).
|
|
14
|
+
* Refer to the docs for more details.
|
|
22
15
|
*
|
|
23
|
-
* @param
|
|
16
|
+
* @param data - The input array.
|
|
17
|
+
* @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 order.
|
|
18
|
+
* @return - A shallow copy of the input array sorted by the provided rules.
|
|
24
19
|
* @signature
|
|
25
|
-
* P.sortBy(
|
|
26
|
-
* P.sortBy.strict(
|
|
20
|
+
* P.sortBy(...rules)(data)
|
|
21
|
+
* P.sortBy.strict(...rules)(data)
|
|
27
22
|
* @example
|
|
28
23
|
* P.pipe(
|
|
29
24
|
* [{ a: 1 }, { a: 3 }, { a: 7 }, { a: 2 }],
|
|
@@ -37,21 +32,26 @@ type SortRule<T> = SortPair<T> | SortProjection<T>;
|
|
|
37
32
|
* @category Array
|
|
38
33
|
* @strict
|
|
39
34
|
*/
|
|
40
|
-
export declare function sortBy<T>(...
|
|
35
|
+
export declare function sortBy<T>(...rules: Readonly<NonEmptyArray<OrderRule<T>>>): (data: ReadonlyArray<T>) => Array<T>;
|
|
41
36
|
/**
|
|
42
|
-
* Sorts the
|
|
43
|
-
* Sorting is based on a native `sort` function. It's not guaranteed to be stable.
|
|
37
|
+
* Sorts `data` using the provided ordering rules. The `sort` is done via the native `Array.prototype.sort` but is performed on a shallow copy of the array to avoid mutating the original data.
|
|
44
38
|
*
|
|
45
|
-
*
|
|
39
|
+
* To maintain the shape of more complex inputs (like non-empty arrays, tuples, etc...) use the `strict` variant.
|
|
46
40
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
41
|
+
* There are several other functions that take order rules and **bypass** the need to sort the array first (in *O(nlogn)* time):
|
|
42
|
+
* `firstBy` === `first(sortBy(data, ...rules))`, O(n).
|
|
43
|
+
* `takeFirstBy` === `take(sortBy(data, ...rules), k)`, O(nlogk).
|
|
44
|
+
* `dropFirstBy` === `drop(sortBy(data, ...rules), k)`, O(nlogk).
|
|
45
|
+
* `nthBy` === `sortBy(data, ...rules).at(k)`, O(n).
|
|
46
|
+
* `rankBy` === `sortedIndex(sortBy(data, ...rules), item)`, O(n).
|
|
47
|
+
* Refer to the docs for more details.
|
|
49
48
|
*
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
49
|
+
* @param data - The input array.
|
|
50
|
+
* @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 order.
|
|
51
|
+
* @return - A shallow copy of the input array sorted by the provided rules.
|
|
52
52
|
* @signature
|
|
53
|
-
* P.sortBy(
|
|
54
|
-
* P.sortBy.strict(
|
|
53
|
+
* P.sortBy(data, ...rules)
|
|
54
|
+
* P.sortBy.strict(data, ...rules)
|
|
55
55
|
* @example
|
|
56
56
|
* P.sortBy(
|
|
57
57
|
* [{ a: 1 }, { a: 3 }, { a: 7 }, { a: 2 }],
|
|
@@ -84,10 +84,10 @@ export declare function sortBy<T>(...sortRules: Readonly<NonEmptyArray<SortRule<
|
|
|
84
84
|
* @category Array
|
|
85
85
|
* @strict
|
|
86
86
|
*/
|
|
87
|
-
export declare function sortBy<T>(array: ReadonlyArray<T>, ...sortRules: Readonly<NonEmptyArray<
|
|
87
|
+
export declare function sortBy<T>(array: ReadonlyArray<T>, ...sortRules: Readonly<NonEmptyArray<OrderRule<T>>>): Array<T>;
|
|
88
88
|
interface Strict {
|
|
89
|
-
<T extends IterableContainer>(...sortRules: Readonly<NonEmptyArray<
|
|
90
|
-
<T extends IterableContainer>(array: T, ...sortRules: Readonly<NonEmptyArray<
|
|
89
|
+
<T extends IterableContainer>(...sortRules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): (array: T) => SortedBy<T>;
|
|
90
|
+
<T extends IterableContainer>(array: T, ...sortRules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): SortedBy<T>;
|
|
91
91
|
}
|
|
92
92
|
type SortedBy<T extends IterableContainer> = {
|
|
93
93
|
-readonly [P in keyof T]: T[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-by.d.ts","sourceRoot":"","sources":["../../../src/array/sort-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sort-by.d.ts","sourceRoot":"","sources":["../../../src/array/sort-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,4BAA4B,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,GAAG,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,KAAK,EAAE,aAAa,CAAC,CAAC,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C,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;CACpC,CAAC;AAEF,yBAAiB,IAAI,CAAC;IACb,MAAM,MAAM,EAAE,MAAa,CAAC;CACpC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the insertion position (index) of an item in an array with items sorted
|
|
3
|
+
* in ascending order using a value function; so that `splice(sortedIndex, 0, item)`
|
|
4
|
+
* would result in maintaining the arrays sort-ness. The array can contain
|
|
5
|
+
* duplicates.
|
|
6
|
+
* If the item already exists in the array the index would be of the *first*
|
|
7
|
+
* occurrence of the item.
|
|
8
|
+
*
|
|
9
|
+
* Runs in O(logN) time.
|
|
10
|
+
*
|
|
11
|
+
* @param data - The (ascending) sorted array.
|
|
12
|
+
* @param item - The item to insert.
|
|
13
|
+
* @param valueFunction - All comparisons would be performed on the result of
|
|
14
|
+
* calling this function on each compared item. Preferably this function should
|
|
15
|
+
* return a `number` or `string`. This function should be the same as the one
|
|
16
|
+
* provided to sortBy to sort the array.
|
|
17
|
+
* @return - Insertion index (In the range 0..data.length)
|
|
18
|
+
*
|
|
19
|
+
* @signature
|
|
20
|
+
* P.sortedIndexBy(data, item, valueFunction)
|
|
21
|
+
* @example
|
|
22
|
+
* P.sortedIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1
|
|
23
|
+
* @dataFirst
|
|
24
|
+
* @indexed
|
|
25
|
+
* @category Array
|
|
26
|
+
*
|
|
27
|
+
* @see sortedIndex, sortedIndexWith, sortedLastIndex, sortedLastIndexBy
|
|
28
|
+
*/
|
|
29
|
+
export declare function sortedIndexBy<T>(data: ReadonlyArray<T>, item: T, valueFunction: (item: T) => NonNullable<unknown>): number;
|
|
30
|
+
/**
|
|
31
|
+
* Find the insertion position (index) of an item in an array with items sorted
|
|
32
|
+
* in ascending order using a value function; so that `splice(sortedIndex, 0, item)`
|
|
33
|
+
* would result in maintaining the arrays sort-ness. The array can contain
|
|
34
|
+
* duplicates.
|
|
35
|
+
* If the item already exists in the array the index would be of the *first*
|
|
36
|
+
* occurrence of the item.
|
|
37
|
+
*
|
|
38
|
+
* Runs in O(logN) time.
|
|
39
|
+
*
|
|
40
|
+
* @param data - The (ascending) sorted array.
|
|
41
|
+
* @param item - The item to insert.
|
|
42
|
+
* @param valueFunction - All comparisons would be performed on the result of
|
|
43
|
+
* calling this function on each compared item. Preferably this function should
|
|
44
|
+
* return a `number` or `string`. This function should be the same as the one
|
|
45
|
+
* provided to sortBy to sort the array.
|
|
46
|
+
* @return - Insertion index (In the range 0..data.length)
|
|
47
|
+
*
|
|
48
|
+
* @signature
|
|
49
|
+
* P.sortedIndexBy(data, item, valueFunction)
|
|
50
|
+
* @example
|
|
51
|
+
* P.sortedIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1
|
|
52
|
+
* @dataLast
|
|
53
|
+
* @indexed
|
|
54
|
+
* @category Array
|
|
55
|
+
*
|
|
56
|
+
* @see sortedIndex, sortedIndexWith, sortedLastIndex, sortedLastIndexBy
|
|
57
|
+
*/
|
|
58
|
+
export declare function sortedIndexBy<T>(item: T, valueFunction: (item: T) => NonNullable<unknown>): (data: ReadonlyArray<T>) => number;
|
|
59
|
+
export declare namespace sortedIndexBy {
|
|
60
|
+
function indexed<T>(data: ReadonlyArray<T>, item: T, valueFunction: (item: T, index?: number) => NonNullable<unknown>): number;
|
|
61
|
+
function indexed<T>(item: T, valueFunction: (item: T, index?: number) => NonNullable<unknown>): (data: ReadonlyArray<T>) => number;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=sorted-index-by.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorted-index-by.d.ts","sourceRoot":"","sources":["../../../src/array/sorted-index-by.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,CAAC,EACP,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC,GAC/C,MAAM,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,IAAI,EAAE,CAAC,EACP,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC,GAC/C,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;AA8BtC,yBAAiB,aAAa,CAAC;IAC7B,SAAgB,OAAO,CAAC,CAAC,EACvB,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,CAAC,EACP,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,WAAW,CAAC,OAAO,CAAC,GAC/D,MAAM,CAAC;IACV,SAAgB,OAAO,CAAC,CAAC,EACvB,IAAI,EAAE,CAAC,EACP,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,WAAW,CAAC,OAAO,CAAC,GAC/D,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;CAIvC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a **binary search** for the index of the item at which the predicate
|
|
3
|
+
* stops returning `true`. This function assumes that the array is "sorted" in
|
|
4
|
+
* regards to the predicate, meaning that running the predicate as a mapper on
|
|
5
|
+
* it would result in an array `[...true[], ...false[]]`.
|
|
6
|
+
* This stricter requirement from the predicate provides us 2 benefits over
|
|
7
|
+
* `findIndex` which does a similar thing:
|
|
8
|
+
* 1. It would run at O(logN) time instead of O(N) time.
|
|
9
|
+
* 2. It always returns a value (it would return `data.length` if the
|
|
10
|
+
* predicate returns `true` for all items).
|
|
11
|
+
*
|
|
12
|
+
* This function is the basis for all other sortedIndex functions which search
|
|
13
|
+
* for a specific item in a sorted array, and it could be used to perform
|
|
14
|
+
* similar efficient searches.
|
|
15
|
+
*
|
|
16
|
+
* @param data - Array, "sorted" by `predicate`
|
|
17
|
+
* @param predicate - A predicate which also defines the array's order
|
|
18
|
+
* @return - Index (In the range 0..data.length)
|
|
19
|
+
*
|
|
20
|
+
* @signature
|
|
21
|
+
* P.sortedIndexWith(data, predicate)
|
|
22
|
+
* @example
|
|
23
|
+
* P.sortedIndexWith(['a','ab','abc'], (item) => item.length < 2) // => 1
|
|
24
|
+
* @dataFirst
|
|
25
|
+
* @indexed
|
|
26
|
+
* @category Array
|
|
27
|
+
*
|
|
28
|
+
* @see findIndex, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy
|
|
29
|
+
*/
|
|
30
|
+
export declare function sortedIndexWith<T>(data: ReadonlyArray<T>, predicate: (item: T) => boolean): number;
|
|
31
|
+
/**
|
|
32
|
+
* Performs a **binary search** for the index of the item at which the predicate
|
|
33
|
+
* stops returning `true`. This function assumes that the array is "sorted" in
|
|
34
|
+
* regards to the predicate, meaning that running the predicate as a mapper on
|
|
35
|
+
* it would result in an array `[...true[], ...false[]]`.
|
|
36
|
+
* This stricter requirement from the predicate provides us 2 benefits over
|
|
37
|
+
* `findIndex` which does a similar thing:
|
|
38
|
+
* 1. It would run at O(logN) time instead of O(N) time.
|
|
39
|
+
* 2. It always returns a value (it would return `data.length` if the
|
|
40
|
+
* predicate returns `false` for all items).
|
|
41
|
+
*
|
|
42
|
+
* This function is the basis for all other sortedIndex functions which search
|
|
43
|
+
* for a specific item in a sorted array, and it could be used to perform
|
|
44
|
+
* similar efficient searches.
|
|
45
|
+
*
|
|
46
|
+
* @param data - Array, "sorted" by `predicate`
|
|
47
|
+
* @param predicate - A predicate which also defines the array's order
|
|
48
|
+
* @return - Index (In the range 0..data.length)
|
|
49
|
+
*
|
|
50
|
+
* @signature
|
|
51
|
+
* P.sortedIndexWith(predicate)(data)
|
|
52
|
+
* @example
|
|
53
|
+
* P.pipe(['a','ab','abc'], P.sortedIndexWith((item) => item.length < 2)) // => 1
|
|
54
|
+
* @dataLast
|
|
55
|
+
* @indexed
|
|
56
|
+
* @category Array
|
|
57
|
+
*
|
|
58
|
+
* @see findIndex, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy
|
|
59
|
+
*/
|
|
60
|
+
export declare function sortedIndexWith<T>(predicate: (item: T) => boolean): (data: ReadonlyArray<T>) => number;
|
|
61
|
+
export declare namespace sortedIndexWith {
|
|
62
|
+
function indexed<T>(data: ReadonlyArray<T>, predicate: (item: T, index: number) => NonNullable<unknown>): number;
|
|
63
|
+
function indexed<T>(predicate: (item: T, index: number) => NonNullable<unknown>): (data: ReadonlyArray<T>) => number;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=sorted-index-with.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorted-index-with.d.ts","sourceRoot":"","sources":["../../../src/array/sorted-index-with.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAC9B,MAAM,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAC9B,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;AAMtC,yBAAiB,eAAe,CAAC;IAC/B,SAAgB,OAAO,CAAC,CAAC,EACvB,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC,OAAO,CAAC,GAC1D,MAAM,CAAC;IACV,SAAgB,OAAO,CAAC,CAAC,EACvB,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC,OAAO,CAAC,GAC1D,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;CAIvC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the insertion position (index) of an item in an array with items sorted
|
|
3
|
+
* in ascending order; so that `splice(sortedIndex, 0, item)` would result in
|
|
4
|
+
* maintaining the array's sort-ness. The array can contain duplicates.
|
|
5
|
+
* If the item already exists in the array the index would be of the *first*
|
|
6
|
+
* occurrence of the item.
|
|
7
|
+
*
|
|
8
|
+
* Runs in O(logN) time.
|
|
9
|
+
*
|
|
10
|
+
* @param data - The (ascending) sorted array.
|
|
11
|
+
* @param item - The item to insert.
|
|
12
|
+
* @return - Insertion index (In the range 0..array.length)
|
|
13
|
+
*
|
|
14
|
+
* @signature
|
|
15
|
+
* P.sortedIndex(data, item)
|
|
16
|
+
* @example
|
|
17
|
+
* P.sortedIndex(['a','a','b','c','c'], 'c') // => 3
|
|
18
|
+
* @dataFirst
|
|
19
|
+
* @category Array
|
|
20
|
+
*
|
|
21
|
+
* @see sortedIndexBy, sortedIndexWith, sortedLastIndex, sortedLastIndexBy
|
|
22
|
+
*/
|
|
23
|
+
export declare function sortedIndex<T>(data: ReadonlyArray<T>, item: T): number;
|
|
24
|
+
/**
|
|
25
|
+
* Find the insertion position (index) of an item in an array with items sorted
|
|
26
|
+
* in ascending order; so that `splice(sortedIndex, 0, item)` would result in
|
|
27
|
+
* maintaining the array's sort-ness. The array can contain duplicates.
|
|
28
|
+
* If the item already exists in the array the index would be of the *first*
|
|
29
|
+
* occurrence of the item.
|
|
30
|
+
*
|
|
31
|
+
* Runs in O(logN) time.
|
|
32
|
+
*
|
|
33
|
+
* @param data - The (ascending) sorted array.
|
|
34
|
+
* @param item - The item to insert.
|
|
35
|
+
* @return - Insertion index (In the range 0..array.length)
|
|
36
|
+
*
|
|
37
|
+
* @signature
|
|
38
|
+
* P.sortedIndex(item)(data)
|
|
39
|
+
* @example
|
|
40
|
+
* P.pipe(['a','a','b','c','c'], P.sortedIndex('c')) // => 3
|
|
41
|
+
* @dataLast
|
|
42
|
+
* @category Array
|
|
43
|
+
*
|
|
44
|
+
* @see sortedIndexBy, sortedIndexWith, sortedLastIndex, sortedLastIndexBy
|
|
45
|
+
*/
|
|
46
|
+
export declare function sortedIndex<T>(item: T): (data: ReadonlyArray<T>) => number;
|
|
47
|
+
//# sourceMappingURL=sorted-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorted-index.d.ts","sourceRoot":"","sources":["../../../src/array/sorted-index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the insertion position (index) of an item in an array with items sorted
|
|
3
|
+
* in ascending order using a value function; so that `splice(sortedIndex, 0, item)`
|
|
4
|
+
* would result in maintaining the arrays sort-ness. The array can contain
|
|
5
|
+
* duplicates.
|
|
6
|
+
* If the item already exists in the array the index would be of the *last*
|
|
7
|
+
* occurrence of the item.
|
|
8
|
+
*
|
|
9
|
+
* Runs in O(logN) time.
|
|
10
|
+
*
|
|
11
|
+
* @param data - The (ascending) sorted array.
|
|
12
|
+
* @param item - The item to insert.
|
|
13
|
+
* @param valueFunction - All comparisons would be performed on the result of
|
|
14
|
+
* calling this function on each compared item. Preferably this function should
|
|
15
|
+
* return a `number` or `string`. This function should be the same as the one
|
|
16
|
+
* provided to sortBy to sort the array.
|
|
17
|
+
* @return - Insertion index (In the range 0..data.length)
|
|
18
|
+
*
|
|
19
|
+
* @signature
|
|
20
|
+
* P.sortedLastIndexBy(data, item, valueFunction)
|
|
21
|
+
* @example
|
|
22
|
+
* P.sortedLastIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1
|
|
23
|
+
* @dataFirst
|
|
24
|
+
* @indexed
|
|
25
|
+
* @category Array
|
|
26
|
+
*
|
|
27
|
+
* @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndex
|
|
28
|
+
*/
|
|
29
|
+
export declare function sortedLastIndexBy<T>(data: ReadonlyArray<T>, item: T, valueFunction: (item: T) => NonNullable<unknown>): number;
|
|
30
|
+
/**
|
|
31
|
+
* Find the insertion position (index) of an item in an array with items sorted
|
|
32
|
+
* in ascending order using a value function; so that `splice(sortedIndex, 0, item)`
|
|
33
|
+
* would result in maintaining the arrays sort-ness. The array can contain
|
|
34
|
+
* duplicates.
|
|
35
|
+
* If the item already exists in the array the index would be of the *last*
|
|
36
|
+
* occurrence of the item.
|
|
37
|
+
*
|
|
38
|
+
* Runs in O(logN) time.
|
|
39
|
+
*
|
|
40
|
+
* @param data - The (ascending) sorted array.
|
|
41
|
+
* @param item - The item to insert.
|
|
42
|
+
* @param valueFunction - All comparisons would be performed on the result of
|
|
43
|
+
* calling this function on each compared item. Preferably this function should
|
|
44
|
+
* return a `number` or `string`. This function should be the same as the one
|
|
45
|
+
* provided to sortBy to sort the array.
|
|
46
|
+
* @return - Insertion index (In the range 0..data.length)
|
|
47
|
+
*
|
|
48
|
+
* @signature
|
|
49
|
+
* P.sortedLastIndexBy(item, valueFunction)(data)
|
|
50
|
+
* @example
|
|
51
|
+
* P.pipe([{age:20},{age:22}],sortedLastIndexBy({age:21},prop('age'))) // => 1
|
|
52
|
+
* @dataLast
|
|
53
|
+
* @indexed
|
|
54
|
+
* @category Array
|
|
55
|
+
*
|
|
56
|
+
* @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndex
|
|
57
|
+
*/
|
|
58
|
+
export declare function sortedLastIndexBy<T>(item: T, valueFunction: (item: T) => NonNullable<unknown>): (data: ReadonlyArray<T>) => number;
|
|
59
|
+
export declare namespace sortedLastIndexBy {
|
|
60
|
+
function indexed<T>(data: ReadonlyArray<T>, item: T, valueFunction: (item: T, index?: number) => NonNullable<unknown>): number;
|
|
61
|
+
function indexed<T>(item: T, valueFunction: (item: T, index?: number) => NonNullable<unknown>): (data: ReadonlyArray<T>) => number;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=sorted-last-index-by.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorted-last-index-by.d.ts","sourceRoot":"","sources":["../../../src/array/sorted-last-index-by.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,CAAC,EACP,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC,GAC/C,MAAM,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,IAAI,EAAE,CAAC,EACP,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC,GAC/C,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;AAMtC,yBAAiB,iBAAiB,CAAC;IACjC,SAAgB,OAAO,CAAC,CAAC,EACvB,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,CAAC,EACP,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,WAAW,CAAC,OAAO,CAAC,GAC/D,MAAM,CAAC;IACV,SAAgB,OAAO,CAAC,CAAC,EACvB,IAAI,EAAE,CAAC,EACP,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,WAAW,CAAC,OAAO,CAAC,GAC/D,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;CAIvC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the insertion position (index) of an item in an array with items sorted
|
|
3
|
+
* in ascending order; so that `splice(sortedIndex, 0, item)` would result in
|
|
4
|
+
* maintaining the array's sort-ness. The array can contain duplicates.
|
|
5
|
+
* If the item already exists in the array the index would be of the *last*
|
|
6
|
+
* occurrence of the item.
|
|
7
|
+
*
|
|
8
|
+
* Runs in O(logN) time.
|
|
9
|
+
*
|
|
10
|
+
* @param data - The (ascending) sorted array.
|
|
11
|
+
* @param item - The item to insert.
|
|
12
|
+
* @return - Insertion index (In the range 0..data.length)
|
|
13
|
+
*
|
|
14
|
+
* @signature
|
|
15
|
+
* P.sortedLastIndex(data, item)
|
|
16
|
+
* @example
|
|
17
|
+
* P.sortedLastIndex(['a','a','b','c','c'], 'c') // => 5
|
|
18
|
+
* @dataFirst
|
|
19
|
+
* @category Array
|
|
20
|
+
*
|
|
21
|
+
* @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy
|
|
22
|
+
*/
|
|
23
|
+
export declare function sortedLastIndex<T>(data: ReadonlyArray<T>, item: T): number;
|
|
24
|
+
/**
|
|
25
|
+
* Find the insertion position (index) of an item in an array with items sorted
|
|
26
|
+
* in ascending order; so that `splice(sortedIndex, 0, item)` would result in
|
|
27
|
+
* maintaining the array's sort-ness. The array can contain duplicates.
|
|
28
|
+
* If the item already exists in the array the index would be of the *last*
|
|
29
|
+
* occurrence of the item.
|
|
30
|
+
*
|
|
31
|
+
* Runs in O(logN) time.
|
|
32
|
+
*
|
|
33
|
+
* @param data - The (ascending) sorted array.
|
|
34
|
+
* @param item - The item to insert.
|
|
35
|
+
* @return - Insertion index (In the range 0..data.length)
|
|
36
|
+
*
|
|
37
|
+
* @signature
|
|
38
|
+
* P.sortedLastIndex(item)(data)
|
|
39
|
+
* @example
|
|
40
|
+
* P.pipe(['a','a','b','c','c'], sortedLastIndex('c')) // => 5
|
|
41
|
+
* @dataLast
|
|
42
|
+
* @category Array
|
|
43
|
+
*
|
|
44
|
+
* @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy
|
|
45
|
+
*/
|
|
46
|
+
export declare function sortedLastIndex<T>(item: T): (data: ReadonlyArray<T>) => number;
|
|
47
|
+
//# sourceMappingURL=sorted-last-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorted-last-index.d.ts","sourceRoot":"","sources":["../../../src/array/sorted-last-index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sum-by.d.ts","sourceRoot":"","sources":["../../../src/array/sum-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"sum-by.d.ts","sourceRoot":"","sources":["../../../src/array/sum-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAgBvE;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,KAAK,CAAC,CAAC,EACrB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GACtB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;AAEvC;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,KAAK,CAAC,CAAC,EACrB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GACtB,MAAM,CAAC;AAMV,yBAAiB,KAAK,CAAC;IACrB,SAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GACzB,MAAM,CAAC;IAEV,SAAgB,OAAO,CAAC,CAAC,EACvB,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,GACzB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;CAKxC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LazyEvaluator } from '../function/pipe';
|
|
2
2
|
/**
|
|
3
3
|
* Returns the first `n` elements of `array`.
|
|
4
4
|
* @param array the array
|
|
@@ -25,6 +25,6 @@ export declare function take<T>(array: ReadonlyArray<T>, n: number): Array<T>;
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function take<T>(n: number): (array: ReadonlyArray<T>) => Array<T>;
|
|
27
27
|
export declare namespace take {
|
|
28
|
-
function lazy<T>(n: number):
|
|
28
|
+
function lazy<T>(n: number): LazyEvaluator<T>;
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=take.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"take.d.ts","sourceRoot":"","sources":["../../../src/array/take.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"take.d.ts","sourceRoot":"","sources":["../../../src/array/take.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKtD;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;AAU1E,yBAAiB,IAAI,CAAC;IACpB,SAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAUnD;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LazyEvaluator } from '../function/pipe';
|
|
2
2
|
type IsEquals<T> = (a: T, b: T) => boolean;
|
|
3
3
|
/**
|
|
4
4
|
* Returns a new array containing only one copy of each element in the original list.
|
|
@@ -34,9 +34,9 @@ export declare function uniqWith<T>(array: ReadonlyArray<T>, isEquals: IsEquals<
|
|
|
34
34
|
* @category Object
|
|
35
35
|
*/
|
|
36
36
|
export declare function uniqWith<T>(isEquals: IsEquals<T>): (array: ReadonlyArray<T>) => Array<T>;
|
|
37
|
-
declare function
|
|
37
|
+
declare function lazy_<T>(isEquals: IsEquals<T>): LazyEvaluator<T>;
|
|
38
38
|
export declare namespace uniqWith {
|
|
39
|
-
const lazy: typeof
|
|
39
|
+
const lazy: typeof lazy_ & {
|
|
40
40
|
readonly indexed: true;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniq-with.d.ts","sourceRoot":"","sources":["../../../src/array/uniq-with.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"uniq-with.d.ts","sourceRoot":"","sources":["../../../src/array/uniq-with.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMtD,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;AAE3C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GACpB,KAAK,CAAC,CAAC,CAAC,CAAC;AAEZ;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GACpB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;AAczC,iBAAS,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAMzD;AAED,yBAAiB,QAAQ,CAAC;IACjB,MAAM,IAAI;;KAAuB,CAAC;CAC1C"}
|