@zenweb/cache 5.0.0 → 5.0.2

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 (2) hide show
  1. package/dist/utils.js +8 -2
  2. package/package.json +2 -2
package/dist/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { zenwebDebug } from '@zenweb/core';
2
- import * as crypto from 'node:crypto';
2
+ import crypto from 'node:crypto';
3
3
  export const debug = zenwebDebug('cache');
4
4
  /**
5
5
  * Promise 等待
@@ -40,7 +40,13 @@ export async function runRedisScript(redis, hash, script, keys, values = []) {
40
40
  */
41
41
  function plainify(obj) {
42
42
  if (Array.isArray(obj)) {
43
- return obj.map(plainify).sort().join(',');
43
+ return obj.map(plainify).join(',');
44
+ }
45
+ if (obj instanceof Date) {
46
+ return obj.toJSON();
47
+ }
48
+ if (Buffer.isBuffer(obj)) {
49
+ return obj.toString('utf-8');
44
50
  }
45
51
  if (obj && typeof obj === 'object') {
46
52
  return Object.keys(obj).sort().map(k => `${k}=${plainify(obj[k])}`).join('&');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zenweb/cache",
3
3
  "type": "module",
4
- "version": "5.0.0",
4
+ "version": "5.0.2",
5
5
  "description": "Zenweb Cache module",
6
6
  "exports": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "scripts": {
12
12
  "build": "rimraf dist && tsc",
13
13
  "prepack": "npm run build",
14
- "test": "mocha --loader ts-node/esm -p tsconfig.json test/**/*.test.ts",
14
+ "test": "mocha --loader=ts-node/esm test/**/*.test.ts",
15
15
  "dev": "cd example && cross-env DEBUG=\\* NODE_ENV=development node --loader ts-node/esm app.ts"
16
16
  },
17
17
  "author": {