@vielzeug/toolkit 1.0.12 → 1.0.14

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.
Files changed (166) hide show
  1. package/dist/array/{sortBy.cjs → arrange.cjs} +2 -2
  2. package/dist/array/arrange.cjs.map +1 -0
  3. package/dist/array/arrange.js +6 -0
  4. package/dist/array/arrange.js.map +1 -0
  5. package/dist/array/chunk.cjs +1 -1
  6. package/dist/array/chunk.cjs.map +1 -1
  7. package/dist/array/chunk.js +15 -12
  8. package/dist/array/chunk.js.map +1 -1
  9. package/dist/array/group.cjs +1 -1
  10. package/dist/array/group.cjs.map +1 -1
  11. package/dist/array/group.js +9 -9
  12. package/dist/array/group.js.map +1 -1
  13. package/dist/array/list.cjs +1 -1
  14. package/dist/array/list.cjs.map +1 -1
  15. package/dist/array/list.js +87 -50
  16. package/dist/array/list.js.map +1 -1
  17. package/dist/array/pick.cjs.map +1 -1
  18. package/dist/array/pick.js.map +1 -1
  19. package/dist/array/remoteList.cjs +2 -0
  20. package/dist/array/remoteList.cjs.map +1 -0
  21. package/dist/array/remoteList.js +123 -0
  22. package/dist/array/remoteList.js.map +1 -0
  23. package/dist/date/expires.cjs.map +1 -1
  24. package/dist/date/expires.js.map +1 -1
  25. package/dist/date/interval.cjs.map +1 -1
  26. package/dist/date/interval.js.map +1 -1
  27. package/dist/date/timeDiff.cjs +1 -1
  28. package/dist/date/timeDiff.cjs.map +1 -1
  29. package/dist/date/timeDiff.js +10 -12
  30. package/dist/date/timeDiff.js.map +1 -1
  31. package/dist/function/curry.cjs +1 -1
  32. package/dist/function/curry.cjs.map +1 -1
  33. package/dist/function/curry.js +3 -3
  34. package/dist/function/curry.js.map +1 -1
  35. package/dist/function/debounce.cjs +1 -1
  36. package/dist/function/debounce.cjs.map +1 -1
  37. package/dist/function/debounce.js +22 -5
  38. package/dist/function/debounce.js.map +1 -1
  39. package/dist/function/memo.cjs +1 -1
  40. package/dist/function/memo.cjs.map +1 -1
  41. package/dist/function/memo.js +14 -13
  42. package/dist/function/memo.js.map +1 -1
  43. package/dist/function/parallel.cjs +2 -0
  44. package/dist/function/parallel.cjs.map +1 -0
  45. package/dist/function/parallel.js +28 -0
  46. package/dist/function/parallel.js.map +1 -0
  47. package/dist/function/proxy.cjs.map +1 -1
  48. package/dist/function/proxy.js.map +1 -1
  49. package/dist/function/prune.cjs +2 -0
  50. package/dist/function/prune.cjs.map +1 -0
  51. package/dist/function/prune.js +30 -0
  52. package/dist/function/prune.js.map +1 -0
  53. package/dist/function/retry.cjs +1 -1
  54. package/dist/function/retry.cjs.map +1 -1
  55. package/dist/function/retry.js +13 -13
  56. package/dist/function/retry.js.map +1 -1
  57. package/dist/function/sleep.cjs +1 -1
  58. package/dist/function/sleep.cjs.map +1 -1
  59. package/dist/function/sleep.js +8 -3
  60. package/dist/function/sleep.js.map +1 -1
  61. package/dist/function/throttle.cjs +1 -1
  62. package/dist/function/throttle.cjs.map +1 -1
  63. package/dist/function/throttle.js +33 -6
  64. package/dist/function/throttle.js.map +1 -1
  65. package/dist/index.cjs +1 -1
  66. package/dist/index.d.ts +455 -95
  67. package/dist/index.js +218 -194
  68. package/dist/index.js.map +1 -1
  69. package/dist/math/abs.cjs +2 -0
  70. package/dist/math/abs.cjs.map +1 -0
  71. package/dist/math/abs.js +7 -0
  72. package/dist/math/abs.js.map +1 -0
  73. package/dist/math/add.cjs +2 -0
  74. package/dist/math/add.cjs.map +1 -0
  75. package/dist/math/add.js +9 -0
  76. package/dist/math/add.js.map +1 -0
  77. package/dist/math/allocate.cjs +2 -0
  78. package/dist/math/allocate.cjs.map +1 -0
  79. package/dist/math/allocate.js +29 -0
  80. package/dist/math/allocate.js.map +1 -0
  81. package/dist/math/average.cjs +1 -1
  82. package/dist/math/average.cjs.map +1 -1
  83. package/dist/math/average.js +18 -12
  84. package/dist/math/average.js.map +1 -1
  85. package/dist/math/distribute.cjs +2 -0
  86. package/dist/math/distribute.cjs.map +1 -0
  87. package/dist/math/distribute.js +18 -0
  88. package/dist/math/distribute.js.map +1 -0
  89. package/dist/math/divide.cjs +2 -0
  90. package/dist/math/divide.cjs.map +1 -0
  91. package/dist/math/divide.js +11 -0
  92. package/dist/math/divide.js.map +1 -0
  93. package/dist/math/median.cjs.map +1 -1
  94. package/dist/math/median.js.map +1 -1
  95. package/dist/math/multiply.cjs +2 -0
  96. package/dist/math/multiply.cjs.map +1 -0
  97. package/dist/math/multiply.js +9 -0
  98. package/dist/math/multiply.js.map +1 -0
  99. package/dist/math/range.cjs +1 -1
  100. package/dist/math/range.cjs.map +1 -1
  101. package/dist/math/range.js +14 -6
  102. package/dist/math/range.js.map +1 -1
  103. package/dist/math/subtract.cjs +2 -0
  104. package/dist/math/subtract.cjs.map +1 -0
  105. package/dist/math/subtract.js +9 -0
  106. package/dist/math/subtract.js.map +1 -0
  107. package/dist/math/sum.cjs +1 -1
  108. package/dist/math/sum.cjs.map +1 -1
  109. package/dist/math/sum.js +11 -18
  110. package/dist/math/sum.js.map +1 -1
  111. package/dist/money/currency.cjs +2 -0
  112. package/dist/money/currency.cjs.map +1 -0
  113. package/dist/money/currency.js +49 -0
  114. package/dist/money/currency.js.map +1 -0
  115. package/dist/money/exchange.cjs +2 -0
  116. package/dist/money/exchange.cjs.map +1 -0
  117. package/dist/money/exchange.js +13 -0
  118. package/dist/money/exchange.js.map +1 -0
  119. package/dist/object/clone.cjs +1 -1
  120. package/dist/object/clone.cjs.map +1 -1
  121. package/dist/object/clone.js +13 -3
  122. package/dist/object/clone.js.map +1 -1
  123. package/dist/object/merge.cjs +1 -1
  124. package/dist/object/merge.cjs.map +1 -1
  125. package/dist/object/merge.js +11 -15
  126. package/dist/object/merge.js.map +1 -1
  127. package/dist/object/parseJSON.cjs.map +1 -1
  128. package/dist/object/parseJSON.js.map +1 -1
  129. package/dist/object/path.cjs.map +1 -1
  130. package/dist/object/path.js.map +1 -1
  131. package/dist/object/seek.cjs +1 -1
  132. package/dist/object/seek.cjs.map +1 -1
  133. package/dist/object/seek.js +8 -6
  134. package/dist/object/seek.js.map +1 -1
  135. package/dist/random/uuid.cjs +1 -1
  136. package/dist/random/uuid.cjs.map +1 -1
  137. package/dist/random/uuid.js +6 -3
  138. package/dist/random/uuid.js.map +1 -1
  139. package/dist/string/camelCase.cjs +1 -1
  140. package/dist/string/camelCase.cjs.map +1 -1
  141. package/dist/string/camelCase.js +3 -3
  142. package/dist/string/camelCase.js.map +1 -1
  143. package/dist/string/similarity.cjs +1 -1
  144. package/dist/string/similarity.cjs.map +1 -1
  145. package/dist/string/similarity.js +24 -21
  146. package/dist/string/similarity.js.map +1 -1
  147. package/dist/string/truncate.cjs +1 -1
  148. package/dist/string/truncate.cjs.map +1 -1
  149. package/dist/string/truncate.js +14 -5
  150. package/dist/string/truncate.js.map +1 -1
  151. package/dist/typed/is.cjs +1 -1
  152. package/dist/typed/is.cjs.map +1 -1
  153. package/dist/typed/is.js +30 -31
  154. package/dist/typed/is.js.map +1 -1
  155. package/dist/typed/isEmpty.cjs +1 -1
  156. package/dist/typed/isEmpty.cjs.map +1 -1
  157. package/dist/typed/isEmpty.js +6 -6
  158. package/dist/typed/isEmpty.js.map +1 -1
  159. package/dist/typed/isEqual.cjs +1 -1
  160. package/dist/typed/isEqual.cjs.map +1 -1
  161. package/dist/typed/isEqual.js +22 -17
  162. package/dist/typed/isEqual.js.map +1 -1
  163. package/package.json +1 -1
  164. package/dist/array/sortBy.cjs.map +0 -1
  165. package/dist/array/sortBy.js +0 -6
  166. package/dist/array/sortBy.js.map +0 -1
