@kikiutils/shared 12.0.0 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/buffer.d.ts +7 -3
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +42 -0
- package/dist/buffer.js.map +1 -0
- package/dist/clipboard.d.ts +8 -6
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +86 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/consola.d.ts +8 -2
- package/dist/consola.d.ts.map +1 -1
- package/dist/consola.js +32 -0
- package/dist/consola.js.map +1 -0
- package/dist/crypto-hash.d.ts +16 -26
- package/dist/crypto-hash.d.ts.map +1 -1
- package/dist/crypto-hash.js +37 -0
- package/dist/crypto-hash.js.map +1 -0
- package/dist/datetime.d.ts +13 -9
- package/dist/datetime.d.ts.map +1 -1
- package/dist/datetime.js +131 -0
- package/dist/datetime.js.map +1 -0
- package/dist/element-plus.d.ts +8 -4
- package/dist/element-plus.d.ts.map +1 -1
- package/dist/element-plus.js +37 -0
- package/dist/element-plus.js.map +1 -0
- package/dist/enum.d.ts +6 -3
- package/dist/enum.d.ts.map +1 -1
- package/dist/enum.js +108 -0
- package/dist/enum.js.map +1 -0
- package/dist/env.d.ts +12 -9
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +51 -0
- package/dist/env.js.map +1 -0
- package/dist/general.d.ts +5 -2
- package/dist/general.d.ts.map +1 -1
- package/dist/general.js +8 -0
- package/dist/general.js.map +1 -0
- package/dist/hash.d.ts +7 -4
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +20 -0
- package/dist/hash.js.map +1 -0
- package/dist/math.d.ts +20 -17
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +36 -0
- package/dist/math.js.map +1 -0
- package/dist/number.d.ts +7 -2
- package/dist/number.d.ts.map +1 -1
- package/dist/number.js +32 -0
- package/dist/number.js.map +1 -0
- package/dist/object.d.ts +4 -1
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +42 -0
- package/dist/object.js.map +1 -0
- package/dist/pino.d.ts +8 -2
- package/dist/pino.d.ts.map +1 -1
- package/dist/pino.js +40 -0
- package/dist/pino.js.map +1 -0
- package/dist/random.d.ts +4 -1
- package/dist/random.d.ts.map +1 -1
- package/dist/random.js +31 -0
- package/dist/random.js.map +1 -0
- package/dist/storage/enhanced/local/core.d.ts +45 -42
- package/dist/storage/enhanced/local/core.d.ts.map +1 -1
- package/dist/storage/enhanced/local/core.js +63 -0
- package/dist/storage/enhanced/local/core.js.map +1 -0
- package/dist/storage/enhanced/local/index.d.ts +3 -3
- package/dist/storage/enhanced/local/index.js +4 -0
- package/dist/storage/enhanced/local/keyed-store.d.ts +14 -11
- package/dist/storage/enhanced/local/keyed-store.d.ts.map +1 -1
- package/dist/storage/enhanced/local/keyed-store.js +36 -0
- package/dist/storage/enhanced/local/keyed-store.js.map +1 -0
- package/dist/storage/enhanced/redis/core.d.ts +64 -59
- package/dist/storage/enhanced/redis/core.d.ts.map +1 -1
- package/dist/storage/enhanced/redis/core.js +85 -0
- package/dist/storage/enhanced/redis/core.js.map +1 -0
- package/dist/storage/enhanced/redis/index.d.ts +3 -3
- package/dist/storage/enhanced/redis/index.js +4 -0
- package/dist/storage/enhanced/redis/keyed-store.d.ts +19 -14
- package/dist/storage/enhanced/redis/keyed-store.d.ts.map +1 -1
- package/dist/storage/enhanced/redis/keyed-store.js +41 -0
- package/dist/storage/enhanced/redis/keyed-store.js.map +1 -0
- package/dist/storage/lru/keyed-store.d.ts +21 -16
- package/dist/storage/lru/keyed-store.d.ts.map +1 -1
- package/dist/storage/lru/keyed-store.js +40 -0
- package/dist/storage/lru/keyed-store.js.map +1 -0
- package/dist/string.d.ts +5 -2
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +42 -0
- package/dist/string.js.map +1 -0
- package/dist/url.d.ts +4 -1
- package/dist/url.d.ts.map +1 -1
- package/dist/url.js +21 -0
- package/dist/url.js.map +1 -0
- package/dist/vue.d.ts +10 -5
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +58 -0
- package/dist/vue.js.map +1 -0
- package/dist/web.d.ts +5 -2
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +32 -0
- package/dist/web.js.map +1 -0
- package/package.json +43 -27
- package/src/env.ts +1 -1
- package/src/vue.ts +1 -1
- package/src/web.ts +1 -1
- package/dist/buffer.cjs +0 -43
- package/dist/buffer.cjs.map +0 -1
- package/dist/buffer.mjs +0 -41
- package/dist/buffer.mjs.map +0 -1
- package/dist/clipboard.cjs +0 -91
- package/dist/clipboard.cjs.map +0 -1
- package/dist/clipboard.mjs +0 -88
- package/dist/clipboard.mjs.map +0 -1
- package/dist/consola.cjs +0 -35
- package/dist/consola.cjs.map +0 -1
- package/dist/consola.mjs +0 -32
- package/dist/consola.mjs.map +0 -1
- package/dist/crypto-hash.cjs +0 -61
- package/dist/crypto-hash.cjs.map +0 -1
- package/dist/crypto-hash.mjs +0 -50
- package/dist/crypto-hash.mjs.map +0 -1
- package/dist/datetime.cjs +0 -134
- package/dist/datetime.cjs.map +0 -1
- package/dist/datetime.mjs +0 -130
- package/dist/datetime.mjs.map +0 -1
- package/dist/element-plus.cjs +0 -37
- package/dist/element-plus.cjs.map +0 -1
- package/dist/element-plus.mjs +0 -35
- package/dist/element-plus.mjs.map +0 -1
- package/dist/enum.cjs +0 -112
- package/dist/enum.cjs.map +0 -1
- package/dist/enum.mjs +0 -108
- package/dist/enum.mjs.map +0 -1
- package/dist/env.cjs +0 -53
- package/dist/env.cjs.map +0 -1
- package/dist/env.mjs +0 -50
- package/dist/env.mjs.map +0 -1
- package/dist/general.cjs +0 -10
- package/dist/general.cjs.map +0 -1
- package/dist/general.mjs +0 -8
- package/dist/general.mjs.map +0 -1
- package/dist/hash.cjs +0 -36
- package/dist/hash.cjs.map +0 -1
- package/dist/hash.mjs +0 -31
- package/dist/hash.mjs.map +0 -1
- package/dist/math.cjs +0 -38
- package/dist/math.cjs.map +0 -1
- package/dist/math.mjs +0 -36
- package/dist/math.mjs.map +0 -1
- package/dist/number.cjs +0 -32
- package/dist/number.cjs.map +0 -1
- package/dist/number.mjs +0 -30
- package/dist/number.mjs.map +0 -1
- package/dist/object.cjs +0 -55
- package/dist/object.cjs.map +0 -1
- package/dist/object.mjs +0 -53
- package/dist/object.mjs.map +0 -1
- package/dist/pino.cjs +0 -42
- package/dist/pino.cjs.map +0 -1
- package/dist/pino.mjs +0 -39
- package/dist/pino.mjs.map +0 -1
- package/dist/random.cjs +0 -31
- package/dist/random.cjs.map +0 -1
- package/dist/random.mjs +0 -29
- package/dist/random.mjs.map +0 -1
- package/dist/storage/enhanced/local/core.cjs +0 -105
- package/dist/storage/enhanced/local/core.cjs.map +0 -1
- package/dist/storage/enhanced/local/core.mjs +0 -103
- package/dist/storage/enhanced/local/core.mjs.map +0 -1
- package/dist/storage/enhanced/local/index.cjs +0 -10
- package/dist/storage/enhanced/local/index.cjs.map +0 -1
- package/dist/storage/enhanced/local/index.d.ts.map +0 -1
- package/dist/storage/enhanced/local/index.mjs +0 -3
- package/dist/storage/enhanced/local/index.mjs.map +0 -1
- package/dist/storage/enhanced/local/keyed-store.cjs +0 -41
- package/dist/storage/enhanced/local/keyed-store.cjs.map +0 -1
- package/dist/storage/enhanced/local/keyed-store.mjs +0 -39
- package/dist/storage/enhanced/local/keyed-store.mjs.map +0 -1
- package/dist/storage/enhanced/redis/core.cjs +0 -144
- package/dist/storage/enhanced/redis/core.cjs.map +0 -1
- package/dist/storage/enhanced/redis/core.mjs +0 -142
- package/dist/storage/enhanced/redis/core.mjs.map +0 -1
- package/dist/storage/enhanced/redis/index.cjs +0 -10
- package/dist/storage/enhanced/redis/index.cjs.map +0 -1
- package/dist/storage/enhanced/redis/index.d.ts.map +0 -1
- package/dist/storage/enhanced/redis/index.mjs +0 -3
- package/dist/storage/enhanced/redis/index.mjs.map +0 -1
- package/dist/storage/enhanced/redis/keyed-store.cjs +0 -46
- package/dist/storage/enhanced/redis/keyed-store.cjs.map +0 -1
- package/dist/storage/enhanced/redis/keyed-store.mjs +0 -44
- package/dist/storage/enhanced/redis/keyed-store.mjs.map +0 -1
- package/dist/storage/lru/keyed-store.cjs +0 -49
- package/dist/storage/lru/keyed-store.cjs.map +0 -1
- package/dist/storage/lru/keyed-store.mjs +0 -47
- package/dist/storage/lru/keyed-store.mjs.map +0 -1
- package/dist/string.cjs +0 -45
- package/dist/string.cjs.map +0 -1
- package/dist/string.mjs +0 -43
- package/dist/string.mjs.map +0 -1
- package/dist/url.cjs +0 -21
- package/dist/url.cjs.map +0 -1
- package/dist/url.mjs +0 -19
- package/dist/url.mjs.map +0 -1
- package/dist/vue.cjs +0 -64
- package/dist/vue.cjs.map +0 -1
- package/dist/vue.mjs +0 -59
- package/dist/vue.mjs.map +0 -1
- package/dist/web.cjs +0 -35
- package/dist/web.cjs.map +0 -1
- package/dist/web.mjs +0 -32
- package/dist/web.mjs.map +0 -1
package/dist/env.cjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Custom error class for handling missing environment variables.
|
|
5
|
-
*
|
|
6
|
-
* Extends the built-in `Error` class and includes the missing key.
|
|
7
|
-
*
|
|
8
|
-
* @extends {Error}
|
|
9
|
-
*/
|
|
10
|
-
class EnvironmentNotFoundError extends Error {
|
|
11
|
-
key;
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new EnvironmentNotFoundError.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} key - The missing environment variable key
|
|
16
|
-
*/
|
|
17
|
-
constructor(key) {
|
|
18
|
-
super(`Missing environment variable: ${key}`);
|
|
19
|
-
this.key = key;
|
|
20
|
-
this.name = this.constructor.name;
|
|
21
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves the value of an environment variable, or throws an error if it is not defined.
|
|
26
|
-
*
|
|
27
|
-
* Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
|
|
28
|
-
* value like `'0'` or `'false'` is considered a valid (defined) value.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} key - The environment variable key to retrieve
|
|
31
|
-
*
|
|
32
|
-
* @returns {string} The value of the environment variable
|
|
33
|
-
*
|
|
34
|
-
* @throws {EnvironmentNotFoundError} If the environment variable is not defined
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* process.env.API_KEY = '';
|
|
39
|
-
* checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered "defined")
|
|
40
|
-
*
|
|
41
|
-
* delete process.env.API_KEY;
|
|
42
|
-
* checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
function checkAndGetEnvValue(key) {
|
|
46
|
-
if (process.env[key] === undefined)
|
|
47
|
-
throw new EnvironmentNotFoundError(key);
|
|
48
|
-
return process.env[key];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
exports.EnvironmentNotFoundError = EnvironmentNotFoundError;
|
|
52
|
-
exports.checkAndGetEnvValue = checkAndGetEnvValue;
|
|
53
|
-
//# sourceMappingURL=env.cjs.map
|
package/dist/env.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.cjs","sources":["../src/env.ts"],"sourcesContent":["/**\n * Custom error class for handling missing environment variables.\n *\n * Extends the built-in `Error` class and includes the missing key.\n *\n * @extends {Error}\n */\nexport class EnvironmentNotFoundError extends Error {\n readonly key: string;\n\n /**\n * Creates a new EnvironmentNotFoundError.\n *\n * @param {string} key - The missing environment variable key\n */\n constructor(key: string) {\n super(`Missing environment variable: ${key}`);\n this.key = key;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Retrieves the value of an environment variable, or throws an error if it is not defined.\n *\n * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string\n * value like `'0'` or `'false'` is considered a valid (defined) value.\n *\n * @param {string} key - The environment variable key to retrieve\n *\n * @returns {string} The value of the environment variable\n *\n * @throws {EnvironmentNotFoundError} If the environment variable is not defined\n *\n * @example\n * ```typescript\n * process.env.API_KEY = '';\n * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered \"defined\")\n *\n * delete process.env.API_KEY;\n * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (process.env[key] === undefined) throw new EnvironmentNotFoundError(key);\n return process.env[key];\n}\n"],"names":[],"mappings":";;AAAA;;;;;;AAMG;AACG,MAAO,wBAAyB,SAAQ,KAAK,CAAA;AACtC,IAAA,GAAG;AAEZ;;;;AAIG;AACH,IAAA,WAAA,CAAY,GAAW,EAAA;AACnB,QAAA,KAAK,CAAC,CAAA,8BAAA,EAAiC,GAAG,CAAA,CAAE,CAAC;AAC7C,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;QACjC,KAAK,CAAC,iBAAiB,GAAG,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;IACrD;AACH;AAED;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC3E,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;;"}
|
package/dist/env.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom error class for handling missing environment variables.
|
|
3
|
-
*
|
|
4
|
-
* Extends the built-in `Error` class and includes the missing key.
|
|
5
|
-
*
|
|
6
|
-
* @extends {Error}
|
|
7
|
-
*/
|
|
8
|
-
class EnvironmentNotFoundError extends Error {
|
|
9
|
-
key;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new EnvironmentNotFoundError.
|
|
12
|
-
*
|
|
13
|
-
* @param {string} key - The missing environment variable key
|
|
14
|
-
*/
|
|
15
|
-
constructor(key) {
|
|
16
|
-
super(`Missing environment variable: ${key}`);
|
|
17
|
-
this.key = key;
|
|
18
|
-
this.name = this.constructor.name;
|
|
19
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Retrieves the value of an environment variable, or throws an error if it is not defined.
|
|
24
|
-
*
|
|
25
|
-
* Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
|
|
26
|
-
* value like `'0'` or `'false'` is considered a valid (defined) value.
|
|
27
|
-
*
|
|
28
|
-
* @param {string} key - The environment variable key to retrieve
|
|
29
|
-
*
|
|
30
|
-
* @returns {string} The value of the environment variable
|
|
31
|
-
*
|
|
32
|
-
* @throws {EnvironmentNotFoundError} If the environment variable is not defined
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* process.env.API_KEY = '';
|
|
37
|
-
* checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered "defined")
|
|
38
|
-
*
|
|
39
|
-
* delete process.env.API_KEY;
|
|
40
|
-
* checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
function checkAndGetEnvValue(key) {
|
|
44
|
-
if (process.env[key] === undefined)
|
|
45
|
-
throw new EnvironmentNotFoundError(key);
|
|
46
|
-
return process.env[key];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { EnvironmentNotFoundError, checkAndGetEnvValue };
|
|
50
|
-
//# sourceMappingURL=env.mjs.map
|
package/dist/env.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.mjs","sources":["../src/env.ts"],"sourcesContent":["/**\n * Custom error class for handling missing environment variables.\n *\n * Extends the built-in `Error` class and includes the missing key.\n *\n * @extends {Error}\n */\nexport class EnvironmentNotFoundError extends Error {\n readonly key: string;\n\n /**\n * Creates a new EnvironmentNotFoundError.\n *\n * @param {string} key - The missing environment variable key\n */\n constructor(key: string) {\n super(`Missing environment variable: ${key}`);\n this.key = key;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Retrieves the value of an environment variable, or throws an error if it is not defined.\n *\n * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string\n * value like `'0'` or `'false'` is considered a valid (defined) value.\n *\n * @param {string} key - The environment variable key to retrieve\n *\n * @returns {string} The value of the environment variable\n *\n * @throws {EnvironmentNotFoundError} If the environment variable is not defined\n *\n * @example\n * ```typescript\n * process.env.API_KEY = '';\n * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered \"defined\")\n *\n * delete process.env.API_KEY;\n * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (process.env[key] === undefined) throw new EnvironmentNotFoundError(key);\n return process.env[key];\n}\n"],"names":[],"mappings":"AAAA;;;;;;AAMG;AACG,MAAO,wBAAyB,SAAQ,KAAK,CAAA;AACtC,IAAA,GAAG;AAEZ;;;;AAIG;AACH,IAAA,WAAA,CAAY,GAAW,EAAA;AACnB,QAAA,KAAK,CAAC,CAAA,8BAAA,EAAiC,GAAG,CAAA,CAAE,CAAC;AAC7C,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;QACjC,KAAK,CAAC,iBAAiB,GAAG,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;IACrD;AACH;AAED;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC3E,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;"}
|
package/dist/general.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable jsdoc/check-param-names */
|
|
4
|
-
function extractFirstValue(value, defaultValue) {
|
|
5
|
-
return (Array.isArray(value) ? value[0] : value) ?? defaultValue;
|
|
6
|
-
}
|
|
7
|
-
/* eslint-enable jsdoc/check-param-names */
|
|
8
|
-
|
|
9
|
-
exports.extractFirstValue = extractFirstValue;
|
|
10
|
-
//# sourceMappingURL=general.cjs.map
|
package/dist/general.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"general.cjs","sources":["../src/general.ts"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n\n/**\n * Extracts the first value from an array or returns the value itself if it's not an array.\n *\n * - If `value` is an array, returns the first element.\n * - If `value` is not an array, returns `value` directly.\n * - If the result is `null` or `undefined`, and `defaultValue` is provided, returns `defaultValue` instead.\n *\n * @template T - The type of the input value(s)\n * @template D - The type of the default value (if provided)\n *\n * @param {T | T[]} value - A single value or an array of values\n * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`\n *\n * @returns {T | D | undefined} The first value or the fallback\n *\n * @example\n * ```typescript\n * import { extractFirstValue } from '@kikiutils/shared/general';\n *\n * console.log(extractFirstValue([1, 2, 3])); // 1\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"],"names":[],"mappings":";;AAAA;AA6BM,SAAU,iBAAiB,CAAO,KAAc,EAAE,YAAgB,EAAA;IACpE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,YAAY;AACpE;AAEA;;;;"}
|
package/dist/general.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jsdoc/check-param-names */
|
|
2
|
-
function extractFirstValue(value, defaultValue) {
|
|
3
|
-
return (Array.isArray(value) ? value[0] : value) ?? defaultValue;
|
|
4
|
-
}
|
|
5
|
-
/* eslint-enable jsdoc/check-param-names */
|
|
6
|
-
|
|
7
|
-
export { extractFirstValue };
|
|
8
|
-
//# sourceMappingURL=general.mjs.map
|
package/dist/general.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"general.mjs","sources":["../src/general.ts"],"sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n\n/**\n * Extracts the first value from an array or returns the value itself if it's not an array.\n *\n * - If `value` is an array, returns the first element.\n * - If `value` is not an array, returns `value` directly.\n * - If the result is `null` or `undefined`, and `defaultValue` is provided, returns `defaultValue` instead.\n *\n * @template T - The type of the input value(s)\n * @template D - The type of the default value (if provided)\n *\n * @param {T | T[]} value - A single value or an array of values\n * @param {D} [defaultValue] - A fallback value if the result is `null` or `undefined`\n *\n * @returns {T | D | undefined} The first value or the fallback\n *\n * @example\n * ```typescript\n * import { extractFirstValue } from '@kikiutils/shared/general';\n *\n * console.log(extractFirstValue([1, 2, 3])); // 1\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"],"names":[],"mappings":"AAAA;AA6BM,SAAU,iBAAiB,CAAO,KAAc,EAAE,YAAgB,EAAA;IACpE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,YAAY;AACpE;AAEA;;;;"}
|
package/dist/hash.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const sha3 = require('@noble/hashes/sha3');
|
|
4
|
-
const utils = require('@noble/hashes/utils');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This file provides a set of functions for creating SHA-3 hash digests
|
|
8
|
-
* using different bit lengths (224, 256, 384, 512).
|
|
9
|
-
* These functions use the [@noble/hashes](https://github.com/paulmillr/noble-hashes) library to generate the hashes.
|
|
10
|
-
* Can be used in the browser, mainly for Nuxt/Vue and other frameworks compiled and executed in the browser.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { sha3256 } from '@kikiutils/shared/hash';
|
|
15
|
-
*
|
|
16
|
-
* console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
function sha3224(data) {
|
|
20
|
-
return utils.bytesToHex(sha3.sha3_224(typeof data === 'string' ? utils.utf8ToBytes(data) : data));
|
|
21
|
-
}
|
|
22
|
-
function sha3256(data) {
|
|
23
|
-
return utils.bytesToHex(sha3.sha3_256(typeof data === 'string' ? utils.utf8ToBytes(data) : data));
|
|
24
|
-
}
|
|
25
|
-
function sha3384(data) {
|
|
26
|
-
return utils.bytesToHex(sha3.sha3_384(typeof data === 'string' ? utils.utf8ToBytes(data) : data));
|
|
27
|
-
}
|
|
28
|
-
function sha3512(data) {
|
|
29
|
-
return utils.bytesToHex(sha3.sha3_512(typeof data === 'string' ? utils.utf8ToBytes(data) : data));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports.sha3224 = sha3224;
|
|
33
|
-
exports.sha3256 = sha3256;
|
|
34
|
-
exports.sha3384 = sha3384;
|
|
35
|
-
exports.sha3512 = sha3512;
|
|
36
|
-
//# sourceMappingURL=hash.cjs.map
|
package/dist/hash.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hash.cjs","sources":["../src/hash.ts"],"sourcesContent":["/**\n * This file provides a set of functions for creating SHA-3 hash digests\n * using different bit lengths (224, 256, 384, 512).\n * These functions use the [@noble/hashes](https://github.com/paulmillr/noble-hashes) library to generate the hashes.\n * Can be used in the browser, mainly for Nuxt/Vue and other frameworks compiled and executed in the browser.\n *\n * @example\n * ```typescript\n * import { sha3256 } from '@kikiutils/shared/hash';\n *\n * console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\n\nimport {\n sha3_224,\n sha3_256,\n sha3_384,\n sha3_512,\n} from '@noble/hashes/sha3';\nimport {\n bytesToHex,\n utf8ToBytes,\n} from '@noble/hashes/utils';\n\nexport function sha3224(data: string | Uint8Array) {\n return bytesToHex(sha3_224(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3256(data: string | Uint8Array) {\n return bytesToHex(sha3_256(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3384(data: string | Uint8Array) {\n return bytesToHex(sha3_384(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3512(data: string | Uint8Array) {\n return bytesToHex(sha3_512(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n"],"names":["bytesToHex","sha3_224","utf8ToBytes","sha3_256","sha3_384","sha3_512"],"mappings":";;;;;AAAA;;;;;;;;;;;;AAYG;AAaG,SAAU,OAAO,CAAC,IAAyB,EAAA;IAC7C,OAAOA,gBAAU,CAACC,aAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAGC,iBAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;AAEM,SAAU,OAAO,CAAC,IAAyB,EAAA;IAC7C,OAAOF,gBAAU,CAACG,aAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAGD,iBAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;AAEM,SAAU,OAAO,CAAC,IAAyB,EAAA;IAC7C,OAAOF,gBAAU,CAACI,aAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAGF,iBAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;AAEM,SAAU,OAAO,CAAC,IAAyB,EAAA;IAC7C,OAAOF,gBAAU,CAACK,aAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAGH,iBAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;;;;;;;"}
|
package/dist/hash.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { sha3_224, sha3_256, sha3_384, sha3_512 } from '@noble/hashes/sha3';
|
|
2
|
-
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This file provides a set of functions for creating SHA-3 hash digests
|
|
6
|
-
* using different bit lengths (224, 256, 384, 512).
|
|
7
|
-
* These functions use the [@noble/hashes](https://github.com/paulmillr/noble-hashes) library to generate the hashes.
|
|
8
|
-
* Can be used in the browser, mainly for Nuxt/Vue and other frameworks compiled and executed in the browser.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { sha3256 } from '@kikiutils/shared/hash';
|
|
13
|
-
*
|
|
14
|
-
* console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
function sha3224(data) {
|
|
18
|
-
return bytesToHex(sha3_224(typeof data === 'string' ? utf8ToBytes(data) : data));
|
|
19
|
-
}
|
|
20
|
-
function sha3256(data) {
|
|
21
|
-
return bytesToHex(sha3_256(typeof data === 'string' ? utf8ToBytes(data) : data));
|
|
22
|
-
}
|
|
23
|
-
function sha3384(data) {
|
|
24
|
-
return bytesToHex(sha3_384(typeof data === 'string' ? utf8ToBytes(data) : data));
|
|
25
|
-
}
|
|
26
|
-
function sha3512(data) {
|
|
27
|
-
return bytesToHex(sha3_512(typeof data === 'string' ? utf8ToBytes(data) : data));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { sha3224, sha3256, sha3384, sha3512 };
|
|
31
|
-
//# sourceMappingURL=hash.mjs.map
|
package/dist/hash.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hash.mjs","sources":["../src/hash.ts"],"sourcesContent":["/**\n * This file provides a set of functions for creating SHA-3 hash digests\n * using different bit lengths (224, 256, 384, 512).\n * These functions use the [@noble/hashes](https://github.com/paulmillr/noble-hashes) library to generate the hashes.\n * Can be used in the browser, mainly for Nuxt/Vue and other frameworks compiled and executed in the browser.\n *\n * @example\n * ```typescript\n * import { sha3256 } from '@kikiutils/shared/hash';\n *\n * console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\n\nimport {\n sha3_224,\n sha3_256,\n sha3_384,\n sha3_512,\n} from '@noble/hashes/sha3';\nimport {\n bytesToHex,\n utf8ToBytes,\n} from '@noble/hashes/utils';\n\nexport function sha3224(data: string | Uint8Array) {\n return bytesToHex(sha3_224(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3256(data: string | Uint8Array) {\n return bytesToHex(sha3_256(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3384(data: string | Uint8Array) {\n return bytesToHex(sha3_384(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3512(data: string | Uint8Array) {\n return bytesToHex(sha3_512(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;AAYG;AAaG,SAAU,OAAO,CAAC,IAAyB,EAAA;IAC7C,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;AAEM,SAAU,OAAO,CAAC,IAAyB,EAAA;IAC7C,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;AAEM,SAAU,OAAO,CAAC,IAAyB,EAAA;IAC7C,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;AAEM,SAAU,OAAO,CAAC,IAAyB,EAAA;IAC7C,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;;;;"}
|
package/dist/math.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const decimal_js = require('decimal.js');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Converts a fraction (numerator / denominator) into a percentage string.
|
|
7
|
-
*
|
|
8
|
-
* - Uses `decimal.js` for precise decimal calculations.
|
|
9
|
-
* - Supports custom decimal places and optional percentage symbol.
|
|
10
|
-
* - Returns `'0.00%'` if result is `NaN` or division is invalid.
|
|
11
|
-
*
|
|
12
|
-
* @param {CalculableValue} molecular - The numerator of the fraction
|
|
13
|
-
* @param {CalculableValue} denominator - The denominator of the fraction
|
|
14
|
-
* @param {ToPercentageStringOptions} [options] - Optional output settings
|
|
15
|
-
*
|
|
16
|
-
* @returns {string} Formatted percentage string
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* import { toPercentageString } from '@kikiutils/shared/math';
|
|
21
|
-
*
|
|
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%
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
function toPercentageString(molecular, denominator, options) {
|
|
28
|
-
const molecularDecimal = new decimal_js.Decimal(molecular.toString());
|
|
29
|
-
const denominatorDecimal = new decimal_js.Decimal(denominator.toString());
|
|
30
|
-
const calculationResult = molecularDecimal.div(denominatorDecimal);
|
|
31
|
-
const result = calculationResult.isNaN()
|
|
32
|
-
? '0.00'
|
|
33
|
-
: calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);
|
|
34
|
-
return options?.withSymbol ?? true ? `${result}%` : result;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.toPercentageString = toPercentageString;
|
|
38
|
-
//# sourceMappingURL=math.cjs.map
|
package/dist/math.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math.cjs","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 * Number of decimal places to include in the result.\n *\n * @default 2\n */\n decimalPlaces?: number;\n\n /**\n * Whether to include the '%' symbol in the result.\n *\n * @default true\n */\n withSymbol?: boolean;\n}\n\n/**\n * Converts a fraction (numerator / denominator) into a percentage string.\n *\n * - Uses `decimal.js` for precise decimal calculations.\n * - Supports custom decimal places and optional percentage symbol.\n * - Returns `'0.00%'` if result is `NaN` or division is invalid.\n *\n * @param {CalculableValue} molecular - The numerator of the fraction\n * @param {CalculableValue} denominator - The denominator of the fraction\n * @param {ToPercentageStringOptions} [options] - Optional output settings\n *\n * @returns {string} Formatted percentage string\n *\n * @example\n * ```typescript\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 const result = calculationResult.isNaN()\n ? '0.00'\n : calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);\n\n return options?.withSymbol ?? true ? `${result}%` : result;\n}\n"],"names":["Decimal"],"mappings":";;;;AAuBA;;;;;;;;;;;;;;;;;;;;;AAqBG;SACa,kBAAkB,CAC9B,SAA0B,EAC1B,WAA4B,EAC5B,OAAmC,EAAA;IAEnC,MAAM,gBAAgB,GAAG,IAAIA,kBAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,IAAIA,kBAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC9D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAClE,IAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK;AAClC,UAAE;AACF,UAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,CAAC;AAEvE,IAAA,OAAO,OAAO,EAAE,UAAU,IAAI,IAAI,GAAG,CAAA,EAAG,MAAM,CAAA,CAAA,CAAG,GAAG,MAAM;AAC9D;;;;"}
|
package/dist/math.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Decimal } from 'decimal.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Converts a fraction (numerator / denominator) into a percentage string.
|
|
5
|
-
*
|
|
6
|
-
* - Uses `decimal.js` for precise decimal calculations.
|
|
7
|
-
* - Supports custom decimal places and optional percentage symbol.
|
|
8
|
-
* - Returns `'0.00%'` if result is `NaN` or division is invalid.
|
|
9
|
-
*
|
|
10
|
-
* @param {CalculableValue} molecular - The numerator of the fraction
|
|
11
|
-
* @param {CalculableValue} denominator - The denominator of the fraction
|
|
12
|
-
* @param {ToPercentageStringOptions} [options] - Optional output settings
|
|
13
|
-
*
|
|
14
|
-
* @returns {string} Formatted percentage string
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import { toPercentageString } from '@kikiutils/shared/math';
|
|
19
|
-
*
|
|
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%
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
function toPercentageString(molecular, denominator, options) {
|
|
26
|
-
const molecularDecimal = new Decimal(molecular.toString());
|
|
27
|
-
const denominatorDecimal = new Decimal(denominator.toString());
|
|
28
|
-
const calculationResult = molecularDecimal.div(denominatorDecimal);
|
|
29
|
-
const result = calculationResult.isNaN()
|
|
30
|
-
? '0.00'
|
|
31
|
-
: calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);
|
|
32
|
-
return options?.withSymbol ?? true ? `${result}%` : result;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { toPercentageString };
|
|
36
|
-
//# sourceMappingURL=math.mjs.map
|
package/dist/math.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math.mjs","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 * Number of decimal places to include in the result.\n *\n * @default 2\n */\n decimalPlaces?: number;\n\n /**\n * Whether to include the '%' symbol in the result.\n *\n * @default true\n */\n withSymbol?: boolean;\n}\n\n/**\n * Converts a fraction (numerator / denominator) into a percentage string.\n *\n * - Uses `decimal.js` for precise decimal calculations.\n * - Supports custom decimal places and optional percentage symbol.\n * - Returns `'0.00%'` if result is `NaN` or division is invalid.\n *\n * @param {CalculableValue} molecular - The numerator of the fraction\n * @param {CalculableValue} denominator - The denominator of the fraction\n * @param {ToPercentageStringOptions} [options] - Optional output settings\n *\n * @returns {string} Formatted percentage string\n *\n * @example\n * ```typescript\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 const result = calculationResult.isNaN()\n ? '0.00'\n : calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);\n\n return options?.withSymbol ?? true ? `${result}%` : result;\n}\n"],"names":[],"mappings":";;AAuBA;;;;;;;;;;;;;;;;;;;;;AAqBG;SACa,kBAAkB,CAC9B,SAA0B,EAC1B,WAA4B,EAC5B,OAAmC,EAAA;IAEnC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC9D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAClE,IAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK;AAClC,UAAE;AACF,UAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,CAAC;AAEvE,IAAA,OAAO,OAAO,EAAE,UAAU,IAAI,IAAI,GAAG,CAAA,EAAG,MAAM,CAAA,CAAA,CAAG,GAAG,MAAM;AAC9D;;;;"}
|
package/dist/number.cjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const millify = require('millify');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Converts a large number into a compact, human-readable string using `millify`.
|
|
7
|
-
*
|
|
8
|
-
* Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.
|
|
9
|
-
*
|
|
10
|
-
* @param {number} value - The number to format
|
|
11
|
-
* @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`
|
|
12
|
-
*
|
|
13
|
-
* @returns {string} The compact number string
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { toCompactNumberString } from '@kikiutils/shared/number';
|
|
18
|
-
*
|
|
19
|
-
* console.log(toCompactNumberString(1234567)); // 1.23m
|
|
20
|
-
* console.log(toCompactNumberString(1234567, { precision: 3 })); // 1.235m
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
function toCompactNumberString(value, options) {
|
|
24
|
-
return millify.millify(value, {
|
|
25
|
-
lowercase: true,
|
|
26
|
-
precision: 2,
|
|
27
|
-
...options,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.toCompactNumberString = toCompactNumberString;
|
|
32
|
-
//# sourceMappingURL=number.cjs.map
|
package/dist/number.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"number.cjs","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 * Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.\n *\n * @param {number} value - The number to format\n * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`\n *\n * @returns {string} The compact number string\n *\n * @example\n * ```typescript\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"],"names":["millify"],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,qBAAqB,CAAC,KAAa,EAAE,OAAuC,EAAA;IACxF,OAAOA,eAAO,CACV,KAAK,EACL;AACI,QAAA,SAAS,EAAE,IAAI;AACf,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,GAAG,OAAO;AACb,KAAA,CACJ;AACL;;;;"}
|
package/dist/number.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { millify } from 'millify';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Converts a large number into a compact, human-readable string using `millify`.
|
|
5
|
-
*
|
|
6
|
-
* Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.
|
|
7
|
-
*
|
|
8
|
-
* @param {number} value - The number to format
|
|
9
|
-
* @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`
|
|
10
|
-
*
|
|
11
|
-
* @returns {string} The compact number string
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { toCompactNumberString } from '@kikiutils/shared/number';
|
|
16
|
-
*
|
|
17
|
-
* console.log(toCompactNumberString(1234567)); // 1.23m
|
|
18
|
-
* console.log(toCompactNumberString(1234567, { precision: 3 })); // 1.235m
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
function toCompactNumberString(value, options) {
|
|
22
|
-
return millify(value, {
|
|
23
|
-
lowercase: true,
|
|
24
|
-
precision: 2,
|
|
25
|
-
...options,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { toCompactNumberString };
|
|
30
|
-
//# sourceMappingURL=number.mjs.map
|
package/dist/number.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"number.mjs","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 * Applies lowercase units (e.g. 'k', 'm') and default precision of 2, unless overridden.\n *\n * @param {number} value - The number to format\n * @param {Parameters<typeof millify>[1]} [options] - Optional configuration passed to `millify`\n *\n * @returns {string} The compact number string\n *\n * @example\n * ```typescript\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"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,qBAAqB,CAAC,KAAa,EAAE,OAAuC,EAAA;IACxF,OAAO,OAAO,CACV,KAAK,EACL;AACI,QAAA,SAAS,EAAE,IAAI;AACf,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,GAAG,OAAO;AACb,KAAA,CACJ;AACL;;;;"}
|
package/dist/object.cjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Serializes a nested object into a deterministic, flat string format.
|
|
5
|
-
*
|
|
6
|
-
* This function recursively traverses the input object (including nested objects and arrays),
|
|
7
|
-
* flattens it into key paths using dot notation (e.g. "a.b.0.c"), sorts all keys,
|
|
8
|
-
* and joins each key-value pair into a string with customizable separators.
|
|
9
|
-
*
|
|
10
|
-
* It is designed for use cases such as signature generation, cache key construction,
|
|
11
|
-
* or any context requiring consistent and predictable object serialization.
|
|
12
|
-
*
|
|
13
|
-
* @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
14
|
-
* @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
|
|
15
|
-
* @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
|
|
16
|
-
* @returns {string} A deterministic string representation of the input object
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* import { stringifyObjectDeterministically } from '@kikiutils/shared/object';
|
|
21
|
-
*
|
|
22
|
-
* console.log(stringifyObjectDeterministically({ b: 2, a: { x: 1, y: [3, 4] } })); // a.x=1&a.y.0=3&a.y.1=4&b=2
|
|
23
|
-
* console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // foo:bar
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
function stringifyObjectDeterministically(input, kvSeparator = '=', pairSeparator = '&') {
|
|
27
|
-
const entries = [];
|
|
28
|
-
function walk(object, path = []) {
|
|
29
|
-
if (Array.isArray(object)) {
|
|
30
|
-
object.forEach((value, index) => {
|
|
31
|
-
walk(value, [
|
|
32
|
-
...path,
|
|
33
|
-
index.toString(),
|
|
34
|
-
]);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
else if (object !== null
|
|
38
|
-
&& typeof object === 'object'
|
|
39
|
-
&& Object.prototype.toString.call(object) === '[object Object]') {
|
|
40
|
-
Object.keys(object).sort().forEach((key) => {
|
|
41
|
-
walk(object[key], [
|
|
42
|
-
...path,
|
|
43
|
-
key,
|
|
44
|
-
]);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else
|
|
48
|
-
entries.push(`${path.join('.')}${kvSeparator}${String(object)}`);
|
|
49
|
-
}
|
|
50
|
-
walk(input);
|
|
51
|
-
return entries.sort().join(pairSeparator);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
exports.stringifyObjectDeterministically = stringifyObjectDeterministically;
|
|
55
|
-
//# sourceMappingURL=object.cjs.map
|
package/dist/object.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.cjs","sources":["../src/object.ts"],"sourcesContent":["/**\n * Serializes a nested object into a deterministic, flat string format.\n *\n * This function recursively traverses the input object (including nested objects and arrays),\n * flattens it into key paths using dot notation (e.g. \"a.b.0.c\"), sorts all keys,\n * and joins each key-value pair into a string with customizable separators.\n *\n * It is designed for use cases such as signature generation, cache key construction,\n * or any context requiring consistent and predictable object serialization.\n *\n * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays\n * @param {string} kvSeparator - The string used to separate each key from its value (default: '=')\n * @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')\n * @returns {string} A deterministic string representation of the input object\n *\n * @example\n * ```typescript\n * import { stringifyObjectDeterministically } from '@kikiutils/shared/object';\n *\n * console.log(stringifyObjectDeterministically({ b: 2, a: { x: 1, y: [3, 4] } })); // a.x=1&a.y.0=3&a.y.1=4&b=2\n * console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // foo:bar\n * ```\n */\nexport function stringifyObjectDeterministically(\n input: Record<string, any>,\n kvSeparator: string = '=',\n pairSeparator: string = '&',\n) {\n const entries: string[] = [];\n\n function walk(object: any, path: string[] = []) {\n if (Array.isArray(object)) {\n object.forEach((value, index) => {\n walk(\n value,\n [\n ...path,\n index.toString(),\n ],\n );\n });\n } else if (\n object !== null\n && typeof object === 'object'\n && Object.prototype.toString.call(object) === '[object Object]'\n ) {\n Object.keys(object).sort().forEach((key) => {\n walk(\n object[key],\n [\n ...path,\n key,\n ],\n );\n });\n } else entries.push(`${path.join('.')}${kvSeparator}${String(object)}`);\n }\n\n walk(input);\n return entries.sort().join(pairSeparator);\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,gCAAgC,CAC5C,KAA0B,EAC1B,WAAA,GAAsB,GAAG,EACzB,aAAA,GAAwB,GAAG,EAAA;IAE3B,MAAM,OAAO,GAAa,EAAE;AAE5B,IAAA,SAAS,IAAI,CAAC,MAAW,EAAE,OAAiB,EAAE,EAAA;AAC1C,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAI;gBAC5B,IAAI,CACA,KAAK,EACL;AACI,oBAAA,GAAG,IAAI;oBACP,KAAK,CAAC,QAAQ,EAAE;AACnB,iBAAA,CACJ;AACL,YAAA,CAAC,CAAC;QACN;aAAO,IACH,MAAM,KAAK;eACR,OAAO,MAAM,KAAK;AAClB,eAAA,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,iBAAiB,EACjE;AACE,YAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;AACvC,gBAAA,IAAI,CACA,MAAM,CAAC,GAAG,CAAC,EACX;AACI,oBAAA,GAAG,IAAI;oBACP,GAAG;AACN,iBAAA,CACJ;AACL,YAAA,CAAC,CAAC;QACN;;AAAO,YAAA,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,EAAG,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA,CAAE,CAAC;IAC3E;IAEA,IAAI,CAAC,KAAK,CAAC;IACX,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;AAC7C;;;;"}
|
package/dist/object.mjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serializes a nested object into a deterministic, flat string format.
|
|
3
|
-
*
|
|
4
|
-
* This function recursively traverses the input object (including nested objects and arrays),
|
|
5
|
-
* flattens it into key paths using dot notation (e.g. "a.b.0.c"), sorts all keys,
|
|
6
|
-
* and joins each key-value pair into a string with customizable separators.
|
|
7
|
-
*
|
|
8
|
-
* It is designed for use cases such as signature generation, cache key construction,
|
|
9
|
-
* or any context requiring consistent and predictable object serialization.
|
|
10
|
-
*
|
|
11
|
-
* @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays
|
|
12
|
-
* @param {string} kvSeparator - The string used to separate each key from its value (default: '=')
|
|
13
|
-
* @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')
|
|
14
|
-
* @returns {string} A deterministic string representation of the input object
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import { stringifyObjectDeterministically } from '@kikiutils/shared/object';
|
|
19
|
-
*
|
|
20
|
-
* console.log(stringifyObjectDeterministically({ b: 2, a: { x: 1, y: [3, 4] } })); // a.x=1&a.y.0=3&a.y.1=4&b=2
|
|
21
|
-
* console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // foo:bar
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
function stringifyObjectDeterministically(input, kvSeparator = '=', pairSeparator = '&') {
|
|
25
|
-
const entries = [];
|
|
26
|
-
function walk(object, path = []) {
|
|
27
|
-
if (Array.isArray(object)) {
|
|
28
|
-
object.forEach((value, index) => {
|
|
29
|
-
walk(value, [
|
|
30
|
-
...path,
|
|
31
|
-
index.toString(),
|
|
32
|
-
]);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
else if (object !== null
|
|
36
|
-
&& typeof object === 'object'
|
|
37
|
-
&& Object.prototype.toString.call(object) === '[object Object]') {
|
|
38
|
-
Object.keys(object).sort().forEach((key) => {
|
|
39
|
-
walk(object[key], [
|
|
40
|
-
...path,
|
|
41
|
-
key,
|
|
42
|
-
]);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
else
|
|
46
|
-
entries.push(`${path.join('.')}${kvSeparator}${String(object)}`);
|
|
47
|
-
}
|
|
48
|
-
walk(input);
|
|
49
|
-
return entries.sort().join(pairSeparator);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { stringifyObjectDeterministically };
|
|
53
|
-
//# sourceMappingURL=object.mjs.map
|
package/dist/object.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.mjs","sources":["../src/object.ts"],"sourcesContent":["/**\n * Serializes a nested object into a deterministic, flat string format.\n *\n * This function recursively traverses the input object (including nested objects and arrays),\n * flattens it into key paths using dot notation (e.g. \"a.b.0.c\"), sorts all keys,\n * and joins each key-value pair into a string with customizable separators.\n *\n * It is designed for use cases such as signature generation, cache key construction,\n * or any context requiring consistent and predictable object serialization.\n *\n * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays\n * @param {string} kvSeparator - The string used to separate each key from its value (default: '=')\n * @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')\n * @returns {string} A deterministic string representation of the input object\n *\n * @example\n * ```typescript\n * import { stringifyObjectDeterministically } from '@kikiutils/shared/object';\n *\n * console.log(stringifyObjectDeterministically({ b: 2, a: { x: 1, y: [3, 4] } })); // a.x=1&a.y.0=3&a.y.1=4&b=2\n * console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // foo:bar\n * ```\n */\nexport function stringifyObjectDeterministically(\n input: Record<string, any>,\n kvSeparator: string = '=',\n pairSeparator: string = '&',\n) {\n const entries: string[] = [];\n\n function walk(object: any, path: string[] = []) {\n if (Array.isArray(object)) {\n object.forEach((value, index) => {\n walk(\n value,\n [\n ...path,\n index.toString(),\n ],\n );\n });\n } else if (\n object !== null\n && typeof object === 'object'\n && Object.prototype.toString.call(object) === '[object Object]'\n ) {\n Object.keys(object).sort().forEach((key) => {\n walk(\n object[key],\n [\n ...path,\n key,\n ],\n );\n });\n } else entries.push(`${path.join('.')}${kvSeparator}${String(object)}`);\n }\n\n walk(input);\n return entries.sort().join(pairSeparator);\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,gCAAgC,CAC5C,KAA0B,EAC1B,WAAA,GAAsB,GAAG,EACzB,aAAA,GAAwB,GAAG,EAAA;IAE3B,MAAM,OAAO,GAAa,EAAE;AAE5B,IAAA,SAAS,IAAI,CAAC,MAAW,EAAE,OAAiB,EAAE,EAAA;AAC1C,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAI;gBAC5B,IAAI,CACA,KAAK,EACL;AACI,oBAAA,GAAG,IAAI;oBACP,KAAK,CAAC,QAAQ,EAAE;AACnB,iBAAA,CACJ;AACL,YAAA,CAAC,CAAC;QACN;aAAO,IACH,MAAM,KAAK;eACR,OAAO,MAAM,KAAK;AAClB,eAAA,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,iBAAiB,EACjE;AACE,YAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;AACvC,gBAAA,IAAI,CACA,MAAM,CAAC,GAAG,CAAC,EACX;AACI,oBAAA,GAAG,IAAI;oBACP,GAAG;AACN,iBAAA,CACJ;AACL,YAAA,CAAC,CAAC;QACN;;AAAO,YAAA,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,EAAG,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA,CAAE,CAAC;IAC3E;IAEA,IAAI,CAAC,KAAK,CAAC;IACX,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;AAC7C;;;;"}
|
package/dist/pino.cjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const pino = require('pino');
|
|
4
|
-
const pinoPretty = require('pino-pretty');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Configure pinoPretty to enhance the log output.
|
|
8
|
-
*/
|
|
9
|
-
const stream = pinoPretty.PinoPretty({
|
|
10
|
-
colorize: true, // Enable colored output for better readability
|
|
11
|
-
ignore: 'hostname,pid', // Exclude 'hostname' and 'pid' fields from the logs
|
|
12
|
-
translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l', // Format the timestamp in 'yyyy-mm-dd HH:MM:ss.l' format
|
|
13
|
-
});
|
|
14
|
-
/**
|
|
15
|
-
* A pino logger instance with the configured stream.
|
|
16
|
-
*
|
|
17
|
-
* The logger's level is determined based on the `PINO_LOGGER_LEVEL` and `NODE_ENV` environment variables.
|
|
18
|
-
* If `PINO_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,
|
|
19
|
-
* the level will be set to `error`.
|
|
20
|
-
*
|
|
21
|
-
* To manually change the level, assign the desired level to `logger.level`.
|
|
22
|
-
*
|
|
23
|
-
* See available levels [here](https://getpino.io/#/docs/api?id=level-string).
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import { logger } from '@kikiutils/shared/pino';
|
|
28
|
-
*
|
|
29
|
-
* logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test
|
|
30
|
-
*
|
|
31
|
-
* // Manually change the level
|
|
32
|
-
* logger.level = 'info';
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
const pinoLogger = pino.pino({}, stream);
|
|
36
|
-
const logger = pinoLogger;
|
|
37
|
-
// eslint-disable-next-line style/max-len
|
|
38
|
-
pinoLogger.level = process.env.PINO_LOGGER_LEVEL || (process.env.NODE_ENV === 'production' ? 'error' : pinoLogger.level);
|
|
39
|
-
|
|
40
|
-
exports.logger = logger;
|
|
41
|
-
exports.pinoLogger = pinoLogger;
|
|
42
|
-
//# sourceMappingURL=pino.cjs.map
|
package/dist/pino.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pino.cjs","sources":["../src/pino.ts"],"sourcesContent":["import { pino } from 'pino';\nimport { PinoPretty } from 'pino-pretty';\n\n/**\n * Configure pinoPretty to enhance the log output.\n */\nconst stream = PinoPretty({\n colorize: true, // Enable colored output for better readability\n ignore: 'hostname,pid', // Exclude 'hostname' and 'pid' fields from the logs\n translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l', // Format the timestamp in 'yyyy-mm-dd HH:MM:ss.l' format\n});\n\n/**\n * A pino logger instance with the configured stream.\n *\n * The logger's level is determined based on the `PINO_LOGGER_LEVEL` and `NODE_ENV` environment variables.\n * If `PINO_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,\n * the level will be set to `error`.\n *\n * To manually change the level, assign the desired level to `logger.level`.\n *\n * See available levels [here](https://getpino.io/#/docs/api?id=level-string).\n *\n * @example\n * ```typescript\n * import { logger } from '@kikiutils/shared/pino';\n *\n * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test\n *\n * // Manually change the level\n * logger.level = 'info';\n * ```\n */\nexport const pinoLogger = pino({}, stream);\nexport const logger = pinoLogger;\n// eslint-disable-next-line style/max-len\npinoLogger.level = process.env.PINO_LOGGER_LEVEL || (process.env.NODE_ENV === 'production' ? 'error' : pinoLogger.level);\n"],"names":["PinoPretty","pino"],"mappings":";;;;;AAGA;;AAEG;AACH,MAAM,MAAM,GAAGA,qBAAU,CAAC;IACtB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,cAAc;IACtB,aAAa,EAAE,2BAA2B;AAC7C,CAAA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;AAoBG;AACI,MAAM,UAAU,GAAGC,SAAI,CAAC,EAAE,EAAE,MAAM;AAClC,MAAM,MAAM,GAAG;AACtB;AACA,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC;;;;;"}
|
package/dist/pino.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { pino } from 'pino';
|
|
2
|
-
import { PinoPretty } from 'pino-pretty';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configure pinoPretty to enhance the log output.
|
|
6
|
-
*/
|
|
7
|
-
const stream = PinoPretty({
|
|
8
|
-
colorize: true, // Enable colored output for better readability
|
|
9
|
-
ignore: 'hostname,pid', // Exclude 'hostname' and 'pid' fields from the logs
|
|
10
|
-
translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l', // Format the timestamp in 'yyyy-mm-dd HH:MM:ss.l' format
|
|
11
|
-
});
|
|
12
|
-
/**
|
|
13
|
-
* A pino logger instance with the configured stream.
|
|
14
|
-
*
|
|
15
|
-
* The logger's level is determined based on the `PINO_LOGGER_LEVEL` and `NODE_ENV` environment variables.
|
|
16
|
-
* If `PINO_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,
|
|
17
|
-
* the level will be set to `error`.
|
|
18
|
-
*
|
|
19
|
-
* To manually change the level, assign the desired level to `logger.level`.
|
|
20
|
-
*
|
|
21
|
-
* See available levels [here](https://getpino.io/#/docs/api?id=level-string).
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* import { logger } from '@kikiutils/shared/pino';
|
|
26
|
-
*
|
|
27
|
-
* logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test
|
|
28
|
-
*
|
|
29
|
-
* // Manually change the level
|
|
30
|
-
* logger.level = 'info';
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
const pinoLogger = pino({}, stream);
|
|
34
|
-
const logger = pinoLogger;
|
|
35
|
-
// eslint-disable-next-line style/max-len
|
|
36
|
-
pinoLogger.level = process.env.PINO_LOGGER_LEVEL || (process.env.NODE_ENV === 'production' ? 'error' : pinoLogger.level);
|
|
37
|
-
|
|
38
|
-
export { logger, pinoLogger };
|
|
39
|
-
//# sourceMappingURL=pino.mjs.map
|
package/dist/pino.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pino.mjs","sources":["../src/pino.ts"],"sourcesContent":["import { pino } from 'pino';\nimport { PinoPretty } from 'pino-pretty';\n\n/**\n * Configure pinoPretty to enhance the log output.\n */\nconst stream = PinoPretty({\n colorize: true, // Enable colored output for better readability\n ignore: 'hostname,pid', // Exclude 'hostname' and 'pid' fields from the logs\n translateTime: 'SYS:yyyy-mm-dd HH:MM:ss.l', // Format the timestamp in 'yyyy-mm-dd HH:MM:ss.l' format\n});\n\n/**\n * A pino logger instance with the configured stream.\n *\n * The logger's level is determined based on the `PINO_LOGGER_LEVEL` and `NODE_ENV` environment variables.\n * If `PINO_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,\n * the level will be set to `error`.\n *\n * To manually change the level, assign the desired level to `logger.level`.\n *\n * See available levels [here](https://getpino.io/#/docs/api?id=level-string).\n *\n * @example\n * ```typescript\n * import { logger } from '@kikiutils/shared/pino';\n *\n * logger.info('test'); // [2024-07-11 12:12:30.085] INFO: test\n *\n * // Manually change the level\n * logger.level = 'info';\n * ```\n */\nexport const pinoLogger = pino({}, stream);\nexport const logger = pinoLogger;\n// eslint-disable-next-line style/max-len\npinoLogger.level = process.env.PINO_LOGGER_LEVEL || (process.env.NODE_ENV === 'production' ? 'error' : pinoLogger.level);\n"],"names":[],"mappings":";;;AAGA;;AAEG;AACH,MAAM,MAAM,GAAG,UAAU,CAAC;IACtB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,cAAc;IACtB,aAAa,EAAE,2BAA2B;AAC7C,CAAA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;AAoBG;AACI,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,MAAM;AAClC,MAAM,MAAM,GAAG;AACtB;AACA,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC;;;;"}
|