@kikiutils/shared 9.2.0 → 9.3.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.
Files changed (58) hide show
  1. package/README.md +34 -17
  2. package/dist/env.cjs +10 -13
  3. package/dist/env.cjs.map +1 -1
  4. package/dist/env.d.ts +9 -12
  5. package/dist/env.d.ts.map +1 -1
  6. package/dist/env.mjs +10 -13
  7. package/dist/env.mjs.map +1 -1
  8. package/dist/storage/enhanced/local/core.cjs +103 -0
  9. package/dist/storage/enhanced/local/core.cjs.map +1 -0
  10. package/dist/storage/enhanced/local/core.d.ts +56 -0
  11. package/dist/storage/enhanced/local/core.d.ts.map +1 -0
  12. package/dist/storage/enhanced/local/core.mjs +101 -0
  13. package/dist/storage/enhanced/local/core.mjs.map +1 -0
  14. package/dist/storage/enhanced/local/index.cjs +10 -0
  15. package/dist/storage/enhanced/local/index.cjs.map +1 -0
  16. package/dist/storage/enhanced/local/index.d.ts +3 -0
  17. package/dist/storage/enhanced/local/index.d.ts.map +1 -0
  18. package/dist/storage/enhanced/local/index.mjs +3 -0
  19. package/dist/storage/enhanced/local/index.mjs.map +1 -0
  20. package/dist/storage/enhanced/local/keyed-store.cjs +39 -0
  21. package/dist/storage/enhanced/local/keyed-store.cjs.map +1 -0
  22. package/dist/storage/enhanced/local/keyed-store.d.ts +31 -0
  23. package/dist/storage/enhanced/local/keyed-store.d.ts.map +1 -0
  24. package/dist/storage/enhanced/local/keyed-store.mjs +37 -0
  25. package/dist/storage/enhanced/local/keyed-store.mjs.map +1 -0
  26. package/dist/storage/enhanced/redis/core.cjs +142 -0
  27. package/dist/storage/enhanced/redis/core.cjs.map +1 -0
  28. package/dist/storage/enhanced/redis/core.d.ts +78 -0
  29. package/dist/storage/enhanced/redis/core.d.ts.map +1 -0
  30. package/dist/storage/enhanced/redis/core.mjs +140 -0
  31. package/dist/storage/enhanced/redis/core.mjs.map +1 -0
  32. package/dist/storage/enhanced/redis/index.cjs +10 -0
  33. package/dist/storage/enhanced/redis/index.cjs.map +1 -0
  34. package/dist/storage/enhanced/redis/index.d.ts +3 -0
  35. package/dist/storage/enhanced/redis/index.d.ts.map +1 -0
  36. package/dist/storage/enhanced/redis/index.mjs +3 -0
  37. package/dist/storage/enhanced/redis/index.mjs.map +1 -0
  38. package/dist/storage/enhanced/redis/keyed-store.cjs +44 -0
  39. package/dist/storage/enhanced/redis/keyed-store.cjs.map +1 -0
  40. package/dist/storage/enhanced/redis/keyed-store.d.ts +37 -0
  41. package/dist/storage/enhanced/redis/keyed-store.d.ts.map +1 -0
  42. package/dist/storage/enhanced/redis/keyed-store.mjs +42 -0
  43. package/dist/storage/enhanced/redis/keyed-store.mjs.map +1 -0
  44. package/dist/storage/lru/keyed-store.cjs +49 -0
  45. package/dist/storage/lru/keyed-store.cjs.map +1 -0
  46. package/dist/storage/lru/keyed-store.d.ts +40 -0
  47. package/dist/storage/lru/keyed-store.d.ts.map +1 -0
  48. package/dist/storage/lru/keyed-store.mjs +47 -0
  49. package/dist/storage/lru/keyed-store.mjs.map +1 -0
  50. package/package.json +33 -19
  51. package/src/env.ts +10 -13
  52. package/src/storage/enhanced/local/core.ts +104 -0
  53. package/src/storage/enhanced/local/index.ts +2 -0
  54. package/src/storage/enhanced/local/keyed-store.ts +34 -0
  55. package/src/storage/enhanced/redis/core.ts +149 -0
  56. package/src/storage/enhanced/redis/index.ts +2 -0
  57. package/src/storage/enhanced/redis/keyed-store.ts +41 -0
  58. package/src/storage/lru/keyed-store.ts +48 -0
package/README.md CHANGED
@@ -5,24 +5,25 @@
5
5
  [![codecov][codecov-src]][codecov-href]
6
6
  [![License][license-src]][license-href]
7
7
 
8
- A lightweight modular utility library for JavaScript and TypeScript, offering secure hashing, flexible logging, date utilities, Vue/web helpers, and more.
8
+ A lightweight and modular utility library for modern JavaScript and TypeScript includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.
9
9
 
10
10
  - [✨ Release Notes](./CHANGELOG.md)
11
11
 
12
12
  ## Features
13
13
 