package/dist/index.js CHANGED
@@ -4,214 +4,238 @@ import { chunk as f } from "./array/chunk.js";
4
4
  import { compact as i } from "./array/compact.js";
5
5
  import { contains as a } from "./array/contains.js";
6
6
  import { every as _ } from "./array/every.js";
7
- import { filter as S } from "./array/filter.js";
8
- import { find as l } from "./array/find.js";
9
- import { findIndex as I } from "./array/findIndex.js";
10
- import { findLast as u } from "./array/findLast.js";
7
+ import { filter as l } from "./array/filter.js";
8
+ import { find as c } from "./array/find.js";
9
+ import { findIndex as d } from "./array/findIndex.js";
10
+ import { findLast as I } from "./array/findLast.js";
11
11
  import { flatten as M } from "./array/flatten.js";
12
- import { group as g } from "./array/group.js";
13
- import { list as N } from "./array/list.js";
14
- import { map as b } from "./array/map.js";
12
+ import { group as y } from "./array/group.js";
13
+ import { list as b } from "./array/list.js";
14
+ import { map as v } from "./array/map.js";
15
15
  import { pick as k } from "./array/pick.js";
16
16
  import { reduce as T } from "./array/reduce.js";
17
- import { search as A } from "./array/search.js";
18
- import { select as D } from "./array/select.js";
19
- import { shift as U } from "./array/shift.js";
20
- import { some as w } from "./array/some.js";
21
- import { sort as J } from "./array/sort.js";
22
- import { sortBy as Y } from "./array/sortBy.js";
23
- import { substitute as H } from "./array/substitute.js";
24
- import { uniq as V } from "./array/uniq.js";
25
- import { expires as z } from "./date/expires.js";
26
- import { interval as X } from "./date/interval.js";
27
- import { timeDiff as rr } from "./date/timeDiff.js";
28
- import { assert as er } from "./function/assert.js";
29
- import { assertParams as mr } from "./function/assertParams.js";
30
- import { attempt as fr } from "./function/attempt.js";
31
- import { compare as ir } from "./function/compare.js";
32
- import { compareBy as ar } from "./function/compareBy.js";
33
- import { compose as _r } from "./function/compose.js";
34
- import { curry as Sr } from "./function/curry.js";
35
- import { debounce as lr } from "./function/debounce.js";
17
+ import { remoteList as A } from "./array/remoteList.js";
18
+ import { search as D } from "./array/search.js";
19
+ import { select as U } from "./array/select.js";
20
+ import { shift as w } from "./array/shift.js";
21
+ import { some as J } from "./array/some.js";
22
+ import { sort as Y } from "./array/sort.js";
23
+ import { arrange as H } from "./array/arrange.js";
24
+ import { substitute as V } from "./array/substitute.js";
25
+ import { uniq as z } from "./array/uniq.js";
26
+ import { expires as X } from "./date/expires.js";
27
+ import { interval as rr } from "./date/interval.js";
28
+ import { timeDiff as er } from "./date/timeDiff.js";
29
+ import { assert as mr } from "./function/assert.js";
30
+ import { assertParams as fr } from "./function/assertParams.js";
31
+ import { attempt as ir } from "./function/attempt.js";
32
+ import { compare as ar } from "./function/compare.js";
33
+ import { compareBy as _r } from "./function/compareBy.js";
34
+ import { compose as lr } from "./function/compose.js";
35
+ import { curry as cr } from "./function/curry.js";
36
+ import { debounce as dr } from "./function/debounce.js";
36
37
  import { delay as Ir } from "./function/delay.js";
