@less-is-more/less-js 1.5.0-4 → 1.5.0-5

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/package.json +1 -1
  2. package/src/cache.js +10 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@less-is-more/less-js",
3
- "version": "1.5.0-4",
3
+ "version": "1.5.0-5",
4
4
  "description": "Fast develop kit for nodejs",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/cache.js CHANGED
@@ -43,7 +43,14 @@ module.exports = class Cache {
43
43
  * @param {boolean} useNas 是否使用Nas缓存
44
44
  * @returns 优先返回对象
45
45
  */
46
- static async auto(keyPrefix, timeSecond, args, fn, zip = false, useNas = false) {
46
+ static async auto(
47
+ keyPrefix,
48
+ timeSecond,
49
+ args,
50
+ fn,
51
+ zip = false,
52
+ useNas = false
53
+ ) {
47
54
  let fullKey = keyPrefix;
48
55
  for (let i = 0; i < args.length; i++) {
49
56
  fullKey += ":" + args[i].toString();
@@ -97,9 +104,9 @@ module.exports = class Cache {
97
104
  console.log("Found cache" + (hasLocal ? " local" : ""), fullKey);
98
105
  savedData = Cache._unzip(savedData);
99
106
  // 优先转成json
100
- if (savedData.startsWith("{") || savedData.startsWith("[")) {
107
+ try {
101
108
  return JSON.parse(savedData);
102
- } else {
109
+ } catch (e) {
103
110
  return savedData;
104
111
  }
105
112
  }