@less-is-more/less-js 1.5.1-3 → 1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cache.js +16 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@less-is-more/less-js",
3
- "version": "1.5.1-3",
3
+ "version": "1.5.2-1",
4
4
  "description": "Fast develop kit for nodejs",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/cache.js CHANGED
@@ -4,6 +4,15 @@ const zlib = require("zlib");
4
4
  const Nas = require("./nas");
5
5
 
6
6
  module.exports = class Cache {
7
+ static printLog = true;
8
+
9
+ /*
10
+ * 设置是否打印日志
11
+ * @param {boolean} printLog
12
+ */
13
+ static setPrintLog(printLog) {
14
+ Cache.printLog = printLog;
15
+ }
7
16
  /**
8
17
  * 缓存并获取结果(调用方)
9
18
  * @param {*} key 缓存关键词,拼接参数
@@ -28,7 +37,9 @@ module.exports = class Cache {
28
37
  }
29
38
  }
30
39
  } else {
31
- console.log("Found cache", fullKey);
40
+ if (Cache.printLog) {
41
+ console.log("Found cache", fullKey);
42
+ }
32
43
  return savedData;
33
44
  }
34
45
  }
@@ -49,7 +60,7 @@ module.exports = class Cache {
49
60
  args,
50
61
  fn,
51
62
  zip = false,
52
- useNas = false
63
+ useNas = false,
53
64
  ) {
54
65
  let fullKey = keyPrefix;
55
66
  for (let i = 0; i < args.length; i++) {
@@ -101,7 +112,9 @@ module.exports = class Cache {
101
112
  return result;
102
113
  }
103
114
  } else {
104
- console.log("Found cache" + (hasLocal ? " local" : ""), fullKey);
115
+ if (Cache.printLog) {
116
+ console.log("Found cache" + (hasLocal ? " local" : ""), fullKey);
117
+ }
105
118
  savedData = Cache._unzip(savedData);
106
119
  if (typeof savedData === "string") {
107
120
  // 优先转成json