@nocobase/cache 0.13.0-alpha.4 → 0.13.0-alpha.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/lib/index.js +40 -44
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -1,66 +1,62 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var src_exports = {};
20
+ __export(src_exports, {
21
+ createCache: () => createCache,
22
+ createDefaultCacheConfig: () => createDefaultCacheConfig
5
23
  });
6
- exports.createCache = createCache;
7
- exports.createDefaultCacheConfig = createDefaultCacheConfig;
8
- function _cacheManager() {
9
- const data = require("cache-manager");
10
- _cacheManager = function _cacheManager() {
11
- return data;
12
- };
13
- return data;
14
- }
15
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
16
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18
- /**
19
- * create a default cache config object
20
- * @returns {ICacheConfig}
21
- */
24
+ module.exports = __toCommonJS(src_exports);
25
+ var import_cache_manager = require("cache-manager");
22
26
  function createDefaultCacheConfig() {
23
27
  return {
24
28
  ttl: 86400,
25
- max: 1000,
26
- store: 'memory'
29
+ // seconds
30
+ max: 1e3,
31
+ store: "memory"
27
32
  };
28
33
  }
29
- /**
30
- * create cache
31
- * <br/> if cacheConfig is array and length gt 1 then will be return multi cache, else will be return cache
32
- * @param {ICacheConfig | ICacheConfig[]} cacheConfig
33
- * @returns {Cache}
34
- */
34
+ __name(createDefaultCacheConfig, "createDefaultCacheConfig");
35
35
  function createCache(cacheConfig = createDefaultCacheConfig()) {
36
36
  if (Array.isArray(cacheConfig)) {
37
- // multi cache
38
37
  if (cacheConfig.length === 1) {
39
38
  return createCacheByICacheConfig(cacheConfig[0]);
40
39
  } else {
41
40
  const caches = [];
42
- var _iterator = _createForOfIteratorHelper(cacheConfig),
43
- _step;
44
- try {
45
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
46
- const cacheConfigEle = _step.value;
47
- caches.push(createCacheByICacheConfig(cacheConfigEle));
48
- }
49
- } catch (err) {
50
- _iterator.e(err);
51
- } finally {
52
- _iterator.f();
41
+ for (const cacheConfigEle of cacheConfig) {
42
+ caches.push(createCacheByICacheConfig(cacheConfigEle));
53
43
  }
54
- return (0, _cacheManager().multiCaching)(caches);
44
+ return (0, import_cache_manager.multiCaching)(caches);
55
45
  }
56
46
  } else {
57
47
  return createCacheByICacheConfig(cacheConfig);
58
48
  }
59
49
  }
50
+ __name(createCache, "createCache");
60
51
  function createCacheByICacheConfig(cacheConfig) {
61
- // if storePackage exist then load storePackage and instead store
62
52
  if (cacheConfig.storePackage) {
63
53
  cacheConfig.store = require(cacheConfig.storePackage);
64
54
  }
65
- return (0, _cacheManager().caching)(cacheConfig);
66
- }
55
+ return (0, import_cache_manager.caching)(cacheConfig);
56
+ }
57
+ __name(createCacheByICacheConfig, "createCacheByICacheConfig");
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ createCache,
61
+ createDefaultCacheConfig
62
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cache",
3
- "version": "0.13.0-alpha.4",
3
+ "version": "0.13.0-alpha.5",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
@@ -17,5 +17,5 @@
17
17
  "url": "git+https://github.com/nocobase/nocobase.git",
18
18
  "directory": "packages/cache"
19
19
  },
20
- "gitHead": "29594e9dbb2455e2f3f6bea95340c4ed75789b61"
20
+ "gitHead": "9eabe607b4a20c356fdb2fd95e40fa476986dcb0"
21
21
  }