37
- import { fp as ur } from "./function/fp.js";
38
- import { memo as Mr } from "./function/memo.js";
39
- import { once as gr } from "./function/once.js";
40
- import { pipe as Nr } from "./function/pipe.js";
41
- import { predict as br } from "./function/predict.js";
42
- import { proxy as kr } from "./function/proxy.js";
43
- import { retry as Tr } from "./function/retry.js";
44
- import { sleep as Ar } from "./function/sleep.js";
45
- import { throttle as Dr } from "./function/throttle.js";
46
- import { worker as Ur } from "./function/worker.js";
47
- import { average as wr } from "./math/average.js";
48
- import { boil as Jr } from "./math/boil.js";
49
- import { clamp as Yr } from "./math/clamp.js";
50
- import { max as Hr } from "./math/max.js";
51
- import { median as Vr } from "./math/median.js";
52
- import { min as zr } from "./math/min.js";
53
- import { range as Xr } from "./math/range.js";
54
- import { rate as ro } from "./math/rate.js";
55
- import { round as eo } from "./math/round.js";
56
- import { sum as mo } from "./math/sum.js";
57
- import { clone as fo } from "./object/clone.js";
58
- import { diff as io } from "./object/diff.js";
59
- import { entries as ao } from "./object/entries.js";
60
- import { keys as _o } from "./object/keys.js";
61
- import { merge as So } from "./object/merge.js";
62
- import { parseJSON as lo } from "./object/parseJSON.js";
63
- import { path as Io } from "./object/path.js";
64
- import { seek as uo } from "./object/seek.js";
65
- import { values as Go } from "./object/values.js";
66
- import { draw as yo } from "./random/draw.js";
67
- import { random as vo } from "./random/random.js";
68
- import { shuffle as ho } from "./random/shuffle.js";
69
- import { uuid as Po } from "./random/uuid.js";
70
- import { camelCase as Co } from "./string/camelCase.js";
71
- import { kebabCase as Bo } from "./string/kebabCase.js";
72
- import { pascalCase as Lo } from "./string/pascalCase.js";
73
- import { similarity as qo } from "./string/similarity.js";
74
- import { snakeCase as Fo } from "./string/snakeCase.js";
75
- import { truncate as Wo } from "./string/truncate.js";
76
- import { ge as jo } from "./typed/ge.js";
77
- import { gt as Qo } from "./typed/gt.js";
78
- import { is as Zo } from "./typed/is.js";
79
- import { IS_ARRAY_ERROR_MSG as Ko, isArray as Xo } from "./typed/isArray.js";
80
- import { isBoolean as re } from "./typed/isBoolean.js";
81
- import { IS_DATE_ERROR_MSG as ee, isDate as te } from "./typed/isDate.js";
82
- import { isDefined as pe } from "./typed/isDefined.js";
83
- import { IS_EMPTY_ERROR_MSG as xe, isEmpty as ie } from "./typed/isEmpty.js";
84
- import { IS_EQUAL_ERROR_MSG as ae, isEqual as Re } from "./typed/isEqual.js";
85
- import { isEven as ne } from "./typed/isEven.js";
86
- import { IS_FUNCTION_ERROR_MSG as ce, isFunction as le } from "./typed/isFunction.js";
87
- import { isNegative as Ie } from "./typed/isNegative.js";
88
- import { IS_NIL_ERROR_MSG as ue, isNil as de } from "./typed/isNil.js";
89
- import { IS_NUMBER_ERROR_MSG as Ge, isNumber as ge } from "./typed/isNumber.js";
90
- import { IS_OBJECT_ERROR_MSG as Ne, isObject as ve } from "./typed/isObject.js";
91
- import { isOdd as he } from "./typed/isOdd.js";
92
- import { isPositive as Pe } from "./typed/isPositive.js";
93
- import { IS_PRIMITIVE_ERROR_MSG as Ce, isPrimitive as Ae } from "./typed/isPrimitive.js";
94
- import { IS_PROMISE_ERROR_MSG as De, isPromise as Le } from "./typed/isPromise.js";
95
- import { isRegex as qe } from "./typed/isRegex.js";
96
- import { IS_STRING_ERROR_MSG as Fe, isString as Je } from "./typed/isString.js";
97
- import { IS_WITHIN_ERROR_MSG as Ye, isWithin as je } from "./typed/isWithin.js";
98
- import { isZero as Qe } from "./typed/isZero.js";
99
- import { le as Ze } from "./typed/le.js";
100
- import { lt as Ke } from "./typed/lt.js";
101
- import { typeOf as $e } from "./typed/typeOf.js";
38
+ import { fp as Mr } from "./function/fp.js";
39
+ import { memo as yr } from "./function/memo.js";
40
+ import { once as br } from "./function/once.js";
41
+ import { parallel as vr } from "./function/parallel.js";
42
+ import { pipe as kr } from "./function/pipe.js";
43
+ import { predict as Tr } from "./function/predict.js";
44
+ import { proxy as Ar } from "./function/proxy.js";
45
+ import { prune as Dr } from "./function/prune.js";
46
+ import { retry as Ur } from "./function/retry.js";
47
+ import { sleep as wr } from "./function/sleep.js";
48
+ import { throttle as Jr } from "./function/throttle.js";
49
+ import { worker as Yr } from "./function/worker.js";
50
+ import { abs as Hr } from "./math/abs.js";
51
+ import { add as Vr } from "./math/add.js";
52
+ import { allocate as zr } from "./math/allocate.js";
53
+ import { average as Xr } from "./math/average.js";
54
+ import { boil as ro } from "./math/boil.js";
55
+ import { clamp as eo } from "./math/clamp.js";
56
+ import { distribute as mo } from "./math/distribute.js";
57
+ import { divide as fo } from "./math/divide.js";
58
+ import { max as io } from "./math/max.js";
59
+ import { median as ao } from "./math/median.js";
60
+ import { min as _o } from "./math/min.js";
61
+ import { multiply as lo } from "./math/multiply.js";
62
+ import { range as co } from "./math/range.js";
63
+ import { rate as Eo } from "./math/rate.js";
64
+ import { round as Oo } from "./math/round.js";
65
+ import { subtract as go } from "./math/subtract.js";
66
+ import { sum as Go } from "./math/sum.js";
67
+ import { currency as No } from "./money/currency.js";
68
+ import { exchange as ho } from "./money/exchange.js";
69
+ import { clone as Po } from "./object/clone.js";
70
+ import { diff as Co } from "./object/diff.js";
71
+ import { entries as Bo } from "./object/entries.js";
72
+ import { keys as Lo } from "./object/keys.js";
73
+ import { merge as qo } from "./object/merge.js";
74
+ import { parseJSON as Fo } from "./object/parseJSON.js";
75
+ import { path as Wo } from "./object/path.js";
76
+ import { seek as jo } from "./object/seek.js";
77
+ import { values as Qo } from "./object/values.js";
78
+ import { draw as Zo } from "./random/draw.js";
79
+ import { random as Ko } from "./random/random.js";
80
+ import { shuffle as $o } from "./random/shuffle.js";
81
+ import { uuid as oe } from "./random/uuid.js";
82
+ import { camelCase as te } from "./string/camelCase.js";
83
+ import { kebabCase as pe } from "./string/kebabCase.js";
84
+ import { pascalCase as xe } from "./string/pascalCase.js";
85
+ import { similarity as se } from "./string/similarity.js";
86
+ import { snakeCase as Re } from "./string/snakeCase.js";
87
+ import { truncate as ne } from "./string/truncate.js";
88
+ import { ge as Se } from "./typed/ge.js";
89
+ import { gt as ue } from "./typed/gt.js";
90
+ import { is as Ee } from "./typed/is.js";
91
+ import { IS_ARRAY_ERROR_MSG as Oe, isArray as Me } from "./typed/isArray.js";
92
+ import { isBoolean as ye } from "./typed/isBoolean.js";
93
+ import { IS_DATE_ERROR_MSG as be, isDate as Ne } from "./typed/isDate.js";
94
+ import { isDefined as he } from "./typed/isDefined.js";
95
+ import { IS_EMPTY_ERROR_MSG as Pe, isEmpty as Te } from "./typed/isEmpty.js";
96
+ import { IS_EQUAL_ERROR_MSG as Ae, isEqual as Be } from "./typed/isEqual.js";
97
+ import { isEven as Le } from "./typed/isEven.js";
98
+ import { IS_FUNCTION_ERROR_MSG as qe, isFunction as we } from "./typed/isFunction.js";
99
+ import { isNegative as Je } from "./typed/isNegative.js";
100
+ import { IS_NIL_ERROR_MSG as Ye, isNil as je } from "./typed/isNil.js";
101
+ import { IS_NUMBER_ERROR_MSG as Qe, isNumber as Ve } from "./typed/isNumber.js";
102
+ import { IS_OBJECT_ERROR_MSG as ze, isObject as Ke } from "./typed/isObject.js";
103
+ import { isOdd as $e } from "./typed/isOdd.js";
104
+ import { isPositive as ot } from "./typed/isPositive.js";
105
+ import { IS_PRIMITIVE_ERROR_MSG as tt, isPrimitive as mt } from "./typed/isPrimitive.js";
106
+ import { IS_PROMISE_ERROR_MSG as ft, isPromise as xt } from "./typed/isPromise.js";
107
+ import { isRegex as st } from "./typed/isRegex.js";
108
+ import { IS_STRING_ERROR_MSG as Rt, isString as _t } from "./typed/isString.js";
109
+ import { IS_WITHIN_ERROR_MSG as lt, isWithin as St } from "./typed/isWithin.js";
110
+ import { isZero as ut } from "./typed/isZero.js";
111
+ import { le as Et } from "./typed/le.js";
112
+ import { lt as Ot } from "./typed/lt.js";
113
+ import { typeOf as gt } from "./typed/typeOf.js";
102
114
  export {
103
- Ko as IS_ARRAY_ERROR_MSG,
104
- ee as IS_DATE_ERROR_MSG,
105
- xe as IS_EMPTY_ERROR_MSG,
106
- ae as IS_EQUAL_ERROR_MSG,
107
- ce as IS_FUNCTION_ERROR_MSG,
108
- ue as IS_NIL_ERROR_MSG,
109
- Ge as IS_NUMBER_ERROR_MSG,
110
- Ne as IS_OBJECT_ERROR_MSG,
111
- Ce as IS_PRIMITIVE_ERROR_MSG,
112
- De as IS_PROMISE_ERROR_MSG,
113
- Fe as IS_STRING_ERROR_MSG,
114
- Ye as IS_WITHIN_ERROR_MSG,
115
+ Oe as IS_ARRAY_ERROR_MSG,
116
+ be as IS_DATE_ERROR_MSG,
117
+ Pe as IS_EMPTY_ERROR_MSG,
118
+ Ae as IS_EQUAL_ERROR_MSG,
119
+ qe as IS_FUNCTION_ERROR_MSG,
120
+ Ye as IS_NIL_ERROR_MSG,
121
+ Qe as IS_NUMBER_ERROR_MSG,
122
+ ze as IS_OBJECT_ERROR_MSG,
123
+ tt as IS_PRIMITIVE_ERROR_MSG,
124
+ ft as IS_PROMISE_ERROR_MSG,
125
+ Rt as IS_STRING_ERROR_MSG,
126
+ lt as IS_WITHIN_ERROR_MSG,
127
+ Hr as abs,
128
+ Vr as add,
115
129
  e as aggregate,
130
+ zr as allocate,
116
131
  m as alternate,
117
- er as assert,
118
- mr as assertParams,
119
- fr as attempt,
120
- wr as average,
121
- Jr as boil,
122
- Co as camelCase,
132
+ H as arrange,
133
+ mr as assert,
134
+ fr as assertParams,
135
+ ir as attempt,
136
+ Xr as average,
137
+ ro as boil,
138
+ te as camelCase,
123
139
  f as chunk,
124
- Yr as clamp,
125
- fo as clone,
140
+ eo as clamp,
141
+ Po as clone,
126
142
  i as compact,
127
- ir as compare,
128
- ar as compareBy,
129
- _r as compose,
143
+ ar as compare,
144
+ _r as compareBy,
145
+ lr as compose,
130
146
  a as contains,
131
- Sr as curry,
132
- lr as debounce,
147
+ No as currency,
148
+ cr as curry,
149
+ dr as debounce,
133
150
  Ir as delay,
134
- io as diff,
135
- yo as draw,
136
- ao as entries,
151
+ Co as diff,
152
+ mo as distribute,
153
+ fo as divide,
154
+ Zo as draw,
155
+ Bo as entries,
137
156
  _ as every,
138
- z as expires,
139
- S as filter,
140
- l as find,
141
- I as findIndex,
142
- u as findLast,
157
+ ho as exchange,
158
+ X as expires,
159
+ l as filter,
160
+ c as find,
161
+ d as findIndex,
162
+ I as findLast,
143
163
  M as flatten,
144
- ur as fp,
145
- jo as ge,
146
- g as group,
147
- Qo as gt,
148
- X as interval,
149
- Zo as is,
150
- Xo as isArray,
151
- re as isBoolean,
152
- te as isDate,
153
- pe as isDefined,
154
- ie as isEmpty,
155
- Re as isEqual,
156
- ne as isEven,
157
- le as isFunction,
158
- Ie as isNegative,
159
- de as isNil,
160
- ge as isNumber,
161
- ve as isObject,
162
- he as isOdd,
163
- Pe as isPositive,
164
- Ae as isPrimitive,
165
- Le as isPromise,
166
- qe as isRegex,
167
- Je as isString,
168
- je as isWithin,
169
- Qe as isZero,
170
- Bo as kebabCase,
171
- _o as keys,
172
- Ze as le,
173
- N as list,
174
- Ke as lt,
175
- b as map,
176
- Hr as max,
177
- Vr as median,
178
- Mr as memo,
179
- So as merge,
180
- zr as min,
181
- gr as once,
182
- lo as parseJSON,
183
- Lo as pascalCase,
184
- Io as path,
164
+ Mr as fp,
165
+ Se as ge,
166
+ y as group,
167
+ ue as gt,
168
+ rr as interval,
169
+ Ee as is,
170
+ Me as isArray,
171
+ ye as isBoolean,
172
+ Ne as isDate,
173
+ he as isDefined,
174
+ Te as isEmpty,
175
+ Be as isEqual,
176
+ Le as isEven,
177
+ we as isFunction,
178
+ Je as isNegative,
179
+ je as isNil,
180
+ Ve as isNumber,
181
+ Ke as isObject,
182
+ $e as isOdd,
183
+ ot as isPositive,
184
+ mt as isPrimitive,
185
+ xt as isPromise,
186
+ st as isRegex,
187
+ _t as isString,
188
+ St as isWithin,
189
+ ut as isZero,
190
+ pe as kebabCase,
191
+ Lo as keys,
192
+ Et as le,
193
+ b as list,
194
+ Ot as lt,
195
+ v as map,
196
+ io as max,
197
+ ao as median,
198
+ yr as memo,
199
+ qo as merge,
200
+ _o as min,
201
+ lo as multiply,
202
+ br as once,
203
+ vr as parallel,
204
+ Fo as parseJSON,
205
+ xe as pascalCase,
206
+ Wo as path,
185
207
  k as pick,
186
- Nr as pipe,
187
- br as predict,
188
- kr as proxy,
189
- vo as random,
190
- Xr as range,
191
- ro as rate,
208
+ kr as pipe,
209
+ Tr as predict,
210
+ Ar as proxy,
211
+ Dr as prune,
212
+ Ko as random,
213
+ co as range,
214
+ Eo as rate,
192
215
  T as reduce,
193
- Tr as retry,
194
- eo as round,
195
- A as search,
196
- uo as seek,
197
- D as select,
198
- U as shift,
199
- ho as shuffle,
200
- qo as similarity,
201
- Ar as sleep,
202
- Fo as snakeCase,
203
- w as some,
204
- J as sort,
205
- Y as sortBy,
206
- H as substitute,
207
- mo as sum,
208
- Dr as throttle,
209
- rr as timeDiff,
210
- Wo as truncate,
211
- $e as typeOf,
212
- V as uniq,
213
- Po as uuid,
214
- Go as values,
215
- Ur as worker
216
+ A as remoteList,
217
+ Ur as retry,
218
+ Oo as round,
219
+ D as search,
220
+ jo as seek,
221
+ U as select,
222
+ w as shift,
223
+ $o as shuffle,
224
+ se as similarity,
225
+ wr as sleep,
226
+ Re as snakeCase,
227
+ J as some,
228
+ Y as sort,
229
+ V as substitute,
230
+ go as subtract,
231
+ Go as sum,
232
+ Jr as throttle,
233
+ er as timeDiff,
234
+ ne as truncate,
235
+ gt as typeOf,
236
+ z as uniq,
237
+ oe as uuid,
238
+ Qo as values,
239
+ Yr as worker
216
240
  };
