litus 1.3.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/index.cjs.js +1206 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +779 -0
- package/dist/index.esm.js +1132 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +16 -8
- package/dist/cjs/arr/chunk.d.ts +0 -1
- package/dist/cjs/arr/chunk.js +0 -12
- package/dist/cjs/arr/chunk.js.map +0 -1
- package/dist/cjs/arr/fill.d.ts +0 -1
- package/dist/cjs/arr/fill.js +0 -9
- package/dist/cjs/arr/fill.js.map +0 -1
- package/dist/cjs/arr/find.d.ts +0 -2
- package/dist/cjs/arr/find.js +0 -9
- package/dist/cjs/arr/find.js.map +0 -1
- package/dist/cjs/arr/findAll.d.ts +0 -2
- package/dist/cjs/arr/findAll.js +0 -9
- package/dist/cjs/arr/findAll.js.map +0 -1
- package/dist/cjs/arr/findAllIdx.d.ts +0 -2
- package/dist/cjs/arr/findAllIdx.js +0 -17
- package/dist/cjs/arr/findAllIdx.js.map +0 -1
- package/dist/cjs/arr/findIdx.d.ts +0 -2
- package/dist/cjs/arr/findIdx.js +0 -13
- package/dist/cjs/arr/findIdx.js.map +0 -1
- package/dist/cjs/arr/from.d.ts +0 -1
- package/dist/cjs/arr/from.js +0 -13
- package/dist/cjs/arr/from.js.map +0 -1
- package/dist/cjs/arr/group.d.ts +0 -1
- package/dist/cjs/arr/group.js +0 -16
- package/dist/cjs/arr/group.js.map +0 -1
- package/dist/cjs/arr/groupBy.d.ts +0 -1
- package/dist/cjs/arr/groupBy.js +0 -9
- package/dist/cjs/arr/groupBy.js.map +0 -1
- package/dist/cjs/arr/index.d.ts +0 -17
- package/dist/cjs/arr/index.js +0 -34
- package/dist/cjs/arr/index.js.map +0 -1
- package/dist/cjs/arr/max.d.ts +0 -1
- package/dist/cjs/arr/max.js +0 -15
- package/dist/cjs/arr/max.js.map +0 -1
- package/dist/cjs/arr/min.d.ts +0 -1
- package/dist/cjs/arr/min.js +0 -9
- package/dist/cjs/arr/min.js.map +0 -1
- package/dist/cjs/arr/range.d.ts +0 -1
- package/dist/cjs/arr/range.js +0 -13
- package/dist/cjs/arr/range.js.map +0 -1
- package/dist/cjs/arr/sort.d.ts +0 -1
- package/dist/cjs/arr/sort.js +0 -21
- package/dist/cjs/arr/sort.js.map +0 -1
- package/dist/cjs/arr/transpose.d.ts +0 -2
- package/dist/cjs/arr/transpose.js +0 -12
- package/dist/cjs/arr/transpose.js.map +0 -1
- package/dist/cjs/arr/types.d.ts +0 -11
- package/dist/cjs/arr/types.js +0 -3
- package/dist/cjs/arr/types.js.map +0 -1
- package/dist/cjs/arr/union.d.ts +0 -1
- package/dist/cjs/arr/union.js +0 -8
- package/dist/cjs/arr/union.js.map +0 -1
- package/dist/cjs/arr/unique.d.ts +0 -2
- package/dist/cjs/arr/unique.js +0 -10
- package/dist/cjs/arr/unique.js.map +0 -1
- package/dist/cjs/arr/zip.d.ts +0 -1
- package/dist/cjs/arr/zip.js +0 -7
- package/dist/cjs/arr/zip.js.map +0 -1
- package/dist/cjs/func/apply.d.ts +0 -1
- package/dist/cjs/func/apply.js +0 -8
- package/dist/cjs/func/apply.js.map +0 -1
- package/dist/cjs/func/curry.d.ts +0 -2
- package/dist/cjs/func/curry.js +0 -17
- package/dist/cjs/func/curry.js.map +0 -1
- package/dist/cjs/func/debounce.d.ts +0 -1
- package/dist/cjs/func/debounce.js +0 -15
- package/dist/cjs/func/debounce.js.map +0 -1
- package/dist/cjs/func/index.d.ts +0 -6
- package/dist/cjs/func/index.js +0 -23
- package/dist/cjs/func/index.js.map +0 -1
- package/dist/cjs/func/memo.d.ts +0 -2
- package/dist/cjs/func/memo.js +0 -22
- package/dist/cjs/func/memo.js.map +0 -1
- package/dist/cjs/func/throttle.d.ts +0 -1
- package/dist/cjs/func/throttle.js +0 -19
- package/dist/cjs/func/throttle.js.map +0 -1
- package/dist/cjs/func/types.d.ts +0 -8
- package/dist/cjs/func/types.js +0 -3
- package/dist/cjs/func/types.js.map +0 -1
- package/dist/cjs/func/unapply.d.ts +0 -1
- package/dist/cjs/func/unapply.js +0 -8
- package/dist/cjs/func/unapply.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -13
- package/dist/cjs/index.js +0 -43
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/math/add.d.ts +0 -1
- package/dist/cjs/math/add.js +0 -8
- package/dist/cjs/math/add.js.map +0 -1
- package/dist/cjs/math/aprox.d.ts +0 -1
- package/dist/cjs/math/aprox.js +0 -9
- package/dist/cjs/math/aprox.js.map +0 -1
- package/dist/cjs/math/calc.d.ts +0 -5
- package/dist/cjs/math/calc.js +0 -23
- package/dist/cjs/math/calc.js.map +0 -1
- package/dist/cjs/math/cumsum.d.ts +0 -1
- package/dist/cjs/math/cumsum.js +0 -13
- package/dist/cjs/math/cumsum.js.map +0 -1
- package/dist/cjs/math/divide.d.ts +0 -1
- package/dist/cjs/math/divide.js +0 -6
- package/dist/cjs/math/divide.js.map +0 -1
- package/dist/cjs/math/inRange.d.ts +0 -1
- package/dist/cjs/math/inRange.js +0 -11
- package/dist/cjs/math/inRange.js.map +0 -1
- package/dist/cjs/math/index.d.ts +0 -16
- package/dist/cjs/math/index.js +0 -33
- package/dist/cjs/math/index.js.map +0 -1
- package/dist/cjs/math/interp.d.ts +0 -1
- package/dist/cjs/math/interp.js +0 -22
- package/dist/cjs/math/interp.js.map +0 -1
- package/dist/cjs/math/mean.d.ts +0 -1
- package/dist/cjs/math/mean.js +0 -16
- package/dist/cjs/math/mean.js.map +0 -1
- package/dist/cjs/math/median.d.ts +0 -1
- package/dist/cjs/math/median.js +0 -9
- package/dist/cjs/math/median.js.map +0 -1
- package/dist/cjs/math/mod.d.ts +0 -1
- package/dist/cjs/math/mod.js +0 -8
- package/dist/cjs/math/mod.js.map +0 -1
- package/dist/cjs/math/multiply.d.ts +0 -1
- package/dist/cjs/math/multiply.js +0 -7
- package/dist/cjs/math/multiply.js.map +0 -1
- package/dist/cjs/math/percentile.d.ts +0 -2
- package/dist/cjs/math/percentile.js +0 -49
- package/dist/cjs/math/percentile.js.map +0 -1
- package/dist/cjs/math/pow.d.ts +0 -1
- package/dist/cjs/math/pow.js +0 -8
- package/dist/cjs/math/pow.js.map +0 -1
- package/dist/cjs/math/round.d.ts +0 -2
- package/dist/cjs/math/round.js +0 -15
- package/dist/cjs/math/round.js.map +0 -1
- package/dist/cjs/math/subtract.d.ts +0 -1
- package/dist/cjs/math/subtract.js +0 -6
- package/dist/cjs/math/subtract.js.map +0 -1
- package/dist/cjs/math/sum.d.ts +0 -1
- package/dist/cjs/math/sum.js +0 -8
- package/dist/cjs/math/sum.js.map +0 -1
- package/dist/cjs/math/types.d.ts +0 -4
- package/dist/cjs/math/types.js +0 -3
- package/dist/cjs/math/types.js.map +0 -1
- package/dist/cjs/obj/copy.d.ts +0 -1
- package/dist/cjs/obj/copy.js +0 -16
- package/dist/cjs/obj/copy.js.map +0 -1
- package/dist/cjs/obj/entries.d.ts +0 -2
- package/dist/cjs/obj/entries.js +0 -5
- package/dist/cjs/obj/entries.js.map +0 -1
- package/dist/cjs/obj/equal.d.ts +0 -1
- package/dist/cjs/obj/equal.js +0 -30
- package/dist/cjs/obj/equal.js.map +0 -1
- package/dist/cjs/obj/get.d.ts +0 -1
- package/dist/cjs/obj/get.js +0 -19
- package/dist/cjs/obj/get.js.map +0 -1
- package/dist/cjs/obj/has.d.ts +0 -1
- package/dist/cjs/obj/has.js +0 -8
- package/dist/cjs/obj/has.js.map +0 -1
- package/dist/cjs/obj/index.d.ts +0 -11
- package/dist/cjs/obj/index.js +0 -28
- package/dist/cjs/obj/index.js.map +0 -1
- package/dist/cjs/obj/isObj.d.ts +0 -1
- package/dist/cjs/obj/isObj.js +0 -8
- package/dist/cjs/obj/isObj.js.map +0 -1
- package/dist/cjs/obj/keys.d.ts +0 -2
- package/dist/cjs/obj/keys.js +0 -5
- package/dist/cjs/obj/keys.js.map +0 -1
- package/dist/cjs/obj/merge.d.ts +0 -1
- package/dist/cjs/obj/merge.js +0 -9
- package/dist/cjs/obj/merge.js.map +0 -1
- package/dist/cjs/obj/omit.d.ts +0 -1
- package/dist/cjs/obj/omit.js +0 -13
- package/dist/cjs/obj/omit.js.map +0 -1
- package/dist/cjs/obj/pick.d.ts +0 -1
- package/dist/cjs/obj/pick.js +0 -13
- package/dist/cjs/obj/pick.js.map +0 -1
- package/dist/cjs/obj/types.d.ts +0 -4
- package/dist/cjs/obj/types.js +0 -3
- package/dist/cjs/obj/types.js.map +0 -1
- package/dist/cjs/obj/vals.d.ts +0 -2
- package/dist/cjs/obj/vals.js +0 -5
- package/dist/cjs/obj/vals.js.map +0 -1
- package/dist/cjs/time/index.d.ts +0 -16
- package/dist/cjs/time/index.js +0 -59
- package/dist/cjs/time/index.js.map +0 -1
- package/dist/cjs/time/types.d.ts +0 -4
- package/dist/cjs/time/types.js +0 -3
- package/dist/cjs/time/types.js.map +0 -1
- package/dist/cjs/types/index.d.ts +0 -1
- package/dist/cjs/types/index.js +0 -18
- package/dist/cjs/types/index.js.map +0 -1
- package/dist/cjs/types/primitives.d.ts +0 -4
- package/dist/cjs/types/primitives.js +0 -3
- package/dist/cjs/types/primitives.js.map +0 -1
- package/dist/esm/arr/chunk.d.ts +0 -1
- package/dist/esm/arr/chunk.js +0 -8
- package/dist/esm/arr/chunk.js.map +0 -1
- package/dist/esm/arr/fill.d.ts +0 -1
- package/dist/esm/arr/fill.js +0 -5
- package/dist/esm/arr/fill.js.map +0 -1
- package/dist/esm/arr/find.d.ts +0 -2
- package/dist/esm/arr/find.js +0 -5
- package/dist/esm/arr/find.js.map +0 -1
- package/dist/esm/arr/findAll.d.ts +0 -2
- package/dist/esm/arr/findAll.js +0 -5
- package/dist/esm/arr/findAll.js.map +0 -1
- package/dist/esm/arr/findAllIdx.d.ts +0 -2
- package/dist/esm/arr/findAllIdx.js +0 -13
- package/dist/esm/arr/findAllIdx.js.map +0 -1
- package/dist/esm/arr/findIdx.d.ts +0 -2
- package/dist/esm/arr/findIdx.js +0 -9
- package/dist/esm/arr/findIdx.js.map +0 -1
- package/dist/esm/arr/from.d.ts +0 -1
- package/dist/esm/arr/from.js +0 -9
- package/dist/esm/arr/from.js.map +0 -1
- package/dist/esm/arr/group.d.ts +0 -1
- package/dist/esm/arr/group.js +0 -12
- package/dist/esm/arr/group.js.map +0 -1
- package/dist/esm/arr/groupBy.d.ts +0 -1
- package/dist/esm/arr/groupBy.js +0 -5
- package/dist/esm/arr/groupBy.js.map +0 -1
- package/dist/esm/arr/index.d.ts +0 -17
- package/dist/esm/arr/index.js +0 -18
- package/dist/esm/arr/index.js.map +0 -1
- package/dist/esm/arr/max.d.ts +0 -1
- package/dist/esm/arr/max.js +0 -11
- package/dist/esm/arr/max.js.map +0 -1
- package/dist/esm/arr/min.d.ts +0 -1
- package/dist/esm/arr/min.js +0 -5
- package/dist/esm/arr/min.js.map +0 -1
- package/dist/esm/arr/range.d.ts +0 -1
- package/dist/esm/arr/range.js +0 -9
- package/dist/esm/arr/range.js.map +0 -1
- package/dist/esm/arr/sort.d.ts +0 -1
- package/dist/esm/arr/sort.js +0 -17
- package/dist/esm/arr/sort.js.map +0 -1
- package/dist/esm/arr/transpose.d.ts +0 -2
- package/dist/esm/arr/transpose.js +0 -8
- package/dist/esm/arr/transpose.js.map +0 -1
- package/dist/esm/arr/types.d.ts +0 -11
- package/dist/esm/arr/types.js +0 -2
- package/dist/esm/arr/types.js.map +0 -1
- package/dist/esm/arr/union.d.ts +0 -1
- package/dist/esm/arr/union.js +0 -5
- package/dist/esm/arr/union.js.map +0 -1
- package/dist/esm/arr/unique.d.ts +0 -2
- package/dist/esm/arr/unique.js +0 -6
- package/dist/esm/arr/unique.js.map +0 -1
- package/dist/esm/arr/zip.d.ts +0 -1
- package/dist/esm/arr/zip.js +0 -4
- package/dist/esm/arr/zip.js.map +0 -1
- package/dist/esm/func/apply.d.ts +0 -1
- package/dist/esm/func/apply.js +0 -4
- package/dist/esm/func/apply.js.map +0 -1
- package/dist/esm/func/curry.d.ts +0 -2
- package/dist/esm/func/curry.js +0 -13
- package/dist/esm/func/curry.js.map +0 -1
- package/dist/esm/func/debounce.d.ts +0 -1
- package/dist/esm/func/debounce.js +0 -11
- package/dist/esm/func/debounce.js.map +0 -1
- package/dist/esm/func/index.d.ts +0 -6
- package/dist/esm/func/index.js +0 -7
- package/dist/esm/func/index.js.map +0 -1
- package/dist/esm/func/memo.d.ts +0 -2
- package/dist/esm/func/memo.js +0 -18
- package/dist/esm/func/memo.js.map +0 -1
- package/dist/esm/func/throttle.d.ts +0 -1
- package/dist/esm/func/throttle.js +0 -15
- package/dist/esm/func/throttle.js.map +0 -1
- package/dist/esm/func/types.d.ts +0 -8
- package/dist/esm/func/types.js +0 -2
- package/dist/esm/func/types.js.map +0 -1
- package/dist/esm/func/unapply.d.ts +0 -1
- package/dist/esm/func/unapply.js +0 -4
- package/dist/esm/func/unapply.js.map +0 -1
- package/dist/esm/index.d.ts +0 -13
- package/dist/esm/index.js +0 -14
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/math/add.d.ts +0 -1
- package/dist/esm/math/add.js +0 -5
- package/dist/esm/math/add.js.map +0 -1
- package/dist/esm/math/aprox.d.ts +0 -1
- package/dist/esm/math/aprox.js +0 -5
- package/dist/esm/math/aprox.js.map +0 -1
- package/dist/esm/math/calc.d.ts +0 -5
- package/dist/esm/math/calc.js +0 -19
- package/dist/esm/math/calc.js.map +0 -1
- package/dist/esm/math/cumsum.d.ts +0 -1
- package/dist/esm/math/cumsum.js +0 -9
- package/dist/esm/math/cumsum.js.map +0 -1
- package/dist/esm/math/divide.d.ts +0 -1
- package/dist/esm/math/divide.js +0 -3
- package/dist/esm/math/divide.js.map +0 -1
- package/dist/esm/math/inRange.d.ts +0 -1
- package/dist/esm/math/inRange.js +0 -7
- package/dist/esm/math/inRange.js.map +0 -1
- package/dist/esm/math/index.d.ts +0 -16
- package/dist/esm/math/index.js +0 -17
- package/dist/esm/math/index.js.map +0 -1
- package/dist/esm/math/interp.d.ts +0 -1
- package/dist/esm/math/interp.js +0 -18
- package/dist/esm/math/interp.js.map +0 -1
- package/dist/esm/math/mean.d.ts +0 -1
- package/dist/esm/math/mean.js +0 -12
- package/dist/esm/math/mean.js.map +0 -1
- package/dist/esm/math/median.d.ts +0 -1
- package/dist/esm/math/median.js +0 -5
- package/dist/esm/math/median.js.map +0 -1
- package/dist/esm/math/mod.d.ts +0 -1
- package/dist/esm/math/mod.js +0 -4
- package/dist/esm/math/mod.js.map +0 -1
- package/dist/esm/math/multiply.d.ts +0 -1
- package/dist/esm/math/multiply.js +0 -4
- package/dist/esm/math/multiply.js.map +0 -1
- package/dist/esm/math/percentile.d.ts +0 -2
- package/dist/esm/math/percentile.js +0 -45
- package/dist/esm/math/percentile.js.map +0 -1
- package/dist/esm/math/pow.d.ts +0 -1
- package/dist/esm/math/pow.js +0 -4
- package/dist/esm/math/pow.js.map +0 -1
- package/dist/esm/math/round.d.ts +0 -2
- package/dist/esm/math/round.js +0 -11
- package/dist/esm/math/round.js.map +0 -1
- package/dist/esm/math/subtract.d.ts +0 -1
- package/dist/esm/math/subtract.js +0 -3
- package/dist/esm/math/subtract.js.map +0 -1
- package/dist/esm/math/sum.d.ts +0 -1
- package/dist/esm/math/sum.js +0 -4
- package/dist/esm/math/sum.js.map +0 -1
- package/dist/esm/math/types.d.ts +0 -4
- package/dist/esm/math/types.js +0 -2
- package/dist/esm/math/types.js.map +0 -1
- package/dist/esm/obj/copy.d.ts +0 -1
- package/dist/esm/obj/copy.js +0 -12
- package/dist/esm/obj/copy.js.map +0 -1
- package/dist/esm/obj/entries.d.ts +0 -2
- package/dist/esm/obj/entries.js +0 -2
- package/dist/esm/obj/entries.js.map +0 -1
- package/dist/esm/obj/equal.d.ts +0 -1
- package/dist/esm/obj/equal.js +0 -27
- package/dist/esm/obj/equal.js.map +0 -1
- package/dist/esm/obj/get.d.ts +0 -1
- package/dist/esm/obj/get.js +0 -15
- package/dist/esm/obj/get.js.map +0 -1
- package/dist/esm/obj/has.d.ts +0 -1
- package/dist/esm/obj/has.js +0 -4
- package/dist/esm/obj/has.js.map +0 -1
- package/dist/esm/obj/index.d.ts +0 -11
- package/dist/esm/obj/index.js +0 -12
- package/dist/esm/obj/index.js.map +0 -1
- package/dist/esm/obj/isObj.d.ts +0 -1
- package/dist/esm/obj/isObj.js +0 -4
- package/dist/esm/obj/isObj.js.map +0 -1
- package/dist/esm/obj/keys.d.ts +0 -2
- package/dist/esm/obj/keys.js +0 -2
- package/dist/esm/obj/keys.js.map +0 -1
- package/dist/esm/obj/merge.d.ts +0 -1
- package/dist/esm/obj/merge.js +0 -5
- package/dist/esm/obj/merge.js.map +0 -1
- package/dist/esm/obj/omit.d.ts +0 -1
- package/dist/esm/obj/omit.js +0 -9
- package/dist/esm/obj/omit.js.map +0 -1
- package/dist/esm/obj/pick.d.ts +0 -1
- package/dist/esm/obj/pick.js +0 -9
- package/dist/esm/obj/pick.js.map +0 -1
- package/dist/esm/obj/types.d.ts +0 -4
- package/dist/esm/obj/types.js +0 -2
- package/dist/esm/obj/types.js.map +0 -1
- package/dist/esm/obj/vals.d.ts +0 -2
- package/dist/esm/obj/vals.js +0 -2
- package/dist/esm/obj/vals.js.map +0 -1
- package/dist/esm/time/index.d.ts +0 -16
- package/dist/esm/time/index.js +0 -55
- package/dist/esm/time/index.js.map +0 -1
- package/dist/esm/time/types.d.ts +0 -4
- package/dist/esm/time/types.js +0 -2
- package/dist/esm/time/types.js.map +0 -1
- package/dist/esm/types/index.d.ts +0 -1
- package/dist/esm/types/index.js +0 -2
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/primitives.d.ts +0 -4
- package/dist/esm/types/primitives.js +0 -2
- package/dist/esm/types/primitives.js.map +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binary search for insertion index in a sorted array using a custom accessor
|
|
3
|
+
* @param arr Sorted array to search
|
|
4
|
+
* @param target Value to search for
|
|
5
|
+
* @param getVal Function to extract comparison value from each element
|
|
6
|
+
* @param start Start index (inclusive)
|
|
7
|
+
* @param end End index (exclusive)
|
|
8
|
+
* @returns Index to insert target to maintain order
|
|
9
|
+
*/
|
|
10
|
+
declare const binSearch: <T>(arr: T[], target: number, getVal: (el: T) => number, start?: number, end?: number) => number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Splits an array into multiple chunks of a specified size
|
|
14
|
+
* @param arr Array to split
|
|
15
|
+
* @param size Size of each chunk
|
|
16
|
+
* @returns Array of chunks
|
|
17
|
+
*/
|
|
18
|
+
declare const chunk: <T>(arr: T[], size: number) => T[][];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Creates array of size `n` filled with the specified value
|
|
22
|
+
* @param n Array size
|
|
23
|
+
* @param val Value to fill the array with
|
|
24
|
+
* @returns Array containing `val` repeated `n` times
|
|
25
|
+
*/
|
|
26
|
+
declare const fill: <T>(n: number, val: T) => T[];
|
|
27
|
+
|
|
28
|
+
type Predicate<T, R = boolean> = (val: T, idx: number, arr: T[]) => R;
|
|
29
|
+
type Transpose<T extends unknown[][]> = T[number] extends infer U ? {
|
|
30
|
+
[K in keyof U]: {
|
|
31
|
+
[J in keyof T]: T[J][K & keyof T[J]];
|
|
32
|
+
};
|
|
33
|
+
} : never;
|
|
34
|
+
type Tuple<T, N extends number, R extends T[] = []> = R["length"] extends N ? R : Tuple<T, N, [...R, T]>;
|
|
35
|
+
type ConvertTuple<T extends unknown[], ToType> = {
|
|
36
|
+
[K in keyof T]: ToType;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Finds the first element that matches the given predicate
|
|
41
|
+
* @param arr Array to search
|
|
42
|
+
* @param predicate Function to test each element
|
|
43
|
+
* @param from Start index (inclusive). Default: 0
|
|
44
|
+
* @param to End index (exclusive). Default: arr.length
|
|
45
|
+
* @returns First matching element, or undefined if none found
|
|
46
|
+
*/
|
|
47
|
+
declare const find: <T>(arr: T[], predicate: Predicate<T, boolean>, from?: number, to?: number) => T | undefined;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Finds the index of the first element that matches the given predicate
|
|
51
|
+
* @param arr Array to search
|
|
52
|
+
* @param predicate Function to test each element
|
|
53
|
+
* @param from Start index (inclusive). Default: 0
|
|
54
|
+
* @param to End index (exclusive). Default: arr.length
|
|
55
|
+
* @returns Index of the first matching element, or -1 if none found
|
|
56
|
+
*/
|
|
57
|
+
declare const findIdx: <T>(arr: T[], predicate: Predicate<T, boolean>, from?: number, to?: number) => number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Finds all elements that match the given predicate
|
|
61
|
+
* @param arr Array to search
|
|
62
|
+
* @param predicate Function to test each element
|
|
63
|
+
* @param from Start index (inclusive). Default: 0
|
|
64
|
+
* @param to End index (exclusive). Default: arr.length
|
|
65
|
+
* @param limit Maximum number of matches to return. Default: arr.length
|
|
66
|
+
* @returns Array of matching elements
|
|
67
|
+
*/
|
|
68
|
+
declare const findAll: <T>(arr: T[], predicate: Predicate<T, boolean>, from?: number, to?: number, limit?: number) => T[];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Finds indices of all elements that match the given predicate
|
|
72
|
+
* @param arr Array to search
|
|
73
|
+
* @param predicate Function to test each element
|
|
74
|
+
* @param from Start index (inclusive). Default: 0
|
|
75
|
+
* @param to End index (exclusive). Default: arr.length
|
|
76
|
+
* @param limit Maximum number of indices to return. Default: arr.length
|
|
77
|
+
* @returns Array of matching indices
|
|
78
|
+
*/
|
|
79
|
+
declare const findAllIdx: <T>(arr: T[], predicate: Predicate<T, boolean>, from?: number, to?: number, limit?: number) => number[];
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Creates an array of size `n`, filling each element using the map function
|
|
83
|
+
* @param n Size of the array to create
|
|
84
|
+
* @param mapFn Function that maps each index to an array element
|
|
85
|
+
* @returns Array of mapped values
|
|
86
|
+
*/
|
|
87
|
+
declare const from: <T>(n: number, mapFn: (i: number) => T) => T[];
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Groups array items into an object by a key
|
|
91
|
+
* @param arr Array to group
|
|
92
|
+
* @param getKey Function to extract the group key from each item
|
|
93
|
+
* @returns Object with keys as group ids and values as arrays of grouped items
|
|
94
|
+
*/
|
|
95
|
+
declare const group: <T, K extends PropertyKey>(arr: T[], getKey: (obj: T) => K) => Record<K, T[]>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use `group` instead
|
|
99
|
+
*/
|
|
100
|
+
declare const groupBy: <T extends object, K extends keyof T>(arr: T[], key: T[K] extends PropertyKey ? K : never) => Record<PropertyKey & T[K], T[]>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns the element with the maximum value based on the provided map function
|
|
104
|
+
* @param arr Array to search
|
|
105
|
+
* @param fn Function to extract the value for comparison
|
|
106
|
+
* @returns Element with the maximum value
|
|
107
|
+
*/
|
|
108
|
+
declare const max: <T>(arr: T[], fn: (val: T) => number) => T;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Returns the element with the minimum value based on the provided map function
|
|
112
|
+
* @param arr Array to search
|
|
113
|
+
* @param fn Function to extract the value for comparison
|
|
114
|
+
* @returns Element with the minimum value
|
|
115
|
+
*/
|
|
116
|
+
declare const min: <T>(arr: T[], fn: (val: T) => number) => T;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Creates an array of numbers from `a` up to `b` incremented by `step`
|
|
120
|
+
* @param a Start of the range (inclusive)
|
|
121
|
+
* @param b End of the range (exclusive)
|
|
122
|
+
* @param step Step between elements (default is 1)
|
|
123
|
+
* @returns Array of numbers in the specified range
|
|
124
|
+
*/
|
|
125
|
+
declare const range: (a: number, b: number, step?: number) => number[];
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Sorts an array in-place based on a mapping function
|
|
129
|
+
* @param arr Array to sort
|
|
130
|
+
* @param mapFn Function to map each element to a sortable value
|
|
131
|
+
* @returns Sorted array in-place
|
|
132
|
+
*/
|
|
133
|
+
declare const sort: <T>(arr: T[], mapFn: (el: T) => number | string) => T[];
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Transposes a 2D array (matrix), switching its rows and columns
|
|
137
|
+
* @param matrix The 2D array to transpose
|
|
138
|
+
* @returns Transposed matrix
|
|
139
|
+
*/
|
|
140
|
+
declare const transpose: <T extends unknown[][]>(matrix: T) => Transpose<T>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Creates a set containing unique values from all provided arrays
|
|
144
|
+
* @param arrs Arrays to union
|
|
145
|
+
* @returns Set of unique values
|
|
146
|
+
*/
|
|
147
|
+
declare const union: <T>(...arrs: T[][]) => Set<T>;
|
|
148
|
+
|
|
149
|
+
type Literal = boolean | number | string;
|
|
150
|
+
type Nullish = null | undefined;
|
|
151
|
+
type Primitive = Literal | bigint | symbol;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Creates array of unique values from the input array, preserving their order
|
|
155
|
+
* @param arr Array of primitive values
|
|
156
|
+
* @returns Array of unique values
|
|
157
|
+
*/
|
|
158
|
+
declare const unique: <T extends Primitive>(arr: T[]) => T[];
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Creates an array of grouped elements, where each group contains the elements
|
|
162
|
+
* at the corresponding index from the input arrays
|
|
163
|
+
* @param arrays Arrays to process
|
|
164
|
+
* @returns Array of grouped elements
|
|
165
|
+
*/
|
|
166
|
+
declare const zip: <T extends unknown[][]>(...args: T) => Transpose<T>;
|
|
167
|
+
|
|
168
|
+
declare const index$5_binSearch: typeof binSearch;
|
|
169
|
+
declare const index$5_chunk: typeof chunk;
|
|
170
|
+
declare const index$5_fill: typeof fill;
|
|
171
|
+
declare const index$5_find: typeof find;
|
|
172
|
+
declare const index$5_findAll: typeof findAll;
|
|
173
|
+
declare const index$5_findAllIdx: typeof findAllIdx;
|
|
174
|
+
declare const index$5_findIdx: typeof findIdx;
|
|
175
|
+
declare const index$5_from: typeof from;
|
|
176
|
+
declare const index$5_group: typeof group;
|
|
177
|
+
declare const index$5_groupBy: typeof groupBy;
|
|
178
|
+
declare const index$5_max: typeof max;
|
|
179
|
+
declare const index$5_min: typeof min;
|
|
180
|
+
declare const index$5_range: typeof range;
|
|
181
|
+
declare const index$5_sort: typeof sort;
|
|
182
|
+
declare const index$5_transpose: typeof transpose;
|
|
183
|
+
declare const index$5_union: typeof union;
|
|
184
|
+
declare const index$5_unique: typeof unique;
|
|
185
|
+
declare const index$5_zip: typeof zip;
|
|
186
|
+
declare namespace index$5 {
|
|
187
|
+
export {
|
|
188
|
+
index$5_binSearch as binSearch,
|
|
189
|
+
index$5_chunk as chunk,
|
|
190
|
+
index$5_fill as fill,
|
|
191
|
+
index$5_find as find,
|
|
192
|
+
index$5_findAll as findAll,
|
|
193
|
+
index$5_findAllIdx as findAllIdx,
|
|
194
|
+
index$5_findIdx as findIdx,
|
|
195
|
+
index$5_from as from,
|
|
196
|
+
index$5_group as group,
|
|
197
|
+
index$5_groupBy as groupBy,
|
|
198
|
+
index$5_max as max,
|
|
199
|
+
index$5_min as min,
|
|
200
|
+
index$5_range as range,
|
|
201
|
+
index$5_sort as sort,
|
|
202
|
+
index$5_transpose as transpose,
|
|
203
|
+
index$5_union as union,
|
|
204
|
+
index$5_unique as unique,
|
|
205
|
+
index$5_zip as zip,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Transforms a function with spread arguments into one with array argument
|
|
211
|
+
* @param fn Function accepting spread arguments
|
|
212
|
+
* @returns Function accepting an array of arguments
|
|
213
|
+
*/
|
|
214
|
+
declare const apply: <T extends unknown[], R>(fn: (...args: T) => R) => (arg: T) => R;
|
|
215
|
+
|
|
216
|
+
type UnaryFn = (arg: any) => unknown;
|
|
217
|
+
type CurryArgs<T extends unknown[]> = T extends [...infer Ti, unknown] ? CurryArgs<Ti> | T : [];
|
|
218
|
+
type CurryRest<T extends unknown[], A extends CurryArgs<T>> = T extends [
|
|
219
|
+
unknown,
|
|
220
|
+
...infer Ti
|
|
221
|
+
] ? A extends [unknown, ...infer Ai extends CurryArgs<Ti>] ? CurryRest<Ti, Ai> : T : [];
|
|
222
|
+
type CurryFnRes<R, T extends unknown[], A extends CurryArgs<T>> = CurryRest<T, A> extends [] ? R : CurryFn<R, CurryRest<T, A>>;
|
|
223
|
+
type CurryFn<R, T extends unknown[]> = <A extends CurryArgs<T>>(...args: A) => CurryFnRes<R, T, A>;
|
|
224
|
+
type FirstFnArg<T> = T extends [(arg: infer A) => unknown, ...unknown[]] ? A : never;
|
|
225
|
+
type LastFnReturn<T> = T extends [...unknown[], (arg: unknown) => infer R] ? R : never;
|
|
226
|
+
type PipedFn<T extends UnaryFn[]> = (arg: FirstFnArg<T>) => LastFnReturn<T>;
|
|
227
|
+
type PipeOps<T extends UnaryFn[] = UnaryFn[]> = T extends [
|
|
228
|
+
infer F1 extends UnaryFn,
|
|
229
|
+
infer F2 extends UnaryFn,
|
|
230
|
+
...infer Rest extends UnaryFn[]
|
|
231
|
+
] ? F2 extends (arg: ReturnType<F1>) => unknown ? [F1, ...PipeOps<[F2, ...Rest]>] : [] : T extends [UnaryFn] ? T : [];
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Creates a curried version of a function, allowing partial application of arguments
|
|
235
|
+
* @param fn Function to curry
|
|
236
|
+
* @param arity Number of arguments the function expects. Default: fn.length
|
|
237
|
+
* @returns Curried function
|
|
238
|
+
*/
|
|
239
|
+
declare const curry: <R, T extends unknown[]>(fn: (...args: T) => R, arity?: number) => CurryFn<R, T>;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Creates a debounced version of a function that delays invoking until after the specified delay.
|
|
243
|
+
* Only the last call within the delay period is executed
|
|
244
|
+
* @param fn Function to debounce
|
|
245
|
+
* @param delay Delay in milliseconds. Default: 100
|
|
246
|
+
* @returns Debounced function
|
|
247
|
+
*/
|
|
248
|
+
declare const debounce: <A extends unknown[]>(fn: (...args: A) => void, delay?: number) => (...args: A) => void;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Returns the input value unchanged
|
|
252
|
+
* @param value Value to return
|
|
253
|
+
* @returns Same value provided as input
|
|
254
|
+
*/
|
|
255
|
+
declare const identity: <T>(x: T) => T;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Creates a memoized version of a function, caching its output for faster repeated calls.
|
|
259
|
+
* Optionally accepts a custom cache key generator and a TTL (time-to-live) in milliseconds
|
|
260
|
+
* @param fn Function to memoize
|
|
261
|
+
* @param idFn Function to generate a cache key from arguments. Default: JSON.stringify
|
|
262
|
+
* @param ttl Optional cache expiration time in milliseconds. Default: 0 (no expiration)
|
|
263
|
+
* @returns Memoized function
|
|
264
|
+
*/
|
|
265
|
+
declare const memo: <T extends unknown[], R>(fn: (...args: T) => R, idFn?: (arg: T) => Primitive, ttl?: number) => (...args: T) => R;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Ensures the provided function is executed only once
|
|
269
|
+
* Subsequent calls return the result of the first execution
|
|
270
|
+
* @param fn Function to execute only once
|
|
271
|
+
* @returns Function that invokes `fn` only once
|
|
272
|
+
*/
|
|
273
|
+
declare const once: <T>(fn: () => T) => () => T;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Creates a function by composing multiple unary functions from left to right.
|
|
277
|
+
* The output of each function is passed as the input to the next
|
|
278
|
+
* @param fns Sequence of unary functions to compose
|
|
279
|
+
* @returns Composed function from left to right
|
|
280
|
+
*/
|
|
281
|
+
declare const pipe: <T extends UnaryFn[]>(...fns: PipeOps<T>) => PipedFn<T>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Creates a throttled version of the given function that only executes once per specified interval
|
|
285
|
+
* @param fn Function to throttle
|
|
286
|
+
* @param interval Minimum time (ms) between calls. Default: 100
|
|
287
|
+
* @returns Throttled function
|
|
288
|
+
*/
|
|
289
|
+
declare const throttle: <A extends unknown[]>(fn: (...args: A) => void, interval?: number) => (...args: A) => void;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Transforms a function with array argument into one with spread arguments
|
|
293
|
+
* @param fn Function accepting an array of arguments
|
|
294
|
+
* @returns Function accepting spread arguments
|
|
295
|
+
*/
|
|
296
|
+
declare const unapply: <T extends unknown[], R>(fn: (arg: T) => R) => (...args: T) => R;
|
|
297
|
+
|
|
298
|
+
declare const index$4_apply: typeof apply;
|
|
299
|
+
declare const index$4_curry: typeof curry;
|
|
300
|
+
declare const index$4_debounce: typeof debounce;
|
|
301
|
+
declare const index$4_identity: typeof identity;
|
|
302
|
+
declare const index$4_memo: typeof memo;
|
|
303
|
+
declare const index$4_once: typeof once;
|
|
304
|
+
declare const index$4_pipe: typeof pipe;
|
|
305
|
+
declare const index$4_throttle: typeof throttle;
|
|
306
|
+
declare const index$4_unapply: typeof unapply;
|
|
307
|
+
declare namespace index$4 {
|
|
308
|
+
export {
|
|
309
|
+
index$4_apply as apply,
|
|
310
|
+
index$4_curry as curry,
|
|
311
|
+
index$4_debounce as debounce,
|
|
312
|
+
index$4_identity as identity,
|
|
313
|
+
index$4_memo as memo,
|
|
314
|
+
index$4_once as once,
|
|
315
|
+
index$4_pipe as pipe,
|
|
316
|
+
index$4_throttle as throttle,
|
|
317
|
+
index$4_unapply as unapply,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
type Quantity = number[] | number;
|
|
322
|
+
type QuantityT<T extends Quantity> = T extends number ? number : number[];
|
|
323
|
+
type Calc<A extends Quantity[]> = A extends number[] ? number : number[];
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Calculates the sum of given quantities (vectors or scalars)
|
|
327
|
+
* @param q Quantities to add
|
|
328
|
+
* @returns Sum of the input quantities
|
|
329
|
+
* @example
|
|
330
|
+
* add([-4, 1, 0, 3], 5); // [1, 6, 5, 8]
|
|
331
|
+
* add([1, 2], [3, 4]); // [4, 6]
|
|
332
|
+
*/
|
|
333
|
+
declare const add: <A extends Quantity[]>(...q: A) => Calc<A>;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Compares if two numbers are approximately equal using a custom precision
|
|
337
|
+
* @param a First number to compare
|
|
338
|
+
* @param b Second number to compare
|
|
339
|
+
* @param precision Number of decimal places to consider. Default: 4
|
|
340
|
+
* @returns True if numbers are approximately equal, false otherwise
|
|
341
|
+
*/
|
|
342
|
+
declare const aprox: (a: number, b: number, precision?: number) => boolean;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Creates a function that applies the given operation to any combination of scalars and vectors
|
|
346
|
+
* @template T Tuple or array of numbers for the operation
|
|
347
|
+
* @param opFn Operation function to apply to the inputs
|
|
348
|
+
* @returns Function that takes quantities (scalars or vectors) and returns the calculated result
|
|
349
|
+
* @example
|
|
350
|
+
* const fn = calc((a, b, c) => a * b + c);
|
|
351
|
+
* fn([1, 2], 3, 4); // [7, 10]
|
|
352
|
+
*/
|
|
353
|
+
declare const calc: <T extends number[]>(opFn: (...nums: T) => number) => <A extends ConvertTuple<T, Quantity>>(...q: A) => Calc<A>;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Calculates the cumulative sum of an array of numbers
|
|
357
|
+
* @param arr Array of numbers to sum
|
|
358
|
+
* @returns Array of cumulative sums
|
|
359
|
+
*/
|
|
360
|
+
declare const cumsum: (arr: number[]) => number[];
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Calculates the division of two quantities (vectors or scalars)
|
|
364
|
+
* @param a Dividend(s)
|
|
365
|
+
* @param b Divisor(s)
|
|
366
|
+
* @returns Division of the input quantities
|
|
367
|
+
* @example
|
|
368
|
+
* divide([-4, 1, 0, 3], 2); // [-2, 0.5, 0, 1.5]
|
|
369
|
+
* divide([1, 2], [3, 4]); // [1 / 3, 0.5]
|
|
370
|
+
*/
|
|
371
|
+
declare const divide: <A extends [a: Quantity, b: Quantity]>(...q: A) => Calc<A>;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Calculates the linear interpolation of monotonic increasing points (xp, fp) at given x values
|
|
375
|
+
* @param x Points to interpolate
|
|
376
|
+
* @param xp Known x-coordinates (must be increasing)
|
|
377
|
+
* @param fp Known y-coordinates (must be increasing, same length as xp)
|
|
378
|
+
* @returns Interpolated values at each x
|
|
379
|
+
*/
|
|
380
|
+
declare const interp: (x: number[], xp: number[], fp: number[]) => number[];
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Checks if a number is within a half-open range [a, b)
|
|
384
|
+
* @param n The number to check
|
|
385
|
+
* @param a Start of the range
|
|
386
|
+
* @param b End of the range. Default: 0
|
|
387
|
+
* @returns True if n is in [a, b), false otherwise
|
|
388
|
+
*/
|
|
389
|
+
declare const inRange: (n: number, a: number, b?: number) => boolean;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Calculates the mean (average) of an array of numbers. Supports optional weighted mean
|
|
393
|
+
* @param arr Array of numbers
|
|
394
|
+
* @param weights Optional array of weights
|
|
395
|
+
* @returns Mean of the numbers
|
|
396
|
+
*/
|
|
397
|
+
declare const mean: (arr: number[], weights?: number[]) => number;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Calculates the median of an array of numbers
|
|
401
|
+
* @param arr Array of numbers
|
|
402
|
+
* @param weights Optional array of weights
|
|
403
|
+
* @returns Median value
|
|
404
|
+
*/
|
|
405
|
+
declare const median: (arr: number[], weights?: number[]) => number;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Calculates the modulo of two quantities (vectors or scalars)
|
|
409
|
+
* @param x Dividend(s)
|
|
410
|
+
* @param modulo Divisor(s)
|
|
411
|
+
* @returns Modulo, matching the input shape
|
|
412
|
+
* @example
|
|
413
|
+
* mod(5, 3); // 2
|
|
414
|
+
* mod([2, 3, 4], 3); // [2, 0, 1]
|
|
415
|
+
* mod([4, 5], [2, 3]); // [0, 2]
|
|
416
|
+
*/
|
|
417
|
+
declare const mod: <A extends [x: Quantity, modulo: Quantity]>(...q: A) => Calc<A>;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Calculates the multiplication of given quantities (vectors or scalars)
|
|
421
|
+
* @param q Quantities to multiply
|
|
422
|
+
* @returns Product of the input quantities
|
|
423
|
+
* @example
|
|
424
|
+
* multiply([-4, 1, 0, 3], 3); // => [-12, 3, 0, 9]
|
|
425
|
+
* multiply([1, 2], [3, 4]); // => [3, 8]
|
|
426
|
+
*/
|
|
427
|
+
declare const multiply: <A extends Quantity[]>(...q: A) => Calc<A>;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Calculates the given percentile(s) of an array of numbers
|
|
431
|
+
* Supports both linear interpolation and weighted percentiles
|
|
432
|
+
* @param x Array of numbers
|
|
433
|
+
* @param p Percentile(s) to compute (number or array of numbers, 0–100)
|
|
434
|
+
* @param weights Optional array of weights (same length as x)
|
|
435
|
+
* @returns Computed percentile value(s)
|
|
436
|
+
*/
|
|
437
|
+
declare const percentile: <T extends Quantity>(x: number[], p: T, weights?: number[]) => QuantityT<T>;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Calculates the exponentiation of two quantities (vectors or scalars)
|
|
441
|
+
* @param base Base quantity
|
|
442
|
+
* @param exp Exponent quantity
|
|
443
|
+
* @returns base raised to the power of exp
|
|
444
|
+
*/
|
|
445
|
+
declare const pow: <A extends [base: Quantity, exp: Quantity]>(...q: A) => Calc<A>;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Rounds a quantity (vector or scalar) to the specified number of decimal places
|
|
449
|
+
* @param q Quantity to round
|
|
450
|
+
* @param precision Number of decimal places to round to. Default: 0
|
|
451
|
+
* @returns Rounded quantity
|
|
452
|
+
*/
|
|
453
|
+
declare const round: <T extends Quantity>(q: T, precision?: number) => T;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Calculates the subtraction of two quantities (vectors or scalars)
|
|
457
|
+
* @param a Minuend quantity
|
|
458
|
+
* @param b Subtrahend quantity
|
|
459
|
+
* @returns Subtraction of `b` from `a`
|
|
460
|
+
*/
|
|
461
|
+
declare const subtract: <A extends [a: Quantity, b: Quantity]>(...q: A) => Calc<A>;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Calculates the sum of an array of numbers
|
|
465
|
+
* @param arr Numbers to sum
|
|
466
|
+
* @returns Sum of all numbers in the array
|
|
467
|
+
*/
|
|
468
|
+
declare const sum: (arr: number[]) => number;
|
|
469
|
+
|
|
470
|
+
declare const index$3_add: typeof add;
|
|
471
|
+
declare const index$3_aprox: typeof aprox;
|
|
472
|
+
declare const index$3_calc: typeof calc;
|
|
473
|
+
declare const index$3_cumsum: typeof cumsum;
|
|
474
|
+
declare const index$3_divide: typeof divide;
|
|
475
|
+
declare const index$3_inRange: typeof inRange;
|
|
476
|
+
declare const index$3_interp: typeof interp;
|
|
477
|
+
declare const index$3_mean: typeof mean;
|
|
478
|
+
declare const index$3_median: typeof median;
|
|
479
|
+
declare const index$3_mod: typeof mod;
|
|
480
|
+
declare const index$3_multiply: typeof multiply;
|
|
481
|
+
declare const index$3_percentile: typeof percentile;
|
|
482
|
+
declare const index$3_pow: typeof pow;
|
|
483
|
+
declare const index$3_round: typeof round;
|
|
484
|
+
declare const index$3_subtract: typeof subtract;
|
|
485
|
+
declare const index$3_sum: typeof sum;
|
|
486
|
+
declare namespace index$3 {
|
|
487
|
+
export {
|
|
488
|
+
index$3_add as add,
|
|
489
|
+
index$3_aprox as aprox,
|
|
490
|
+
index$3_calc as calc,
|
|
491
|
+
index$3_cumsum as cumsum,
|
|
492
|
+
index$3_divide as divide,
|
|
493
|
+
index$3_inRange as inRange,
|
|
494
|
+
index$3_interp as interp,
|
|
495
|
+
index$3_mean as mean,
|
|
496
|
+
index$3_median as median,
|
|
497
|
+
index$3_mod as mod,
|
|
498
|
+
index$3_multiply as multiply,
|
|
499
|
+
index$3_percentile as percentile,
|
|
500
|
+
index$3_pow as pow,
|
|
501
|
+
index$3_round as round,
|
|
502
|
+
index$3_subtract as subtract,
|
|
503
|
+
index$3_sum as sum,
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Creates a deep copy of the provided object or array
|
|
509
|
+
* @param obj Object or array to copy
|
|
510
|
+
* @returns Deep copy of the input
|
|
511
|
+
*/
|
|
512
|
+
declare const copy: <T>(obj: T) => T;
|
|
513
|
+
|
|
514
|
+
type Entry<T extends object> = [Key<T>, Val<T>];
|
|
515
|
+
type Key<T extends object> = keyof T;
|
|
516
|
+
type Val<T extends object> = T[keyof T];
|
|
517
|
+
type SetPath<Obj extends object, P extends string, Val> = P extends `${infer K}.${infer Rest}` ? {
|
|
518
|
+
[Key in K | keyof Obj]: Key extends K ? Rest extends [] ? Val : SetPath<Key extends keyof Obj ? Obj[Key] extends object ? Obj[Key] : object : object, Rest, Val> : Key extends keyof Obj ? Obj[Key] : never;
|
|
519
|
+
} : Obj;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Retrieves a strongly-typed array of the entries (key, value) of an object
|
|
523
|
+
* @param obj Object whose entries are to be retrieved
|
|
524
|
+
* @returns Array of key-value pairs from the object
|
|
525
|
+
*/
|
|
526
|
+
declare const entries: <T extends object>(obj: T) => Entry<T>[];
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Performs a deep comparison between multiple objects to determine if they are equal
|
|
530
|
+
* @param objs Objects to compare
|
|
531
|
+
* @returns True if all objects are deeply equal, false otherwise
|
|
532
|
+
*/
|
|
533
|
+
declare const equal: (...args: unknown[]) => boolean;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Gets a value at a nested path of an object or array
|
|
537
|
+
* @param obj Source object
|
|
538
|
+
* @param path Dot-separated path string
|
|
539
|
+
* @param fallback Value to return if the path is not found
|
|
540
|
+
* @returns Value at the specified path or the fallback
|
|
541
|
+
*/
|
|
542
|
+
declare const get: <T>(obj: object, path: string, fallback?: T | undefined) => T;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Checks if an object has all specified properties
|
|
546
|
+
* @param obj Object to check
|
|
547
|
+
* @param keys Property keys to look for
|
|
548
|
+
* @returns True if all keys exist on the object, false otherwise
|
|
549
|
+
*/
|
|
550
|
+
declare const has: <K extends PropertyKey>(obj: object, ...keys: K[]) => obj is Record<K, unknown>;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Checks if the provided value is a non-null object
|
|
554
|
+
* @param el Value to check
|
|
555
|
+
* @returns True if `el` is a non-null object, otherwise false
|
|
556
|
+
*/
|
|
557
|
+
declare const isObj: (el: unknown) => el is object;
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Retrieves a strongly-typed array of the keys of an object
|
|
561
|
+
* @param obj Object whose keys are to be retrieved
|
|
562
|
+
* @returns Array of the object's keys
|
|
563
|
+
*/
|
|
564
|
+
declare const keys: <T extends object>(obj: T) => Key<T>[];
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Creates a strongly-typed object from the shallow merge of deep copies of two objects
|
|
568
|
+
* If both objects have the same property, the value from the second object overwrites the first
|
|
569
|
+
* @param a First object to merge
|
|
570
|
+
* @param b Second object to merge
|
|
571
|
+
* @returns The merged object with properties from both a and b
|
|
572
|
+
*/
|
|
573
|
+
declare const merge: <A extends object, B extends object>(a: A, b: B) => A & B;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Creates a deep copy of an object without the specified keys
|
|
577
|
+
* @param obj Source object
|
|
578
|
+
* @param keys Array of keys to omit from the result
|
|
579
|
+
* @returns New object without the specified keys
|
|
580
|
+
*/
|
|
581
|
+
declare const omit: <T, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Creates a deep copy of an object with only the specified keys
|
|
585
|
+
* @param obj Source object
|
|
586
|
+
* @param keys Array of keys to pick from the object
|
|
587
|
+
* @returns New object with only the picked keys
|
|
588
|
+
*/
|
|
589
|
+
declare const pick: <T, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Sets a value at a nested path of an object, creating nested objects if needed
|
|
593
|
+
* @param obj Target object to modify
|
|
594
|
+
* @param path Dot-separated string path where the value should be set
|
|
595
|
+
* @param value Value to set at the specified path
|
|
596
|
+
* @returns Modified object with the value set at the given path
|
|
597
|
+
*/
|
|
598
|
+
declare const set: <T extends object, P extends string, V>(obj: T, path: P, value: V) => SetPath<T, P, V>;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Retrieves a strongly-typed array of the values of an object
|
|
602
|
+
* @param obj Source object
|
|
603
|
+
* @returns Array of the object's values
|
|
604
|
+
*/
|
|
605
|
+
declare const vals: <T extends object>(obj: T) => Val<T>[];
|
|
606
|
+
|
|
607
|
+
declare const index$2_copy: typeof copy;
|
|
608
|
+
declare const index$2_entries: typeof entries;
|
|
609
|
+
declare const index$2_equal: typeof equal;
|
|
610
|
+
declare const index$2_get: typeof get;
|
|
611
|
+
declare const index$2_has: typeof has;
|
|
612
|
+
declare const index$2_isObj: typeof isObj;
|
|
613
|
+
declare const index$2_keys: typeof keys;
|
|
614
|
+
declare const index$2_merge: typeof merge;
|
|
615
|
+
declare const index$2_omit: typeof omit;
|
|
616
|
+
declare const index$2_pick: typeof pick;
|
|
617
|
+
declare const index$2_set: typeof set;
|
|
618
|
+
declare const index$2_vals: typeof vals;
|
|
619
|
+
declare namespace index$2 {
|
|
620
|
+
export {
|
|
621
|
+
index$2_copy as copy,
|
|
622
|
+
index$2_entries as entries,
|
|
623
|
+
index$2_equal as equal,
|
|
624
|
+
index$2_get as get,
|
|
625
|
+
index$2_has as has,
|
|
626
|
+
index$2_isObj as isObj,
|
|
627
|
+
index$2_keys as keys,
|
|
628
|
+
index$2_merge as merge,
|
|
629
|
+
index$2_omit as omit,
|
|
630
|
+
index$2_pick as pick,
|
|
631
|
+
index$2_set as set,
|
|
632
|
+
index$2_vals as vals,
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Returns a random integer between two numbers
|
|
638
|
+
* @param a Lower bound (inclusive)
|
|
639
|
+
* @param b Upper bound (exclusive). Default: 0
|
|
640
|
+
* @returns Random integer between a and b
|
|
641
|
+
*/
|
|
642
|
+
declare const randInt: (a: number, b?: number) => number;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Selects a random index based on the provided weights
|
|
646
|
+
* @param weights Array of non-negative weights
|
|
647
|
+
* @returns Selected index
|
|
648
|
+
*/
|
|
649
|
+
declare const randWeight: (weights: number[]) => number;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Samples elements from an array randomly, optionally using weights to influence selection
|
|
653
|
+
* @param data Array to sample from
|
|
654
|
+
* @param size Number of elements to sample
|
|
655
|
+
* @param weights Optional array of weights for weighted sampling
|
|
656
|
+
* @returns New array containing the sampled elements
|
|
657
|
+
*/
|
|
658
|
+
declare const sample: <T>(data: T[], size: number, weights?: number[] | undefined) => T[];
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Shuffles an array randomly, optionally using weights to influence the
|
|
662
|
+
* likelihood of selecting elements first
|
|
663
|
+
* @param data Array to shuffle
|
|
664
|
+
* @param weights Optional array of weights for weighted shuffling
|
|
665
|
+
* @returns New array with the elements shuffled
|
|
666
|
+
*/
|
|
667
|
+
declare const shuffle: <T>(data: T[], weights?: number[]) => T[];
|
|
668
|
+
|
|
669
|
+
declare const index$1_randInt: typeof randInt;
|
|
670
|
+
declare const index$1_randWeight: typeof randWeight;
|
|
671
|
+
declare const index$1_sample: typeof sample;
|
|
672
|
+
declare const index$1_shuffle: typeof shuffle;
|
|
673
|
+
declare namespace index$1 {
|
|
674
|
+
export {
|
|
675
|
+
index$1_randInt as randInt,
|
|
676
|
+
index$1_randWeight as randWeight,
|
|
677
|
+
index$1_sample as sample,
|
|
678
|
+
index$1_shuffle as shuffle,
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Converts a string to camelCase
|
|
684
|
+
* @param str String to convert
|
|
685
|
+
* @returns camelCase version of the input string
|
|
686
|
+
*/
|
|
687
|
+
declare const camel: (str: string) => string;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Capitalizes the first letter of a string and converts the rest to lowercase
|
|
691
|
+
* @param str String to capitalize
|
|
692
|
+
* @returns Capitalized string
|
|
693
|
+
*/
|
|
694
|
+
declare const capitalize: (str: string) => string;
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Converts a string to kebab-case
|
|
698
|
+
* @param str String to convert
|
|
699
|
+
* @returns kebab-case version of the input string
|
|
700
|
+
*/
|
|
701
|
+
declare const kebab: (str: string) => string;
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Converts a string to PascalCase
|
|
705
|
+
* @param str String to convert
|
|
706
|
+
* @returns PascalCase version of the input string
|
|
707
|
+
*/
|
|
708
|
+
declare const pascal: (str: string) => string;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Converts a string to snake_case
|
|
712
|
+
* @param str String to convert
|
|
713
|
+
* @returns snake_case version of the input string
|
|
714
|
+
*/
|
|
715
|
+
declare const snake: (str: string) => string;
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Replaces placeholders in the format `{{path.to.value}}` within a string
|
|
719
|
+
* with corresponding values from the provided data object
|
|
720
|
+
* @param str String containing placeholders to replace
|
|
721
|
+
* @param data Object with values for the placeholders
|
|
722
|
+
* @returns String with placeholders replaced by their values
|
|
723
|
+
*/
|
|
724
|
+
declare const template: (str: string, data: object) => string;
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Removes leading and trailing whitespace or specified characters from a string
|
|
728
|
+
* @param str String to trim
|
|
729
|
+
* @param chars Optional characters to trim from the string. Default: whitespace
|
|
730
|
+
* @returns Trimmed string
|
|
731
|
+
*/
|
|
732
|
+
declare const trim: (str: string, chars?: string) => string;
|
|
733
|
+
|
|
734
|
+
declare const index_camel: typeof camel;
|
|
735
|
+
declare const index_capitalize: typeof capitalize;
|
|
736
|
+
declare const index_kebab: typeof kebab;
|
|
737
|
+
declare const index_pascal: typeof pascal;
|
|
738
|
+
declare const index_snake: typeof snake;
|
|
739
|
+
declare const index_template: typeof template;
|
|
740
|
+
declare const index_trim: typeof trim;
|
|
741
|
+
declare namespace index {
|
|
742
|
+
export {
|
|
743
|
+
index_camel as camel,
|
|
744
|
+
index_capitalize as capitalize,
|
|
745
|
+
index_kebab as kebab,
|
|
746
|
+
index_pascal as pascal,
|
|
747
|
+
index_snake as snake,
|
|
748
|
+
index_template as template,
|
|
749
|
+
index_trim as trim,
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
type Split<S extends string, D extends string = "."> = S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
|
|
754
|
+
|
|
755
|
+
type TimeFormat = "date" | "full" | "time";
|
|
756
|
+
type TimeFormatOptions = Record<TimeFormat, Intl.DateTimeFormatOptions>;
|
|
757
|
+
type TimeUnit = "d" | "h" | "m" | "ms" | "s";
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* @deprecated Time module is deprecated and may be removed in future releases
|
|
761
|
+
*/
|
|
762
|
+
declare class Time {
|
|
763
|
+
static UNITS: Record<TimeUnit, number>;
|
|
764
|
+
static formatOptions: TimeFormatOptions;
|
|
765
|
+
static locales?: Intl.LocalesArgument;
|
|
766
|
+
private readonly date;
|
|
767
|
+
constructor(val?: number, unit?: TimeUnit);
|
|
768
|
+
static convert(val: number, from: TimeUnit, to?: TimeUnit): number;
|
|
769
|
+
add(val: number, unit?: TimeUnit): number;
|
|
770
|
+
format(mode?: TimeFormat, local?: Intl.LocalesArgument, opts?: Intl.DateTimeFormatOptions): string;
|
|
771
|
+
get(unit?: TimeUnit): number;
|
|
772
|
+
getDayTime(unit?: TimeUnit): number;
|
|
773
|
+
set(val: number, unit?: TimeUnit): number;
|
|
774
|
+
setDayTime(val: number, unit?: TimeUnit): number;
|
|
775
|
+
toDate(): Date;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
export { Time, add, apply, aprox, index$5 as arr, binSearch, calc, camel, capitalize, chunk, copy, cumsum, curry, debounce, divide, entries, equal, fill, find, findAll, findAllIdx, findIdx, from, index$4 as func, get, group, groupBy, has, identity, inRange, interp, isObj, kebab, keys, index$3 as math, max, mean, median, memo, merge, min, mod, multiply, index$2 as obj, omit, once, pascal, percentile, pick, pipe, pow, index$1 as rand, randInt, randWeight, range, round, sample, set, shuffle, snake, sort, index as str, subtract, sum, template, throttle, transpose, trim, unapply, union, unique, vals, zip };
|
|
779
|
+
export type { ConvertTuple, Entry, Key, Literal, Nullish, Predicate, Primitive, SetPath, Split, TimeFormat, TimeFormatOptions, TimeUnit, Transpose, Tuple, Val };
|