14
- - 📋 Clipboard utilities for copying text and blobs to the clipboard (Browser only)
15
- - 📜 Simple and flexible logging with Consola and Pino
16
- - 🔒 Secure hash utilities: MD5, SHA3-224/256/384/512
17
- - 📅 Datetime utilities for formatting, ranges, and offsets
18
- - 🔢 Enum helpers to extract values and keys
19
- - 🌱 Environment variable checker with error handling (Node only)
20
- - 📈 Math utilities like percentage formatting and rounding
21
- - 💎 Number formatting (e.g. compact, currency, padding)
22
- - 🔤 String tools such as random string generation and casing helpers
23
- - 🌐 URL utilities for parsing and building query strings
24
- - 🧩 Vue 3 utilities
25
- - ⚙️ General-purpose utilities like value extractors and type guards
14
+ - 📋 Clipboard utilities copy text and blobs using the modern Clipboard API (Browser only)
15
+ - 📜 Logging utilities — simple and extensible logging via Consola and Pino
16
+ - 🔒 Crypto utilities — secure hashing functions: MD5, SHA3-224/256/384/512
17
+ - 📅 Datetime utilities manipulate, format, and offset dates and ranges
18
+ - 🔢 Enum utilities extract enum keys and values (number or string)
19
+ - 🌱 Environment helpers safe env var access with error handling (Node only)
20
+ - 📈 Math utilities rounding, formatting percentages, and ratios
21
+ - 💎 Number utilities number padding, compact display, currency formatting
22
+ - 🔤 String utilities casing, trimming, random string generation, etc.
23
+ - 🌐 URL utilities parse and construct query strings and redirect URLs
24
+ - 🧩 Vue 3 utilities — composables like scroll preservation and key handling
25
+ - 🖥️ Web utilities browser DOM helpers (e.g. scroll to top, key matching)
26
+ - 🗄️ Storage utilities — enhanced localStorage, Redis, and LRU abstractions
26
27
  - 📦 Modular by design — import only what you need via `@kikiutils/shared/<module>`
27
28
 
28
29
  ## Requirements
@@ -66,15 +67,15 @@ logger.info(value);
66
67
 
67
68
  Each module file includes function-level comments and usage examples.
68
69
 
69
- ### [consola](./src/consola.ts)
70
-
71
- Console logger integration.
72
-
73
70
  ### [clipboard](./src/clipboard.ts)
74
71
 
75
72
  - `copyBlobToClipboard`
76
73
  - `copyTextToClipboard`
77
74
 
75
+ ### [consola](./src/consola.ts)
76
+
77
+ Console logger integration.
78
+
78
79
  ### [crypto-hash](./src/crypto-hash.ts)
79
80
 
80
81
  - `cryptoMd5`, `cryptoMd5ToBuffer`
@@ -125,6 +126,22 @@ Pino logger integration.
125
126
 
126
127
  - `generateWithNestedRandomLength`
127
128
 
129
+ ### storage
130
+
131
+ #### [enhanced-local](./src/storage/enhanced/local/index.ts)
132
+
133
+ - `createKeyedEnhancedLocalStore`
134
+ - `enhancedLocalStorage`
135
+
136
+ #### [enhanced-redis](./src/storage/enhanced/redis/index.ts)
137
+
138
+ - `createEnhancedRedisStorage`
139
+ - `createKeyedEnhancedRedisStore`
140
+
141
+ #### [lru/keyed-store](./src/storage/lru/keyed-store.ts)
142
+
143
+ - `createKeyedLruStore`
144
+
128
145
  ### [string](./src/string.ts)
129
146
 
130
147
  - `randomString`
package/dist/env.cjs CHANGED
@@ -22,9 +22,12 @@ class EnvironmentNotFoundError extends Error {
22
22
  }
23
23
  }
24
24
  /**
25
- * Retrieves the value of an environment variable, or throws an error if not set.
25
+ * Retrieves the value of an environment variable, or throws an error if it is not defined.
26
26
  *
27
- * @param {string} key - The environment variable key to check.
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.
28
31
  *
29
32
  * @returns {string} The value of the environment variable.
30
33
  *
@@ -32,21 +35,15 @@ class EnvironmentNotFoundError extends Error {
32
35
  *
33
36
  * @example
34
37
  * ```typescript
35
- * import { checkAndGetEnvValue } from '@kikiutils/shared/env';
36
- *
37
- * // When the environment variable 'API_KEY' is set:
38
- * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY
38
+ * process.env.API_KEY = '';
39
+ * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered "defined")
39
40
  *
40
- * // When the environment variable 'API_KEY' is not set:
41
- * try {
42
- * const apiKey = checkAndGetEnvValue('API_KEY');
43
- * } catch (error) {
44
- * console.error(error); // Missing environment variable: API_KEY
45
- * }
41
+ * delete process.env.API_KEY;
42
+ * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError
46
43
  * ```
47
44
  */
48
45
  function checkAndGetEnvValue(key) {
49
- if (!process.env[key])
46
+ if (process.env[key] === undefined)
50
47
  throw new EnvironmentNotFoundError(key);
51
48
  return process.env[key];
52
49
  }
package/dist/env.cjs.map CHANGED
@@ -1 +1 @@
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 not set.\n *\n * @param {string} key - The environment variable key to check.\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 * import { checkAndGetEnvValue } from '@kikiutils/shared/env';\n *\n * // When the environment variable 'API_KEY' is set:\n * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY\n *\n * // When the environment variable 'API_KEY' is not set:\n * try {\n * const apiKey = checkAndGetEnvValue('API_KEY');\n * } catch (error) {\n * console.error(error); // Missing environment variable: API_KEY\n * }\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (!process.env[key]) 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;;AAExD;AAED;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC9D,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;;"}
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;;AAExD;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.d.ts CHANGED
@@ -15,9 +15,12 @@ export declare class EnvironmentNotFoundError extends Error {
15
15
  constructor(key: string);
16
16
  }
