@kikiutils/shared 10.3.0 → 10.4.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/dist/buffer.cjs +43 -0
- package/dist/buffer.cjs.map +1 -0
- package/dist/buffer.d.ts +35 -0
- package/dist/buffer.d.ts.map +1 -0
- package/dist/buffer.mjs +41 -0
- package/dist/buffer.mjs.map +1 -0
- package/dist/clipboard.cjs +4 -4
- package/dist/clipboard.cjs.map +1 -1
- package/dist/clipboard.d.ts +3 -3
- package/dist/clipboard.mjs +4 -4
- package/dist/clipboard.mjs.map +1 -1
- package/dist/datetime.cjs +13 -13
- package/dist/datetime.cjs.map +1 -1
- package/dist/datetime.d.ts +12 -12
- package/dist/datetime.mjs +13 -13
- package/dist/datetime.mjs.map +1 -1
- package/dist/element-plus.cjs +6 -6
- package/dist/element-plus.cjs.map +1 -1
- package/dist/element-plus.d.ts +6 -6
- package/dist/element-plus.mjs +6 -6
- package/dist/element-plus.mjs.map +1 -1
- package/dist/enum.cjs +12 -12
- package/dist/enum.cjs.map +1 -1
- package/dist/enum.d.ts +12 -12
- package/dist/enum.mjs +12 -12
- package/dist/enum.mjs.map +1 -1
- package/dist/env.cjs +4 -4
- package/dist/env.cjs.map +1 -1
- package/dist/env.d.ts +4 -4
- package/dist/env.mjs +4 -4
- package/dist/env.mjs.map +1 -1
- package/dist/general.cjs.map +1 -1
- package/dist/general.d.ts +5 -5
- package/dist/general.mjs.map +1 -1
- package/dist/math.cjs +4 -4
- package/dist/math.cjs.map +1 -1
- package/dist/math.d.ts +4 -4
- package/dist/math.mjs +4 -4
- package/dist/math.mjs.map +1 -1
- package/dist/number.cjs +3 -3
- package/dist/number.cjs.map +1 -1
- package/dist/number.d.ts +3 -3
- package/dist/number.mjs +3 -3
- package/dist/number.mjs.map +1 -1
- package/dist/object.cjs +4 -4
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.ts +4 -4
- package/dist/object.mjs +4 -4
- package/dist/object.mjs.map +1 -1
- package/dist/random.cjs +7 -7
- package/dist/random.cjs.map +1 -1
- package/dist/random.d.ts +7 -7
- package/dist/random.mjs +7 -7
- package/dist/random.mjs.map +1 -1
- package/dist/storage/enhanced/local/core.cjs +11 -11
- package/dist/storage/enhanced/local/core.cjs.map +1 -1
- package/dist/storage/enhanced/local/core.d.ts +9 -9
- package/dist/storage/enhanced/local/core.mjs +11 -11
- package/dist/storage/enhanced/local/core.mjs.map +1 -1
- package/dist/storage/enhanced/local/keyed-store.cjs +3 -3
- package/dist/storage/enhanced/local/keyed-store.cjs.map +1 -1
- package/dist/storage/enhanced/local/keyed-store.d.ts +3 -3
- package/dist/storage/enhanced/local/keyed-store.mjs +3 -3
- package/dist/storage/enhanced/local/keyed-store.mjs.map +1 -1
- package/dist/storage/enhanced/redis/core.cjs +18 -18
- package/dist/storage/enhanced/redis/core.cjs.map +1 -1
- package/dist/storage/enhanced/redis/core.d.ts +16 -16
- package/dist/storage/enhanced/redis/core.mjs +18 -18
- package/dist/storage/enhanced/redis/core.mjs.map +1 -1
- package/dist/storage/enhanced/redis/keyed-store.cjs +4 -4
- package/dist/storage/enhanced/redis/keyed-store.cjs.map +1 -1
- package/dist/storage/enhanced/redis/keyed-store.d.ts +4 -4
- package/dist/storage/enhanced/redis/keyed-store.mjs +4 -4
- package/dist/storage/enhanced/redis/keyed-store.mjs.map +1 -1
- package/dist/storage/lru/keyed-store.cjs +3 -3
- package/dist/storage/lru/keyed-store.cjs.map +1 -1
- package/dist/storage/lru/keyed-store.d.ts +3 -3
- package/dist/storage/lru/keyed-store.mjs +3 -3
- package/dist/storage/lru/keyed-store.mjs.map +1 -1
- package/dist/string.cjs +5 -5
- package/dist/string.cjs.map +1 -1
- package/dist/string.d.ts +4 -4
- package/dist/string.mjs +5 -5
- package/dist/string.mjs.map +1 -1
- package/dist/url.cjs +3 -3
- package/dist/url.cjs.map +1 -1
- package/dist/url.d.ts +3 -3
- package/dist/url.mjs +3 -3
- package/dist/url.mjs.map +1 -1
- package/dist/vue.cjs +6 -6
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.ts +6 -6
- package/dist/vue.mjs +6 -6
- package/dist/vue.mjs.map +1 -1
- package/dist/web.cjs +4 -4
- package/dist/web.cjs.map +1 -1
- package/dist/web.d.ts +4 -4
- package/dist/web.mjs +4 -4
- package/dist/web.mjs.map +1 -1
- package/package.json +2 -2
- package/src/buffer.ts +41 -0
- package/src/clipboard.ts +4 -4
- package/src/datetime.ts +13 -13
- package/src/element-plus.ts +6 -6
- package/src/enum.ts +12 -12
- package/src/env.ts +4 -4
- package/src/general.ts +5 -5
- package/src/math.ts +4 -4
- package/src/number.ts +3 -3
- package/src/object.ts +4 -4
- package/src/random.ts +7 -7
- package/src/storage/enhanced/local/core.ts +11 -11
- package/src/storage/enhanced/local/keyed-store.ts +3 -3
- package/src/storage/enhanced/redis/core.ts +18 -18
- package/src/storage/enhanced/redis/keyed-store.ts +4 -4
- package/src/storage/lru/keyed-store.ts +3 -3
- package/src/string.ts +5 -5
- package/src/url.ts +3 -3
- package/src/vue.ts +6 -6
- package/src/web.ts +4 -4
|
@@ -5,9 +5,9 @@ import { Redis } from 'ioredis';
|
|
|
5
5
|
* This utility provides a typed, serializable key-value store backed by Redis,
|
|
6
6
|
* supporting TTL operations and safe deserialization of complex types (e.g. Date, Map).
|
|
7
7
|
*
|
|
8
|
-
* @param {Redis | string} ioRedisInstanceOrUrl - Either an existing `ioredis` instance or a Redis connection string
|
|
8
|
+
* @param {Redis | string} ioRedisInstanceOrUrl - Either an existing `ioredis` instance or a Redis connection string
|
|
9
9
|
*
|
|
10
|
-
* @returns A frozen object that wraps Redis commands with typed get/set logic and encoding
|
|
10
|
+
* @returns A frozen object that wraps Redis commands with typed get/set logic and encoding
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
@@ -22,40 +22,40 @@ export declare function createEnhancedRedisStorage(ioRedisInstanceOrUrl: Redis |
|
|
|
22
22
|
/**
|
|
23
23
|
* Retrieves a value from Redis and decodes it.
|
|
24
24
|
*
|
|
25
|
-
* @template T - The expected return type
|
|
25
|
+
* @template T - The expected return type
|
|
26
26
|
*
|
|
27
|
-
* @param {string} key - The Redis key
|
|
27
|
+
* @param {string} key - The Redis key
|
|
28
28
|
*
|
|
29
|
-
* @returns {Promise<null | T>} The decoded value or null if not found
|
|
29
|
+
* @returns {Promise<null | T>} The decoded value or null if not found
|
|
30
30
|
*/
|
|
31
31
|
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
32
32
|
/**
|
|
33
33
|
* Gets the remaining TTL (in seconds) for a given key.
|
|
34
34
|
*
|
|
35
|
-
* @param {string} key - The Redis key
|
|
35
|
+
* @param {string} key - The Redis key
|
|
36
36
|
*
|
|
37
|
-
* @returns {Promise<number>} The number of seconds until the key expires, or -1 if no expiration is set
|
|
37
|
+
* @returns {Promise<number>} The number of seconds until the key expires, or -1 if no expiration is set
|
|
38
38
|
*/
|
|
39
39
|
getItemTtl: (key: string) => Promise<number>;
|
|
40
40
|
/**
|
|
41
41
|
* Checks whether a key exists in Redis.
|
|
42
42
|
*
|
|
43
|
-
* @param {string} key - The Redis key
|
|
43
|
+
* @param {string} key - The Redis key
|
|
44
44
|
*
|
|
45
|
-
* @returns {Promise<boolean>} True if the key exists, false otherwise
|
|
45
|
+
* @returns {Promise<boolean>} True if the key exists, false otherwise
|
|
46
46
|
*/
|
|
47
47
|
hasItem: (key: string) => Promise<boolean>;
|
|
48
48
|
/**
|
|
49
49
|
* The underlying Redis instance, exposed for advanced operations.
|
|
50
50
|
* Use with caution; most use cases should rely on the wrapper methods.
|
|
51
51
|
*
|
|
52
|
-
* @returns {Redis} The underlying Redis instance
|
|
52
|
+
* @returns {Redis} The underlying Redis instance
|
|
53
53
|
*/
|
|
54
54
|
readonly instance: Redis;
|
|
55
55
|
/**
|
|
56
56
|
* Removes a key from Redis.
|
|
57
57
|
*
|
|
58
|
-
* @param {string} key - The Redis key to delete
|
|
58
|
+
* @param {string} key - The Redis key to delete
|
|
59
59
|
*
|
|
60
60
|
* @returns {Promise<boolean>} A Promise that resolves to `true` if the key was removed,
|
|
61
61
|
* or `false` if it did not exist.
|
|
@@ -64,16 +64,16 @@ export declare function createEnhancedRedisStorage(ioRedisInstanceOrUrl: Redis |
|
|
|
64
64
|
/**
|
|
65
65
|
* Stores a value in Redis without expiration.
|
|
66
66
|
*
|
|
67
|
-
* @param {string} key - The Redis key
|
|
68
|
-
* @param {any} value - The value to store. Will be serialized
|
|
67
|
+
* @param {string} key - The Redis key
|
|
68
|
+
* @param {any} value - The value to store. Will be serialized
|
|
69
69
|
*/
|
|
70
70
|
setItem: (key: string, value: any) => Promise<"OK">;
|
|
71
71
|
/**
|
|
72
72
|
* Stores a value in Redis with a time-to-live (TTL).
|
|
73
73
|
*
|
|
74
|
-
* @param {string} key - The Redis key
|
|
75
|
-
* @param {number} seconds - Expiration time in seconds
|
|
76
|
-
* @param {any} value - The value to store. Will be serialized
|
|
74
|
+
* @param {string} key - The Redis key
|
|
75
|
+
* @param {number} seconds - Expiration time in seconds
|
|
76
|
+
* @param {any} value - The value to store. Will be serialized
|
|
77
77
|
*/
|
|
78
78
|
setItemWithTtl(key: string, seconds: number, value: any): Promise<"OK">;
|
|
79
79
|
}>;
|
|
@@ -16,9 +16,9 @@ const customValueHeaderLength = customValueHeader.byteLength + 1;
|
|
|
16
16
|
* This utility provides a typed, serializable key-value store backed by Redis,
|
|
17
17
|
* supporting TTL operations and safe deserialization of complex types (e.g. Date, Map).
|
|
18
18
|
*
|
|
19
|
-
* @param {Redis | string} ioRedisInstanceOrUrl - Either an existing `ioredis` instance or a Redis connection string
|
|
19
|
+
* @param {Redis | string} ioRedisInstanceOrUrl - Either an existing `ioredis` instance or a Redis connection string
|
|
20
20
|
*
|
|
21
|
-
* @returns A frozen object that wraps Redis commands with typed get/set logic and encoding
|
|
21
|
+
* @returns A frozen object that wraps Redis commands with typed get/set logic and encoding
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
@@ -35,11 +35,11 @@ function createEnhancedRedisStorage(ioRedisInstanceOrUrl) {
|
|
|
35
35
|
/**
|
|
36
36
|
* Retrieves a value from Redis and decodes it.
|
|
37
37
|
*
|
|
38
|
-
* @template T - The expected return type
|
|
38
|
+
* @template T - The expected return type
|
|
39
39
|
*
|
|
40
|
-
* @param {string} key - The Redis key
|
|
40
|
+
* @param {string} key - The Redis key
|
|
41
41
|
*
|
|
42
|
-
* @returns {Promise<null | T>} The decoded value or null if not found
|
|
42
|
+
* @returns {Promise<null | T>} The decoded value or null if not found
|
|
43
43
|
*/
|
|
44
44
|
async getItem(key) {
|
|
45
45
|
const rawValue = await instance.getBuffer(key);
|
|
@@ -48,24 +48,24 @@ function createEnhancedRedisStorage(ioRedisInstanceOrUrl) {
|
|
|
48
48
|
/**
|
|
49
49
|
* Gets the remaining TTL (in seconds) for a given key.
|
|
50
50
|
*
|
|
51
|
-
* @param {string} key - The Redis key
|
|
51
|
+
* @param {string} key - The Redis key
|
|
52
52
|
*
|
|
53
|
-
* @returns {Promise<number>} The number of seconds until the key expires, or -1 if no expiration is set
|
|
53
|
+
* @returns {Promise<number>} The number of seconds until the key expires, or -1 if no expiration is set
|
|
54
54
|
*/
|
|
55
55
|
getItemTtl: (key) => instance.ttl(key),
|
|
56
56
|
/**
|
|
57
57
|
* Checks whether a key exists in Redis.
|
|
58
58
|
*
|
|
59
|
-
* @param {string} key - The Redis key
|
|
59
|
+
* @param {string} key - The Redis key
|
|
60
60
|
*
|
|
61
|
-
* @returns {Promise<boolean>} True if the key exists, false otherwise
|
|
61
|
+
* @returns {Promise<boolean>} True if the key exists, false otherwise
|
|
62
62
|
*/
|
|
63
63
|
hasItem: async (key) => await instance.exists(key) === 1,
|
|
64
64
|
/**
|
|
65
65
|
* The underlying Redis instance, exposed for advanced operations.
|
|
66
66
|
* Use with caution; most use cases should rely on the wrapper methods.
|
|
67
67
|
*
|
|
68
|
-
* @returns {Redis} The underlying Redis instance
|
|
68
|
+
* @returns {Redis} The underlying Redis instance
|
|
69
69
|
*/
|
|
70
70
|
get instance() {
|
|
71
71
|
return instance;
|
|
@@ -73,7 +73,7 @@ function createEnhancedRedisStorage(ioRedisInstanceOrUrl) {
|
|
|
73
73
|
/**
|
|
74
74
|
* Removes a key from Redis.
|
|
75
75
|
*
|
|
76
|
-
* @param {string} key - The Redis key to delete
|
|
76
|
+
* @param {string} key - The Redis key to delete
|
|
77
77
|
*
|
|
78
78
|
* @returns {Promise<boolean>} A Promise that resolves to `true` if the key was removed,
|
|
79
79
|
* or `false` if it did not exist.
|
|
@@ -82,16 +82,16 @@ function createEnhancedRedisStorage(ioRedisInstanceOrUrl) {
|
|
|
82
82
|
/**
|
|
83
83
|
* Stores a value in Redis without expiration.
|
|
84
84
|
*
|
|
85
|
-
* @param {string} key - The Redis key
|
|
86
|
-
* @param {any} value - The value to store. Will be serialized
|
|
85
|
+
* @param {string} key - The Redis key
|
|
86
|
+
* @param {any} value - The value to store. Will be serialized
|
|
87
87
|
*/
|
|
88
88
|
setItem: (key, value) => instance.set(key, encodeToStorageValue(value)),
|
|
89
89
|
/**
|
|
90
90
|
* Stores a value in Redis with a time-to-live (TTL).
|
|
91
91
|
*
|
|
92
|
-
* @param {string} key - The Redis key
|
|
93
|
-
* @param {number} seconds - Expiration time in seconds
|
|
94
|
-
* @param {any} value - The value to store. Will be serialized
|
|
92
|
+
* @param {string} key - The Redis key
|
|
93
|
+
* @param {number} seconds - Expiration time in seconds
|
|
94
|
+
* @param {any} value - The value to store. Will be serialized
|
|
95
95
|
*/
|
|
96
96
|
setItemWithTtl(key, seconds, value) {
|
|
97
97
|
return instance.setex(key, seconds, encodeToStorageValue(value));
|
|
@@ -110,11 +110,11 @@ function decodeStorageValue(data) {
|
|
|
110
110
|
return deserialize(JSON.parse(payload.toString()));
|
|
111
111
|
}
|
|
112
112
|
catch {
|
|
113
|
-
throw new Error('[RedisStorage] Failed to parse JSON payload
|
|
113
|
+
throw new Error('[RedisStorage] Failed to parse JSON payload');
|
|
114
114
|
}
|
|
115
115
|
case StorageValueEncodingType.String: return payload.toString();
|
|
116
116
|
default:
|
|
117
|
-
throw new Error(`[RedisStorage] Unknown encoding type: ${type}
|
|
117
|
+
throw new Error(`[RedisStorage] Unknown encoding type: ${type}`);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
function encodeToStorageValue(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.mjs","sources":["../../../../src/storage/enhanced/redis/core.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\nimport { Redis } from 'ioredis';\nimport {\n deserialize,\n serialize,\n} from 'superjson';\n\nenum StorageValueEncodingType {\n Buffer = 0,\n Json = 1,\n String = 2,\n}\n\nconst customValueHeader = Buffer.of(\n 0xE2,\n 0x81,\n 0xA0,\n);\n\nconst customValueHeaderLength = customValueHeader.byteLength + 1;\n\n/**\n * Creates an enhanced Redis-based storage interface using SuperJSON encoding.\n *\n * This utility provides a typed, serializable key-value store backed by Redis,\n * supporting TTL operations and safe deserialization of complex types (e.g. Date, Map).\n *\n * @param {Redis | string} ioRedisInstanceOrUrl - Either an existing `ioredis` instance or a Redis connection string
|
|
1
|
+
{"version":3,"file":"core.mjs","sources":["../../../../src/storage/enhanced/redis/core.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\nimport { Redis } from 'ioredis';\nimport {\n deserialize,\n serialize,\n} from 'superjson';\n\nenum StorageValueEncodingType {\n Buffer = 0,\n Json = 1,\n String = 2,\n}\n\nconst customValueHeader = Buffer.of(\n 0xE2,\n 0x81,\n 0xA0,\n);\n\nconst customValueHeaderLength = customValueHeader.byteLength + 1;\n\n/**\n * Creates an enhanced Redis-based storage interface using SuperJSON encoding.\n *\n * This utility provides a typed, serializable key-value store backed by Redis,\n * supporting TTL operations and safe deserialization of complex types (e.g. Date, Map).\n *\n * @param {Redis | string} ioRedisInstanceOrUrl - Either an existing `ioredis` instance or a Redis connection string\n *\n * @returns A frozen object that wraps Redis commands with typed get/set logic and encoding\n *\n * @example\n * ```typescript\n * import { createEnhancedRedisStorage } from '@kikiutils/shared/storage/enhanced/redis';\n *\n * const redisStorage = createEnhancedRedisStorage('redis://localhost');\n * await redisStorage.setItem('user:1', { name: 'user' });\n * const user = await redisStorage.getItem<{ name: string }>('user:1');\n * ```\n */\nexport function createEnhancedRedisStorage(ioRedisInstanceOrUrl: Redis | string) {\n const instance = ioRedisInstanceOrUrl instanceof Redis ? ioRedisInstanceOrUrl : new Redis(ioRedisInstanceOrUrl);\n return Object.freeze({\n /**\n * Retrieves a value from Redis and decodes it.\n *\n * @template T - The expected return type\n *\n * @param {string} key - The Redis key\n *\n * @returns {Promise<null | T>} The decoded value or null if not found\n */\n async getItem<T = unknown>(key: string) {\n const rawValue = await instance.getBuffer(key);\n return rawValue ? decodeStorageValue(rawValue) as T : null;\n },\n /**\n * Gets the remaining TTL (in seconds) for a given key.\n *\n * @param {string} key - The Redis key\n *\n * @returns {Promise<number>} The number of seconds until the key expires, or -1 if no expiration is set\n */\n getItemTtl: (key: string) => instance.ttl(key),\n /**\n * Checks whether a key exists in Redis.\n *\n * @param {string} key - The Redis key\n *\n * @returns {Promise<boolean>} True if the key exists, false otherwise\n */\n hasItem: async (key: string) => await instance.exists(key) === 1,\n /**\n * The underlying Redis instance, exposed for advanced operations.\n * Use with caution; most use cases should rely on the wrapper methods.\n *\n * @returns {Redis} The underlying Redis instance\n */\n get instance() {\n return instance;\n },\n /**\n * Removes a key from Redis.\n *\n * @param {string} key - The Redis key to delete\n *\n * @returns {Promise<boolean>} A Promise that resolves to `true` if the key was removed,\n * or `false` if it did not exist.\n */\n removeItem: async (key: string) => await instance.del(key) === 1,\n /**\n * Stores a value in Redis without expiration.\n *\n * @param {string} key - The Redis key\n * @param {any} value - The value to store. Will be serialized\n */\n setItem: (key: string, value: any) => instance.set(key, encodeToStorageValue(value)),\n /**\n * Stores a value in Redis with a time-to-live (TTL).\n *\n * @param {string} key - The Redis key\n * @param {number} seconds - Expiration time in seconds\n * @param {any} value - The value to store. Will be serialized\n */\n setItemWithTtl(key: string, seconds: number, value: any) {\n return instance.setex(key, seconds, encodeToStorageValue(value));\n },\n });\n}\n\nfunction decodeStorageValue(data: Buffer) {\n if (!isCustomFormat(data)) return data;\n const payload = data.subarray(customValueHeaderLength);\n const type = data[customValueHeader.byteLength];\n switch (type) {\n case StorageValueEncodingType.Buffer: return payload;\n case StorageValueEncodingType.Json:\n try {\n return deserialize(JSON.parse(payload.toString()));\n } catch {\n throw new Error('[RedisStorage] Failed to parse JSON payload');\n }\n case StorageValueEncodingType.String: return payload.toString();\n default:\n throw new Error(`[RedisStorage] Unknown encoding type: ${type}`);\n }\n}\n\nfunction encodeToStorageValue(value: any) {\n if (Buffer.isBuffer(value)) return toCustomValue(StorageValueEncodingType.Buffer, value);\n if (typeof value === 'string') return toCustomValue(StorageValueEncodingType.String, Buffer.from(value));\n return toCustomValue(StorageValueEncodingType.Json, Buffer.from(JSON.stringify(serialize(value))));\n}\n\nfunction isCustomFormat(buffer: Buffer) {\n return (\n buffer.length >= customValueHeaderLength\n && buffer[0] === customValueHeader[0]\n && buffer[1] === customValueHeader[1]\n && buffer[2] === customValueHeader[2]\n );\n}\n\nfunction toCustomValue(type: StorageValueEncodingType, payload: Buffer) {\n return Buffer.concat([\n customValueHeader,\n Buffer.of(type),\n payload,\n ]);\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
* to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.
|
|
9
9
|
* It is ideal for namespaced data, caching, and session handling.
|
|
10
10
|
*
|
|
11
|
-
* @template D - The value type to store
|
|
11
|
+
* @template D - The value type to store
|
|
12
12
|
*
|
|
13
|
-
* @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance
|
|
13
|
+
* @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance
|
|
14
14
|
*
|
|
15
|
-
* @returns A factory that accepts a key generator function and returns a scoped Redis storage interface
|
|
15
|
+
* @returns A factory that accepts a key generator function and returns a scoped Redis storage interface
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
@@ -32,7 +32,7 @@ function createKeyedEnhancedRedisStore(storage) {
|
|
|
32
32
|
/**
|
|
33
33
|
* Resolves the storage key from the given arguments.
|
|
34
34
|
*
|
|
35
|
-
* @returns {string} The final string key used internally
|
|
35
|
+
* @returns {string} The final string key used internally
|
|
36
36
|
*/
|
|
37
37
|
resolveKey: (...args) => getKeyFunction(...args),
|
|
38
38
|
setItem: (value, ...args) => storage.setItem(getKeyFunction(...args), value),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyed-store.cjs","sources":["../../../../src/storage/enhanced/redis/keyed-store.ts"],"sourcesContent":["import type { createEnhancedRedisStorage } from './core';\n\n/**\n * Creates a reusable, type-safe Redis-backed storage interface based on `createEnhancedRedisStorage`\n * and a dynamic key-generation function.\n *\n * This utility abstracts away key construction and provides high-level access\n * to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.\n * It is ideal for namespaced data, caching, and session handling.\n *\n * @template D - The value type to store
|
|
1
|
+
{"version":3,"file":"keyed-store.cjs","sources":["../../../../src/storage/enhanced/redis/keyed-store.ts"],"sourcesContent":["import type { createEnhancedRedisStorage } from './core';\n\n/**\n * Creates a reusable, type-safe Redis-backed storage interface based on `createEnhancedRedisStorage`\n * and a dynamic key-generation function.\n *\n * This utility abstracts away key construction and provides high-level access\n * to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.\n * It is ideal for namespaced data, caching, and session handling.\n *\n * @template D - The value type to store\n *\n * @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance\n *\n * @returns A factory that accepts a key generator function and returns a scoped Redis storage interface\n *\n * @example\n * ```typescript\n * import { createKeyedEnhancedRedisStore } from '@kikiutils/shared/storage/enhanced/redis';\n *\n * const userStore = createKeyedEnhancedRedisStore<User>(redisStorage)((id: number) => `user:${id}`);\n * await userStore.setItem({ id: 123, name: 'user' }, 123);\n * const user = await userStore.getItem(123);\n * ```\n */\nexport function createKeyedEnhancedRedisStore<D = unknown>(storage: ReturnType<typeof createEnhancedRedisStorage>) {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n getItem: (...args: P) => storage.getItem<D>(getKeyFunction(...args)),\n getItemTtl: (...args: P) => storage.getItemTtl(getKeyFunction(...args)),\n hasItem: (...args: P) => storage.hasItem(getKeyFunction(...args)),\n removeItem: (...args: P) => storage.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) => storage.setItem(getKeyFunction(...args), value),\n setItemWithTtl(seconds: number, value: D, ...args: P) {\n return storage.setItemWithTtl(getKeyFunction(...args), seconds, value);\n },\n });\n}\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,6BAA6B,CAAc,OAAsD,EAAA;IAC7G,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAI,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACpE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE;;;;AAIG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;QACnD,OAAO,EAAE,CAAC,KAAQ,EAAE,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;AAClF,QAAA,cAAc,CAAC,OAAe,EAAE,KAAQ,EAAE,GAAG,IAAO,EAAA;AAChD,YAAA,OAAO,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC;QAC1E,CAAC;AACJ,KAAA,CAAC;AACN;;;;"}
|
|
@@ -7,11 +7,11 @@ import type { createEnhancedRedisStorage } from './core';
|
|
|
7
7
|
* to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.
|
|
8
8
|
* It is ideal for namespaced data, caching, and session handling.
|
|
9
9
|
*
|
|
10
|
-
* @template D - The value type to store
|
|
10
|
+
* @template D - The value type to store
|
|
11
11
|
*
|
|
12
|
-
* @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance
|
|
12
|
+
* @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance
|
|
13
13
|
*
|
|
14
|
-
* @returns A factory that accepts a key generator function and returns a scoped Redis storage interface
|
|
14
|
+
* @returns A factory that accepts a key generator function and returns a scoped Redis storage interface
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
@@ -30,7 +30,7 @@ export declare function createKeyedEnhancedRedisStore<D = unknown>(storage: Retu
|
|
|
30
30
|
/**
|
|
31
31
|
* Resolves the storage key from the given arguments.
|
|
32
32
|
*
|
|
33
|
-
* @returns {string} The final string key used internally
|
|
33
|
+
* @returns {string} The final string key used internally
|
|
34
34
|
*/
|
|
35
35
|
resolveKey: (...args: P) => string;
|
|
36
36
|
setItem: (value: D, ...args: P) => Promise<"OK">;
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.
|
|
7
7
|
* It is ideal for namespaced data, caching, and session handling.
|
|
8
8
|
*
|
|
9
|
-
* @template D - The value type to store
|
|
9
|
+
* @template D - The value type to store
|
|
10
10
|
*
|
|
11
|
-
* @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance
|
|
11
|
+
* @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance
|
|
12
12
|
*
|
|
13
|
-
* @returns A factory that accepts a key generator function and returns a scoped Redis storage interface
|
|
13
|
+
* @returns A factory that accepts a key generator function and returns a scoped Redis storage interface
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
|
@@ -30,7 +30,7 @@ function createKeyedEnhancedRedisStore(storage) {
|
|
|
30
30
|
/**
|
|
31
31
|
* Resolves the storage key from the given arguments.
|
|
32
32
|
*
|
|
33
|
-
* @returns {string} The final string key used internally
|
|
33
|
+
* @returns {string} The final string key used internally
|
|
34
34
|
*/
|
|
35
35
|
resolveKey: (...args) => getKeyFunction(...args),
|
|
36
36
|
setItem: (value, ...args) => storage.setItem(getKeyFunction(...args), value),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyed-store.mjs","sources":["../../../../src/storage/enhanced/redis/keyed-store.ts"],"sourcesContent":["import type { createEnhancedRedisStorage } from './core';\n\n/**\n * Creates a reusable, type-safe Redis-backed storage interface based on `createEnhancedRedisStorage`\n * and a dynamic key-generation function.\n *\n * This utility abstracts away key construction and provides high-level access\n * to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.\n * It is ideal for namespaced data, caching, and session handling.\n *\n * @template D - The value type to store
|
|
1
|
+
{"version":3,"file":"keyed-store.mjs","sources":["../../../../src/storage/enhanced/redis/keyed-store.ts"],"sourcesContent":["import type { createEnhancedRedisStorage } from './core';\n\n/**\n * Creates a reusable, type-safe Redis-backed storage interface based on `createEnhancedRedisStorage`\n * and a dynamic key-generation function.\n *\n * This utility abstracts away key construction and provides high-level access\n * to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.\n * It is ideal for namespaced data, caching, and session handling.\n *\n * @template D - The value type to store\n *\n * @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance\n *\n * @returns A factory that accepts a key generator function and returns a scoped Redis storage interface\n *\n * @example\n * ```typescript\n * import { createKeyedEnhancedRedisStore } from '@kikiutils/shared/storage/enhanced/redis';\n *\n * const userStore = createKeyedEnhancedRedisStore<User>(redisStorage)((id: number) => `user:${id}`);\n * await userStore.setItem({ id: 123, name: 'user' }, 123);\n * const user = await userStore.getItem(123);\n * ```\n */\nexport function createKeyedEnhancedRedisStore<D = unknown>(storage: ReturnType<typeof createEnhancedRedisStorage>) {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n getItem: (...args: P) => storage.getItem<D>(getKeyFunction(...args)),\n getItemTtl: (...args: P) => storage.getItemTtl(getKeyFunction(...args)),\n hasItem: (...args: P) => storage.hasItem(getKeyFunction(...args)),\n removeItem: (...args: P) => storage.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) => storage.setItem(getKeyFunction(...args), value),\n setItemWithTtl(seconds: number, value: D, ...args: P) {\n return storage.setItemWithTtl(getKeyFunction(...args), seconds, value);\n },\n });\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,6BAA6B,CAAc,OAAsD,EAAA;IAC7G,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAI,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACpE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE;;;;AAIG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;QACnD,OAAO,EAAE,CAAC,KAAQ,EAAE,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;AAClF,QAAA,cAAc,CAAC,OAAe,EAAE,KAAQ,EAAE,GAAG,IAAO,EAAA;AAChD,YAAA,OAAO,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC;QAC1E,CAAC;AACJ,KAAA,CAAC;AACN;;;;"}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
* This utility allows structured access to cache entries using a dynamic key-generation function.
|
|
7
7
|
*
|
|
8
|
-
* @template D - The specific value type exposed by this store (must extend `V`)
|
|
8
|
+
* @template D - The specific value type exposed by this store (must extend `V`)
|
|
9
9
|
*
|
|
10
|
-
* @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache
|
|
10
|
+
* @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`
|
|
11
11
|
*
|
|
12
|
-
* @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store
|
|
12
|
+
* @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyed-store.cjs","sources":["../../../src/storage/lru/keyed-store.ts"],"sourcesContent":["import type { LRUCache } from 'lru-cache';\n\n/**\n * Creates a reusable, type-safe keyed store wrapper for an LRUCache instance.\n *\n * This utility allows structured access to cache entries using a dynamic key-generation function.\n *\n * @template D - The specific value type exposed by this store (must extend `V`)
|
|
1
|
+
{"version":3,"file":"keyed-store.cjs","sources":["../../../src/storage/lru/keyed-store.ts"],"sourcesContent":["import type { LRUCache } from 'lru-cache';\n\n/**\n * Creates a reusable, type-safe keyed store wrapper for an LRUCache instance.\n *\n * This utility allows structured access to cache entries using a dynamic key-generation function.\n *\n * @template D - The specific value type exposed by this store (must extend `V`)\n *\n * @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`\n *\n * @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store\n *\n * @example\n * ```typescript\n * import { createKeyedLruStore } from '@kikiutils/shared/storage/lru/keyed-store';\n *\n * const lruCache = new LRUCache({ max: 5000 });\n * const userStore = createKeyedLruStore<User>(lruCache)((id: number) => `user:${id}`);\n * userStore.setItem({ id: 1 }, 1);\n * const user = userStore.getItem(1);\n * ```\n */\nexport function createKeyedLruStore<D = unknown>(lruInstance: LRUCache<any, any, any>) {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n /**\n * Return a value from the cache. Will update the recency of the cache entry found.\n *\n * If the key is not found, returns `null`.\n */\n getItem(...args: P) {\n const rawValue = lruInstance.get(getKeyFunction(...args));\n return rawValue as D ?? null;\n },\n getItemTtl: (...args: P) => lruInstance.getRemainingTTL(getKeyFunction(...args)),\n hasItem: (...args: P) => lruInstance.has(getKeyFunction(...args)),\n removeItem: (...args: P) => lruInstance.delete(getKeyFunction(...args)),\n /**\n * Resolves the full cache key from the given arguments.\n */\n resolveKey: (...args: P) => getKeyFunction(...args),\n setItem(value: D, ...args: P) {\n lruInstance.set(getKeyFunction(...args), value);\n },\n });\n}\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAc,WAAoC,EAAA;IACjF,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E;;;;AAIG;QACH,OAAO,CAAC,GAAG,IAAO,EAAA;AACd,YAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;YACzD,OAAO,QAAa,IAAI,IAAI;QAChC,CAAC;AACD,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AAChF,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE;;AAEG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;AACnD,QAAA,OAAO,CAAC,KAAQ,EAAE,GAAG,IAAO,EAAA;YACxB,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;QACnD,CAAC;AACJ,KAAA,CAAC;AACN;;;;"}
|
|
@@ -4,11 +4,11 @@ import type { LRUCache } from 'lru-cache';
|
|
|
4
4
|
*
|
|
5
5
|
* This utility allows structured access to cache entries using a dynamic key-generation function.
|
|
6
6
|
*
|
|
7
|
-
* @template D - The specific value type exposed by this store (must extend `V`)
|
|
7
|
+
* @template D - The specific value type exposed by this store (must extend `V`)
|
|
8
8
|
*
|
|
9
|
-
* @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache
|
|
9
|
+
* @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`
|
|
10
10
|
*
|
|
11
|
-
* @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store
|
|
11
|
+
* @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This utility allows structured access to cache entries using a dynamic key-generation function.
|
|
5
5
|
*
|
|
6
|
-
* @template D - The specific value type exposed by this store (must extend `V`)
|
|
6
|
+
* @template D - The specific value type exposed by this store (must extend `V`)
|
|
7
7
|
*
|
|
8
|
-
* @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache
|
|
8
|
+
* @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`
|
|
9
9
|
*
|
|
10
|
-
* @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store
|
|
10
|
+
* @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyed-store.mjs","sources":["../../../src/storage/lru/keyed-store.ts"],"sourcesContent":["import type { LRUCache } from 'lru-cache';\n\n/**\n * Creates a reusable, type-safe keyed store wrapper for an LRUCache instance.\n *\n * This utility allows structured access to cache entries using a dynamic key-generation function.\n *\n * @template D - The specific value type exposed by this store (must extend `V`)
|
|
1
|
+
{"version":3,"file":"keyed-store.mjs","sources":["../../../src/storage/lru/keyed-store.ts"],"sourcesContent":["import type { LRUCache } from 'lru-cache';\n\n/**\n * Creates a reusable, type-safe keyed store wrapper for an LRUCache instance.\n *\n * This utility allows structured access to cache entries using a dynamic key-generation function.\n *\n * @template D - The specific value type exposed by this store (must extend `V`)\n *\n * @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`\n *\n * @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store\n *\n * @example\n * ```typescript\n * import { createKeyedLruStore } from '@kikiutils/shared/storage/lru/keyed-store';\n *\n * const lruCache = new LRUCache({ max: 5000 });\n * const userStore = createKeyedLruStore<User>(lruCache)((id: number) => `user:${id}`);\n * userStore.setItem({ id: 1 }, 1);\n * const user = userStore.getItem(1);\n * ```\n */\nexport function createKeyedLruStore<D = unknown>(lruInstance: LRUCache<any, any, any>) {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n /**\n * Return a value from the cache. Will update the recency of the cache entry found.\n *\n * If the key is not found, returns `null`.\n */\n getItem(...args: P) {\n const rawValue = lruInstance.get(getKeyFunction(...args));\n return rawValue as D ?? null;\n },\n getItemTtl: (...args: P) => lruInstance.getRemainingTTL(getKeyFunction(...args)),\n hasItem: (...args: P) => lruInstance.has(getKeyFunction(...args)),\n removeItem: (...args: P) => lruInstance.delete(getKeyFunction(...args)),\n /**\n * Resolves the full cache key from the given arguments.\n */\n resolveKey: (...args: P) => getKeyFunction(...args),\n setItem(value: D, ...args: P) {\n lruInstance.set(getKeyFunction(...args), value);\n },\n });\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAc,WAAoC,EAAA;IACjF,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E;;;;AAIG;QACH,OAAO,CAAC,GAAG,IAAO,EAAA;AACd,YAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;YACzD,OAAO,QAAa,IAAI,IAAI;QAChC,CAAC;AACD,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AAChF,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE;;AAEG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;AACnD,QAAA,OAAO,CAAC,KAAQ,EAAE,GAAG,IAAO,EAAA;YACxB,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;QACnD,CAAC;AACJ,KAAA,CAAC;AACN;;;;"}
|
package/dist/string.cjs
CHANGED
|
@@ -15,12 +15,12 @@ const CHARSETS = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Generates a random string of a given length using a specified character set.
|
|
17
17
|
*
|
|
18
|
-
* @param {number} length - The length of the string to generate. Must be a positive integer
|
|
19
|
-
* @param {RandomStringMode} [mode] - The character set to use
|
|
18
|
+
* @param {number} length - The length of the string to generate. Must be a positive integer
|
|
19
|
+
* @param {RandomStringMode} [mode] - The character set to use
|
|
20
20
|
*
|
|
21
|
-
* @returns {string} The generated random string
|
|
21
|
+
* @returns {string} The generated random string
|
|
22
22
|
*
|
|
23
|
-
* @throws {Error} If the length is not a positive integer or the mode is unsupported
|
|
23
|
+
* @throws {Error} If the length is not a positive integer or the mode is unsupported
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```typescript
|
|
@@ -33,7 +33,7 @@ const CHARSETS = {
|
|
|
33
33
|
*/
|
|
34
34
|
function randomString(length, mode = 'alphabetic') {
|
|
35
35
|
if (!Number.isInteger(length) || length <= 0) {
|
|
36
|
-
throw new Error(`Invalid length: ${length}. Must be a positive integer
|
|
36
|
+
throw new Error(`Invalid length: ${length}. Must be a positive integer`);
|
|
37
37
|
}
|
|
38
38
|
const charset = CHARSETS[mode];
|
|
39
39
|
if (!charset)
|
package/dist/string.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.cjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer
|
|
1
|
+
{"version":3,"file":"string.cjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer\n * @param {RandomStringMode} [mode] - The character set to use\n *\n * @returns {string} The generated random string\n *\n * @throws {Error} If the length is not a positive integer or the mode is unsupported\n *\n * @example\n * ```typescript\n * import { randomString } from '@kikiutils/shared/string';\n *\n * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)\n * console.log(randomString(6, 'numeric')); // e.g. '402398'\n * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'\n * ```\n */\nexport function randomString(length: number, mode: RandomStringMode = 'alphabetic') {\n if (!Number.isInteger(length) || length <= 0) {\n throw new Error(`Invalid length: ${length}. Must be a positive integer`);\n }\n\n const charset = CHARSETS[mode];\n if (!charset) throw new Error(`Unsupported mode: ${mode}`);\n return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');\n}\n"],"names":[],"mappings":";;AASA,MAAM,MAAM,GAAG,YAAY;AAC3B,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,QAAQ,GAAqC;IAC/C,YAAY,EAAE,SAAS,GAAG,SAAS;AACnC,IAAA,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;AAC9C,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;AACvC,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;CAC1C;AAED;;;;;;;;;;;;;;;;;;AAkBG;SACa,YAAY,CAAC,MAAc,EAAE,OAAyB,YAAY,EAAA;AAC9E,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAA,4BAAA,CAA8B,CAAC;IAC5E;AAEA,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC9B,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAA,CAAE,CAAC;AAC1D,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACrG;;;;"}
|
package/dist/string.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ export type RandomStringMode = 'alphabetic' | 'alphanumeric' | 'lowercase' | 'lo
|
|
|
2
2
|
/**
|
|
3
3
|
* Generates a random string of a given length using a specified character set.
|
|
4
4
|
*
|
|
5
|
-
* @param {number} length - The length of the string to generate. Must be a positive integer
|
|
6
|
-
* @param {RandomStringMode} [mode] - The character set to use
|
|
5
|
+
* @param {number} length - The length of the string to generate. Must be a positive integer
|
|
6
|
+
* @param {RandomStringMode} [mode] - The character set to use
|
|
7
7
|
*
|
|
8
|
-
* @returns {string} The generated random string
|
|
8
|
+
* @returns {string} The generated random string
|
|
9
9
|
*
|
|
10
|
-
* @throws {Error} If the length is not a positive integer or the mode is unsupported
|
|
10
|
+
* @throws {Error} If the length is not a positive integer or the mode is unsupported
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
package/dist/string.mjs
CHANGED
|
@@ -13,12 +13,12 @@ const CHARSETS = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Generates a random string of a given length using a specified character set.
|
|
15
15
|
*
|
|
16
|
-
* @param {number} length - The length of the string to generate. Must be a positive integer
|
|
17
|
-
* @param {RandomStringMode} [mode] - The character set to use
|
|
16
|
+
* @param {number} length - The length of the string to generate. Must be a positive integer
|
|
17
|
+
* @param {RandomStringMode} [mode] - The character set to use
|
|
18
18
|
*
|
|
19
|
-
* @returns {string} The generated random string
|
|
19
|
+
* @returns {string} The generated random string
|
|
20
20
|
*
|
|
21
|
-
* @throws {Error} If the length is not a positive integer or the mode is unsupported
|
|
21
|
+
* @throws {Error} If the length is not a positive integer or the mode is unsupported
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
@@ -31,7 +31,7 @@ const CHARSETS = {
|
|
|
31
31
|
*/
|
|
32
32
|
function randomString(length, mode = 'alphabetic') {
|
|
33
33
|
if (!Number.isInteger(length) || length <= 0) {
|
|
34
|
-
throw new Error(`Invalid length: ${length}. Must be a positive integer
|
|
34
|
+
throw new Error(`Invalid length: ${length}. Must be a positive integer`);
|
|
35
35
|
}
|
|
36
36
|
const charset = CHARSETS[mode];
|
|
37
37
|
if (!charset)
|
package/dist/string.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.mjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer
|
|
1
|
+
{"version":3,"file":"string.mjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer\n * @param {RandomStringMode} [mode] - The character set to use\n *\n * @returns {string} The generated random string\n *\n * @throws {Error} If the length is not a positive integer or the mode is unsupported\n *\n * @example\n * ```typescript\n * import { randomString } from '@kikiutils/shared/string';\n *\n * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)\n * console.log(randomString(6, 'numeric')); // e.g. '402398'\n * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'\n * ```\n */\nexport function randomString(length: number, mode: RandomStringMode = 'alphabetic') {\n if (!Number.isInteger(length) || length <= 0) {\n throw new Error(`Invalid length: ${length}. Must be a positive integer`);\n }\n\n const charset = CHARSETS[mode];\n if (!charset) throw new Error(`Unsupported mode: ${mode}`);\n return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');\n}\n"],"names":[],"mappings":"AASA,MAAM,MAAM,GAAG,YAAY;AAC3B,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,QAAQ,GAAqC;IAC/C,YAAY,EAAE,SAAS,GAAG,SAAS;AACnC,IAAA,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;AAC9C,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;AACvC,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;CAC1C;AAED;;;;;;;;;;;;;;;;;;AAkBG;SACa,YAAY,CAAC,MAAc,EAAE,OAAyB,YAAY,EAAA;AAC9E,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAA,4BAAA,CAA8B,CAAC;IAC5E;AAEA,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC9B,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAA,CAAE,CAAC;AAC1D,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACrG;;;;"}
|
package/dist/url.cjs
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Typically used to preserve the user's current path for post-login navigation.
|
|
7
7
|
*
|
|
8
|
-
* @param {string} url - The target URL to modify
|
|
9
|
-
* @param {string} redirectPath - The path to use as the redirect destination
|
|
8
|
+
* @param {string} url - The target URL to modify
|
|
9
|
+
* @param {string} redirectPath - The path to use as the redirect destination
|
|
10
10
|
*
|
|
11
|
-
* @returns {string} A new URL string with the `redirect` query parameter
|
|
11
|
+
* @returns {string} A new URL string with the `redirect` query parameter
|
|
12
12
|
*/
|
|
13
13
|
function appendRedirectParamToUrl(url, redirectPath) {
|
|
14
14
|
const [base, rawQuery = ''] = url.split('?');
|
package/dist/url.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.cjs","sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param {string} url - The target URL to modify
|
|
1
|
+
{"version":3,"file":"url.cjs","sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param {string} url - The target URL to modify\n * @param {string} redirectPath - The path to use as the redirect destination\n *\n * @returns {string} A new URL string with the `redirect` query parameter\n */\nexport function appendRedirectParamToUrl(url: string, redirectPath: string) {\n const [base, rawQuery = ''] = url.split('?');\n const searchParams = new URLSearchParams(rawQuery);\n searchParams.set('redirect', redirectPath);\n return `${base}?${searchParams.toString()}`;\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;AASG;AACG,SAAU,wBAAwB,CAAC,GAAW,EAAE,YAAoB,EAAA;AACtE,IAAA,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,IAAA,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC;AAClD,IAAA,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1C,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,YAAY,CAAC,QAAQ,EAAE,EAAE;AAC/C;;;;"}
|
package/dist/url.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Typically used to preserve the user's current path for post-login navigation.
|
|
5
5
|
*
|
|
6
|
-
* @param {string} url - The target URL to modify
|
|
7
|
-
* @param {string} redirectPath - The path to use as the redirect destination
|
|
6
|
+
* @param {string} url - The target URL to modify
|
|
7
|
+
* @param {string} redirectPath - The path to use as the redirect destination
|
|
8
8
|
*
|
|
9
|
-
* @returns {string} A new URL string with the `redirect` query parameter
|
|
9
|
+
* @returns {string} A new URL string with the `redirect` query parameter
|
|
10
10
|
*/
|
|
11
11
|
export declare function appendRedirectParamToUrl(url: string, redirectPath: string): string;
|
|
12
12
|
//# sourceMappingURL=url.d.ts.map
|
package/dist/url.mjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Typically used to preserve the user's current path for post-login navigation.
|
|
5
5
|
*
|
|
6
|
-
* @param {string} url - The target URL to modify
|
|
7
|
-
* @param {string} redirectPath - The path to use as the redirect destination
|
|
6
|
+
* @param {string} url - The target URL to modify
|
|
7
|
+
* @param {string} redirectPath - The path to use as the redirect destination
|
|
8
8
|
*
|
|
9
|
-
* @returns {string} A new URL string with the `redirect` query parameter
|
|
9
|
+
* @returns {string} A new URL string with the `redirect` query parameter
|
|
10
10
|
*/
|
|
11
11
|
function appendRedirectParamToUrl(url, redirectPath) {
|
|
12
12
|
const [base, rawQuery = ''] = url.split('?');
|
package/dist/url.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.mjs","sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param {string} url - The target URL to modify
|
|
1
|
+
{"version":3,"file":"url.mjs","sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param {string} url - The target URL to modify\n * @param {string} redirectPath - The path to use as the redirect destination\n *\n * @returns {string} A new URL string with the `redirect` query parameter\n */\nexport function appendRedirectParamToUrl(url: string, redirectPath: string) {\n const [base, rawQuery = ''] = url.split('?');\n const searchParams = new URLSearchParams(rawQuery);\n searchParams.set('redirect', redirectPath);\n return `${base}?${searchParams.toString()}`;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AACG,SAAU,wBAAwB,CAAC,GAAW,EAAE,YAAoB,EAAA;AACtE,IAAA,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,IAAA,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC;AAClD,IAAA,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1C,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,YAAY,CAAC,QAAQ,EAAE,EAAE;AAC/C;;;;"}
|