@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 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 (typeof i === 'string')
76
- return i;
77
- if (typeof i === 'number')
78
- return String(i);
79
- if (typeof i === 'undefined')
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);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zenweb/cache",
3
3
  "type": "module",
4
- "version": "5.2.0",
4
+ "version": "5.2.1",
5
5
  "description": "Zenweb Cache module",
6
6
  "exports": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",