@vielzeug/toolkit 1.0.13 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/{sortBy.cjs → arrange.cjs} +2 -2
- package/dist/array/arrange.cjs.map +1 -0
- package/dist/array/arrange.js +6 -0
- package/dist/array/arrange.js.map +1 -0
- package/dist/array/chunk.cjs.map +1 -1
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/list.cjs +1 -1
- package/dist/array/list.cjs.map +1 -1
- package/dist/array/list.js +86 -53
- package/dist/array/list.js.map +1 -1
- package/dist/array/remoteList.cjs +2 -0
- package/dist/array/remoteList.cjs.map +1 -0
- package/dist/array/remoteList.js +123 -0
- package/dist/array/remoteList.js.map +1 -0
- package/dist/async/attempt.cjs.map +1 -0
- package/dist/async/attempt.js.map +1 -0
- package/dist/async/defer.cjs +2 -0
- package/dist/async/defer.cjs.map +1 -0
- package/dist/async/defer.js +10 -0
- package/dist/async/defer.js.map +1 -0
- package/dist/async/delay.cjs.map +1 -0
- package/dist/async/delay.js.map +1 -0
- package/dist/async/parallel.cjs +2 -0
- package/dist/async/parallel.cjs.map +1 -0
- package/dist/async/parallel.js +28 -0
- package/dist/async/parallel.js.map +1 -0
- package/dist/async/pool.cjs +2 -0
- package/dist/async/pool.cjs.map +1 -0
- package/dist/async/pool.js +22 -0
- package/dist/async/pool.js.map +1 -0
- package/dist/async/predict.cjs.map +1 -0
- package/dist/async/predict.js.map +1 -0
- package/dist/async/queue.cjs +2 -0
- package/dist/async/queue.cjs.map +1 -0
- package/dist/async/queue.js +57 -0
- package/dist/async/queue.js.map +1 -0
- package/dist/async/race.cjs +2 -0
- package/dist/async/race.cjs.map +1 -0
- package/dist/async/race.js +8 -0
- package/dist/async/race.js.map +1 -0
- package/dist/async/retry.cjs.map +1 -0
- package/dist/{function → async}/retry.js +4 -4
- package/dist/async/retry.js.map +1 -0
- package/dist/async/sleep.cjs +2 -0
- package/dist/async/sleep.cjs.map +1 -0
- package/dist/{function → async}/sleep.js +1 -1
- package/dist/async/sleep.js.map +1 -0
- package/dist/async/waitFor.cjs +2 -0
- package/dist/async/waitFor.cjs.map +1 -0
- package/dist/async/waitFor.js +37 -0
- package/dist/async/waitFor.js.map +1 -0
- package/dist/date/expires.cjs.map +1 -1
- package/dist/date/expires.js.map +1 -1
- package/dist/date/interval.cjs.map +1 -1
- package/dist/date/interval.js.map +1 -1
- package/dist/date/timeDiff.cjs.map +1 -1
- package/dist/date/timeDiff.js.map +1 -1
- package/dist/function/memo.cjs.map +1 -1
- package/dist/function/memo.js.map +1 -1
- package/dist/function/proxy.cjs.map +1 -1
- package/dist/function/proxy.js.map +1 -1
- package/dist/function/prune.cjs +2 -0
- package/dist/function/prune.cjs.map +1 -0
- package/dist/function/prune.js +30 -0
- package/dist/function/prune.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +575 -51
- package/dist/index.js +242 -206
- package/dist/index.js.map +1 -1
- package/dist/logit/dist/logit.cjs +1 -1
- package/dist/logit/dist/logit.cjs.map +1 -1
- package/dist/logit/dist/logit.js +147 -64
- package/dist/logit/dist/logit.js.map +1 -1
- package/dist/math/abs.cjs +2 -0
- package/dist/math/abs.cjs.map +1 -0
- package/dist/math/abs.js +7 -0
- package/dist/math/abs.js.map +1 -0
- package/dist/math/add.cjs +2 -0
- package/dist/math/add.cjs.map +1 -0
- package/dist/math/add.js +9 -0
- package/dist/math/add.js.map +1 -0
- package/dist/math/allocate.cjs +2 -0
- package/dist/math/allocate.cjs.map +1 -0
- package/dist/math/allocate.js +29 -0
- package/dist/math/allocate.js.map +1 -0
- package/dist/math/distribute.cjs +2 -0
- package/dist/math/distribute.cjs.map +1 -0
- package/dist/math/distribute.js +18 -0
- package/dist/math/distribute.js.map +1 -0
- package/dist/math/divide.cjs +2 -0
- package/dist/math/divide.cjs.map +1 -0
- package/dist/math/divide.js +11 -0
- package/dist/math/divide.js.map +1 -0
- package/dist/math/multiply.cjs +2 -0
- package/dist/math/multiply.cjs.map +1 -0
- package/dist/math/multiply.js +9 -0
- package/dist/math/multiply.js.map +1 -0
- package/dist/math/subtract.cjs +2 -0
- package/dist/math/subtract.cjs.map +1 -0
- package/dist/math/subtract.js +9 -0
- package/dist/math/subtract.js.map +1 -0
- package/dist/money/currency.cjs +2 -0
- package/dist/money/currency.cjs.map +1 -0
- package/dist/money/currency.js +49 -0
- package/dist/money/currency.js.map +1 -0
- package/dist/money/exchange.cjs +2 -0
- package/dist/money/exchange.cjs.map +1 -0
- package/dist/money/exchange.js +13 -0
- package/dist/money/exchange.js.map +1 -0
- package/dist/object/cache.cjs +2 -0
- package/dist/object/cache.cjs.map +1 -0
- package/dist/object/cache.js +63 -0
- package/dist/object/cache.js.map +1 -0
- package/dist/object/merge.cjs.map +1 -1
- package/dist/object/merge.js.map +1 -1
- package/dist/object/parseJSON.cjs.map +1 -1
- package/dist/object/parseJSON.js.map +1 -1
- package/dist/object/path.cjs.map +1 -1
- package/dist/object/path.js.map +1 -1
- package/package.json +1 -1
- package/dist/array/sortBy.cjs.map +0 -1
- package/dist/array/sortBy.js +0 -6
- package/dist/array/sortBy.js.map +0 -1
- package/dist/function/attempt.cjs.map +0 -1
- package/dist/function/attempt.js.map +0 -1
- package/dist/function/delay.cjs.map +0 -1
- package/dist/function/delay.js.map +0 -1
- package/dist/function/predict.cjs.map +0 -1
- package/dist/function/predict.js.map +0 -1
- package/dist/function/retry.cjs.map +0 -1
- package/dist/function/retry.js.map +0 -1
- package/dist/function/sleep.cjs +0 -2
- package/dist/function/sleep.cjs.map +0 -1
- package/dist/function/sleep.js.map +0 -1
- /package/dist/{function → async}/attempt.cjs +0 -0
- /package/dist/{function → async}/attempt.js +0 -0
- /package/dist/{function → async}/delay.cjs +0 -0
- /package/dist/{function → async}/delay.js +0 -0
- /package/dist/{function → async}/predict.cjs +0 -0
- /package/dist/{function → async}/predict.js +0 -0
- /package/dist/{function → async}/retry.cjs +0 -0
package/dist/logit/dist/logit.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const
|
|
1
|
+
const $ = {}, h = {
|
|
2
2
|
debug: "log",
|
|
3
3
|
success: "log"
|
|
4
|
-
},
|
|
4
|
+
}, w = () => typeof window < "u" && $?.NODE_ENV ? !1 : typeof process < "u" && process.env?.NODE_ENV ? process.env.NODE_ENV === "production" : !1, d = w(), x = typeof window < "u" && window.matchMedia?.("(prefers-color-scheme: dark)").matches, b = {
|
|
5
5
|
debug: { bg: "#616161", border: "#424242", color: "#fff", icon: "☕", symbol: "🅳" },
|
|
6
6
|
error: { bg: "#d32f2f", border: "#c62828", color: "#fff", icon: "✘", symbol: "🅴" },
|
|
7
7
|
group: { bg: "#546e7a", border: "#455a64", color: "#fff", icon: "⚭", symbol: "🅶" },
|
|
8
8
|
info: { bg: "#1976d2", border: "#1565c0", color: "#fff", icon: "ℹ", symbol: "🅸" },
|
|
9
|
-
ns:
|
|
9
|
+
ns: x ? { bg: "#fafafa", border: "#c7c7c7", color: "#000" } : { bg: "#424242", border: "#212121", color: "#fff" },
|
|
10
10
|
success: { bg: "#689f38", border: "#558b2f", color: "#fff", icon: "✔", symbol: "🆂" },
|
|
11
11
|
time: { bg: "#0097a7", border: "#00838f", color: "#fff", icon: "⏲", symbol: "🆃" },
|
|
12
12
|
trace: { bg: "#d81b60", border: "#c2185b", color: "#fff", icon: "⛢", symbol: "🆃" },
|
|
13
13
|
warn: { bg: "#ffb300", border: "#ffa000", color: "#fff", icon: "⚠", symbol: "🆆" }
|
|
14
|
-
},
|
|
14
|
+
}, m = {
|
|
15
15
|
debug: 0,
|
|
16
16
|
trace: 1,
|
|
17
17
|
time: 2,
|
|
@@ -21,76 +21,91 @@ const w = {}, v = {
|
|
|
21
21
|
warn: 6,
|
|
22
22
|
error: 7,
|
|
23
23
|
off: 8
|
|
24
|
-
},
|
|
24
|
+
}, o = {
|
|
25
25
|
environment: !0,
|
|
26
26
|
logLevel: "debug",
|
|
27
27
|
namespace: "",
|
|
28
28
|
remote: { handler: void 0, logLevel: "off" },
|
|
29
29
|
timestamp: !0,
|
|
30
30
|
variant: "symbol"
|
|
31
|
-
}, i = (e) =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
}, i = (e) => m[o.logLevel] <= m[e], p = () => (/* @__PURE__ */ new Date()).toISOString().slice(11, 23), g = () => d ? "🄿" : "🄳", y = (e, r) => {
|
|
32
|
+
o.remote.handler && m[o.remote.logLevel] <= m[e] && Promise.resolve().then(() => {
|
|
33
|
+
o.remote.handler?.(e, {
|
|
34
|
+
args: r,
|
|
35
|
+
environment: d ? "production" : "development",
|
|
36
|
+
namespace: o.namespace || void 0,
|
|
37
|
+
timestamp: o.timestamp ? p() : void 0
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}, f = (e) => h[e] || e, L = "border: 1px solid", E = "border-radius: 4px", u = "border-radius: 8px; font: italic small-caps bold 12px; font-weight: lighter; padding: 0 4px;", l = (e, r = "") => {
|
|
41
|
+
const { bg: t, color: s, border: n } = b[e], a = `${L} ${n}; ${E}`;
|
|
42
|
+
switch (o.variant) {
|
|
36
43
|
case "symbol":
|
|
37
|
-
return
|
|
44
|
+
return `color: ${t}; ${a}; padding: 1px 1px 0${r}`;
|
|
38
45
|
case "icon":
|
|
39
|
-
return
|
|
46
|
+
return `color: ${t}; ${a}; padding: 0 3px${r}`;
|
|
40
47
|
default:
|
|
41
|
-
return `background: ${t}; color: ${
|
|
48
|
+
return `background: ${t}; color: ${s}; ${a}; font-weight: bold; padding: 0 3px${r}`;
|
|
42
49
|
}
|
|
43
|
-
},
|
|
44
|
-
const
|
|
45
|
-
return t === "text" || !
|
|
50
|
+
}, v = (e) => {
|
|
51
|
+
const r = b[e], { variant: t } = o;
|
|
52
|
+
return t === "text" || !r || !r[t] ? e.toUpperCase() : r[t];
|
|
46
53
|
};
|
|
47
54
|
function D(e) {
|
|
48
|
-
const { namespace:
|
|
49
|
-
let n = `%c${
|
|
50
|
-
const
|
|
51
|
-
return
|
|
55
|
+
const { namespace: r, timestamp: t, environment: s } = o;
|
|
56
|
+
let n = `%c${v(e)}%c`;
|
|
57
|
+
const a = [l(e), ""];
|
|
58
|
+
return r && (n += ` %c${r}%c`, a.push(l("ns", `; ${u}`), "")), s && (n += ` %c${g()}%c`, a.push("color: darkgray", "")), t && (n += ` %c${p()}%c`, a.push("color: gray", "")), { format: n, parts: a };
|
|
52
59
|
}
|
|
53
|
-
const
|
|
60
|
+
const c = (e, ...r) => {
|
|
54
61
|
if (typeof window > "u") {
|
|
55
|
-
const
|
|
56
|
-
|
|
62
|
+
const a = console[f(e)];
|
|
63
|
+
a(`${v(e)} | ${g()} |`, ...r);
|
|
57
64
|
return;
|
|
58
65
|
}
|
|
59
66
|
if (!i(e)) return;
|
|
60
|
-
const { format: t, parts:
|
|
61
|
-
n(t, ...
|
|
62
|
-
},
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
},
|
|
67
|
+
const { format: t, parts: s } = D(e), n = console[f(e)];
|
|
68
|
+
n(t, ...s, ...r), y(e, r);
|
|
69
|
+
}, N = (e) => {
|
|
70
|
+
const r = Math.floor(Date.now() - e);
|
|
71
|
+
return r ? `${r}ms` : "";
|
|
72
|
+
}, O = {
|
|
66
73
|
/**
|
|
67
74
|
* Asserts a condition and logs an error if it's false.
|
|
68
75
|
*/
|
|
69
|
-
assert: (e,
|
|
70
|
-
debug: (...e) =>
|
|
71
|
-
error: (...e) =>
|
|
76
|
+
assert: (e, r, t) => console.assert(e, r, t),
|
|
77
|
+
debug: (...e) => c("debug", ...e),
|
|
78
|
+
error: (...e) => c("error", ...e),
|
|
79
|
+
/**
|
|
80
|
+
* Gets whether the environment indicator is shown.
|
|
81
|
+
*/
|
|
82
|
+
getEnvironment: () => o.environment,
|
|
72
83
|
/**
|
|
73
84
|
* Gets the current log level.
|
|
74
85
|
*/
|
|
75
|
-
getLevel: () =>
|
|
86
|
+
getLevel: () => o.logLevel,
|
|
76
87
|
/**
|
|
77
88
|
* Gets the current namespace prefix.
|
|
78
89
|
*/
|
|
79
|
-
getPrefix: () =>
|
|
90
|
+
getPrefix: () => o.namespace,
|
|
80
91
|
/**
|
|
81
92
|
* Gets whether timestamps are shown.
|
|
82
93
|
*/
|
|
83
|
-
getTimestamp: () =>
|
|
94
|
+
getTimestamp: () => o.timestamp,
|
|
95
|
+
/**
|
|
96
|
+
* Gets the current display variant.
|
|
97
|
+
*/
|
|
98
|
+
getVariant: () => o.variant,
|
|
84
99
|
/**
|
|
85
100
|
* Creates a collapsed group in the console.
|
|
86
101
|
*/
|
|
87
|
-
groupCollapsed: (e,
|
|
102
|
+
groupCollapsed: (e, r = "GROUP", t = Date.now()) => {
|
|
88
103
|
if (!i("success")) return;
|
|
89
|
-
const
|
|
104
|
+
const s = N(t), n = g(), a = o.timestamp ? p() : "";
|
|
90
105
|
console.groupCollapsed(
|
|
91
|
-
`%c${
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
`%c${r}%c${o.namespace}%c${n}%c${a}%c${s}%c${e}`,
|
|
107
|
+
l("group", "; margin-right: 6px; padding: 1px 3px 0"),
|
|
108
|
+
l("ns", `; ${u}; margin-right: 6px`),
|
|
94
109
|
"color: darkgray; margin-right: 6px",
|
|
95
110
|
"color: gray; font-weight: lighter; margin-right: 6px",
|
|
96
111
|
"color: gray; font-weight: lighter; margin-right: 6px",
|
|
@@ -103,56 +118,92 @@ const a = (e, ...o) => {
|
|
|
103
118
|
groupEnd: () => {
|
|
104
119
|
i("success") && console.groupEnd();
|
|
105
120
|
},
|
|
106
|
-
info: (...e) =>
|
|
121
|
+
info: (...e) => c("info", ...e),
|
|
107
122
|
/**
|
|
108
|
-
*
|
|
123
|
+
* Creates a scoped logger with a namespaced prefix.
|
|
124
|
+
* Does not mutate global state - returns an isolated logger instance.
|
|
125
|
+
*
|
|
126
|
+
* @param namespace - The namespace to prepend to all log messages
|
|
127
|
+
* @returns A scoped logger with all logging methods
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* const apiLogger = Logit.scope('api');
|
|
132
|
+
* apiLogger.info('Request received'); // [API] Request received
|
|
133
|
+
*
|
|
134
|
+
* const dbLogger = Logit.scope('database');
|
|
135
|
+
* dbLogger.error('Connection failed'); // [DATABASE] Connection failed
|
|
136
|
+
* ```
|
|
109
137
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
138
|
+
scope: (e) => {
|
|
139
|
+
const r = o.namespace, t = r ? `${r}.${e}` : e;
|
|
140
|
+
return {
|
|
141
|
+
debug: (...s) => {
|
|
142
|
+
const n = o.namespace;
|
|
143
|
+
o.namespace = t, c("debug", ...s), o.namespace = n;
|
|
144
|
+
},
|
|
145
|
+
error: (...s) => {
|
|
146
|
+
const n = o.namespace;
|
|
147
|
+
o.namespace = t, c("error", ...s), o.namespace = n;
|
|
148
|
+
},
|
|
149
|
+
info: (...s) => {
|
|
150
|
+
const n = o.namespace;
|
|
151
|
+
o.namespace = t, c("info", ...s), o.namespace = n;
|
|
152
|
+
},
|
|
153
|
+
success: (...s) => {
|
|
154
|
+
const n = o.namespace;
|
|
155
|
+
o.namespace = t, c("success", ...s), o.namespace = n;
|
|
156
|
+
},
|
|
157
|
+
trace: (...s) => {
|
|
158
|
+
const n = o.namespace;
|
|
159
|
+
o.namespace = t, c("trace", ...s), o.namespace = n;
|
|
160
|
+
},
|
|
161
|
+
warn: (...s) => {
|
|
162
|
+
const n = o.namespace;
|
|
163
|
+
o.namespace = t, c("warn", ...s), o.namespace = n;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
112
166
|
},
|
|
113
167
|
/**
|
|
114
168
|
* Sets the minimum log level to display.
|
|
115
169
|
*/
|
|
116
170
|
setLogLevel: (e) => {
|
|
117
|
-
|
|
171
|
+
o.logLevel = e;
|
|
118
172
|
},
|
|
119
173
|
/**
|
|
120
174
|
* Sets the namespace prefix for all logs.
|
|
121
175
|
*/
|
|
122
176
|
setPrefix: (e) => {
|
|
123
|
-
|
|
177
|
+
o.namespace = e;
|
|
124
178
|
},
|
|
125
179
|
/**
|
|
126
180
|
* Configures remote logging options.
|
|
127
181
|
*/
|
|
128
182
|
setRemote: (e) => {
|
|
129
|
-
|
|
183
|
+
o.remote = e;
|
|
130
184
|
},
|
|
131
185
|
/**
|
|
132
186
|
* Sets the log level for remote logging.
|
|
133
187
|
*/
|
|
134
188
|
setRemoteLogLevel: (e) => {
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
/**
|
|
138
|
-
* Sets the display variant (text, icon, or symbol).
|
|
139
|
-
*/
|
|
140
|
-
setVariant: (e) => {
|
|
141
|
-
r.variant = e;
|
|
189
|
+
o.remote.logLevel = e;
|
|
142
190
|
},
|
|
143
191
|
/**
|
|
144
|
-
*
|
|
192
|
+
* Configures Logit with custom options.
|
|
193
|
+
*
|
|
194
|
+
* Note: The remote option will be merged with existing remote config,
|
|
195
|
+
* not replaced entirely. To clear a remote handler, set remote.handler to undefined.
|
|
145
196
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
197
|
+
setup: (e) => {
|
|
198
|
+
e.remote && (o.remote = { ...o.remote, ...e.remote }, delete e.remote), Object.assign(o, e);
|
|
148
199
|
},
|
|
149
200
|
/**
|
|
150
|
-
*
|
|
201
|
+
* Sets the display variant (text, icon, or symbol).
|
|
151
202
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
203
|
+
setVariant: (e) => {
|
|
204
|
+
o.variant = e;
|
|
154
205
|
},
|
|
155
|
-
success: (...e) =>
|
|
206
|
+
success: (...e) => c("success", ...e),
|
|
156
207
|
/**
|
|
157
208
|
* Displays data in a table format.
|
|
158
209
|
*/
|
|
@@ -171,10 +222,42 @@ const a = (e, ...o) => {
|
|
|
171
222
|
timeEnd: (e) => {
|
|
172
223
|
i("time") && console.timeEnd(e);
|
|
173
224
|
},
|
|
174
|
-
|
|
175
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Toggles or sets the environment indicator visibility.
|
|
227
|
+
* When called without arguments, toggles the current state.
|
|
228
|
+
*
|
|
229
|
+
* @param value - Optional boolean to explicitly set the state
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* Logit.toggleEnvironment(); // Toggles current state
|
|
234
|
+
* Logit.toggleEnvironment(true); // Shows environment indicator
|
|
235
|
+
* Logit.toggleEnvironment(false); // Hides environment indicator
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
toggleEnvironment: (e) => {
|
|
239
|
+
o.environment = e ?? !o.environment;
|
|
240
|
+
},
|
|
241
|
+
/**
|
|
242
|
+
* Toggles or sets timestamp visibility in logs.
|
|
243
|
+
* When called without arguments, toggles the current state.
|
|
244
|
+
*
|
|
245
|
+
* @param value - Optional boolean to explicitly set the state
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* Logit.toggleTimestamp(); // Toggles current state
|
|
250
|
+
* Logit.toggleTimestamp(true); // Shows timestamps
|
|
251
|
+
* Logit.toggleTimestamp(false); // Hides timestamps
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
toggleTimestamp: (e) => {
|
|
255
|
+
o.timestamp = e ?? !o.timestamp;
|
|
256
|
+
},
|
|
257
|
+
trace: (...e) => c("trace", ...e),
|
|
258
|
+
warn: (...e) => c("warn", ...e)
|
|
176
259
|
};
|
|
177
260
|
export {
|
|
178
|
-
|
|
261
|
+
O as Logit
|
|
179
262
|
};
|
|
180
263
|
//# sourceMappingURL=logit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logit.js","sources":["../../../../logit/dist/logit.js"],"sourcesContent":["const $ = {};\nconst v = {\n debug: \"log\",\n success: \"log\"\n}, w = () => typeof window < \"u\" && $?.NODE_ENV ? !1 : typeof process < \"u\" && process.env?.NODE_ENV ? process.env.NODE_ENV === \"production\" : !1, _ = w(), L = typeof window < \"u\" && window.matchMedia?.(\"(prefers-color-scheme: dark)\").matches, b = {\n debug: { bg: \"#616161\", border: \"#424242\", color: \"#fff\", icon: \"☕\", symbol: \"🅳\" },\n error: { bg: \"#d32f2f\", border: \"#c62828\", color: \"#fff\", icon: \"✘\", symbol: \"🅴\" },\n group: { bg: \"#546e7a\", border: \"#455a64\", color: \"#fff\", icon: \"⚭\", symbol: \"🅶\" },\n info: { bg: \"#1976d2\", border: \"#1565c0\", color: \"#fff\", icon: \"ℹ\", symbol: \"🅸\" },\n ns: L ? { bg: \"#fafafa\", border: \"#c7c7c7\", color: \"#000\" } : { bg: \"#424242\", border: \"#212121\", color: \"#fff\" },\n success: { bg: \"#689f38\", border: \"#558b2f\", color: \"#fff\", icon: \"✔\", symbol: \"🆂\" },\n time: { bg: \"#0097a7\", border: \"#00838f\", color: \"#fff\", icon: \"⏲\", symbol: \"🆃\" },\n trace: { bg: \"#d81b60\", border: \"#c2185b\", color: \"#fff\", icon: \"⛢\", symbol: \"🆃\" },\n warn: { bg: \"#ffb300\", border: \"#ffa000\", color: \"#fff\", icon: \"⚠\", symbol: \"🆆\" }\n}, l = {\n debug: 0,\n trace: 1,\n time: 2,\n table: 3,\n info: 4,\n success: 5,\n warn: 6,\n error: 7,\n off: 8\n}, r = {\n environment: !0,\n logLevel: \"debug\",\n namespace: \"\",\n remote: { handler: void 0, logLevel: \"off\" },\n timestamp: !0,\n variant: \"symbol\"\n}, a = (e) => l[r.logLevel] <= l[e], u = () => (/* @__PURE__ */ new Date()).toISOString().slice(11, 23), d = () => _ ? \"🄿\" : \"🄳\", x = (e, o) => {\n r.remote.handler && l[r.remote.logLevel] <= l[e] && r.remote.handler(e, ...o);\n}, g = (e) => v[e] || e, m = \"border: 1px solid\", p = \"border-radius: 4px\", h = \"border-radius: 8px; font: italic small-caps bold 12px; font-weight: lighter\", f = (e, o = \"\") => {\n const { bg: t, color: c, border: n } = b[e], s = `color: ${t}; ${m} ${n}; ${p}`;\n switch (r.variant) {\n case \"symbol\":\n return `${s}; padding: 1px 1px 0${o}`;\n case \"icon\":\n return `${s}; padding: 0 3px${o}`;\n default:\n return `background: ${t}; color: ${c}; ${m} ${n}; ${p}; font-weight: bold; padding: 0 3px${o}`;\n }\n}, E = (e) => {\n const o = b[e], { variant: t } = r;\n return t === \"text\" || !o[t] ? e.toUpperCase() : o[t];\n};\nfunction D(e) {\n const { namespace: o, timestamp: t, environment: c } = r;\n let n = `%c${E(e)}%c`;\n const s = [f(e), \"\"];\n return o && (n += ` %c${o}%c`, s.push(f(\"ns\", `; ${h}`), \"\")), c && (n += ` %c${d()}%c`, s.push(\"color: darkgray\", \"\")), t && (n += ` %c${u()}%c`, s.push(\"color: gray\", \"\")), { format: n, parts: s };\n}\nconst i = (e, ...o) => {\n if (typeof window > \"u\") {\n const s = console[g(e)];\n s(`${E(e)} | ${d()} |`, ...o);\n return;\n }\n if (!a(e)) return;\n const { format: t, parts: c } = D(e), n = console[g(e)];\n n(t, ...c, ...o), x(e, o);\n}, O = (e) => {\n const o = Math.floor(Date.now() - e);\n return o ? `${o}ms` : \"\";\n}, y = {\n /**\n * Asserts a condition and logs an error if it's false.\n */\n assert: (e, o, t) => console.assert(e, o, t),\n debug: (...e) => i(\"debug\", ...e),\n error: (...e) => i(\"error\", ...e),\n /**\n * Gets the current log level.\n */\n getLevel: () => r.logLevel,\n /**\n * Gets the current namespace prefix.\n */\n getPrefix: () => r.namespace,\n /**\n * Gets whether timestamps are shown.\n */\n getTimestamp: () => r.timestamp,\n /**\n * Creates a collapsed group in the console.\n */\n groupCollapsed: (e, o = \"GROUP\", t = Date.now()) => {\n if (!a(\"success\")) return;\n const c = O(t), n = d(), s = r.timestamp ? u() : \"\";\n console.groupCollapsed(\n `%c${o}%c${r.namespace}%c${n}%c${s}%c${c}%c${e}`,\n f(\"group\", \"; margin-right: 6px; padding: 1px 3px 0\"),\n f(\"ns\", `; ${h}; margin-right: 6px`),\n \"color: darkgray; margin-right: 6px\",\n \"color: gray; font-weight: lighter; margin-right: 6px\",\n \"color: gray; font-weight: lighter; margin-right: 6px\",\n \"color: inherit; font-weight: lighter\"\n );\n },\n /**\n * Ends the current console group.\n */\n groupEnd: () => {\n a(\"success\") && console.groupEnd();\n },\n info: (...e) => i(\"info\", ...e),\n /**\n * Initializes Logit with custom options.\n */\n initialise: (e) => {\n Object.assign(r, e);\n },\n /**\n * Sets the minimum log level to display.\n */\n setLogLevel: (e) => {\n r.logLevel = e;\n },\n /**\n * Sets the namespace prefix for all logs.\n */\n setPrefix: (e) => {\n r.namespace = e;\n },\n /**\n * Configures remote logging options.\n */\n setRemote: (e) => {\n r.remote = e;\n },\n /**\n * Sets the log level for remote logging.\n */\n setRemoteLogLevel: (e) => {\n r.remote.logLevel = e;\n },\n /**\n * Sets the display variant (text, icon, or symbol).\n */\n setVariant: (e) => {\n r.variant = e;\n },\n /**\n * Shows or hides the environment indicator.\n */\n showEnvironment: (e) => {\n r.environment = e;\n },\n /**\n * Shows or hides timestamps in logs.\n */\n showTimestamp: (e) => {\n r.timestamp = e;\n },\n success: (...e) => i(\"success\", ...e),\n /**\n * Displays data in a table format.\n */\n table: (...e) => {\n a(\"table\") && console.table(...e);\n },\n /**\n * Starts a timer with the given label.\n */\n time: (e) => {\n a(\"time\") && console.time(e);\n },\n /**\n * Ends a timer with the given label.\n */\n timeEnd: (e) => {\n a(\"time\") && console.timeEnd(e);\n },\n trace: (...e) => i(\"trace\", ...e),\n warn: (...e) => i(\"warn\", ...e)\n};\nexport {\n y as Logit\n};\n//# sourceMappingURL=logit.js.map\n"],"names":["$","w","_","a","d","x","g","m","h","E","i","y"],"mappings":"AAAA,MAAMA,IAAI,CAAA,GACJ,IAAI;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AACX,GAAGC,IAAI,MAAM,OAAO,SAAS,OAAOD,GAAG,WAAW,KAAK,OAAO,UAAU,OAAO,QAAQ,KAAK,WAAW,QAAQ,IAAI,aAAa,eAAe,IAAIE,IAAID,EAAC,GAAI,IAAI,OAAO,SAAS,OAAO,OAAO,aAAa,8BAA8B,EAAE,SAA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,MAAM,CAAC,MAAM;AACX,IAAAA,EAAE,MAAM,KAAK,QAAQ,KAAK,CAAC;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA,EAIA,SAAS,CAAC,MAAM;AACd,IAAAA,EAAE,MAAM,KAAK,QAAQ,QAAQ,CAAC;AAAA,EAChC;AAAA,EACA,OAAO,IAAI,MAAMO,EAAE,SAAS,GAAG,CAAC;AAAA,EAChC,MAAM,IAAI,MAAMA,EAAE,QAAQ,GAAG,CAAC;AAChC;"}
|
|
1
|
+
{"version":3,"file":"logit.js","sources":["../../../../logit/dist/logit.js"],"sourcesContent":["const h = {};\nconst E = {\n debug: \"log\",\n success: \"log\"\n}, $ = () => typeof window < \"u\" && h?.NODE_ENV ? !1 : typeof process < \"u\" && process.env?.NODE_ENV ? process.env.NODE_ENV === \"production\" : !1, g = $(), w = typeof window < \"u\" && window.matchMedia?.(\"(prefers-color-scheme: dark)\").matches, u = {\n debug: { bg: \"#616161\", border: \"#424242\", color: \"#fff\", icon: \"☕\", symbol: \"🅳\" },\n error: { bg: \"#d32f2f\", border: \"#c62828\", color: \"#fff\", icon: \"✘\", symbol: \"🅴\" },\n group: { bg: \"#546e7a\", border: \"#455a64\", color: \"#fff\", icon: \"⚭\", symbol: \"🅶\" },\n info: { bg: \"#1976d2\", border: \"#1565c0\", color: \"#fff\", icon: \"ℹ\", symbol: \"🅸\" },\n ns: w ? { bg: \"#fafafa\", border: \"#c7c7c7\", color: \"#000\" } : { bg: \"#424242\", border: \"#212121\", color: \"#fff\" },\n success: { bg: \"#689f38\", border: \"#558b2f\", color: \"#fff\", icon: \"✔\", symbol: \"🆂\" },\n time: { bg: \"#0097a7\", border: \"#00838f\", color: \"#fff\", icon: \"⏲\", symbol: \"🆃\" },\n trace: { bg: \"#d81b60\", border: \"#c2185b\", color: \"#fff\", icon: \"⛢\", symbol: \"🆃\" },\n warn: { bg: \"#ffb300\", border: \"#ffa000\", color: \"#fff\", icon: \"⚠\", symbol: \"🆆\" }\n}, m = {\n debug: 0,\n trace: 1,\n time: 2,\n table: 3,\n info: 4,\n success: 5,\n warn: 6,\n error: 7,\n off: 8\n}, o = {\n environment: !0,\n logLevel: \"debug\",\n namespace: \"\",\n remote: { handler: void 0, logLevel: \"off\" },\n timestamp: !0,\n variant: \"symbol\"\n}, i = (e) => m[o.logLevel] <= m[e], p = () => (/* @__PURE__ */ new Date()).toISOString().slice(11, 23), d = () => g ? \"🄿\" : \"🄳\", _ = (e, n) => {\n o.remote.handler && m[o.remote.logLevel] <= m[e] && Promise.resolve().then(() => {\n o.remote.handler?.(e, {\n args: n,\n environment: g ? \"production\" : \"development\",\n namespace: o.namespace || void 0,\n timestamp: o.timestamp ? p() : void 0\n });\n });\n}, f = (e) => E[e] || e, L = \"border: 1px solid\", x = \"border-radius: 4px\", b = \"border-radius: 8px; font: italic small-caps bold 12px; font-weight: lighter; padding: 0 4px;\", l = (e, n = \"\") => {\n const { bg: r, color: s, border: t } = u[e], c = `${L} ${t}; ${x}`;\n switch (o.variant) {\n case \"symbol\":\n return `color: ${r}; ${c}; padding: 1px 1px 0${n}`;\n case \"icon\":\n return `color: ${r}; ${c}; padding: 0 3px${n}`;\n default:\n return `background: ${r}; color: ${s}; ${c}; font-weight: bold; padding: 0 3px${n}`;\n }\n}, v = (e) => {\n const n = u[e], { variant: r } = o;\n return r === \"text\" || !n || !n[r] ? e.toUpperCase() : n[r];\n};\nfunction D(e) {\n const { namespace: n, timestamp: r, environment: s } = o;\n let t = `%c${v(e)}%c`;\n const c = [l(e), \"\"];\n return n && (t += ` %c${n}%c`, c.push(l(\"ns\", `; ${b}`), \"\")), s && (t += ` %c${d()}%c`, c.push(\"color: darkgray\", \"\")), r && (t += ` %c${p()}%c`, c.push(\"color: gray\", \"\")), { format: t, parts: c };\n}\nconst a = (e, ...n) => {\n if (typeof window > \"u\") {\n const c = console[f(e)];\n c(`${v(e)} | ${d()} |`, ...n);\n return;\n }\n if (!i(e)) return;\n const { format: r, parts: s } = D(e), t = console[f(e)];\n t(r, ...s, ...n), _(e, n);\n}, N = (e) => {\n const n = Math.floor(Date.now() - e);\n return n ? `${n}ms` : \"\";\n}, O = {\n /**\n * Asserts a condition and logs an error if it's false.\n */\n assert: (e, n, r) => console.assert(e, n, r),\n debug: (...e) => a(\"debug\", ...e),\n error: (...e) => a(\"error\", ...e),\n /**\n * Gets whether the environment indicator is shown.\n */\n getEnvironment: () => o.environment,\n /**\n * Gets the current log level.\n */\n getLevel: () => o.logLevel,\n /**\n * Gets the current namespace prefix.\n */\n getPrefix: () => o.namespace,\n /**\n * Gets whether timestamps are shown.\n */\n getTimestamp: () => o.timestamp,\n /**\n * Gets the current display variant.\n */\n getVariant: () => o.variant,\n /**\n * Creates a collapsed group in the console.\n */\n groupCollapsed: (e, n = \"GROUP\", r = Date.now()) => {\n if (!i(\"success\")) return;\n const s = N(r), t = d(), c = o.timestamp ? p() : \"\";\n console.groupCollapsed(\n `%c${n}%c${o.namespace}%c${t}%c${c}%c${s}%c${e}`,\n l(\"group\", \"; margin-right: 6px; padding: 1px 3px 0\"),\n l(\"ns\", `; ${b}; margin-right: 6px`),\n \"color: darkgray; margin-right: 6px\",\n \"color: gray; font-weight: lighter; margin-right: 6px\",\n \"color: gray; font-weight: lighter; margin-right: 6px\",\n \"color: inherit; font-weight: lighter\"\n );\n },\n /**\n * Ends the current console group.\n */\n groupEnd: () => {\n i(\"success\") && console.groupEnd();\n },\n info: (...e) => a(\"info\", ...e),\n /**\n * Creates a scoped logger with a namespaced prefix.\n * Does not mutate global state - returns an isolated logger instance.\n *\n * @param namespace - The namespace to prepend to all log messages\n * @returns A scoped logger with all logging methods\n *\n * @example\n * ```ts\n * const apiLogger = Logit.scope('api');\n * apiLogger.info('Request received'); // [API] Request received\n *\n * const dbLogger = Logit.scope('database');\n * dbLogger.error('Connection failed'); // [DATABASE] Connection failed\n * ```\n */\n scope: (e) => {\n const n = o.namespace, r = n ? `${n}.${e}` : e;\n return {\n debug: (...s) => {\n const t = o.namespace;\n o.namespace = r, a(\"debug\", ...s), o.namespace = t;\n },\n error: (...s) => {\n const t = o.namespace;\n o.namespace = r, a(\"error\", ...s), o.namespace = t;\n },\n info: (...s) => {\n const t = o.namespace;\n o.namespace = r, a(\"info\", ...s), o.namespace = t;\n },\n success: (...s) => {\n const t = o.namespace;\n o.namespace = r, a(\"success\", ...s), o.namespace = t;\n },\n trace: (...s) => {\n const t = o.namespace;\n o.namespace = r, a(\"trace\", ...s), o.namespace = t;\n },\n warn: (...s) => {\n const t = o.namespace;\n o.namespace = r, a(\"warn\", ...s), o.namespace = t;\n }\n };\n },\n /**\n * Sets the minimum log level to display.\n */\n setLogLevel: (e) => {\n o.logLevel = e;\n },\n /**\n * Sets the namespace prefix for all logs.\n */\n setPrefix: (e) => {\n o.namespace = e;\n },\n /**\n * Configures remote logging options.\n */\n setRemote: (e) => {\n o.remote = e;\n },\n /**\n * Sets the log level for remote logging.\n */\n setRemoteLogLevel: (e) => {\n o.remote.logLevel = e;\n },\n /**\n * Configures Logit with custom options.\n *\n * Note: The remote option will be merged with existing remote config,\n * not replaced entirely. To clear a remote handler, set remote.handler to undefined.\n */\n setup: (e) => {\n e.remote && (o.remote = { ...o.remote, ...e.remote }, delete e.remote), Object.assign(o, e);\n },\n /**\n * Sets the display variant (text, icon, or symbol).\n */\n setVariant: (e) => {\n o.variant = e;\n },\n success: (...e) => a(\"success\", ...e),\n /**\n * Displays data in a table format.\n */\n table: (...e) => {\n i(\"table\") && console.table(...e);\n },\n /**\n * Starts a timer with the given label.\n */\n time: (e) => {\n i(\"time\") && console.time(e);\n },\n /**\n * Ends a timer with the given label.\n */\n timeEnd: (e) => {\n i(\"time\") && console.timeEnd(e);\n },\n /**\n * Toggles or sets the environment indicator visibility.\n * When called without arguments, toggles the current state.\n *\n * @param value - Optional boolean to explicitly set the state\n *\n * @example\n * ```ts\n * Logit.toggleEnvironment(); // Toggles current state\n * Logit.toggleEnvironment(true); // Shows environment indicator\n * Logit.toggleEnvironment(false); // Hides environment indicator\n * ```\n */\n toggleEnvironment: (e) => {\n o.environment = e ?? !o.environment;\n },\n /**\n * Toggles or sets timestamp visibility in logs.\n * When called without arguments, toggles the current state.\n *\n * @param value - Optional boolean to explicitly set the state\n *\n * @example\n * ```ts\n * Logit.toggleTimestamp(); // Toggles current state\n * Logit.toggleTimestamp(true); // Shows timestamps\n * Logit.toggleTimestamp(false); // Hides timestamps\n * ```\n */\n toggleTimestamp: (e) => {\n o.timestamp = e ?? !o.timestamp;\n },\n trace: (...e) => a(\"trace\", ...e),\n warn: (...e) => a(\"warn\", ...e)\n};\nexport {\n O as Logit\n};\n//# sourceMappingURL=logit.js.map\n"],"names":["h","E","$","g","w","u","d","_","n","x","b","r","t","c","a"],"mappings":"AAAA,MAAMA,IAAI,CAAA,GACJC,IAAI;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AACX,GAAGC,IAAI,MAAM,OAAO,SAAS,OAAOF,GAAG,WAAW,KAAK,OAAO,UAAU,OAAO,QAAQ,KAAK,WAAW,QAAQ,IAAI,aAAa,eAAe,IAAIG,IAAID,EAAC,GAAIE,IAAI,OAAO,SAAS,OAAO,OAAO,aAAa,8BAA8B,EAAE,SAASC,IAAI;AAAA,EACtP,OAAO,EAAE,IAAI,WAAW,QAAQ,WAAW,OAAO,QAAQ,MAAM,KAAK,QAAQ,KAAI;AAAA,EACjF,OAAO,EAAE,IAAI,WAAW,QAAQ,WAAW,OAAO,QAAQ,MAAM,KAAK,QAAQ,KAAI;AAAA,EACjF,OAAO,EAAE,IAAI,WAAW,QAAQ,WAAW,OAAO,QAAQ,MAAM,KAAK,QAAQ,KAAI;AAAA,EACjF,MAAM,EAAE,IAAI,WAAW,QAAQ,WAAW,OAAO,QAAQ,MAAM,KAAK,QAAQ,KAAI;AAAA,EAChF,IAAID,IAAI,EAAE,IAAI,WAAW,QAAQ,WAAW,OAAO,OAAM,IAAK,EAAE,IAAI,WAAW,QAAQ,WAAW,OAAO,OAAM;AAAA,EAC/G,SAAS,EAAE,IAA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;AAAA;AAAA;AAAA;AAAA,EAcA,iBAAiB,CAAC,MAAM;AACtB,MAAE,YAAY,KAAK,CAAC,EAAE;AAAA,EACxB;AAAA,EACA,OAAO,IAAI,MAAMA,EAAE,SAAS,GAAG,CAAC;AAAA,EAChC,MAAM,IAAI,MAAMA,EAAE,QAAQ,GAAG,CAAC;AAChC;"}
|
|
@@ -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"}
|
package/dist/math/abs.js
ADDED
|
@@ -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"}
|
package/dist/math/add.js
ADDED
|
@@ -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;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(r,e){if(e<1)throw new Error("Parts must be at least 1");if(typeof r=="bigint"){const t=r/BigInt(e),b=r%BigInt(e),o=[];for(let n=0;n<e;n++)o.push(n<Number(b)?t+1n:t);return o}const i=Math.floor(r/e),u=r-i*e,s=[];for(let t=0;t<e;t++)s.push(t<u?i+1:i);return s}exports.distribute=c;
|
|
2
|
+
//# sourceMappingURL=distribute.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distribute.cjs","sources":["../../src/math/distribute.ts"],"sourcesContent":["/**\n * Distributes an amount evenly among N parties.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * Useful for splitting bills, costs, or payments equally.\n *\n * @example\n * ```ts\n * // Split $100 among 3 people\n * distribute(100, 3);\n * // [34, 33, 33] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * distribute(10000n, 3);\n * // [3334n, 3333n, 3333n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to distribute\n * @param parts - Number of parts to divide into\n * @returns Array of distributed amounts (a sum equals original amount)\n * @throws {Error} If parts are less than 1\n */\nexport function distribute(amount: number, parts: number): number[];\nexport function distribute(amount: bigint, parts: number): bigint[];\nexport function distribute(amount: number | bigint, parts: number): (number | bigint)[] {\n if (parts < 1) {\n throw new Error('Parts must be at least 1');\n }\n\n if (typeof amount === 'bigint') {\n const baseShare = amount / BigInt(parts);\n const remainder = amount % BigInt(parts);\n const results: bigint[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(i < Number(remainder) ? baseShare + 1n : baseShare);\n }\n\n return results;\n }\n\n // Handle number type\n const baseShare = Math.floor(amount / parts);\n const remainder = amount - baseShare * parts;\n const results: number[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(i < remainder ? baseShare + 1 : baseShare);\n }\n\n return results;\n}\n"],"names":["distribute","amount","parts","baseShare","remainder","results","i"],"mappings":"gFAuBO,SAASA,EAAWC,EAAyBC,EAAoC,CACtF,GAAIA,EAAQ,EACV,MAAM,IAAI,MAAM,0BAA0B,EAG5C,GAAI,OAAOD,GAAW,SAAU,CAC9B,MAAME,EAAYF,EAAS,OAAOC,CAAK,EACjCE,EAAYH,EAAS,OAAOC,CAAK,EACjCG,EAAoB,CAAA,EAE1B,QAASC,EAAI,EAAGA,EAAIJ,EAAOI,IAEzBD,EAAQ,KAAKC,EAAI,OAAOF,CAAS,EAAID,EAAY,GAAKA,CAAS,EAGjE,OAAOE,CACT,CAGA,MAAMF,EAAY,KAAK,MAAMF,EAASC,CAAK,EACrCE,EAAYH,EAASE,EAAYD,EACjCG,EAAoB,CAAA,EAE1B,QAASC,EAAI,EAAGA,EAAIJ,EAAOI,IAEzBD,EAAQ,KAAKC,EAAIF,EAAYD,EAAY,EAAIA,CAAS,EAGxD,OAAOE,CACT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function b(t, e) {
|
|
2
|
+
if (e < 1)
|
|
3
|
+
throw new Error("Parts must be at least 1");
|
|
4
|
+
if (typeof t == "bigint") {
|
|
5
|
+
const r = t / BigInt(e), f = t % BigInt(e), o = [];
|
|
6
|
+
for (let n = 0; n < e; n++)
|
|
7
|
+
o.push(n < Number(f) ? r + 1n : r);
|
|
8
|
+
return o;
|
|
9
|
+
}
|
|
10
|
+
const i = Math.floor(t / e), c = t - i * e, s = [];
|
|
11
|
+
for (let r = 0; r < e; r++)
|
|
12
|
+
s.push(r < c ? i + 1 : i);
|
|
13
|
+
return s;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
b as distribute
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=distribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distribute.js","sources":["../../src/math/distribute.ts"],"sourcesContent":["/**\n * Distributes an amount evenly among N parties.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * Useful for splitting bills, costs, or payments equally.\n *\n * @example\n * ```ts\n * // Split $100 among 3 people\n * distribute(100, 3);\n * // [34, 33, 33] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * distribute(10000n, 3);\n * // [3334n, 3333n, 3333n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to distribute\n * @param parts - Number of parts to divide into\n * @returns Array of distributed amounts (a sum equals original amount)\n * @throws {Error} If parts are less than 1\n */\nexport function distribute(amount: number, parts: number): number[];\nexport function distribute(amount: bigint, parts: number): bigint[];\nexport function distribute(amount: number | bigint, parts: number): (number | bigint)[] {\n if (parts < 1) {\n throw new Error('Parts must be at least 1');\n }\n\n if (typeof amount === 'bigint') {\n const baseShare = amount / BigInt(parts);\n const remainder = amount % BigInt(parts);\n const results: bigint[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(i < Number(remainder) ? baseShare + 1n : baseShare);\n }\n\n return results;\n }\n\n // Handle number type\n const baseShare = Math.floor(amount / parts);\n const remainder = amount - baseShare * parts;\n const results: number[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(i < remainder ? baseShare + 1 : baseShare);\n }\n\n return results;\n}\n"],"names":["distribute","amount","parts","baseShare","remainder","results","i"],"mappings":"AAuBO,SAASA,EAAWC,GAAyBC,GAAoC;AACtF,MAAIA,IAAQ;AACV,UAAM,IAAI,MAAM,0BAA0B;AAG5C,MAAI,OAAOD,KAAW,UAAU;AAC9B,UAAME,IAAYF,IAAS,OAAOC,CAAK,GACjCE,IAAYH,IAAS,OAAOC,CAAK,GACjCG,IAAoB,CAAA;AAE1B,aAASC,IAAI,GAAGA,IAAIJ,GAAOI;AAEzBD,MAAAA,EAAQ,KAAKC,IAAI,OAAOF,CAAS,IAAID,IAAY,KAAKA,CAAS;AAGjE,WAAOE;AAAAA,EACT;AAGA,QAAMF,IAAY,KAAK,MAAMF,IAASC,CAAK,GACrCE,IAAYH,IAASE,IAAYD,GACjCG,IAAoB,CAAA;AAE1B,WAASC,IAAI,GAAGA,IAAIJ,GAAOI;AAEzB,IAAAD,EAAQ,KAAKC,IAAIF,IAAYD,IAAY,IAAIA,CAAS;AAGxD,SAAOE;AACT;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(t,e){if(e===0||e===0n)throw new Error("Division by zero");if(typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number")return t/e;throw new TypeError("Both arguments must be of the same type (number or bigint)")}exports.divide=r;
|
|
2
|
+
//# sourceMappingURL=divide.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divide.cjs","sources":["../../src/math/divide.ts"],"sourcesContent":["/**\n * Divides a number by a divisor with precision handling for financial calculations.\n * Supports both regular numbers and bigint for exact precision.\n *\n * @example\n * ```ts\n * divide(20, 5); // 4\n * divide(0.6, 3); // 0.2 (precision-safe)\n * divide(500n, 5n); // 100n\n * ```\n *\n * @param a - Number to divide (dividend)\n * @param b - Divisor\n * @returns Quotient of a divided by b\n * @throws {Error} If divisor is zero\n */\nexport function divide(a: number, b: number): number;\nexport function divide(a: bigint, b: bigint): bigint;\nexport function divide(a: number | bigint, b: number | bigint): number | bigint {\n if (b === 0 || b === 0n) {\n throw new Error('Division by zero');\n }\n\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":["divide","a","b"],"mappings":"gFAkBO,SAASA,EAAOC,EAAoBC,EAAqC,CAC9E,GAAIA,IAAM,GAAKA,IAAM,GACnB,MAAM,IAAI,MAAM,kBAAkB,EAMpC,GAHI,OAAOD,GAAM,UAAY,OAAOC,GAAM,UAGtC,OAAOD,GAAM,UAAY,OAAOC,GAAM,SACxC,OAAOD,EAAIC,EAEb,MAAM,IAAI,UAAU,4DAA4D,CAClF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function t(r, e) {
|
|
2
|
+
if (e === 0 || e === 0n)
|
|
3
|
+
throw new Error("Division by zero");
|
|
4
|
+
if (typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number")
|
|
5
|
+
return r / e;
|
|
6
|
+
throw new TypeError("Both arguments must be of the same type (number or bigint)");
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
t as divide
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=divide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divide.js","sources":["../../src/math/divide.ts"],"sourcesContent":["/**\n * Divides a number by a divisor with precision handling for financial calculations.\n * Supports both regular numbers and bigint for exact precision.\n *\n * @example\n * ```ts\n * divide(20, 5); // 4\n * divide(0.6, 3); // 0.2 (precision-safe)\n * divide(500n, 5n); // 100n\n * ```\n *\n * @param a - Number to divide (dividend)\n * @param b - Divisor\n * @returns Quotient of a divided by b\n * @throws {Error} If divisor is zero\n */\nexport function divide(a: number, b: number): number;\nexport function divide(a: bigint, b: bigint): bigint;\nexport function divide(a: number | bigint, b: number | bigint): number | bigint {\n if (b === 0 || b === 0n) {\n throw new Error('Division by zero');\n }\n\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":["divide","a","b"],"mappings":"AAkBO,SAASA,EAAOC,GAAoBC,GAAqC;AAC9E,MAAIA,MAAM,KAAKA,MAAM;AACnB,UAAM,IAAI,MAAM,kBAAkB;AAMpC,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 r(t,e){if(typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number")return t*e;throw new TypeError("Both arguments must be of the same type (number or bigint)")}exports.multiply=r;
|
|
2
|
+
//# sourceMappingURL=multiply.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiply.cjs","sources":["../../src/math/multiply.ts"],"sourcesContent":["/**\n * Multiplies a number by a scalar with precision handling for financial calculations.\n * Supports both regular numbers and bigint for exact precision.\n *\n * @example\n * ```ts\n * multiply(10, 5); // 50\n * multiply(0.1, 3); // 0.3 (precision-safe)\n * multiply(100n, 5n); // 500n\n * ```\n *\n * @param a - Number to multiply\n * @param b - Multiplier\n * @returns Product of a and b\n */\nexport function multiply(a: number, b: number): number;\nexport function multiply(a: bigint, b: bigint): bigint;\nexport function multiply(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":["multiply","a","b"],"mappings":"gFAiBO,SAASA,EAASC,EAAoBC,EAAqC,CAIhF,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(t, e) {
|
|
2
|
+
if (typeof t == "bigint" && typeof e == "bigint" || typeof t == "number" && typeof e == "number")
|
|
3
|
+
return t * e;
|
|
4
|
+
throw new TypeError("Both arguments must be of the same type (number or bigint)");
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
r as multiply
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=multiply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiply.js","sources":["../../src/math/multiply.ts"],"sourcesContent":["/**\n * Multiplies a number by a scalar with precision handling for financial calculations.\n * Supports both regular numbers and bigint for exact precision.\n *\n * @example\n * ```ts\n * multiply(10, 5); // 50\n * multiply(0.1, 3); // 0.3 (precision-safe)\n * multiply(100n, 5n); // 500n\n * ```\n *\n * @param a - Number to multiply\n * @param b - Multiplier\n * @returns Product of a and b\n */\nexport function multiply(a: number, b: number): number;\nexport function multiply(a: bigint, b: bigint): bigint;\nexport function multiply(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":["multiply","a","b"],"mappings":"AAiBO,SAASA,EAASC,GAAoBC,GAAqC;AAIhF,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 r(t,e){if(typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number")return t-e;throw new TypeError("Both arguments must be of the same type (number or bigint)")}exports.subtract=r;
|
|
2
|
+
//# sourceMappingURL=subtract.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subtract.cjs","sources":["../../src/math/subtract.ts"],"sourcesContent":["/**\n * Subtracts one number from another with precision handling for financial calculations.\n * Supports both regular numbers and bigint for exact precision.\n *\n * @example\n * ```ts\n * subtract(20, 10); // 10\n * subtract(0.3, 0.1); // 0.2 (precision-safe)\n * subtract(300n, 100n); // 200n\n * ```\n *\n * @param a - Number to subtract from\n * @param b - Number to subtract\n * @returns Difference of a and b\n */\nexport function subtract(a: number, b: number): number;\nexport function subtract(a: bigint, b: bigint): bigint;\nexport function subtract(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":["subtract","a","b"],"mappings":"gFAiBO,SAASA,EAASC,EAAoBC,EAAqC,CAIhF,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(t, e) {
|
|
2
|
+
if (typeof t == "bigint" && typeof e == "bigint" || typeof t == "number" && typeof e == "number")
|
|
3
|
+
return t - e;
|
|
4
|
+
throw new TypeError("Both arguments must be of the same type (number or bigint)");
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
r as subtract
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=subtract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subtract.js","sources":["../../src/math/subtract.ts"],"sourcesContent":["/**\n * Subtracts one number from another with precision handling for financial calculations.\n * Supports both regular numbers and bigint for exact precision.\n *\n * @example\n * ```ts\n * subtract(20, 10); // 10\n * subtract(0.3, 0.1); // 0.2 (precision-safe)\n * subtract(300n, 100n); // 200n\n * ```\n *\n * @param a - Number to subtract from\n * @param b - Number to subtract\n * @returns Difference of a and b\n */\nexport function subtract(a: number, b: number): number;\nexport function subtract(a: bigint, b: bigint): bigint;\nexport function subtract(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":["subtract","a","b"],"mappings":"AAiBO,SAASA,EAASC,GAAoBC,GAAqC;AAIhF,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 u(e,t={}){const{locale:c="en-US",style:i="symbol",minimumFractionDigits:s,maximumFractionDigits:a}=t,n=l(e.currency),o=10**n,m=Number(e.amount)/o;let r;switch(i){case"symbol":r="symbol";break;case"code":r="code";break;case"name":r="name";break;default:r="symbol"}return new Intl.NumberFormat(c,{currency:e.currency,currencyDisplay:r,maximumFractionDigits:a??n,minimumFractionDigits:s??n,style:"currency"}).format(m)}function l(e){const t=["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"],c=["BHD","IQD","JOD","KWD","LYD","OMR","TND"];return t.includes(e.toUpperCase())?0:c.includes(e.toUpperCase())?3:2}exports.currency=u;
|
|
2
|
+
//# sourceMappingURL=currency.cjs.map
|