@kikiutils/shared 18.0.1 → 18.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buffer.d.ts +19 -21
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +18 -19
- package/dist/buffer.js.map +1 -1
- package/dist/classes/enhanced-date.d.ts +457 -0
- package/dist/classes/enhanced-date.d.ts.map +1 -0
- package/dist/classes/enhanced-date.js +635 -0
- package/dist/classes/enhanced-date.js.map +1 -0
- package/dist/classes/path.d.ts +211 -48
- package/dist/classes/path.d.ts.map +1 -1
- package/dist/classes/path.js +188 -54
- package/dist/classes/path.js.map +1 -1
- package/dist/classes/precision-number.d.ts +44 -39
- package/dist/classes/precision-number.d.ts.map +1 -1
- package/dist/classes/precision-number.js +51 -45
- package/dist/classes/precision-number.js.map +1 -1
- package/dist/classes/ssh-client.d.ts +3 -4
- package/dist/classes/ssh-client.d.ts.map +1 -1
- package/dist/classes/ssh-client.js +2 -2
- package/dist/classes/ssh-client.js.map +1 -1
- package/dist/clipboard.d.ts +25 -26
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +23 -23
- package/dist/clipboard.js.map +1 -1
- package/dist/consola.d.ts +12 -15
- package/dist/consola.d.ts.map +1 -1
- package/dist/consola.js +10 -12
- package/dist/consola.js.map +1 -1
- package/dist/crypto-hash.d.ts +65 -56
- package/dist/crypto-hash.d.ts.map +1 -1
- package/dist/crypto-hash.js +55 -45
- package/dist/crypto-hash.js.map +1 -1
- package/dist/datetime.d.ts +41 -53
- package/dist/datetime.d.ts.map +1 -1
- package/dist/datetime.js +53 -66
- package/dist/datetime.js.map +1 -1
- package/dist/element-plus.d.ts +13 -14
- package/dist/element-plus.d.ts.map +1 -1
- package/dist/element-plus.js +11 -11
- package/dist/element-plus.js.map +1 -1
- package/dist/enum.d.ts +39 -36
- package/dist/enum.d.ts.map +1 -1
- package/dist/enum.js +36 -32
- package/dist/enum.js.map +1 -1
- package/dist/env.d.ts +22 -15
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -12
- package/dist/env.js.map +1 -1
- package/dist/event-awaiter.d.ts +47 -52
- package/dist/event-awaiter.d.ts.map +1 -1
- package/dist/event-awaiter.js +46 -50
- package/dist/event-awaiter.js.map +1 -1
- package/dist/general.d.ts +22 -17
- package/dist/general.d.ts.map +1 -1
- package/dist/general.js.map +1 -1
- package/dist/hash.d.ts +24 -21
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +20 -16
- package/dist/hash.js.map +1 -1
- package/dist/math.d.ts +20 -19
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +14 -12
- package/dist/math.js.map +1 -1
- package/dist/number.d.ts +10 -9
- package/dist/number.d.ts.map +1 -1
- package/dist/number.js +9 -7
- package/dist/number.js.map +1 -1
- package/dist/object.d.ts +22 -10
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +21 -8
- package/dist/object.js.map +1 -1
- package/dist/pino.d.ts +13 -15
- package/dist/pino.d.ts.map +1 -1
- package/dist/pino.js +10 -15
- package/dist/pino.js.map +1 -1
- package/dist/random.d.ts +17 -15
- package/dist/random.d.ts.map +1 -1
- package/dist/random.js +16 -13
- package/dist/random.js.map +1 -1
- package/dist/redis/script-runner.d.ts +57 -0
- package/dist/redis/script-runner.d.ts.map +1 -0
- package/dist/redis/script-runner.js +46 -0
- package/dist/redis/script-runner.js.map +1 -0
- package/dist/storages/lru/keyed-store.d.ts +18 -14
- package/dist/storages/lru/keyed-store.d.ts.map +1 -1
- package/dist/storages/lru/keyed-store.js +17 -12
- package/dist/storages/lru/keyed-store.js.map +1 -1
- package/dist/storages/redis/keyed-store.d.ts +11 -21
- package/dist/storages/redis/keyed-store.d.ts.map +1 -1
- package/dist/storages/redis/keyed-store.js +10 -19
- package/dist/storages/redis/keyed-store.js.map +1 -1
- package/dist/storages/redis/msgpack.d.ts +33 -13
- package/dist/storages/redis/msgpack.d.ts.map +1 -1
- package/dist/storages/redis/msgpack.js +32 -11
- package/dist/storages/redis/msgpack.js.map +1 -1
- package/dist/storages/redis/types.d.ts +34 -17
- package/dist/storages/redis/types.d.ts.map +1 -1
- package/dist/string.d.ts +12 -11
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +20 -15
- package/dist/string.js.map +1 -1
- package/dist/time.d.ts +26 -21
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js +24 -18
- package/dist/time.js.map +1 -1
- package/dist/types/filtered-key-path.d.ts +4 -15
- package/dist/types/filtered-key-path.d.ts.map +1 -1
- package/dist/types/index.d.ts +10 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/vue.d.ts +7 -7
- package/dist/types/vue.d.ts.map +1 -1
- package/dist/url.d.ts +15 -14
- package/dist/url.d.ts.map +1 -1
- package/dist/url.js +12 -10
- package/dist/url.js.map +1 -1
- package/dist/vue.d.ts +19 -21
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +15 -16
- package/dist/vue.js.map +1 -1
- package/dist/web.d.ts +14 -11
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +12 -8
- package/dist/web.js.map +1 -1
- package/package.json +21 -21
- package/src/buffer.ts +18 -19
- package/src/classes/enhanced-date.ts +715 -0
- package/src/classes/path.ts +248 -96
- package/src/classes/precision-number.ts +61 -53
- package/src/classes/ssh-client.ts +8 -5
- package/src/clipboard.ts +23 -23
- package/src/consola.ts +10 -12
- package/src/crypto-hash.ts +55 -45
- package/src/datetime.ts +65 -85
- package/src/element-plus.ts +11 -11
- package/src/enum.ts +36 -32
- package/src/env.ts +20 -12
- package/src/event-awaiter.ts +49 -50
- package/src/general.ts +20 -14
- package/src/hash.ts +20 -16
- package/src/math.ts +18 -16
- package/src/number.ts +9 -7
- package/src/object.ts +21 -8
- package/src/pino.ts +11 -15
- package/src/random.ts +16 -13
- package/src/redis/script-runner.ts +107 -0
- package/src/storages/lru/keyed-store.ts +17 -12
- package/src/storages/redis/keyed-store.ts +10 -19
- package/src/storages/redis/msgpack.ts +32 -11
- package/src/storages/redis/types.ts +32 -14
- package/src/string.ts +10 -8
- package/src/time.ts +24 -18
- package/src/types/filtered-key-path.ts +9 -14
- package/src/types/vue.ts +6 -5
- package/src/url.ts +12 -10
- package/src/vue.ts +15 -16
- package/src/web.ts +12 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-awaiter.js","names":[
|
|
1
|
+
{"version":3,"file":"event-awaiter.js","names":[],"sources":["../src/event-awaiter.ts"],"sourcesContent":["/**\n * An asynchronous keyed event rendezvous for one or more waiting consumers.\n *\n * @remarks\n * Triggers resolve the currently registered waiters; values are not retained for future waits.\n * Timeouts and subsequent abort events resolve affected waiters with `undefined`.\n * Use `triggerAll` to resolve pending waits during cleanup. Timers and abort listeners are not proactively\n * removed by triggers, so they may remain until their timeout or abort event occurs.\n *\n * @typeParam T - The value delivered to waiting consumers.\n */\nexport class EventAwaiter<T> {\n // Private instance properties\n #promiseResolvers = new Map<string, ((value: PromiseLike<T | undefined> | T | undefined) => void)[]>();\n\n // Public instance methods\n\n /**\n * Resolves all currently pending waits for a key with the supplied value.\n *\n * @param key - The event identifier; a key without pending waits has no effect.\n * @param value - The delivered value; `undefined` indicates no result.\n */\n trigger(key: string, value: T | undefined) {\n const resolvers = this.#promiseResolvers.get(key);\n if (resolvers) {\n this.#promiseResolvers.delete(key);\n resolvers?.forEach((resolve) => resolve(value));\n }\n }\n\n /**\n * Resolves all currently pending waits and clears their registrations.\n *\n * @param value - The delivered value; omission resolves all pending waits with `undefined`.\n */\n triggerAll(value: T | undefined = undefined) {\n for (const [_, resolvers] of this.#promiseResolvers.entries()) resolvers.forEach((resolve) => resolve(value));\n this.#promiseResolvers.clear();\n }\n\n /**\n * Waits for a trigger associated with a key.\n *\n * @remarks\n * By default, multiple waiters share a key and all receive the next trigger value.\n * `strict` mode rejects duplicate waits; `override` mode resolves existing waits with `undefined` before\n * registering the new wait. Timeout and abort remove only the affected waiter's registration.\n * An already aborted signal is not checked; only an abort event emitted after registration ends the wait.\n * Without a timeout or subsequent abort, the wait remains pending until a trigger arrives.\n *\n * @param key - The event identifier to wait for.\n * @param timeoutMs - The optional timeout in milliseconds, using native `setTimeout` timing rules.\n * @param mode - The policy for existing waiters; omission allows multiple waiters.\n * @param signal - A signal whose subsequent abort event ends this wait.\n *\n * @returns A promise resolving to the triggered value, or `undefined` after timeout, abort, or replacement.\n *\n * @throws Error through promise rejection if `strict` mode encounters an existing waiter.\n */\n wait(key: string, timeoutMs?: number, mode?: 'override' | 'strict', signal?: AbortSignal) {\n return new Promise<T | undefined>((resolve) => {\n const resolvers = this.#promiseResolvers.get(key) || [];\n if (resolvers.length) {\n switch (mode) {\n case 'override':\n resolvers.forEach((r) => r(undefined));\n resolvers.length = 0;\n break;\n case 'strict':\n throw new Error(`Duplicate wait detected for key: ${key}`);\n }\n }\n\n resolvers.push(resolve);\n this.#promiseResolvers.set(key, resolvers);\n if (timeoutMs != null) {\n setTimeout(\n () => {\n const resolvers = this.#promiseResolvers.get(key);\n if (resolvers?.includes(resolve)) {\n resolve(undefined);\n const newResolvers = resolvers.filter((r) => r !== resolve);\n if (newResolvers.length) this.#promiseResolvers.set(key, newResolvers);\n else this.#promiseResolvers.delete(key);\n }\n },\n timeoutMs,\n );\n }\n\n if (signal) {\n signal.addEventListener(\n 'abort',\n () => {\n const resolvers = this.#promiseResolvers.get(key);\n if (resolvers?.includes(resolve)) {\n resolve(undefined);\n const newResolvers = resolvers.filter((r) => r !== resolve);\n if (newResolvers.length) this.#promiseResolvers.set(key, newResolvers);\n else this.#promiseResolvers.delete(key);\n }\n },\n { once: true },\n );\n }\n });\n }\n\n /**\n * Waits for a key while rejecting duplicate registrations.\n *\n * @param key - The event identifier to wait for.\n * @param timeoutMs - The optional timeout in milliseconds.\n * @param signal - A signal whose subsequent abort event ends this wait; an already aborted signal is not checked.\n *\n * @returns A promise resolving to the triggered value, or `undefined` on timeout or subsequent abort.\n *\n * @throws Error through promise rejection if the key already has a pending waiter.\n *\n * @see {@link EventAwaiter.wait}\n */\n waitExclusive(key: string, timeoutMs?: number, signal?: AbortSignal) {\n return this.wait(key, timeoutMs, 'strict', signal);\n }\n\n /**\n * Replaces existing waiters for a key and waits for its next trigger.\n *\n * @remarks\n * Existing waiters resolve with `undefined` before the new waiter is registered.\n *\n * @param key - The event identifier to wait for.\n * @param timeoutMs - The optional timeout in milliseconds.\n * @param signal - A signal whose subsequent abort event ends this wait; an already aborted signal is not checked.\n *\n * @returns A promise resolving to the triggered value, or `undefined` on timeout, subsequent abort, or replacement.\n *\n * @see {@link EventAwaiter.wait}\n */\n waitLatest(key: string, timeoutMs?: number, signal?: AbortSignal) {\n return this.wait(key, timeoutMs, 'override', signal);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,eAAb,MAA6B;CAEzB,oCAAoB,IAAI,IAA6E;;;;;;;CAUrG,QAAQ,KAAa,OAAsB;EACvC,MAAM,YAAY,KAAK,kBAAkB,IAAI,GAAG;EAChD,IAAI,WAAW;GACX,KAAK,kBAAkB,OAAO,GAAG;GACjC,WAAW,SAAS,YAAY,QAAQ,KAAK,CAAC;EAClD;CACJ;;;;;;CAOA,WAAW,QAAuB,KAAA,GAAW;EACzC,KAAK,MAAM,CAAC,GAAG,cAAc,KAAK,kBAAkB,QAAQ,GAAG,UAAU,SAAS,YAAY,QAAQ,KAAK,CAAC;EAC5G,KAAK,kBAAkB,MAAM;CACjC;;;;;;;;;;;;;;;;;;;;CAqBA,KAAK,KAAa,WAAoB,MAA8B,QAAsB;EACtF,OAAO,IAAI,SAAwB,YAAY;GAC3C,MAAM,YAAY,KAAK,kBAAkB,IAAI,GAAG,KAAK,CAAC;GACtD,IAAI,UAAU,QACV,QAAQ,MAAR;IACI,KAAK;KACD,UAAU,SAAS,MAAM,EAAE,KAAA,CAAS,CAAC;KACrC,UAAU,SAAS;KACnB;IACJ,KAAK,UACD,MAAM,IAAI,MAAM,oCAAoC,KAAK;GACjE;GAGJ,UAAU,KAAK,OAAO;GACtB,KAAK,kBAAkB,IAAI,KAAK,SAAS;GACzC,IAAI,aAAa,MACb,iBACU;IACF,MAAM,YAAY,KAAK,kBAAkB,IAAI,GAAG;IAChD,IAAI,WAAW,SAAS,OAAO,GAAG;KAC9B,QAAQ,KAAA,CAAS;KACjB,MAAM,eAAe,UAAU,QAAQ,MAAM,MAAM,OAAO;KAC1D,IAAI,aAAa,QAAQ,KAAK,kBAAkB,IAAI,KAAK,YAAY;UAChE,KAAK,kBAAkB,OAAO,GAAG;IAC1C;GACJ,GACA,SACJ;GAGJ,IAAI,QACA,OAAO,iBACH,eACM;IACF,MAAM,YAAY,KAAK,kBAAkB,IAAI,GAAG;IAChD,IAAI,WAAW,SAAS,OAAO,GAAG;KAC9B,QAAQ,KAAA,CAAS;KACjB,MAAM,eAAe,UAAU,QAAQ,MAAM,MAAM,OAAO;KAC1D,IAAI,aAAa,QAAQ,KAAK,kBAAkB,IAAI,KAAK,YAAY;UAChE,KAAK,kBAAkB,OAAO,GAAG;IAC1C;GACJ,GACA,EAAE,MAAM,KAAK,CACjB;EAER,CAAC;CACL;;;;;;;;;;;;;;CAeA,cAAc,KAAa,WAAoB,QAAsB;EACjE,OAAO,KAAK,KAAK,KAAK,WAAW,UAAU,MAAM;CACrD;;;;;;;;;;;;;;;CAgBA,WAAW,KAAa,WAAoB,QAAsB;EAC9D,OAAO,KAAK,KAAK,KAAK,WAAW,YAAY,MAAM;CACvD;AACJ"}
|
package/dist/general.d.ts
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
//#region src/general.d.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Returns the first array element or the input value, with a nullish fallback.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* An empty array, `null`, or `undefined` selects the fallback; omission of a fallback yields `undefined`.
|
|
7
|
+
* The input and selected values are not copied or changed.
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
9
|
+
* @typeParam T - The input value or array element type.
|
|
10
|
+
* @typeParam D - The fallback type when the fallback overload is used.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
12
|
+
* @param value - A single value or an array of values.
|
|
13
|
+
* @param defaultValue - The fallback returned when the selected value is nullish.
|
|
14
14
|
*
|
|
15
|
-
* @returns
|
|
15
|
+
* @returns The selected non-nullish value, or the fallback without copying either value.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
19
20
|
* import { extractFirstValue } from '@kikiutils/shared/general';
|
|
20
21
|
*
|
|
21
|
-
* console.log(extractFirstValue([
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* console.log(extractFirstValue([
|
|
23
|
+
* 1,
|
|
24
|
+
* 2,
|
|
25
|
+
* 3,
|
|
26
|
+
* ])); // => 1
|
|
27
|
+
*
|
|
28
|
+
* console.log(extractFirstValue('hello')); // => 'hello'
|
|
29
|
+
* console.log(extractFirstValue([], 'default')); // => 'default'
|
|
30
|
+
* console.log(extractFirstValue(undefined, 'fallback')); // => 'fallback'
|
|
25
31
|
* ```
|
|
26
32
|
*/
|
|
27
|
-
declare function extractFirstValue<T>(value: T | T[]): T | undefined;
|
|
28
|
-
declare function extractFirstValue<T, D>(value: T | T[], defaultValue: D): D | NonNullable<T>;
|
|
33
|
+
export declare function extractFirstValue<T>(value: T | T[]): T | undefined;
|
|
34
|
+
export declare function extractFirstValue<T, D>(value: T | T[], defaultValue: D): D | NonNullable<T>;
|
|
29
35
|
//#endregion
|
|
30
|
-
export { extractFirstValue };
|
|
31
36
|
//# sourceMappingURL=general.d.ts.map
|
package/dist/general.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.d.ts","names":[],"sources":["../src/general.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"general.d.ts","names":[],"sources":["../src/general.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiCgB,kBAAkB,GAAG,OAAO,IAAI,MAAM;wBACtC,kBAAkB,GAAG,GAAG,OAAO,IAAI,KAAK,cAAc,IAAI,IAAI,YAAY"}
|
package/dist/general.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.js","names":[],"sources":["../src/general.ts"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"general.js","names":[],"sources":["../src/general.ts"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n\n/**\n * Returns the first array element or the input value, with a nullish fallback.\n *\n * @remarks\n * An empty array, `null`, or `undefined` selects the fallback; omission of a fallback yields `undefined`.\n * The input and selected values are not copied or changed.\n *\n * @typeParam T - The input value or array element type.\n * @typeParam D - The fallback type when the fallback overload is used.\n *\n * @param value - A single value or an array of values.\n * @param defaultValue - The fallback returned when the selected value is nullish.\n *\n * @returns The selected non-nullish value, or the fallback without copying either value.\n *\n * @example\n *\n * ```ts\n * import { extractFirstValue } from '@kikiutils/shared/general';\n *\n * console.log(extractFirstValue([\n * 1,\n * 2,\n * 3,\n * ])); // => 1\n *\n * console.log(extractFirstValue('hello')); // => 'hello'\n * console.log(extractFirstValue([], 'default')); // => 'default'\n * console.log(extractFirstValue(undefined, 'fallback')); // => 'fallback'\n * ```\n */\nexport function extractFirstValue<T>(value: T | T[]): T | undefined;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue: D): D | NonNullable<T>;\nexport function extractFirstValue<T, D>(value: T | T[], defaultValue?: D) {\n return (Array.isArray(value) ? value[0] : value) ?? defaultValue;\n}\n\n/* eslint-enable jsdoc/check-param-names */\n"],"mappings":";AAmCA,SAAgB,kBAAwB,OAAgB,cAAkB;CACtE,QAAQ,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,UAAU;AACxD"}
|
package/dist/hash.d.ts
CHANGED
|
@@ -2,63 +2,66 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Computes the SHA-3 hash of the given data using the 224-bit digest.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
5
|
+
* @param data - The UTF-8 string or raw bytes to hash.
|
|
6
6
|
*
|
|
7
|
-
* @returns
|
|
7
|
+
* @returns The hexadecimal hash digest.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
11
12
|
* import { sha3224 } from '@kikiutils/shared/hash';
|
|
12
13
|
*
|
|
13
|
-
* console.log(sha3224('test')); // 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
|
|
14
|
+
* console.log(sha3224('test')); // => 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
|
|
14
15
|
* ```
|
|
15
16
|
*/
|
|
16
|
-
declare function sha3224(data: string | Uint8Array): string;
|
|
17
|
+
export declare function sha3224(data: string | Uint8Array): string;
|
|
17
18
|
/**
|
|
18
19
|
* Computes the SHA-3 hash of the given data using the 256-bit digest.
|
|
19
20
|
*
|
|
20
|
-
* @param
|
|
21
|
+
* @param data - The UTF-8 string or raw bytes to hash.
|
|
21
22
|
*
|
|
22
|
-
* @returns
|
|
23
|
+
* @returns The hexadecimal hash digest.
|
|
23
24
|
*
|
|
24
25
|
* @example
|
|
25
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
26
28
|
* import { sha3256 } from '@kikiutils/shared/hash';
|
|
27
29
|
*
|
|
28
|
-
* console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
|
30
|
+
* console.log(sha3256('test')); // => 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
|
29
31
|
* ```
|
|
30
32
|
*/
|
|
31
|
-
declare function sha3256(data: string | Uint8Array): string;
|
|
33
|
+
export declare function sha3256(data: string | Uint8Array): string;
|
|
32
34
|
/**
|
|
33
35
|
* Computes the SHA-3 hash of the given data using the 384-bit digest.
|
|
34
36
|
*
|
|
35
|
-
* @param
|
|
37
|
+
* @param data - The UTF-8 string or raw bytes to hash.
|
|
36
38
|
*
|
|
37
|
-
* @returns
|
|
39
|
+
* @returns The hexadecimal hash digest.
|
|
38
40
|
*
|
|
39
41
|
* @example
|
|
40
|
-
*
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
41
44
|
* import { sha3384 } from '@kikiutils/shared/hash';
|
|
42
45
|
*
|
|
43
|
-
* console.log(sha3384('test')); // e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
|
|
46
|
+
* console.log(sha3384('test')); // => e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
|
|
44
47
|
* ```
|
|
45
48
|
*/
|
|
46
|
-
declare function sha3384(data: string | Uint8Array): string;
|
|
49
|
+
export declare function sha3384(data: string | Uint8Array): string;
|
|
47
50
|
/**
|
|
48
51
|
* Computes the SHA-3 hash of the given data using the 512-bit digest.
|
|
49
52
|
*
|
|
50
|
-
* @param
|
|
53
|
+
* @param data - The UTF-8 string or raw bytes to hash.
|
|
51
54
|
*
|
|
52
|
-
* @returns
|
|
55
|
+
* @returns The hexadecimal hash digest.
|
|
53
56
|
*
|
|
54
57
|
* @example
|
|
55
|
-
*
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
56
60
|
* import { sha3512 } from '@kikiutils/shared/hash';
|
|
57
61
|
*
|
|
58
|
-
* console.log(sha3512('test')); // 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
|
|
62
|
+
* console.log(sha3512('test')); // => 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
|
|
59
63
|
* ```
|
|
60
64
|
*/
|
|
61
|
-
declare function sha3512(data: string | Uint8Array): string;
|
|
65
|
+
export declare function sha3512(data: string | Uint8Array): string;
|
|
62
66
|
//#endregion
|
|
63
|
-
export { sha3224, sha3256, sha3384, sha3512 };
|
|
64
67
|
//# sourceMappingURL=hash.d.ts.map
|
package/dist/hash.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","names":[],"sources":["../src/hash.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.d.ts","names":[],"sources":["../src/hash.ts"],"mappings":";;;;;;;;;;;;;;;;wBA0BgB,QAAQ,eAAe;;;;;;;;;;;;;;;;wBAmBvB,QAAQ,eAAe;;;;;;;;;;;;;;;;wBAmBvB,QAAQ,eAAe;;;;;;;;;;;;;;;;wBAmBvB,QAAQ,eAAe"}
|
package/dist/hash.js
CHANGED
|
@@ -4,15 +4,16 @@ import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Computes the SHA-3 hash of the given data using the 224-bit digest.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param data - The UTF-8 string or raw bytes to hash.
|
|
8
8
|
*
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns The hexadecimal hash digest.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
13
14
|
* import { sha3224 } from '@kikiutils/shared/hash';
|
|
14
15
|
*
|
|
15
|
-
* console.log(sha3224('test')); // 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
|
|
16
|
+
* console.log(sha3224('test')); // => 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
19
|
function sha3224(data) {
|
|
@@ -21,15 +22,16 @@ function sha3224(data) {
|
|
|
21
22
|
/**
|
|
22
23
|
* Computes the SHA-3 hash of the given data using the 256-bit digest.
|
|
23
24
|
*
|
|
24
|
-
* @param
|
|
25
|
+
* @param data - The UTF-8 string or raw bytes to hash.
|
|
25
26
|
*
|
|
26
|
-
* @returns
|
|
27
|
+
* @returns The hexadecimal hash digest.
|
|
27
28
|
*
|
|
28
29
|
* @example
|
|
29
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
30
32
|
* import { sha3256 } from '@kikiutils/shared/hash';
|
|
31
33
|
*
|
|
32
|
-
* console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
|
34
|
+
* console.log(sha3256('test')); // => 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
|
33
35
|
* ```
|
|
34
36
|
*/
|
|
35
37
|
function sha3256(data) {
|
|
@@ -38,15 +40,16 @@ function sha3256(data) {
|
|
|
38
40
|
/**
|
|
39
41
|
* Computes the SHA-3 hash of the given data using the 384-bit digest.
|
|
40
42
|
*
|
|
41
|
-
* @param
|
|
43
|
+
* @param data - The UTF-8 string or raw bytes to hash.
|
|
42
44
|
*
|
|
43
|
-
* @returns
|
|
45
|
+
* @returns The hexadecimal hash digest.
|
|
44
46
|
*
|
|
45
47
|
* @example
|
|
46
|
-
*
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
47
50
|
* import { sha3384 } from '@kikiutils/shared/hash';
|
|
48
51
|
*
|
|
49
|
-
* console.log(sha3384('test')); // e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
|
|
52
|
+
* console.log(sha3384('test')); // => e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
|
|
50
53
|
* ```
|
|
51
54
|
*/
|
|
52
55
|
function sha3384(data) {
|
|
@@ -55,15 +58,16 @@ function sha3384(data) {
|
|
|
55
58
|
/**
|
|
56
59
|
* Computes the SHA-3 hash of the given data using the 512-bit digest.
|
|
57
60
|
*
|
|
58
|
-
* @param
|
|
61
|
+
* @param data - The UTF-8 string or raw bytes to hash.
|
|
59
62
|
*
|
|
60
|
-
* @returns
|
|
63
|
+
* @returns The hexadecimal hash digest.
|
|
61
64
|
*
|
|
62
65
|
* @example
|
|
63
|
-
*
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
64
68
|
* import { sha3512 } from '@kikiutils/shared/hash';
|
|
65
69
|
*
|
|
66
|
-
* console.log(sha3512('test')); // 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
|
|
70
|
+
* console.log(sha3512('test')); // => 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
|
|
67
71
|
* ```
|
|
68
72
|
*/
|
|
69
73
|
function sha3512(data) {
|
package/dist/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","names":[],"sources":["../src/hash.ts"],"sourcesContent":["import {\n sha3_224,\n sha3_256,\n sha3_384,\n sha3_512,\n} from '@noble/hashes/sha3.js';\nimport {\n bytesToHex,\n utf8ToBytes,\n} from '@noble/hashes/utils.js';\n\n/**\n * Computes the SHA-3 hash of the given data using the 224-bit digest.\n *\n * @param
|
|
1
|
+
{"version":3,"file":"hash.js","names":[],"sources":["../src/hash.ts"],"sourcesContent":["import {\n sha3_224,\n sha3_256,\n sha3_384,\n sha3_512,\n} from '@noble/hashes/sha3.js';\nimport {\n bytesToHex,\n utf8ToBytes,\n} from '@noble/hashes/utils.js';\n\n/**\n * Computes the SHA-3 hash of the given data using the 224-bit digest.\n *\n * @param data - The UTF-8 string or raw bytes to hash.\n *\n * @returns The hexadecimal hash digest.\n *\n * @example\n *\n * ```ts\n * import { sha3224 } from '@kikiutils/shared/hash';\n *\n * console.log(sha3224('test')); // => 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b\n * ```\n */\nexport function sha3224(data: string | Uint8Array) {\n return bytesToHex(sha3_224(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 256-bit digest.\n *\n * @param data - The UTF-8 string or raw bytes to hash.\n *\n * @returns The hexadecimal hash digest.\n *\n * @example\n *\n * ```ts\n * import { sha3256 } from '@kikiutils/shared/hash';\n *\n * console.log(sha3256('test')); // => 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\nexport function sha3256(data: string | Uint8Array) {\n return bytesToHex(sha3_256(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 384-bit digest.\n *\n * @param data - The UTF-8 string or raw bytes to hash.\n *\n * @returns The hexadecimal hash digest.\n *\n * @example\n *\n * ```ts\n * import { sha3384 } from '@kikiutils/shared/hash';\n *\n * console.log(sha3384('test')); // => e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...\n * ```\n */\nexport function sha3384(data: string | Uint8Array) {\n return bytesToHex(sha3_384(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 512-bit digest.\n *\n * @param data - The UTF-8 string or raw bytes to hash.\n *\n * @returns The hexadecimal hash digest.\n *\n * @example\n *\n * ```ts\n * import { sha3512 } from '@kikiutils/shared/hash';\n *\n * console.log(sha3512('test')); // => 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...\n * ```\n */\nexport function sha3512(data: string | Uint8Array) {\n return bytesToHex(sha3_512(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,SAAgB,QAAQ,MAA2B;CAC/C,OAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,IAAI,IAAI,IAAI,CAAC;AACnF;;;;;;;;;;;;;;;;AAiBA,SAAgB,QAAQ,MAA2B;CAC/C,OAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,IAAI,IAAI,IAAI,CAAC;AACnF;;;;;;;;;;;;;;;;AAiBA,SAAgB,QAAQ,MAA2B;CAC/C,OAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,IAAI,IAAI,IAAI,CAAC;AACnF;;;;;;;;;;;;;;;;AAiBA,SAAgB,QAAQ,MAA2B;CAC/C,OAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,IAAI,IAAI,IAAI,CAAC;AACnF"}
|
package/dist/math.d.ts
CHANGED
|
@@ -6,43 +6,44 @@ type CalculableValue = Decimal.Value | {
|
|
|
6
6
|
/**
|
|
7
7
|
* Options for configuring the output of `toPercentageString`.
|
|
8
8
|
*/
|
|
9
|
-
interface ToPercentageStringOptions {
|
|
9
|
+
export interface ToPercentageStringOptions {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* The number of decimal places to include in the result.
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
13
|
+
* @defaultValue 2
|
|
14
14
|
*/
|
|
15
15
|
decimalPlaces?: number;
|
|
16
16
|
/**
|
|
17
|
-
* Whether to include the
|
|
17
|
+
* Whether to include the `%` symbol in the result.
|
|
18
18
|
*
|
|
19
|
-
* @
|
|
19
|
+
* @defaultValue true
|
|
20
20
|
*/
|
|
21
21
|
withSymbol?: boolean;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Converts a
|
|
24
|
+
* Converts a numerator and denominator into a formatted percentage.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* A `NaN` or infinite quotient produces `0.00`, regardless of the configured decimal places;
|
|
28
|
+
* the percent symbol is appended according to `options.withSymbol`.
|
|
29
|
+
* Invalid decimal input and formatting options propagate decimal.js exceptions.
|
|
29
30
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
31
|
+
* @param molecular - The numerator of the fraction.
|
|
32
|
+
* @param denominator - The denominator of the fraction.
|
|
33
|
+
* @param options - Output precision and percent-symbol settings.
|
|
33
34
|
*
|
|
34
|
-
* @returns
|
|
35
|
+
* @returns The formatted percentage string.
|
|
35
36
|
*
|
|
36
37
|
* @example
|
|
37
|
-
*
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
38
40
|
* import { toPercentageString } from '@kikiutils/shared/math';
|
|
39
41
|
*
|
|
40
|
-
* console.log(toPercentageString(50, 200)); // 25.00%
|
|
41
|
-
* console.log(toPercentageString(50, 200, { withSymbol: false })); // 25.00
|
|
42
|
-
* console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // 25.0%
|
|
42
|
+
* console.log(toPercentageString(50, 200)); // => '25.00%'
|
|
43
|
+
* console.log(toPercentageString(50, 200, { withSymbol: false })); // => '25.00'
|
|
44
|
+
* console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // => '25.0%'
|
|
43
45
|
* ```
|
|
44
46
|
*/
|
|
45
|
-
declare function toPercentageString(molecular: CalculableValue, denominator: CalculableValue, options?: ToPercentageStringOptions): string;
|
|
47
|
+
export declare function toPercentageString(molecular: CalculableValue, denominator: CalculableValue, options?: ToPercentageStringOptions): string;
|
|
46
48
|
//#endregion
|
|
47
|
-
export { ToPercentageStringOptions, toPercentageString };
|
|
48
49
|
//# sourceMappingURL=math.d.ts.map
|
package/dist/math.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","names":[],"sources":["../src/math.ts"],"mappings":";;KAEK,kBAAkB,QAAQ;EAAU;;;;;
|
|
1
|
+
{"version":3,"file":"math.d.ts","names":[],"sources":["../src/math.ts"],"mappings":";;KAEK,kBAAkB,QAAQ;EAAU;;;;;iBAKxB;;;;;;EAMb;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BY,mBACZ,WAAW,iBACX,aAAa,iBACb,UAAU"}
|
package/dist/math.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { Decimal } from "decimal.js";
|
|
2
2
|
//#region src/math.ts
|
|
3
3
|
/**
|
|
4
|
-
* Converts a
|
|
4
|
+
* Converts a numerator and denominator into a formatted percentage.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A `NaN` or infinite quotient produces `0.00`, regardless of the configured decimal places;
|
|
8
|
+
* the percent symbol is appended according to `options.withSymbol`.
|
|
9
|
+
* Invalid decimal input and formatting options propagate decimal.js exceptions.
|
|
9
10
|
*
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
11
|
+
* @param molecular - The numerator of the fraction.
|
|
12
|
+
* @param denominator - The denominator of the fraction.
|
|
13
|
+
* @param options - Output precision and percent-symbol settings.
|
|
13
14
|
*
|
|
14
|
-
* @returns
|
|
15
|
+
* @returns The formatted percentage string.
|
|
15
16
|
*
|
|
16
17
|
* @example
|
|
17
|
-
*
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
18
20
|
* import { toPercentageString } from '@kikiutils/shared/math';
|
|
19
21
|
*
|
|
20
|
-
* console.log(toPercentageString(50, 200)); // 25.00%
|
|
21
|
-
* console.log(toPercentageString(50, 200, { withSymbol: false })); // 25.00
|
|
22
|
-
* console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // 25.0%
|
|
22
|
+
* console.log(toPercentageString(50, 200)); // => '25.00%'
|
|
23
|
+
* console.log(toPercentageString(50, 200, { withSymbol: false })); // => '25.00'
|
|
24
|
+
* console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // => '25.0%'
|
|
23
25
|
* ```
|
|
24
26
|
*/
|
|
25
27
|
function toPercentageString(molecular, denominator, options) {
|
package/dist/math.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","names":[],"sources":["../src/math.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\n\ntype CalculableValue = Decimal.Value | { toString: () => string };\n\n/**\n * Options for configuring the output of `toPercentageString`.\n */\nexport interface ToPercentageStringOptions {\n /**\n *
|
|
1
|
+
{"version":3,"file":"math.js","names":[],"sources":["../src/math.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\n\ntype CalculableValue = Decimal.Value | { toString: () => string };\n\n/**\n * Options for configuring the output of `toPercentageString`.\n */\nexport interface ToPercentageStringOptions {\n /**\n * The number of decimal places to include in the result.\n *\n * @defaultValue 2\n */\n decimalPlaces?: number;\n\n /**\n * Whether to include the `%` symbol in the result.\n *\n * @defaultValue true\n */\n withSymbol?: boolean;\n}\n\n/**\n * Converts a numerator and denominator into a formatted percentage.\n *\n * @remarks\n * A `NaN` or infinite quotient produces `0.00`, regardless of the configured decimal places;\n * the percent symbol is appended according to `options.withSymbol`.\n * Invalid decimal input and formatting options propagate decimal.js exceptions.\n *\n * @param molecular - The numerator of the fraction.\n * @param denominator - The denominator of the fraction.\n * @param options - Output precision and percent-symbol settings.\n *\n * @returns The formatted percentage string.\n *\n * @example\n *\n * ```ts\n * import { toPercentageString } from '@kikiutils/shared/math';\n *\n * console.log(toPercentageString(50, 200)); // => '25.00%'\n * console.log(toPercentageString(50, 200, { withSymbol: false })); // => '25.00'\n * console.log(toPercentageString(50, 200, { decimalPlaces: 1 })); // => '25.0%'\n * ```\n */\nexport function toPercentageString(\n molecular: CalculableValue,\n denominator: CalculableValue,\n options?: ToPercentageStringOptions,\n) {\n const molecularDecimal = new Decimal(molecular.toString());\n const denominatorDecimal = new Decimal(denominator.toString());\n const calculationResult = molecularDecimal.div(denominatorDecimal);\n\n const result = calculationResult.isNaN() || !calculationResult.isFinite()\n ? '0.00'\n : calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);\n\n return options?.withSymbol ?? true ? `${result}%` : result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,mBACZ,WACA,aACA,SACF;CACE,MAAM,mBAAmB,IAAI,QAAQ,UAAU,SAAS,CAAC;CACzD,MAAM,qBAAqB,IAAI,QAAQ,YAAY,SAAS,CAAC;CAC7D,MAAM,oBAAoB,iBAAiB,IAAI,kBAAkB;CAEjE,MAAM,SAAS,kBAAkB,MAAM,KAAK,CAAC,kBAAkB,SAAS,IAClE,SACA,kBAAkB,MAAM,GAAG,CAAC,CAAC,QAAQ,SAAS,iBAAiB,CAAC;CAEtE,OAAO,SAAS,cAAc,OAAO,GAAG,OAAO,KAAK;AACxD"}
|
package/dist/number.d.ts
CHANGED
|
@@ -3,22 +3,23 @@ import { millify } from "millify";
|
|
|
3
3
|
/**
|
|
4
4
|
* Converts a large number into a compact, human-readable string using `millify`.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Uses lowercase units, for example `k` and `m`, and a precision of `2` unless overridden.
|
|
7
8
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
9
|
+
* @param value - The number to format.
|
|
10
|
+
* @param options - Optional configuration passed to `millify`.
|
|
10
11
|
*
|
|
11
|
-
* @returns
|
|
12
|
+
* @returns The compact number string.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
15
17
|
* import { toCompactNumberString } from '@kikiutils/shared/number';
|
|
16
18
|
*
|
|
17
|
-
* console.log(toCompactNumberString(1234567)); // 1.23m
|
|
18
|
-
* console.log(toCompactNumberString(1234567, { precision: 3 })); // 1.235m
|
|
19
|
+
* console.log(toCompactNumberString(1234567)); // => 1.23m
|
|
20
|
+
* console.log(toCompactNumberString(1234567, { precision: 3 })); // => 1.235m
|
|
19
21
|
* ```
|
|
20
22
|
*/
|
|
21
|
-
declare function toCompactNumberString(value: number, options?: Parameters<typeof millify>[1]): string;
|
|
23
|
+
export declare function toCompactNumberString(value: number, options?: Parameters<typeof millify>[1]): string;
|
|
22
24
|
//#endregion
|
|
23
|
-
export { toCompactNumberString };
|
|
24
25
|
//# sourceMappingURL=number.d.ts.map
|
package/dist/number.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","names":[],"sources":["../src/number.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"number.d.ts","names":[],"sources":["../src/number.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBAsBgB,sBAAsB,eAAe,UAAU,kBAAkB"}
|
package/dist/number.js
CHANGED
|
@@ -3,19 +3,21 @@ import { millify } from "millify";
|
|
|
3
3
|
/**
|
|
4
4
|
* Converts a large number into a compact, human-readable string using `millify`.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Uses lowercase units, for example `k` and `m`, and a precision of `2` unless overridden.
|
|
7
8
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
9
|
+
* @param value - The number to format.
|
|
10
|
+
* @param options - Optional configuration passed to `millify`.
|
|
10
11
|
*
|
|
11
|
-
* @returns
|
|
12
|
+
* @returns The compact number string.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
15
17
|
* import { toCompactNumberString } from '@kikiutils/shared/number';
|
|
16
18
|
*
|
|
17
|
-
* console.log(toCompactNumberString(1234567)); // 1.23m
|
|
18
|
-
* console.log(toCompactNumberString(1234567, { precision: 3 })); // 1.235m
|
|
19
|
+
* console.log(toCompactNumberString(1234567)); // => 1.23m
|
|
20
|
+
* console.log(toCompactNumberString(1234567, { precision: 3 })); // => 1.235m
|
|
19
21
|
* ```
|
|
20
22
|
*/
|
|
21
23
|
function toCompactNumberString(value, options) {
|
package/dist/number.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","names":[],"sources":["../src/number.ts"],"sourcesContent":["import { millify } from 'millify';\n\n/**\n * Converts a large number into a compact, human-readable string using `millify`.\n *\n *
|
|
1
|
+
{"version":3,"file":"number.js","names":[],"sources":["../src/number.ts"],"sourcesContent":["import { millify } from 'millify';\n\n/**\n * Converts a large number into a compact, human-readable string using `millify`.\n *\n * @remarks\n * Uses lowercase units, for example `k` and `m`, and a precision of `2` unless overridden.\n *\n * @param value - The number to format.\n * @param options - Optional configuration passed to `millify`.\n *\n * @returns The compact number string.\n *\n * @example\n *\n * ```ts\n * import { toCompactNumberString } from '@kikiutils/shared/number';\n *\n * console.log(toCompactNumberString(1234567)); // => 1.23m\n * console.log(toCompactNumberString(1234567, { precision: 3 })); // => 1.235m\n * ```\n */\nexport function toCompactNumberString(value: number, options?: Parameters<typeof millify>[1]) {\n return millify(\n value,\n {\n lowercase: true,\n precision: 2,\n ...options,\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,sBAAsB,OAAe,SAAyC;CAC1F,OAAO,QACH,OACA;EACI,WAAW;EACX,WAAW;EACX,GAAG;CACP,CACJ;AACJ"}
|
package/dist/object.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Serializes a nested object into a deterministic, flat string format.
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* This function recursively traverses the input object (including nested objects and arrays),
|
|
6
7
|
* flattens it into key paths using dot notation (e.g. "a.b.0.c"), sorts all keys,
|
|
7
8
|
* and joins each key-value pair into a string with customizable separators.
|
|
@@ -12,21 +13,32 @@
|
|
|
12
13
|
* Note: Empty objects and arrays produce an empty string, which is useful for
|
|
13
14
|
* generating deterministic signature payloads.
|
|
14
15
|
*
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
*
|
|
16
|
+
* @param input - The object to serialize. Can contain nested objects and arrays.
|
|
17
|
+
* @param kvSeparator - The string used to separate each key from its value (default: '=').
|
|
18
|
+
* @param pairSeparator - The string used to separate each key-value pair (default: '&').
|
|
19
|
+
*
|
|
20
|
+
* @returns A deterministic string representation of the input object.
|
|
19
21
|
*
|
|
20
22
|
* @example
|
|
21
|
-
*
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
22
25
|
* import { stringifyObjectDeterministically } from '@kikiutils/shared/object';
|
|
23
26
|
*
|
|
24
|
-
* console.log(stringifyObjectDeterministically({
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
+
* console.log(stringifyObjectDeterministically({
|
|
28
|
+
* b: 2,
|
|
29
|
+
* a: {
|
|
30
|
+
* x: 1,
|
|
31
|
+
* y: [
|
|
32
|
+
* 3,
|
|
33
|
+
* 4,
|
|
34
|
+
* ],
|
|
35
|
+
* },
|
|
36
|
+
* })); // => a.x=1&a.y.0=3&a.y.1=4&b=2
|
|
37
|
+
*
|
|
38
|
+
* console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // => foo:bar
|
|
39
|
+
* console.log(stringifyObjectDeterministically({})); // => ''
|
|
27
40
|
* ```
|
|
28
41
|
*/
|
|
29
|
-
declare function stringifyObjectDeterministically(input: Record<string, any>, kvSeparator?: string, pairSeparator?: string): string;
|
|
42
|
+
export declare function stringifyObjectDeterministically(input: Record<string, any>, kvSeparator?: string, pairSeparator?: string): string;
|
|
30
43
|
//#endregion
|
|
31
|
-
export { stringifyObjectDeterministically };
|
|
32
44
|
//# sourceMappingURL=object.d.ts.map
|
package/dist/object.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","names":[],"sources":["../src/object.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"object.d.ts","names":[],"sources":["../src/object.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCgB,iCACZ,OAAO,qBACP,sBACA"}
|