17
17
  /**
18
- * Retrieves the value of an environment variable, or throws an error if not set.
18
+ * Retrieves the value of an environment variable, or throws an error if it is not defined.
19
19
  *
20
- * @param {string} key - The environment variable key to check.
20
+ * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
21
+ * value like `'0'` or `'false'` is considered a valid (defined) value.
22
+ *
23
+ * @param {string} key - The environment variable key to retrieve.
21
24
  *
22
25
  * @returns {string} The value of the environment variable.
23
26
  *
@@ -25,17 +28,11 @@ export declare class EnvironmentNotFoundError extends Error {
25
28
  *
26
29
  * @example
27
30
  * ```typescript
28
- * import { checkAndGetEnvValue } from '@kikiutils/shared/env';
29
- *
30
- * // When the environment variable 'API_KEY' is set:
31
- * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY
31
+ * process.env.API_KEY = '';
32
+ * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered "defined")
32
33
  *
33
- * // When the environment variable 'API_KEY' is not set:
34
- * try {
35
- * const apiKey = checkAndGetEnvValue('API_KEY');
36
- * } catch (error) {
37
- * console.error(error); // Missing environment variable: API_KEY
38
- * }
34
+ * delete process.env.API_KEY;
35
+ * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError
39
36
  * ```
40
37
  */
41
38
  export declare function checkAndGetEnvValue(key: string): string;
package/dist/env.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;;OAIG;gBACS,GAAG,EAAE,MAAM;CAM1B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGvD"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;;OAIG;gBACS,GAAG,EAAE,MAAM;CAM1B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGvD"}
package/dist/env.mjs CHANGED
@@ -20,9 +20,12 @@ class EnvironmentNotFoundError extends Error {
20
20
  }
21
21
  }
22
22
  /**
23
- * Retrieves the value of an environment variable, or throws an error if not set.
23
+ * Retrieves the value of an environment variable, or throws an error if it is not defined.
24
24
  *
25
- * @param {string} key - The environment variable key to check.
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.
26
29
  *
27
30
  * @returns {string} The value of the environment variable.
28
31
  *
@@ -30,21 +33,15 @@ class EnvironmentNotFoundError extends Error {
30
33
  *
31
34
  * @example
32
35
  * ```typescript
33
- * import { checkAndGetEnvValue } from '@kikiutils/shared/env';
34
- *
35
- * // When the environment variable 'API_KEY' is set:
36
- * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY
36
+ * process.env.API_KEY = '';
37
+ * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered "defined")
37
38
  *
38
- * // When the environment variable 'API_KEY' is not set:
39
- * try {
40
- * const apiKey = checkAndGetEnvValue('API_KEY');
41
- * } catch (error) {
42
- * console.error(error); // Missing environment variable: API_KEY
43
- * }
39
+ * delete process.env.API_KEY;
40
+ * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError
44
41
  * ```
45
42
  */
46
43
  function checkAndGetEnvValue(key) {
47
- if (!process.env[key])
44
+ if (process.env[key] === undefined)
48
45
  throw new EnvironmentNotFoundError(key);
49
46
  return process.env[key];
50
47
  }
