@vope/utils 1.4.0 → 1.4.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.
package/cjs/index.js CHANGED
@@ -1,52 +1,78 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
4
11
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.wait = exports.connectURLParams = exports.joinPaths = exports.Union = exports.rotateRad = exports.rotateAngle = exports.deconPowersSum = exports.once = exports.MemoryPower = exports.MemoryList = exports.MemoryBasic = exports.isNull = exports.isEmpty = exports.isClass = exports.inputRegex = exports.getEncoding = exports.hash8strings = exports.hash8object = exports.hash8json = exports.deepWeakEqual = exports.compareVersion = exports.classnames = exports.clamp = void 0;
7
- var clamp_1 = require("./clamp");
8
- Object.defineProperty(exports, "clamp", { enumerable: true, get: function () { return __importDefault(clamp_1).default; } });
9
- var classnames_1 = require("./classnames");
10
- Object.defineProperty(exports, "classnames", { enumerable: true, get: function () { return __importDefault(classnames_1).default; } });
11
- var version_1 = require("./compare/version");
12
- Object.defineProperty(exports, "compareVersion", { enumerable: true, get: function () { return __importDefault(version_1).default; } });
13
- var weak_equal_1 = require("./compare/weak-equal");
14
- Object.defineProperty(exports, "deepWeakEqual", { enumerable: true, get: function () { return __importDefault(weak_equal_1).default; } });
15
- var json_1 = require("./convert/json");
16
- Object.defineProperty(exports, "hash8json", { enumerable: true, get: function () { return __importDefault(json_1).default; } });
17
- var object_1 = require("./convert/object");
18
- Object.defineProperty(exports, "hash8object", { enumerable: true, get: function () { return __importDefault(object_1).default; } });
19
- var strings_1 = require("./convert/strings");
20
- Object.defineProperty(exports, "hash8strings", { enumerable: true, get: function () { return __importDefault(strings_1).default; } });
21
- var encoding_1 = require("./encoding");
22
- Object.defineProperty(exports, "getEncoding", { enumerable: true, get: function () { return __importDefault(encoding_1).default; } });
23
- var input_regex_1 = require("./input-regex");
24
- Object.defineProperty(exports, "inputRegex", { enumerable: true, get: function () { return __importDefault(input_regex_1).default; } });
25
- var class_1 = require("./is/class");
26
- Object.defineProperty(exports, "isClass", { enumerable: true, get: function () { return __importDefault(class_1).default; } });
27
- var empty_1 = require("./is/empty");
28
- Object.defineProperty(exports, "isEmpty", { enumerable: true, get: function () { return __importDefault(empty_1).default; } });
29
- var null_1 = require("./is/null");
30
- Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return __importDefault(null_1).default; } });
31
- var basic_1 = require("./memory/basic");
32
- Object.defineProperty(exports, "MemoryBasic", { enumerable: true, get: function () { return __importDefault(basic_1).default; } });
33
- var list_1 = require("./memory/list");
34
- Object.defineProperty(exports, "MemoryList", { enumerable: true, get: function () { return __importDefault(list_1).default; } });
35
- var power_1 = require("./memory/power");
36
- Object.defineProperty(exports, "MemoryPower", { enumerable: true, get: function () { return __importDefault(power_1).default; } });
37
- var once_1 = require("./once");
38
- Object.defineProperty(exports, "once", { enumerable: true, get: function () { return __importDefault(once_1).default; } });
39
- var decon_1 = require("./power/decon");
40
- Object.defineProperty(exports, "deconPowersSum", { enumerable: true, get: function () { return __importDefault(decon_1).default; } });
41
- var angle_1 = require("./rotate/angle");
42
- Object.defineProperty(exports, "rotateAngle", { enumerable: true, get: function () { return __importDefault(angle_1).default; } });
43
- var rad_1 = require("./rotate/rad");
44
- Object.defineProperty(exports, "rotateRad", { enumerable: true, get: function () { return __importDefault(rad_1).default; } });
45
- var union_1 = require("./union");
46
- Object.defineProperty(exports, "Union", { enumerable: true, get: function () { return __importDefault(union_1).default; } });
47
- var join_1 = require("./url/join");
48
- Object.defineProperty(exports, "joinPaths", { enumerable: true, get: function () { return __importDefault(join_1).default; } });
49
- var params_1 = require("./url/params");
50
- Object.defineProperty(exports, "connectURLParams", { enumerable: true, get: function () { return __importDefault(params_1).default; } });
51
- var wait_1 = require("./wait");
52
- Object.defineProperty(exports, "wait", { enumerable: true, get: function () { return __importDefault(wait_1).default; } });
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ MemoryBasic: () => import_basic.default,
32
+ MemoryList: () => import_list.default,
33
+ MemoryPower: () => import_power.default,
34
+ Union: () => import_union.default,
35
+ clamp: () => import_clamp.default,
36
+ classnames: () => import_classnames.default,
37
+ compareVersion: () => import_version.default,
38
+ connectURLParams: () => import_params.default,
39
+ deconPowersSum: () => import_decon.default,
40
+ deepWeakEqual: () => import_weak_equal.default,
41
+ getEncoding: () => import_encoding.default,
42
+ hash8json: () => import_json.default,
43
+ hash8object: () => import_object.default,
44
+ hash8strings: () => import_strings.default,
45
+ inputRegex: () => import_input_regex.default,
46
+ isClass: () => import_class.default,
47
+ isEmpty: () => import_empty.default,
48
+ isNull: () => import_null.default,
49
+ joinPaths: () => import_join.default,
50
+ once: () => import_once.default,
51
+ rotateAngle: () => import_angle.default,
52
+ rotateRad: () => import_rad.default,
53
+ wait: () => import_wait.default
54
+ });
55
+ module.exports = __toCommonJS(src_exports);
56
+ var import_clamp = __toESM(require("./clamp"), 1);
57
+ var import_classnames = __toESM(require("./classnames"), 1);
58
+ var import_version = __toESM(require("./compare/version"), 1);
59
+ var import_weak_equal = __toESM(require("./compare/weak-equal"), 1);
60
+ var import_json = __toESM(require("./convert/json"), 1);
61
+ var import_object = __toESM(require("./convert/object"), 1);
62
+ var import_strings = __toESM(require("./convert/strings"), 1);
63
+ var import_encoding = __toESM(require("./encoding"), 1);
64
+ var import_input_regex = __toESM(require("./input-regex"), 1);
65
+ var import_class = __toESM(require("./is/class"), 1);
66
+ var import_empty = __toESM(require("./is/empty"), 1);
67
+ var import_null = __toESM(require("./is/null"), 1);
68
+ var import_basic = __toESM(require("./memory/basic"), 1);
69
+ var import_list = __toESM(require("./memory/list"), 1);
70
+ var import_power = __toESM(require("./memory/power"), 1);
71
+ var import_once = __toESM(require("./once"), 1);
72
+ var import_decon = __toESM(require("./power/decon"), 1);
73
+ var import_angle = __toESM(require("./rotate/angle"), 1);
74
+ var import_rad = __toESM(require("./rotate/rad"), 1);
75
+ var import_union = __toESM(require("./union"), 1);
76
+ var import_join = __toESM(require("./url/join"), 1);
77
+ var import_params = __toESM(require("./url/params"), 1);
78
+ var import_wait = __toESM(require("./wait"), 1);
@@ -1,10 +1,29 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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 input_regex_exports = {};
20
+ __export(input_regex_exports, {
21
+ default: () => input_regex_default
22
+ });
23
+ module.exports = __toCommonJS(input_regex_exports);
3
24
  const RE_REGEX = /[$()*+.[?\\^{|]/g;
4
25
  const RE_STRING = /[$()*+.[?\\^{|-]/g;
5
26
  function inputRegex(text, flags) {
6
- return flags === false
7
- ? text.replace(RE_STRING, ($0) => '\\' + $0)
8
- : new RegExp(text.replace(RE_REGEX, ($0) => '\\' + $0), flags);
27
+ return flags === false ? text.replace(RE_STRING, ($0) => "\\" + $0) : new RegExp(text.replace(RE_REGEX, ($0) => "\\" + $0), flags);
9
28
  }
10
- exports.default = inputRegex;
29
+ var input_regex_default = inputRegex;
package/cjs/is/class.js CHANGED
@@ -1,32 +1,49 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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 class_exports = {};
20
+ __export(class_exports, {
21
+ default: () => class_default
22
+ });
23
+ module.exports = __toCommonJS(class_exports);
3
24
  const re_anonymous = /^function\s+\(|^function\s+anonymous\(/;
4
25
  const re_function = /^function\s+[A-Z]/;
5
26
  const re_this = /\b\(this\b|\bthis[\.\[]\b/;
6
27
  const re_check = /classCallCheck\(this/;
7
28
  const re_default = /^function\sdefault_\d+\s*\(/;
8
- /**
9
- * 检测是否为class
10
- */
11
29
  const isClass = (value, strict = true) => {
12
- if (typeof value !== 'function')
13
- return false;
14
- const proto = value.prototype;
15
- if (!proto || proto.constructor !== value)
16
- return false;
17
- const str = value.toString();
18
- if (str.slice(0, 5) === 'class'
19
- || Object.getOwnPropertyNames(proto).length >= 2)
20
- return true;
21
- if (re_anonymous.test(str))
22
- return false;
23
- if (strict && re_function.test(str))
24
- return true;
25
- if (re_this.test(str)) {
26
- if (!strict || re_check.test(str))
27
- return true;
28
- return re_default.test(str);
29
- }
30
+ if (typeof value !== "function")
31
+ return false;
32
+ const proto = value.prototype;
33
+ if (!proto || proto.constructor !== value)
34
+ return false;
35
+ const str = value.toString();
36
+ if (str.slice(0, 5) === "class" || Object.getOwnPropertyNames(proto).length >= 2)
37
+ return true;
38
+ if (re_anonymous.test(str))
30
39
  return false;
40
+ if (strict && re_function.test(str))
41
+ return true;
42
+ if (re_this.test(str)) {
43
+ if (!strict || re_check.test(str))
44
+ return true;
45
+ return re_default.test(str);
46
+ }
47
+ return false;
31
48
  };
32
- exports.default = isClass;
49
+ var class_default = isClass;
package/cjs/is/empty.js CHANGED
@@ -1,12 +1,36 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
4
11
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const null_1 = __importDefault(require("./null"));
7
- /**
8
- * 检测是否为空(undefined/null/'')
9
- */
10
- const isEmpty = (value) => (0, null_1.default)(value)
11
- || value === '';
12
- exports.default = isEmpty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var empty_exports = {};
30
+ __export(empty_exports, {
31
+ default: () => empty_default
32
+ });
33
+ module.exports = __toCommonJS(empty_exports);
34
+ var import_null = __toESM(require("./null"), 1);
35
+ const isEmpty = (value) => (0, import_null.default)(value) || value === "";
36
+ var empty_default = isEmpty;
package/cjs/is/null.js CHANGED
@@ -1,8 +1,25 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * 检测是否无值(undefined/null)
5
- */
6
- const isNull = (value) => value === void 0
7
- || value === null;
8
- exports.default = isNull;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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 null_exports = {};
20
+ __export(null_exports, {
21
+ default: () => null_default
22
+ });
23
+ module.exports = __toCommonJS(null_exports);
24
+ const isNull = (value) => value === void 0 || value === null;
25
+ var null_default = isNull;
@@ -1,148 +1,168 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
4
11
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const strings_1 = __importDefault(require("../convert/strings"));
7
- /**
8
- * 分类存储(通过继承,可用于拓展存储方式)
9
- */
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var basic_exports = {};
30
+ __export(basic_exports, {
31
+ default: () => MemoryBasic
32
+ });
33
+ module.exports = __toCommonJS(basic_exports);
34
+ var import_strings = __toESM(require("../convert/strings"), 1);
10
35
  class MemoryBasic {
11
- key;
12
- #mount;
13
- #reflex;
14
- list = [];
15
- memorys = new Map();
16
- /**
17
- * 返回存储长度
18
- */
19
- get size() {
20
- return this.list.length;
21
- }
22
- /**
23
- * @param key 用于对数据进行分类的key
24
- * @param config
25
- */
26
- constructor(key, config) {
27
- this.key = key;
28
- this.#mount = config.mount;
29
- this.#reflex = config.reflex;
30
- }
31
- getType(data) {
32
- const { key } = this;
33
- return typeof key === 'function' ? key(data) : data[key];
34
- }
35
- push(...list) {
36
- const { memorys } = this;
37
- list.forEach((data) => {
38
- const type = this.getType(data);
39
- const memory = memorys.get(type);
40
- const index = this.list.push(data) - 1;
41
- const result = this.#mount(index, memory);
42
- memory === result || memorys.set(type, result);
43
- });
44
- return this;
45
- }
46
- /**
47
- * 遍历所有存储数据(按入栈顺序)
48
- */
49
- forEach(callback) {
50
- this.list.forEach(callback);
51
- return this;
52
- }
53
- /**
54
- * 遍历所有存储类型
55
- */
56
- forType(callback) {
57
- const { memorys, list } = this;
58
- for (const [type, memory] of memorys) {
59
- const caches = this.#reflex(memory).map((index) => list[index]);
60
- callback(caches, type);
61
- }
62
- return this;
63
- }
64
- /**
65
- * 检测存储是否包含某种类型
66
- */
67
- includes(type) {
68
- return this.memorys.has(type);
36
+ /**
37
+ * @param key 用于对数据进行分类的key
38
+ * @param config
39
+ */
40
+ constructor(key, config) {
41
+ this.key = key;
42
+ this.#mount = config.mount;
43
+ this.#reflex = config.reflex;
44
+ }
45
+ #mount;
46
+ #reflex;
47
+ list = [];
48
+ memorys = /* @__PURE__ */ new Map();
49
+ /**
50
+ * 返回存储长度
51
+ */
52
+ get size() {
53
+ return this.list.length;
54
+ }
55
+ getType(data) {
56
+ const { key } = this;
57
+ return typeof key === "function" ? key(data) : data[key];
58
+ }
59
+ push(...list) {
60
+ const { memorys } = this;
61
+ list.forEach((data) => {
62
+ const type = this.getType(data);
63
+ const memory = memorys.get(type);
64
+ const index = this.list.push(data) - 1;
65
+ const result = this.#mount(index, memory);
66
+ memory === result || memorys.set(type, result);
67
+ });
68
+ return this;
69
+ }
70
+ /**
71
+ * 遍历所有存储数据(按入栈顺序)
72
+ */
73
+ forEach(callback) {
74
+ this.list.forEach(callback);
75
+ return this;
76
+ }
77
+ /**
78
+ * 遍历所有存储类型
79
+ */
80
+ forType(callback) {
81
+ const { memorys, list } = this;
82
+ for (const [type, memory] of memorys) {
83
+ const caches = this.#reflex(memory).map((index) => list[index]);
84
+ callback(caches, type);
69
85
  }
70
- /**
71
- * 获取指定类型存储数据
72
- */
73
- get(type) {
74
- const memory = this.memorys.get(type);
75
- return memory === void 0
76
- ? null
77
- : this.#reflex(memory).map((count) => this.list[count]);
78
- }
79
- /**
80
- * 删除指定存储数据
81
- */
82
- delete(data) {
83
- const { memorys, list } = this;
84
- let index = -1;
85
- if (!list.some((value, i) => {
86
- if (data === value) {
87
- index = i;
88
- list.splice(index, 1);
89
- const type = this.getType(value);
90
- const memory = this.#reflex(memorys.get(type));
91
- if (memory.length === 1) {
92
- memorys.delete(type);
93
- }
94
- else {
95
- memory.some((count, j) => {
96
- if (count === i) {
97
- memory.splice(j, 1);
98
- return true;
99
- }
100
- });
101
- }
102
- return true;
103
- }
104
- }))
105
- return this;
106
- for (const [type, target] of memorys) {
107
- const memory = this.#reflex(target);
108
- memory.forEach((value, index) => {
109
- if (value >= index) {
110
- memory[index] = value - 1;
111
- }
112
- });
113
- if (memory !== target) {
114
- let reactor;
115
- memory.forEach((count) => {
116
- reactor = this.#mount(count, reactor);
117
- });
118
- memorys.set(type, reactor);
86
+ return this;
87
+ }
88
+ /**
89
+ * 检测存储是否包含某种类型
90
+ */
91
+ includes(type) {
92
+ return this.memorys.has(type);
93
+ }
94
+ /**
95
+ * 获取指定类型存储数据
96
+ */
97
+ get(type) {
98
+ const memory = this.memorys.get(type);
99
+ return memory === void 0 ? null : this.#reflex(memory).map((count) => this.list[count]);
100
+ }
101
+ /**
102
+ * 删除指定存储数据
103
+ */
104
+ delete(data) {
105
+ const { memorys, list } = this;
106
+ let index = -1;
107
+ if (!list.some((value, i) => {
108
+ if (data === value) {
109
+ index = i;
110
+ list.splice(index, 1);
111
+ const type = this.getType(value);
112
+ const memory = this.#reflex(memorys.get(type));
113
+ if (memory.length === 1) {
114
+ memorys.delete(type);
115
+ } else {
116
+ memory.some((count, j) => {
117
+ if (count === i) {
118
+ memory.splice(j, 1);
119
+ return true;
119
120
  }
121
+ });
120
122
  }
121
- return this;
122
- }
123
- /**
124
- * 删除指定类型存储数据
125
- */
126
- deleteType(type) {
127
- const { memorys, list } = this;
128
- if (!memorys.has(type))
129
- return this;
130
- const local = (0, strings_1.default)(this.#reflex(memorys.get(type)));
131
- const Memory = this.constructor;
132
- const imitator = new Memory(this.key);
133
- list.forEach((data, index) => {
134
- index in local || imitator.push(data);
123
+ return true;
124
+ }
125
+ }))
126
+ return this;
127
+ for (const [type, target] of memorys) {
128
+ const memory = this.#reflex(target);
129
+ memory.forEach((value, index2) => {
130
+ if (value >= index2) {
131
+ memory[index2] = value - 1;
132
+ }
133
+ });
134
+ if (memory !== target) {
135
+ let reactor;
136
+ memory.forEach((count) => {
137
+ reactor = this.#mount(count, reactor);
135
138
  });
136
- this.list = imitator.list;
137
- this.memorys = imitator.memorys;
138
- return this;
139
- }
140
- /**
141
- * 清理存储
142
- */
143
- clear() {
144
- this.list = [];
145
- this.memorys.clear();
139
+ memorys.set(type, reactor);
140
+ }
146
141
  }
142
+ return this;
143
+ }
144
+ /**
145
+ * 删除指定类型存储数据
146
+ */
147
+ deleteType(type) {
148
+ const { memorys, list } = this;
149
+ if (!memorys.has(type))
150
+ return this;
151
+ const local = (0, import_strings.default)(this.#reflex(memorys.get(type)));
152
+ const Memory2 = this.constructor;
153
+ const imitator = new Memory2(this.key);
154
+ list.forEach((data, index) => {
155
+ index in local || imitator.push(data);
156
+ });
157
+ this.list = imitator.list;
158
+ this.memorys = imitator.memorys;
159
+ return this;
160
+ }
161
+ /**
162
+ * 清理存储
163
+ */
164
+ clear() {
165
+ this.list = [];
166
+ this.memorys.clear();
167
+ }
147
168
  }
148
- exports.default = MemoryBasic;