@less-is-more/less-js 1.2.22 → 1.2.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@less-is-more/less-js",
3
- "version": "1.2.22",
3
+ "version": "1.2.23",
4
4
  "description": "Fast develop kit for nodejs",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/cache.js CHANGED
@@ -69,7 +69,7 @@ module.exports = class Cache {
69
69
  } else {
70
70
  console.log("Found cache", fullKey);
71
71
  // 优先转成json
72
- if (savedData.startsWith("{")) {
72
+ if (savedData.startsWith("{") || savedData.startsWith("[")) {
73
73
  return JSON.parse(savedData);
74
74
  } else {
75
75
  return savedData;
@@ -81,5 +81,16 @@ describe("cache.js", () => {
81
81
  const compare = { a: 1, b: 2 };
82
82
  assert(result.a === compare.a);
83
83
  });
84
+ it("return array", async () => {
85
+ async function test(a, b) {
86
+ return await Cache.auto("test4", 20, arguments, () => {
87
+ console.log(a, b);
88
+ return [{ a, b }];
89
+ });
90
+ }
91
+ const result = await test(1, 2);
92
+ console.log("result", JSON.stringify(result));
93
+ assert(result.length === 1);
94
+ });
84
95
  });
85
96
  });