@zenweb/cache 5.2.0 → 5.2.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/types.d.ts +1 -1
- package/dist/utils.js +8 -6
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -145,6 +145,6 @@ export interface LockGetOption extends GetOption, SetOption, LockOption {
|
|
|
145
145
|
*/
|
|
146
146
|
noWait?: boolean;
|
|
147
147
|
}
|
|
148
|
-
export type CacheKeyType = string | number | object;
|
|
148
|
+
export type CacheKeyType = string | number | object | undefined | null | boolean;
|
|
149
149
|
export type CacheHelperOption = Omit<LockGetOption, 'parse' | 'noWait'>;
|
|
150
150
|
export type CacheHelperKey<P extends CacheKeyType[]> = string | ((...param: P) => string | Promise<string>);
|
package/dist/utils.js
CHANGED
|
@@ -72,12 +72,14 @@ function plainifyOrHash(obj) {
|
|
|
72
72
|
*/
|
|
73
73
|
export function cacheKey(...key) {
|
|
74
74
|
return key.map(i => {
|
|
75
|
-
if (
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
return '';
|
|
75
|
+
if (i === null)
|
|
76
|
+
return 'N';
|
|
77
|
+
switch (typeof i) {
|
|
78
|
+
case 'string': return i;
|
|
79
|
+
case 'number': return String(i);
|
|
80
|
+
case 'boolean': return i ? 'T' : 'F';
|
|
81
|
+
case 'undefined': return '';
|
|
82
|
+
}
|
|
81
83
|
if (i instanceof Date)
|
|
82
84
|
return i.toJSON();
|
|
83
85
|
return plainifyOrHash(i);
|