217
241
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t){return typeof t=="bigint"?t<0n?-t:t:Math.abs(t)}exports.abs=n;
2
+ //# sourceMappingURL=abs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abs.cjs","sources":["../../src/math/abs.ts"],"sourcesContent":["/**\n * Returns the absolute value of a number.\n * Supports both regular numbers and bigint.\n *\n * @example\n * ```ts\n * abs(-5); // 5\n * abs(3); // 3\n * abs(-100n); // 100n\n * ```\n *\n * @param value - The number or bigint to get absolute value of\n * @returns Absolute value\n */\nexport function abs(value: number): number;\nexport function abs(value: bigint): bigint;\nexport function abs(value: number | bigint): number | bigint {\n if (typeof value === 'bigint') {\n return value < 0n ? -value : value;\n }\n return Math.abs(value);\n}\n"],"names":["abs","value"],"mappings":"gFAgBO,SAASA,EAAIC,EAAyC,CAC3D,OAAI,OAAOA,GAAU,SACZA,EAAQ,GAAK,CAACA,EAAQA,EAExB,KAAK,IAAIA,CAAK,CACvB"}
@@ -0,0 +1,7 @@
1
+ function n(t) {
2
+ return typeof t == "bigint" ? t < 0n ? -t : t : Math.abs(t);
3
+ }
4
+ export {
5
+ n as abs
6
+ };
7
+ //# sourceMappingURL=abs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abs.js","sources":["../../src/math/abs.ts"],"sourcesContent":["/**\n * Returns the absolute value of a number.\n * Supports both regular numbers and bigint.\n *\n * @example\n * ```ts\n * abs(-5); // 5\n * abs(3); // 3\n * abs(-100n); // 100n\n * ```\n *\n * @param value - The number or bigint to get absolute value of\n * @returns Absolute value\n */\nexport function abs(value: number): number;\nexport function abs(value: bigint): bigint;\nexport function abs(value: number | bigint): number | bigint {\n if (typeof value === 'bigint') {\n return value < 0n ? -value : value;\n }\n return Math.abs(value);\n}\n"],"names":["abs","value"],"mappings":"AAgBO,SAASA,EAAIC,GAAyC;AAC3D,SAAI,OAAOA,KAAU,WACZA,IAAQ,KAAK,CAACA,IAAQA,IAExB,KAAK,IAAIA,CAAK;AACvB;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(e,t){if(typeof e=="bigint"&&typeof t=="bigint"||typeof e=="number"&&typeof t=="number")return e+t;throw new TypeError("Both arguments must be of the same type (number or bigint)")}exports.add=r;
2
+ //# sourceMappingURL=add.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.cjs","sources":["../../src/math/add.ts"],"sourcesContent":["/**\n * Adds two numbers with precision handling for financial calculations.\n * Supports both regular numbers and bigint for exact precision.\n *\n * @example\n * ```ts\n * add(10, 20); // 30\n * add(0.1, 0.2); // 0.3 (precision-safe)\n * add(100n, 200n); // 300n\n * ```\n *\n * @param a - First number or bigint\n * @param b - Second number or bigint\n * @returns Sum of a and b\n */\nexport function add(a: number, b: number): number;\nexport function add(a: bigint, b: bigint): bigint;\nexport function add(a: number | bigint, b: number | bigint): number | bigint {\n if (typeof a === 'bigint' && typeof b === 'bigint') {\n return a + b;\n }\n if (typeof a === 'number' && typeof b === 'number') {\n return a + b;\n }\n throw new TypeError('Both arguments must be of the same type (number or bigint)');\n}\n"],"names":["add","a","b"],"mappings":"gFAiBO,SAASA,EAAIC,EAAoBC,EAAqC,CAI3E,GAHI,OAAOD,GAAM,UAAY,OAAOC,GAAM,UAGtC,OAAOD,GAAM,UAAY,OAAOC,GAAM,SACxC,OAAOD,EAAIC,EAEb,MAAM,IAAI,UAAU,4DAA4D,CAClF"}
@@ -0,0 +1,9 @@
1
+ function r(e, t) {
2
+ if (typeof e == "bigint" && typeof t == "bigint" || typeof e == "number" && typeof t == "number")
3
+ return e + t;
4
+ throw new TypeError("Both arguments must be of the same type (number or bigint)");
5
+ }
6
+ export {
7
+ r as add
8
+ };
9
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.js","sources":["../../src/math/add.ts"],"sourcesContent":["/**\n * Adds two numbers with precision handling for financial calculations.\n * Supports both regular numbers and bigint for exact precision.\n *\n * @example\n * ```ts\n * add(10, 20); // 30\n * add(0.1, 0.2); // 0.3 (precision-safe)\n * add(100n, 200n); // 300n\n * ```\n *\n * @param a - First number or bigint\n * @param b - Second number or bigint\n * @returns Sum of a and b\n */\nexport function add(a: number, b: number): number;\nexport function add(a: bigint, b: bigint): bigint;\nexport function add(a: number | bigint, b: number | bigint): number | bigint {\n if (typeof a === 'bigint' && typeof b === 'bigint') {\n return a + b;\n }\n if (typeof a === 'number' && typeof b === 'number') {\n return a + b;\n }\n throw new TypeError('Both arguments must be of the same type (number or bigint)');\n}\n"],"names":["add","a","b"],"mappings":"AAiBO,SAASA,EAAIC,GAAoBC,GAAqC;AAI3E,MAHI,OAAOD,KAAM,YAAY,OAAOC,KAAM,YAGtC,OAAOD,KAAM,YAAY,OAAOC,KAAM;AACxC,WAAOD,IAAIC;AAEb,QAAM,IAAI,UAAU,4DAA4D;AAClF;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(o,t){if(t.length===0)throw new Error("Ratios array cannot be empty");if(t.some(e=>e<0))throw new Error("Ratios must be non-negative");const n=t.reduce((e,r)=>e+r,0);if(n===0)throw new Error("Total ratio cannot be zero");if(typeof o=="bigint"){const e=[];let r=o;for(let h=0;h<t.length-1;h++){const s=o*BigInt(Math.floor(t[h]*1e6))/BigInt(Math.floor(n*1e6));e.push(s),r-=s}return e.push(r),e}const l=[];let i=o;for(let e=0;e<t.length-1;e++){const r=Math.floor(o*t[e]/n);l.push(r),i-=r}return l.push(i),l}exports.allocate=a;
2
+ //# sourceMappingURL=allocate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allocate.cjs","sources":["../../src/math/allocate.ts"],"sourcesContent":["/**\n * Distributes an amount proportionally according to given ratios.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * Critical for financial operations like splitting payments to avoid rounding errors.\n *\n * @example\n * ```ts\n * // Split $100 in ratio 1:2:3\n * allocate(100, [1, 2, 3]);\n * // [17, 33, 50] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * allocate(10000n, [1, 1, 1]);\n * // [3334n, 3333n, 3333n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to allocate\n * @param ratios - Array of ratios for distribution\n * @returns Array of allocated amounts (sum equals original amount)\n * @throws {Error} If ratios array is empty or contains negative values\n */\nexport function allocate(amount: number, ratios: number[]): number[];\nexport function allocate(amount: bigint, ratios: number[]): bigint[];\nexport function allocate(amount: number | bigint, ratios: number[]): (number | bigint)[] {\n if (ratios.length === 0) {\n throw new Error('Ratios array cannot be empty');\n }\n\n if (ratios.some((r) => r < 0)) {\n throw new Error('Ratios must be non-negative');\n }\n\n const totalRatio = ratios.reduce((sum, ratio) => sum + ratio, 0);\n\n if (totalRatio === 0) {\n throw new Error('Total ratio cannot be zero');\n }\n\n if (typeof amount === 'bigint') {\n const results: bigint[] = [];\n let remainder = amount;\n\n for (let i = 0; i < ratios.length - 1; i++) {\n const share = (amount * BigInt(Math.floor(ratios[i] * 1000000))) / BigInt(Math.floor(totalRatio * 1000000));\n results.push(share);\n remainder -= share;\n }\n\n // Last allocation gets the remainder to ensure exact sum\n results.push(remainder);\n return results;\n }\n\n // Handle number type\n const results: number[] = [];\n let remainder = amount;\n\n for (let i = 0; i < ratios.length - 1; i++) {\n const share = Math.floor((amount * ratios[i]) / totalRatio);\n results.push(share);\n remainder -= share;\n }\n\n // Last allocation gets the remainder to ensure exact sum\n results.push(remainder);\n return results;\n}\n"],"names":["allocate","amount","ratios","r","totalRatio","sum","ratio","results","remainder","i","share"],"mappings":"gFAuBO,SAASA,EAASC,EAAyBC,EAAuC,CACvF,GAAIA,EAAO,SAAW,EACpB,MAAM,IAAI,MAAM,8BAA8B,EAGhD,GAAIA,EAAO,KAAMC,GAAMA,EAAI,CAAC,EAC1B,MAAM,IAAI,MAAM,6BAA6B,EAG/C,MAAMC,EAAaF,EAAO,OAAO,CAACG,EAAKC,IAAUD,EAAMC,EAAO,CAAC,EAE/D,GAAIF,IAAe,EACjB,MAAM,IAAI,MAAM,4BAA4B,EAG9C,GAAI,OAAOH,GAAW,SAAU,CAC9B,MAAMM,EAAoB,CAAA,EAC1B,IAAIC,EAAYP,EAEhB,QAASQ,EAAI,EAAGA,EAAIP,EAAO,OAAS,EAAGO,IAAK,CAC1C,MAAMC,EAAST,EAAS,OAAO,KAAK,MAAMC,EAAOO,CAAC,EAAI,GAAO,CAAC,EAAK,OAAO,KAAK,MAAML,EAAa,GAAO,CAAC,EAC1GG,EAAQ,KAAKG,CAAK,EAClBF,GAAaE,CACf,CAGAH,OAAAA,EAAQ,KAAKC,CAAS,EACfD,CACT,CAGA,MAAMA,EAAoB,CAAA,EAC1B,IAAIC,EAAYP,EAEhB,QAASQ,EAAI,EAAGA,EAAIP,EAAO,OAAS,EAAGO,IAAK,CAC1C,MAAMC,EAAQ,KAAK,MAAOT,EAASC,EAAOO,CAAC,EAAKL,CAAU,EAC1DG,EAAQ,KAAKG,CAAK,EAClBF,GAAaE,CACf,CAGA,OAAAH,EAAQ,KAAKC,CAAS,EACfD,CACT"}
@@ -0,0 +1,29 @@
1
+ function f(o, t) {
2
+ if (t.length === 0)
3
+ throw new Error("Ratios array cannot be empty");
4
+ if (t.some((e) => e < 0))
5
+ throw new Error("Ratios must be non-negative");
6
+ const n = t.reduce((e, r) => e + r, 0);
7
+ if (n === 0)
8
+ throw new Error("Total ratio cannot be zero");
9
+ if (typeof o == "bigint") {
10
+ const e = [];
11
+ let r = o;
12
+ for (let h = 0; h < t.length - 1; h++) {
13
+ const i = o * BigInt(Math.floor(t[h] * 1e6)) / BigInt(Math.floor(n * 1e6));
14
+ e.push(i), r -= i;
15
+ }
16
+ return e.push(r), e;
17
+ }
18
+ const l = [];
19
+ let s = o;
20
+ for (let e = 0; e < t.length - 1; e++) {
21
+ const r = Math.floor(o * t[e] / n);
22
+ l.push(r), s -= r;
23
+ }
24
+ return l.push(s), l;
25
+ }
26
+ export {
27
+ f as allocate
28
+ };
29
+ //# sourceMappingURL=allocate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allocate.js","sources":["../../src/math/allocate.ts"],"sourcesContent":["/**\n * Distributes an amount proportionally according to given ratios.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * Critical for financial operations like splitting payments to avoid rounding errors.\n *\n * @example\n * ```ts\n * // Split $100 in ratio 1:2:3\n * allocate(100, [1, 2, 3]);\n * // [17, 33, 50] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * allocate(10000n, [1, 1, 1]);\n * // [3334n, 3333n, 3333n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to allocate\n * @param ratios - Array of ratios for distribution\n * @returns Array of allocated amounts (sum equals original amount)\n * @throws {Error} If ratios array is empty or contains negative values\n */\nexport function allocate(amount: number, ratios: number[]): number[];\nexport function allocate(amount: bigint, ratios: number[]): bigint[];\nexport function allocate(amount: number | bigint, ratios: number[]): (number | bigint)[] {\n if (ratios.length === 0) {\n throw new Error('Ratios array cannot be empty');\n }\n\n if (ratios.some((r) => r < 0)) {\n throw new Error('Ratios must be non-negative');\n }\n\n const totalRatio = ratios.reduce((sum, ratio) => sum + ratio, 0);\n\n if (totalRatio === 0) {\n throw new Error('Total ratio cannot be zero');\n }\n\n if (typeof amount === 'bigint') {\n const results: bigint[] = [];\n let remainder = amount;\n\n for (let i = 0; i < ratios.length - 1; i++) {\n const share = (amount * BigInt(Math.floor(ratios[i] * 1000000))) / BigInt(Math.floor(totalRatio * 1000000));\n results.push(share);\n remainder -= share;\n }\n\n // Last allocation gets the remainder to ensure exact sum\n results.push(remainder);\n return results;\n }\n\n // Handle number type\n const results: number[] = [];\n let remainder = amount;\n\n for (let i = 0; i < ratios.length - 1; i++) {\n const share = Math.floor((amount * ratios[i]) / totalRatio);\n results.push(share);\n remainder -= share;\n }\n\n // Last allocation gets the remainder to ensure exact sum\n results.push(remainder);\n return results;\n}\n"],"names":["allocate","amount","ratios","r","totalRatio","sum","ratio","results","remainder","i","share"],"mappings":"AAuBO,SAASA,EAASC,GAAyBC,GAAuC;AACvF,MAAIA,EAAO,WAAW;AACpB,UAAM,IAAI,MAAM,8BAA8B;AAGhD,MAAIA,EAAO,KAAK,CAACC,MAAMA,IAAI,CAAC;AAC1B,UAAM,IAAI,MAAM,6BAA6B;AAG/C,QAAMC,IAAaF,EAAO,OAAO,CAACG,GAAKC,MAAUD,IAAMC,GAAO,CAAC;AAE/D,MAAIF,MAAe;AACjB,UAAM,IAAI,MAAM,4BAA4B;AAG9C,MAAI,OAAOH,KAAW,UAAU;AAC9B,UAAMM,IAAoB,CAAA;AAC1B,QAAIC,IAAYP;AAEhB,aAASQ,IAAI,GAAGA,IAAIP,EAAO,SAAS,GAAGO,KAAK;AAC1C,YAAMC,IAAST,IAAS,OAAO,KAAK,MAAMC,EAAOO,CAAC,IAAI,GAAO,CAAC,IAAK,OAAO,KAAK,MAAML,IAAa,GAAO,CAAC;AAC1GG,MAAAA,EAAQ,KAAKG,CAAK,GAClBF,KAAaE;AAAA,IACf;AAGAH,WAAAA,EAAQ,KAAKC,CAAS,GACfD;AAAAA,EACT;AAGA,QAAMA,IAAoB,CAAA;AAC1B,MAAIC,IAAYP;AAEhB,WAASQ,IAAI,GAAGA,IAAIP,EAAO,SAAS,GAAGO,KAAK;AAC1C,UAAMC,IAAQ,KAAK,MAAOT,IAASC,EAAOO,CAAC,IAAKL,CAAU;AAC1D,IAAAG,EAAQ,KAAKG,CAAK,GAClBF,KAAaE;AAAA,EACf;AAGA,SAAAH,EAAQ,KAAKC,CAAS,GACfD;AACT;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./sum.cjs");function o(t,n){if(t.length===0)return;let e;try{e=i.sum(t,n)}catch(r){if(r instanceof TypeError)return;throw r}if(typeof e=="number")return e/t.length;if(e instanceof Date)return new Date(e.getTime()/t.length)}exports.average=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./sum.cjs");function u(e,n){if(e.length===0)return;if((n?n(e[0]):e[0])instanceof Date){const t=e.reduce((i,o)=>{const r=n?n(o):o;if(!(r instanceof Date))throw new TypeError("average expected all items to be Date objects");return i+r.getTime()},0);return new Date(t/e.length)}try{const t=s.sum(e,n);if(typeof t=="number")return t/e.length}catch(t){if(t instanceof TypeError)return;throw t}}exports.average=u;
2
2
  //# sourceMappingURL=average.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"average.cjs","sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers or dates.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * average(arr, (num) => new Date(Date.now() + 1000 * 60 * 60 * 24 * num); // Date object representing 3 days from now\n * ```\n *\n * @param array - The array of numbers or dates to average.\n * @param callback - (optional) A callback function to map the values.\n * @returns The average of the numbers or dates in the array.\n */\n\nexport function average<T>(array: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (array.length === 0) return undefined;\n let total: number | Date | undefined;\n try {\n total = sum(array, callback);\n } catch (err) {\n if (err instanceof TypeError) return undefined;\n throw err;\n }\n if (typeof total === 'number') {\n return total / array.length;\n }\n if (total instanceof Date) {\n // For dates, average by dividing the timestamp sum by array length\n return new Date(total.getTime() / array.length);\n }\n return undefined;\n}\n"],"names":["average","array","callback","total","sum","err"],"mappings":"6GAkBO,SAASA,EAAWC,EAAYC,EAAkE,CACvG,GAAID,EAAM,SAAW,EAAG,OACxB,IAAIE,EACJ,GAAI,CACFA,EAAQC,EAAAA,IAAIH,EAAOC,CAAQ,CAC7B,OAASG,EAAK,CACZ,GAAIA,aAAe,UAAW,OAC9B,MAAMA,CACR,CACA,GAAI,OAAOF,GAAU,SACnB,OAAOA,EAAQF,EAAM,OAEvB,GAAIE,aAAiB,KAEnB,OAAO,IAAI,KAAKA,EAAM,QAAA,EAAYF,EAAM,MAAM,CAGlD"}