package/dist/env.mjs.map CHANGED
@@ -1 +1 @@
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 not set.\n *\n * @param {string} key - The environment variable key to check.\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 * import { checkAndGetEnvValue } from '@kikiutils/shared/env';\n *\n * // When the environment variable 'API_KEY' is set:\n * console.log(checkAndGetEnvValue('API_KEY')); // value of API_KEY\n *\n * // When the environment variable 'API_KEY' is not set:\n * try {\n * const apiKey = checkAndGetEnvValue('API_KEY');\n * } catch (error) {\n * console.error(error); // Missing environment variable: API_KEY\n * }\n * ```\n */\nexport function checkAndGetEnvValue(key: string): string {\n if (!process.env[key]) 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;;AAExD;AAED;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAU,mBAAmB,CAAC,GAAW,EAAA;AAC3C,IAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,wBAAwB,CAAC,GAAG,CAAC;AAC9D,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B;;;;"}
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;;AAExD;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;;;;"}
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ const superjson = require('superjson');
4
+
5
+ var StorageValueEncodingType;
6
+ (function (StorageValueEncodingType) {
7
+ StorageValueEncodingType["Json"] = "0";
8
+ StorageValueEncodingType["String"] = "1";
9
+ })(StorageValueEncodingType || (StorageValueEncodingType = {}));
10
+ const customValueHeader = '​⁠';
11
+ const customValueHeaderLength = customValueHeader.length + 1;
12
+ const toCustomValue = (type, payload) => `${customValueHeader}${type}${payload}`;
13
+ /**
14
+ * An enhanced localStorage wrapper that supports storing
15
+ * complex data types (e.g. Dates, Maps, Sets) using SuperJSON encoding.
16
+ *
17
+ * This utility preserves type structure when saving and retrieving values.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * enhancedLocalStorage.setItem('user', { name: 'user', createdAt: new Date() });
22
+ * const user = enhancedLocalStorage.getItem<{ name: string, createdAt: Date }>('user');
23
+ * ```
24
+ */
25
+ const enhancedLocalStorage = Object.freeze({
26
+ /**
27
+ * Removes all items from localStorage.
28
+ */
29
+ clear: () => window.localStorage.clear(),
30
+ /**
31
+ * Retrieves a value by key and decodes it using SuperJSON or raw string.
32
+ *
33
+ * @template T - The expected type of the value.
34
+ *
35
+ * @param {string} key - The key of the value to retrieve.
36
+ *
37
+ * @returns {null | T} The decoded value or null if not found.
38
+ */
39
+ getItem(key) {
40
+ const rawValue = window.localStorage.getItem(key);
41
+ return rawValue ? decodeStorageValue(rawValue) : null;
42
+ },
43
+ /**
44
+ * Checks whether a key exists in localStorage.
45
+ *
46
+ * @param {string} key - The key to check.
47
+ *
48
+ * @returns {boolean} True if the key exists, false otherwise.
49
+ */
50
+ hasItem: (key) => window.localStorage.getItem(key) !== null,
51
+ /**
52
+ * Returns the number of items stored in localStorage.
53
+ *
54
+ * @returns {number} The number of items stored in localStorage.
55
+ */
56
+ get length() {
57
+ return window.localStorage.length;
58
+ },
59
+ /**
60
+ * Removes a specific key from localStorage.
61
+ *
62
+ * @param {string} key - The key to remove.
63
+ */
64
+ removeItem: (key) => window.localStorage.removeItem(key),
65
+ /**
66
+ * Stores a value in localStorage with automatic serialization.
67
+ *
68
+ * @param {string} key - The key to store the value under.
69
+ * @param {any} value - The value to store.
70
+ */
71
+ setItem: (key, value) => window.localStorage.setItem(key, encodeToStorageValue(value)),
72
+ });
73
+ function decodeStorageValue(data) {
74
+ if (!isCustomFormat(data))
75
+ return data;
76
+ const payload = data.substring(customValueHeaderLength);
77
+ const type = data.charAt(customValueHeader.length);
78
+ switch (type) {
79
+ case StorageValueEncodingType.Json:
80
+ try {
81
+ return superjson.deserialize(JSON.parse(payload));
82
+ }
83
+ catch {
84
+ throw new Error('[EnhancedLocalStorage] Failed to parse JSON payload.');
85
+ }
86
+ case StorageValueEncodingType.String: return payload;
87
+ default:
88
+ throw new Error(`[EnhancedLocalStorage] Unknown encoding type: ${type}.`);
89
+ }
90
+ }
91
+ function encodeToStorageValue(value) {
92
+ if (typeof value === 'string')
93
+ return toCustomValue(StorageValueEncodingType.String, value);
94
+ return toCustomValue(StorageValueEncodingType.Json, JSON.stringify(superjson.serialize(value)));
95
+ }
96
+ function isCustomFormat(data) {
97
+ return (data.length >= customValueHeaderLength
98
+ && data[0] === customValueHeader[0]
99
+ && data[1] === customValueHeader[1]);
100
+ }
101
+
102
+ exports.enhancedLocalStorage = enhancedLocalStorage;
103
+ //# sourceMappingURL=core.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.cjs","sources":["../../../../src/storage/enhanced/local/core.ts"],"sourcesContent":["import {\n deserialize,\n serialize,\n} from 'superjson';\n\nenum StorageValueEncodingType {\n Json = '0',\n String = '1',\n}\n\nconst customValueHeader = '​⁠';\nconst customValueHeaderLength = customValueHeader.length + 1;\nconst toCustomValue = (type: StorageValueEncodingType, payload: string) => `${customValueHeader}${type}${payload}`;\n\n/**\n * An enhanced localStorage wrapper that supports storing\n * complex data types (e.g. Dates, Maps, Sets) using SuperJSON encoding.\n *\n * This utility preserves type structure when saving and retrieving values.\n *\n * @example\n * ```typescript\n * enhancedLocalStorage.setItem('user', { name: 'user', createdAt: new Date() });\n * const user = enhancedLocalStorage.getItem<{ name: string, createdAt: Date }>('user');\n * ```\n */\nexport const enhancedLocalStorage = Object.freeze({\n /**\n * Removes all items from localStorage.\n */\n clear: () => window.localStorage.clear(),\n /**\n * Retrieves a value by key and decodes it using SuperJSON or raw string.\n *\n * @template T - The expected type of the value.\n *\n * @param {string} key - The key of the value to retrieve.\n *\n * @returns {null | T} The decoded value or null if not found.\n */\n getItem<T = unknown>(key: string) {\n const rawValue = window.localStorage.getItem(key);\n return rawValue ? decodeStorageValue(rawValue) as T : null;\n },\n /**\n * Checks whether a key exists in localStorage.\n *\n * @param {string} key - The key to check.\n *\n * @returns {boolean} True if the key exists, false otherwise.\n */\n hasItem: (key: string) => window.localStorage.getItem(key) !== null,\n /**\n * Returns the number of items stored in localStorage.\n *\n * @returns {number} The number of items stored in localStorage.\n */\n get length() {\n return window.localStorage.length;\n },\n /**\n * Removes a specific key from localStorage.\n *\n * @param {string} key - The key to remove.\n */\n removeItem: (key: string) => window.localStorage.removeItem(key),\n /**\n * Stores a value in localStorage with automatic serialization.\n *\n * @param {string} key - The key to store the value under.\n * @param {any} value - The value to store.\n */\n setItem: (key: string, value: any) => window.localStorage.setItem(key, encodeToStorageValue(value)),\n});\n\nfunction decodeStorageValue(data: string) {\n if (!isCustomFormat(data)) return data;\n const payload = data.substring(customValueHeaderLength);\n const type = data.charAt(customValueHeader.length);\n switch (type) {\n case StorageValueEncodingType.Json:\n try {\n return deserialize(JSON.parse(payload));\n } catch {\n throw new Error('[EnhancedLocalStorage] Failed to parse JSON payload.');\n }\n case StorageValueEncodingType.String: return payload;\n default:\n throw new Error(`[EnhancedLocalStorage] Unknown encoding type: ${type}.`);\n }\n}\n\nfunction encodeToStorageValue(value: any) {\n if (typeof value === 'string') return toCustomValue(StorageValueEncodingType.String, value);\n return toCustomValue(StorageValueEncodingType.Json, JSON.stringify(serialize(value)));\n}\n\nfunction isCustomFormat(data: string) {\n return (\n data.length >= customValueHeaderLength\n && data[0] === customValueHeader[0]\n && data[1] === customValueHeader[1]\n );\n}\n"],"names":["deserialize","serialize"],"mappings":";;;;AAKA,IAAK,wBAGJ;AAHD,CAAA,UAAK,wBAAwB,EAAA;AACzB,IAAA,wBAAA,CAAA,MAAA,CAAA,GAAA,GAAU;AACV,IAAA,wBAAA,CAAA,QAAA,CAAA,GAAA,GAAY;AAChB,CAAC,EAHI,wBAAwB,KAAxB,wBAAwB,GAG5B,EAAA,CAAA,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAI;AAC9B,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,MAAM,GAAG,CAAC;AAC5D,MAAM,aAAa,GAAG,CAAC,IAA8B,EAAE,OAAe,KAAK,CAAA,EAAG,iBAAiB,CAAG,EAAA,IAAI,CAAG,EAAA,OAAO,EAAE;AAElH;;;;;;;;;;;AAWG;AACU,MAAA,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;AAC9C;;AAEG;IACH,KAAK,EAAE,MAAM,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE;AACxC;;;;;;;;AAQG;AACH,IAAA,OAAO,CAAc,GAAW,EAAA;QAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC;AACjD,QAAA,OAAO,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAM,GAAG,IAAI;KAC7D;AACD;;;;;;AAMG;AACH,IAAA,OAAO,EAAE,CAAC,GAAW,KAAK,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI;AACnE;;;;AAIG;AACH,IAAA,IAAI,MAAM,GAAA;AACN,QAAA,OAAO,MAAM,CAAC,YAAY,CAAC,MAAM;KACpC;AACD;;;;AAIG;AACH,IAAA,UAAU,EAAE,CAAC,GAAW,KAAK,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;AAChE;;;;;AAKG;IACH,OAAO,EAAE,CAAC,GAAW,EAAE,KAAU,KAAK,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACtG,CAAA;AAED,SAAS,kBAAkB,CAAC,IAAY,EAAA;AACpC,IAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC;IACvD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC;IAClD,QAAQ,IAAI;QACR,KAAK,wBAAwB,CAAC,IAAI;AAC9B,YAAA,IAAI;gBACA,OAAOA,qBAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;;AACzC,YAAA,MAAM;AACJ,gBAAA,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC;;AAE/E,QAAA,KAAK,wBAAwB,CAAC,MAAM,EAAE,OAAO,OAAO;AACpD,QAAA;AACI,YAAA,MAAM,IAAI,KAAK,CAAC,iDAAiD,IAAI,CAAA,CAAA,CAAG,CAAC;;AAErF;AAEA,SAAS,oBAAoB,CAAC,KAAU,EAAA;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC;AAC3F,IAAA,OAAO,aAAa,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAACC,mBAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACzF;AAEA,SAAS,cAAc,CAAC,IAAY,EAAA;AAChC,IAAA,QACI,IAAI,CAAC,MAAM,IAAI;AACZ,WAAA,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC;WAC/B,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC;AAE3C;;;;"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * An enhanced localStorage wrapper that supports storing
3
+ * complex data types (e.g. Dates, Maps, Sets) using SuperJSON encoding.
4
+ *
5
+ * This utility preserves type structure when saving and retrieving values.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * enhancedLocalStorage.setItem('user', { name: 'user', createdAt: new Date() });
10
+ * const user = enhancedLocalStorage.getItem<{ name: string, createdAt: Date }>('user');
11
+ * ```
12
+ */
13
+ export declare const enhancedLocalStorage: Readonly<{
14
+ /**
15
+ * Removes all items from localStorage.
16
+ */
17
+ clear: () => void;
18
+ /**
19
+ * Retrieves a value by key and decodes it using SuperJSON or raw string.
20
+ *
21
+ * @template T - The expected type of the value.
22
+ *
23
+ * @param {string} key - The key of the value to retrieve.
24
+ *
25
+ * @returns {null | T} The decoded value or null if not found.
26
+ */
27
+ getItem<T = unknown>(key: string): T | null;
28
+ /**
29
+ * Checks whether a key exists in localStorage.
30
+ *
31
+ * @param {string} key - The key to check.
32
+ *
33
+ * @returns {boolean} True if the key exists, false otherwise.
34
+ */
35
+ hasItem: (key: string) => boolean;
36
+ /**
37
+ * Returns the number of items stored in localStorage.
38
+ *
39
+ * @returns {number} The number of items stored in localStorage.
40
+ */
41
+ readonly length: number;
42
+ /**
43
+ * Removes a specific key from localStorage.
44
+ *
45
+ * @param {string} key - The key to remove.
46
+ */
47
+ removeItem: (key: string) => void;
48
+ /**
49
+ * Stores a value in localStorage with automatic serialization.
50
+ *
51
+ * @param {string} key - The key to store the value under.
52
+ * @param {any} value - The value to store.
53
+ */
54
+ setItem: (key: string, value: any) => void;
55
+ }>;
56
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/storage/enhanced/local/core.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB;IAC7B;;OAEG;;IAEH;;;;;;;;OAQG;YACK,CAAC,iBAAiB,MAAM;IAIhC;;;;;;OAMG;mBACY,MAAM;IACrB;;;;OAIG;;IAIH;;;;OAIG;sBACe,MAAM;IACxB;;;;;OAKG;mBACY,MAAM,SAAS,GAAG;EACnC,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { serialize, deserialize } from 'superjson';
2
+
3
+ var StorageValueEncodingType;
4
+ (function (StorageValueEncodingType) {
5
+ StorageValueEncodingType["Json"] = "0";
6
+ StorageValueEncodingType["String"] = "1";
7
+ })(StorageValueEncodingType || (StorageValueEncodingType = {}));
8
+ const customValueHeader = '​⁠';
9
+ const customValueHeaderLength = customValueHeader.length + 1;
10
+ const toCustomValue = (type, payload) => `${customValueHeader}${type}${payload}`;
11
+ /**
12
+ * An enhanced localStorage wrapper that supports storing
13
+ * complex data types (e.g. Dates, Maps, Sets) using SuperJSON encoding.
14
+ *
15
+ * This utility preserves type structure when saving and retrieving values.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * enhancedLocalStorage.setItem('user', { name: 'user', createdAt: new Date() });
20
+ * const user = enhancedLocalStorage.getItem<{ name: string, createdAt: Date }>('user');
21
+ * ```
22
+ */
23
+ const enhancedLocalStorage = Object.freeze({
24
+ /**
25
+ * Removes all items from localStorage.
26
+ */
27
+ clear: () => window.localStorage.clear(),
28
+ /**
29
+ * Retrieves a value by key and decodes it using SuperJSON or raw string.
30
+ *
31
+ * @template T - The expected type of the value.
32
+ *
33
+ * @param {string} key - The key of the value to retrieve.
34
+ *
35
+ * @returns {null | T} The decoded value or null if not found.
36
+ */
37
+ getItem(key) {
38
+ const rawValue = window.localStorage.getItem(key);
39
+ return rawValue ? decodeStorageValue(rawValue) : null;
40
+ },
41
+ /**
42
+ * Checks whether a key exists in localStorage.
43
+ *
44
+ * @param {string} key - The key to check.
45
+ *
46
+ * @returns {boolean} True if the key exists, false otherwise.
47
+ */
48
+ hasItem: (key) => window.localStorage.getItem(key) !== null,
49
+ /**
50
+ * Returns the number of items stored in localStorage.
51
+ *
52
+ * @returns {number} The number of items stored in localStorage.
53
+ */
54
+ get length() {
55
+ return window.localStorage.length;
56
+ },
57
+ /**
58
+ * Removes a specific key from localStorage.
59
+ *
60
+ * @param {string} key - The key to remove.
61
+ */
62
+ removeItem: (key) => window.localStorage.removeItem(key),
63
+ /**
64
+ * Stores a value in localStorage with automatic serialization.
65
+ *
66
+ * @param {string} key - The key to store the value under.
67
+ * @param {any} value - The value to store.
68
+ */
69
+ setItem: (key, value) => window.localStorage.setItem(key, encodeToStorageValue(value)),
70
+ });
71
+ function decodeStorageValue(data) {
72
+ if (!isCustomFormat(data))
73
+ return data;
74
+ const payload = data.substring(customValueHeaderLength);
75
+ const type = data.charAt(customValueHeader.length);
76
+ switch (type) {
77
+ case StorageValueEncodingType.Json:
78
+ try {
79
+ return deserialize(JSON.parse(payload));
80
+ }
81
+ catch {
82
+ throw new Error('[EnhancedLocalStorage] Failed to parse JSON payload.');
83
+ }
84
+ case StorageValueEncodingType.String: return payload;
85
+ default:
86
+ throw new Error(`[EnhancedLocalStorage] Unknown encoding type: ${type}.`);
87
+ }
88
+ }
89
+ function encodeToStorageValue(value) {
90
+ if (typeof value === 'string')
91
+ return toCustomValue(StorageValueEncodingType.String, value);
92
+ return toCustomValue(StorageValueEncodingType.Json, JSON.stringify(serialize(value)));
93
+ }
94
+ function isCustomFormat(data) {
95
+ return (data.length >= customValueHeaderLength
96
+ && data[0] === customValueHeader[0]
97
+ && data[1] === customValueHeader[1]);
98
+ }
99
+
100
+ export { enhancedLocalStorage };
101
+ //# sourceMappingURL=core.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.mjs","sources":["../../../../src/storage/enhanced/local/core.ts"],"sourcesContent":["import {\n deserialize,\n serialize,\n} from 'superjson';\n\nenum StorageValueEncodingType {\n Json = '0',\n String = '1',\n}\n\nconst customValueHeader = '​⁠';\nconst customValueHeaderLength = customValueHeader.length + 1;\nconst toCustomValue = (type: StorageValueEncodingType, payload: string) => `${customValueHeader}${type}${payload}`;\n\n/**\n * An enhanced localStorage wrapper that supports storing\n * complex data types (e.g. Dates, Maps, Sets) using SuperJSON encoding.\n *\n * This utility preserves type structure when saving and retrieving values.\n *\n * @example\n * ```typescript\n * enhancedLocalStorage.setItem('user', { name: 'user', createdAt: new Date() });\n * const user = enhancedLocalStorage.getItem<{ name: string, createdAt: Date }>('user');\n * ```\n */\nexport const enhancedLocalStorage = Object.freeze({\n /**\n * Removes all items from localStorage.\n */\n clear: () => window.localStorage.clear(),\n /**\n * Retrieves a value by key and decodes it using SuperJSON or raw string.\n *\n * @template T - The expected type of the value.\n *\n * @param {string} key - The key of the value to retrieve.\n *\n * @returns {null | T} The decoded value or null if not found.\n */\n getItem<T = unknown>(key: string) {\n const rawValue = window.localStorage.getItem(key);\n return rawValue ? decodeStorageValue(rawValue) as T : null;\n },\n /**\n * Checks whether a key exists in localStorage.\n *\n * @param {string} key - The key to check.\n *\n * @returns {boolean} True if the key exists, false otherwise.\n */\n hasItem: (key: string) => window.localStorage.getItem(key) !== null,\n /**\n * Returns the number of items stored in localStorage.\n *\n * @returns {number} The number of items stored in localStorage.\n */\n get length() {\n return window.localStorage.length;\n },\n /**\n * Removes a specific key from localStorage.\n *\n * @param {string} key - The key to remove.\n */\n removeItem: (key: string) => window.localStorage.removeItem(key),\n /**\n * Stores a value in localStorage with automatic serialization.\n *\n * @param {string} key - The key to store the value under.\n * @param {any} value - The value to store.\n */\n setItem: (key: string, value: any) => window.localStorage.setItem(key, encodeToStorageValue(value)),\n});\n\nfunction decodeStorageValue(data: string) {\n if (!isCustomFormat(data)) return data;\n const payload = data.substring(customValueHeaderLength);\n const type = data.charAt(customValueHeader.length);\n switch (type) {\n case StorageValueEncodingType.Json:\n try {\n return deserialize(JSON.parse(payload));\n } catch {\n throw new Error('[EnhancedLocalStorage] Failed to parse JSON payload.');\n }\n case StorageValueEncodingType.String: return payload;\n default:\n throw new Error(`[EnhancedLocalStorage] Unknown encoding type: ${type}.`);\n }\n}\n\nfunction encodeToStorageValue(value: any) {\n if (typeof value === 'string') return toCustomValue(StorageValueEncodingType.String, value);\n return toCustomValue(StorageValueEncodingType.Json, JSON.stringify(serialize(value)));\n}\n\nfunction isCustomFormat(data: string) {\n return (\n data.length >= customValueHeaderLength\n && data[0] === customValueHeader[0]\n && data[1] === customValueHeader[1]\n );\n}\n"],"names":[],"mappings":";;AAKA,IAAK,wBAGJ;AAHD,CAAA,UAAK,wBAAwB,EAAA;AACzB,IAAA,wBAAA,CAAA,MAAA,CAAA,GAAA,GAAU;AACV,IAAA,wBAAA,CAAA,QAAA,CAAA,GAAA,GAAY;AAChB,CAAC,EAHI,wBAAwB,KAAxB,wBAAwB,GAG5B,EAAA,CAAA,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAI;AAC9B,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,MAAM,GAAG,CAAC;AAC5D,MAAM,aAAa,GAAG,CAAC,IAA8B,EAAE,OAAe,KAAK,CAAA,EAAG,iBAAiB,CAAG,EAAA,IAAI,CAAG,EAAA,OAAO,EAAE;AAElH;;;;;;;;;;;AAWG;AACU,MAAA,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;AAC9C;;AAEG;IACH,KAAK,EAAE,MAAM,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE;AACxC;;;;;;;;AAQG;AACH,IAAA,OAAO,CAAc,GAAW,EAAA;QAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC;AACjD,QAAA,OAAO,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAM,GAAG,IAAI;KAC7D;AACD;;;;;;AAMG;AACH,IAAA,OAAO,EAAE,CAAC,GAAW,KAAK,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI;AACnE;;;;AAIG;AACH,IAAA,IAAI,MAAM,GAAA;AACN,QAAA,OAAO,MAAM,CAAC,YAAY,CAAC,MAAM;KACpC;AACD;;;;AAIG;AACH,IAAA,UAAU,EAAE,CAAC,GAAW,KAAK,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;AAChE;;;;;AAKG;IACH,OAAO,EAAE,CAAC,GAAW,EAAE,KAAU,KAAK,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACtG,CAAA;AAED,SAAS,kBAAkB,CAAC,IAAY,EAAA;AACpC,IAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC;IACvD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC;IAClD,QAAQ,IAAI;QACR,KAAK,wBAAwB,CAAC,IAAI;AAC9B,YAAA,IAAI;gBACA,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;;AACzC,YAAA,MAAM;AACJ,gBAAA,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC;;AAE/E,QAAA,KAAK,wBAAwB,CAAC,MAAM,EAAE,OAAO,OAAO;AACpD,QAAA;AACI,YAAA,MAAM,IAAI,KAAK,CAAC,iDAAiD,IAAI,CAAA,CAAA,CAAG,CAAC;;AAErF;AAEA,SAAS,oBAAoB,CAAC,KAAU,EAAA;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC;AAC3F,IAAA,OAAO,aAAa,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACzF;AAEA,SAAS,cAAc,CAAC,IAAY,EAAA;AAChC,IAAA,QACI,IAAI,CAAC,MAAM,IAAI;AACZ,WAAA,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC;WAC/B,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC;AAE3C;;;;"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const core = require('./core.cjs');
4
+ const keyedStore = require('./keyed-store.cjs');
5
+
6
+
7
+
8
+ exports.enhancedLocalStorage = core.enhancedLocalStorage;
9
+ exports.createKeyedEnhancedLocalStore = keyedStore.createKeyedEnhancedLocalStore;
10
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ export { enhancedLocalStorage } from './core';
2
+ export { createKeyedEnhancedLocalStore } from './keyed-store';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/enhanced/local/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { enhancedLocalStorage } from './core.mjs';
2
+ export { createKeyedEnhancedLocalStore } from './keyed-store.mjs';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ const core = require('./core.cjs');
4
+
5
+ /**
6
+ * Creates a reusable, type-safe storage interface based on `enhancedLocalStorage`
7
+ * and a dynamic key-generation function.
8
+ *
9
+ * This utility allows you to abstract away key construction logic and work directly
10
+ * with scoped key-value operations like `getItem`, `setItem`, and `removeItem`.
11
+ *
12
+ * @template D - The value type to store.
13
+ *
14
+ * @returns A factory that accepts a key generator function and returns a scoped storage interface.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const userStore = createKeyedEnhancedLocalStore<User>()((id: number) => `user:${id}`);
19
+ * userStore.setItem({ id: 123, name: 'user' }, 123);
20
+ * const user = userStore.getItem(123);
21
+ * ```
22
+ */
23
+ function createKeyedEnhancedLocalStore() {
24
+ return (getKeyFunction) => Object.freeze({
25
+ getItem: (...args) => core.enhancedLocalStorage.getItem(getKeyFunction(...args)),
26
+ hasItem: (...args) => core.enhancedLocalStorage.hasItem(getKeyFunction(...args)),
27
+ removeItem: (...args) => core.enhancedLocalStorage.removeItem(getKeyFunction(...args)),
28
+ /**
29
+ * Resolves the storage key from the given arguments.
30
+ *
31
+ * @returns {string} The final string key used internally.
32
+ */
33
+ resolveKey: (...args) => getKeyFunction(...args),
34
+ setItem: (value, ...args) => core.enhancedLocalStorage.setItem(getKeyFunction(...args), value),
35
+ });
36
+ }
37
+
38
+ exports.createKeyedEnhancedLocalStore = createKeyedEnhancedLocalStore;
39
+ //# sourceMappingURL=keyed-store.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-store.cjs","sources":["../../../../src/storage/enhanced/local/keyed-store.ts"],"sourcesContent":["import { enhancedLocalStorage } from './core';\n\n/**\n * Creates a reusable, type-safe storage interface based on `enhancedLocalStorage`\n * and a dynamic key-generation function.\n *\n * This utility allows you to abstract away key construction logic and work directly\n * with scoped key-value operations like `getItem`, `setItem`, and `removeItem`.\n *\n * @template D - The value type to store.\n *\n * @returns A factory that accepts a key generator function and returns a scoped storage interface.\n *\n * @example\n * ```typescript\n * const userStore = createKeyedEnhancedLocalStore<User>()((id: number) => `user:${id}`);\n * userStore.setItem({ id: 123, name: 'user' }, 123);\n * const user = userStore.getItem(123);\n * ```\n */\nexport function createKeyedEnhancedLocalStore<D = unknown>() {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n getItem: (...args: P) => enhancedLocalStorage.getItem<D>(getKeyFunction(...args)),\n hasItem: (...args: P) => enhancedLocalStorage.hasItem(getKeyFunction(...args)),\n removeItem: (...args: P) => enhancedLocalStorage.removeItem(getKeyFunction(...args)),\n /**\n * Resolves the storage key from the given arguments.\n *\n * @returns {string} The final string key used internally.\n */\n resolveKey: (...args: P) => getKeyFunction(...args),\n setItem: (value: D, ...args: P) => enhancedLocalStorage.setItem(getKeyFunction(...args), value),\n });\n}\n"],"names":["enhancedLocalStorage"],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;AAiBG;SACa,6BAA6B,GAAA;IACzC,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAKA,yBAAoB,CAAC,OAAO,CAAI,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjF,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAKA,yBAAoB,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9E,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAKA,yBAAoB,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACpF;;;;AAIG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;QACnD,OAAO,EAAE,CAAC,KAAQ,EAAE,GAAG,IAAO,KAAKA,yBAAoB,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;AAClG,KAAA,CAAC;AACN;;;;"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Creates a reusable, type-safe storage interface based on `enhancedLocalStorage`
3
+ * and a dynamic key-generation function.
4
+ *
5
+ * This utility allows you to abstract away key construction logic and work directly
6
+ * with scoped key-value operations like `getItem`, `setItem`, and `removeItem`.
7
+ *
8
+ * @template D - The value type to store.
9
+ *
10
+ * @returns A factory that accepts a key generator function and returns a scoped storage interface.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const userStore = createKeyedEnhancedLocalStore<User>()((id: number) => `user:${id}`);
15
+ * userStore.setItem({ id: 123, name: 'user' }, 123);
16
+ * const user = userStore.getItem(123);
17
+ * ```
18
+ */
19
+ export declare function createKeyedEnhancedLocalStore<D = unknown>(): <P extends any[]>(getKeyFunction: (...args: P) => string) => Readonly<{
20
+ getItem: (...args: P) => D | null;
21
+ hasItem: (...args: P) => boolean;
22
+ removeItem: (...args: P) => void;
23
+ /**
24
+ * Resolves the storage key from the given arguments.
25
+ *
26
+ * @returns {string} The final string key used internally.
27
+ */
28
+ resolveKey: (...args: P) => string;
29
+ setItem: (value: D, ...args: P) => void;
30
+ }>;
31
+ //# sourceMappingURL=keyed-store.d.ts.map