1
+ {"version":3,"file":"average.cjs","sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers or dates.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * average(arr, (num) => new Date(Date.now() + 1000 * 60 * 60 * 24 * num); // Date object representing 3 days from now\n * ```\n *\n * @param array - The array of numbers or dates to average.\n * @param callback - (optional) A callback function to map the values.\n * @returns The average of the numbers or dates in the array.\n */\n\nexport function average<T>(array: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (array.length === 0) return undefined;\n\n // Check if we are dealing with Dates (either directly or via callback)\n const firstItem = callback ? callback(array[0]) : array[0];\n const isDate = firstItem instanceof Date;\n\n if (isDate) {\n const totalTimestamp = array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : item;\n if (!(val instanceof Date)) {\n throw new TypeError('average expected all items to be Date objects');\n }\n return acc + val.getTime();\n }, 0);\n return new Date(totalTimestamp / array.length);\n }\n\n // Handle numbers\n try {\n const total = sum(array, callback as (item: T) => number);\n if (typeof total === 'number') {\n return total / array.length;\n }\n } catch (err) {\n if (err instanceof TypeError) return undefined;\n throw err;\n }\n\n return undefined;\n}\n"],"names":["average","array","callback","totalTimestamp","acc","item","val","total","sum","err"],"mappings":"6GAkBO,SAASA,EAAWC,EAAYC,EAAkE,CACvG,GAAID,EAAM,SAAW,EAAG,OAMxB,IAHkBC,EAAWA,EAASD,EAAM,CAAC,CAAC,EAAIA,EAAM,CAAC,aACrB,KAExB,CACV,MAAME,EAAiBF,EAAM,OAAe,CAACG,EAAKC,IAAS,CACzD,MAAMC,EAAMJ,EAAWA,EAASG,CAAI,EAAIA,EACxC,GAAI,EAAEC,aAAe,MACnB,MAAM,IAAI,UAAU,+CAA+C,EAErE,OAAOF,EAAME,EAAI,QAAA,CACnB,EAAG,CAAC,EACJ,OAAO,IAAI,KAAKH,EAAiBF,EAAM,MAAM,CAC/C,CAGA,GAAI,CACF,MAAMM,EAAQC,EAAAA,IAAIP,EAAOC,CAA+B,EACxD,GAAI,OAAOK,GAAU,SACnB,OAAOA,EAAQN,EAAM,MAEzB,OAASQ,EAAK,CACZ,GAAIA,aAAe,UAAW,OAC9B,MAAMA,CACR,CAGF"}
@@ -1,19 +1,25 @@
1
- import { sum as o } from "./sum.js";
2
- function f(t, r) {
1
+ import { sum as s } from "./sum.js";
2
+ function p(t, n) {
3
3
  if (t.length === 0) return;
4
- let e;
4
+ if ((n ? n(t[0]) : t[0]) instanceof Date) {
5
+ const e = t.reduce((i, o) => {
6
+ const r = n ? n(o) : o;
7
+ if (!(r instanceof Date))
8
+ throw new TypeError("average expected all items to be Date objects");
9
+ return i + r.getTime();
10
+ }, 0);
11
+ return new Date(e / t.length);
12
+ }
5
13
  try {
6
- e = o(t, r);
7
- } catch (n) {
8
- if (n instanceof TypeError) return;
9
- throw n;
14
+ const e = s(t, n);
15
+ if (typeof e == "number")
16
+ return e / t.length;
17
+ } catch (e) {
18
+ if (e instanceof TypeError) return;
19
+ throw e;
10
20
  }
11
- if (typeof e == "number")
12
- return e / t.length;
13
- if (e instanceof Date)
14
- return new Date(e.getTime() / t.length);
15
21
  }
16
22
  export {
17
- f as average
23
+ p as average
18
24
  };
19
25
  //# sourceMappingURL=average.js.map