@vope/utils 1.6.7 → 1.7.0

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/dist/index.cjs.js CHANGED
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  Union: () => Union,
37
37
  WeekLastUnit: () => WeekLastUnit,
38
38
  WildcardUnit: () => WildcardUnit,
39
+ asyncLock: () => async_lock_default,
39
40
  calc: () => calc_default,
40
41
  clamp: () => clamp,
41
42
  classnames: () => classnames,
@@ -61,11 +62,13 @@ __export(index_exports, {
61
62
  desensDecrypt: () => desensDecrypt,
62
63
  desensEncrypt: () => desensEncrypt,
63
64
  desensReplace: () => desensReplace,
65
+ disableEnumerable: () => disable_enumerable_default,
64
66
  flatURLParams: () => flatURLParams,
65
67
  getEncoding: () => getEncoding,
66
68
  hash8json: () => hash8json,
67
69
  hash8object: () => hash8object,
68
70
  hash8strings: () => hash8strings,
71
+ indexSort: () => index_sort_default,
69
72
  inputRegex: () => inputRegex,
70
73
  isAggUnit: () => isAggUnit,
71
74
  isCalc: () => isCalc,
@@ -89,19 +92,69 @@ __export(index_exports, {
89
92
  });
90
93
  module.exports = __toCommonJS(index_exports);
91
94
 
92
- // src/calc.ts
95
+ // src/async-lock.ts
93
96
  var import_lodash_es = require("lodash-es");
97
+ var isAccessor = (sp) => {
98
+ return sp !== void 0 && "value" in sp && (0, import_lodash_es.isBoolean)(sp.value);
99
+ };
100
+ var async_lock_default = (callback, {
101
+ validate: validate2,
102
+ sp = { value: false }
103
+ } = {}) => {
104
+ const isA = isAccessor(sp);
105
+ const getter = () => isA ? sp.value : sp.get();
106
+ const setter = (value) => isA ? sp.value = value : sp.set(value);
107
+ let lock = false;
108
+ let local;
109
+ return {
110
+ get spin() {
111
+ return getter();
112
+ },
113
+ async callback(...args) {
114
+ if (getter() || lock) return local;
115
+ setter(true);
116
+ local = callback(...args).then((result) => {
117
+ if ((0, import_lodash_es.isFunction)(validate2)) {
118
+ lock = validate2(result);
119
+ } else if (validate2 !== void 0) {
120
+ lock = validate2 === result;
121
+ }
122
+ return result;
123
+ });
124
+ await local;
125
+ setter(false);
126
+ return local;
127
+ },
128
+ unlock() {
129
+ lock = false;
130
+ }
131
+ };
132
+ };
133
+
134
+ // src/calc.ts
135
+ var import_lodash_es2 = require("lodash-es");
94
136
  var { parseFloat } = Number;
95
- var formatter = (value) => (0, import_lodash_es.isNumber)(value) ? value && `${value}px` : value;
96
- var isCalc = (value) => value.slice(0, 5) === "calc(" && value.slice(-1) === ")";
97
- var re_numerical = /^(-?(?:\.\d+|\d+(?:\.\d+)?))([a-zA-Z]+|%)$/;
137
+ var re_numerical = /^(-?(?:\.\d+|\d+(?:\.\d+)?)(?:e\d+)?)([a-zA-Z]+|%)$/;
98
138
  var re_zero = /^0[a-zA-Z]+$/;
139
+ var re_method_start = /[a-z]/i;
140
+ var re_method_next = /^\w*\(/;
141
+ var formatter = (value) => {
142
+ if ((0, import_lodash_es2.isNumber)(value)) {
143
+ return value && `${value}px`;
144
+ }
145
+ const matchs = value.match(re_numerical) || (isCalc(value) ? value.slice(5, -1).match(re_numerical) : null);
146
+ if (matchs) {
147
+ return matchs[1] === "0" ? 0 : matchs[1] + matchs[2];
148
+ }
149
+ return value;
150
+ };
151
+ var isCalc = (value) => value.slice(0, 5) === "calc(" && value.slice(-1) === ")";
99
152
  var Memory = class {
100
153
  data = {};
101
154
  memory = {};
102
155
  add(index, value, unit) {
103
156
  const { data, memory } = this;
104
- if (!(0, import_lodash_es.isNumber)(value)) {
157
+ if (!(0, import_lodash_es2.isNumber)(value)) {
105
158
  data[index] = { value };
106
159
  } else {
107
160
  const point = memory[unit];
@@ -119,7 +172,7 @@ var Manager = class {
119
172
  memory = new Memory();
120
173
  push(value, index) {
121
174
  const { memory } = this;
122
- if ((0, import_lodash_es.isNumber)(value)) return memory.add(index, value, "px");
175
+ if ((0, import_lodash_es2.isNumber)(value)) return memory.add(index, value, "px");
123
176
  const matchs = value.match(re_numerical);
124
177
  if (matchs) return memory.add(index, parseFloat(matchs[1]), matchs[2]);
125
178
  if (!isCalc(value)) return memory.add(index, value);
@@ -136,34 +189,93 @@ var calc = (...list) => {
136
189
  if (size === 1) return formatter(list[0]);
137
190
  const manager = new Manager();
138
191
  list.forEach((value2, index) => manager.push(value2, index));
192
+ let count = 0;
139
193
  const value = list.reduce((caches, _, index) => {
140
194
  const data = manager.at(index);
141
195
  if (!data || data.value === 0) return caches;
142
196
  const { value: value2, unit } = data;
143
197
  let tmp;
144
- if ((0, import_lodash_es.isNumber)(value2)) {
198
+ if ((0, import_lodash_es2.isNumber)(value2)) {
145
199
  tmp = value2 + unit;
146
200
  } else {
147
201
  tmp = value2;
148
202
  }
149
203
  if (!caches) return tmp;
204
+ count++;
150
205
  return tmp[0] === "-" ? `${caches} - ${tmp.slice(1)}` : `${caches} + ${tmp}`;
151
206
  }, "");
152
- return !value || re_zero.test(value) ? 0 : `calc(${value})`;
207
+ return !value ? 0 : count === 0 ? re_zero.test(value) ? 0 : value : `calc(${value})`;
208
+ };
209
+ var exp_max_method_name = null;
210
+ var isMethod = (value) => {
211
+ if (!re_method_start.test(value)) {
212
+ exp_max_method_name = null;
213
+ return false;
214
+ }
215
+ const matchs = value.slice(1).match(re_method_next);
216
+ if (!matchs || value.slice(-1) !== ")") {
217
+ exp_max_method_name = null;
218
+ return false;
219
+ }
220
+ const size = matchs[0].length;
221
+ let count = 0;
222
+ for (let i = size + 1; i < value.length - 1; i++) {
223
+ const c = value[i];
224
+ if (c === "(") {
225
+ count++;
226
+ } else if (c === ")" && count-- === 0) {
227
+ exp_max_method_name = null;
228
+ return false;
229
+ }
230
+ }
231
+ if (count === 0) {
232
+ exp_max_method_name = value.slice(0, size);
233
+ return true;
234
+ } else {
235
+ exp_max_method_name = null;
236
+ return false;
237
+ }
238
+ };
239
+ calc.getExpMN = (value) => {
240
+ isMethod(value);
241
+ return exp_max_method_name;
242
+ };
243
+ calc.multiply = (value, multiple) => {
244
+ if (value === 0 || multiple === 0) return 0;
245
+ if ((0, import_lodash_es2.isNumber)(value)) return `${value * multiple}px`;
246
+ if (multiple === 1) return value;
247
+ const tmp = formatter(value);
248
+ if (!tmp) return 0;
249
+ const matchs = tmp.match(re_numerical);
250
+ return matchs ? parseFloat(matchs[1]) * multiple + matchs[2] : isCalc(tmp) ? `calc(${tmp.slice(4)} * ${multiple})` : isMethod(tmp) ? `calc(${tmp} * ${multiple})` : `calc((${value}) * ${multiple})`;
251
+ };
252
+ calc.divide = (value, divisor) => {
253
+ if (divisor === 0) throw new Error("The divisor cannot be 0");
254
+ if (value === 0) return 0;
255
+ if (divisor === 1) return formatter(value);
256
+ const tmp = formatter(value);
257
+ if (!tmp) return 0;
258
+ const matchs = tmp.match(re_numerical);
259
+ return matchs ? parseFloat(matchs[1]) / divisor + matchs[2] : isCalc(tmp) ? `calc(${tmp.slice(4)} / ${divisor})` : isMethod(tmp) ? `calc(${tmp} / ${divisor})` : `calc((${value}) / ${divisor})`;
153
260
  };
154
261
  calc.formatter = formatter;
155
262
  var zero = "0px";
156
263
  var u = void 0;
157
264
  calc.clamp = (value, { min, max }) => {
158
- const val = calc.formatter(value);
265
+ const val = formatter(value) || zero;
159
266
  if (min !== u && max !== u) {
160
- return `clamp(${calc.formatter(min) || zero}, ${val || zero}, ${calc.formatter(max) || zero})`;
161
- } else if (max !== u) {
162
- return `max(${calc.formatter(max) || zero}, ${val || zero})`;
267
+ min = formatter(min) || zero;
268
+ max = formatter(max) || zero;
269
+ return min === max ? max : `clamp(${min}, ${val}, ${max})`;
270
+ }
271
+ if (max !== u) {
272
+ max = formatter(max) || zero;
273
+ return max === zero ? val : `max(${max}, ${val})`;
163
274
  } else if (min !== u) {
164
- return `min(${calc.formatter(min) || zero}, ${val || zero})`;
275
+ min = formatter(min) || zero;
276
+ return min === val ? val : `min(${min}, ${val})`;
165
277
  } else {
166
- return val;
278
+ return val === zero ? 0 : val;
167
279
  }
168
280
  };
169
281
  var calc_default = calc;
@@ -179,14 +291,14 @@ var clamp = (value, min, max) => {
179
291
  };
180
292
 
181
293
  // src/classnames.ts
182
- var import_lodash_es2 = require("lodash-es");
294
+ var import_lodash_es3 = require("lodash-es");
183
295
  var add = (a, b) => a ? a + " " + b : b;
184
296
  var classnames = (...list) => list.reduce((caches, data) => {
185
- if ((0, import_lodash_es2.isString)(data)) {
297
+ if ((0, import_lodash_es3.isString)(data)) {
186
298
  data && (caches = add(caches, data));
187
299
  } else if (Array.isArray(data)) {
188
- data.forEach((value) => value && (0, import_lodash_es2.isString)(value) && (caches = add(caches, value)));
189
- } else if (!(0, import_lodash_es2.isBoolean)(data)) {
300
+ data.forEach((value) => value && (0, import_lodash_es3.isString)(value) && (caches = add(caches, value)));
301
+ } else if (!(0, import_lodash_es3.isBoolean)(data)) {
190
302
  for (const key in data) {
191
303
  key && data[key] && (caches = add(caches, key));
192
304
  }
@@ -258,7 +370,7 @@ var hash8object = (list, key) => list.reduce((caches, data) => {
258
370
  }, /* @__PURE__ */ new Map());
259
371
 
260
372
  // src/cron.ts
261
- var import_lodash_es3 = require("lodash-es");
373
+ var import_lodash_es4 = require("lodash-es");
262
374
  var {
263
375
  parseInt,
264
376
  isInteger,
@@ -574,7 +686,7 @@ var AggUnit = class {
574
686
  if (Array.isArray(values)) {
575
687
  tmp = values.reduce((caches, data) => {
576
688
  let tmp2;
577
- if ((0, import_lodash_es3.isNumber)(data)) {
689
+ if ((0, import_lodash_es4.isNumber)(data)) {
578
690
  tmp2 = `${data}`;
579
691
  } else {
580
692
  tmp2 = data.text();
@@ -638,7 +750,7 @@ var formaterAgg = (value, min, max) => {
638
750
  value.some((data) => {
639
751
  if (validate(data, min, max)) {
640
752
  tmp.push(
641
- (0, import_lodash_es3.isNumber)(data) ? data : new RangeUnit(data[0], data[1])
753
+ (0, import_lodash_es4.isNumber)(data) ? data : new RangeUnit(data[0], data[1])
642
754
  );
643
755
  return false;
644
756
  } else {
@@ -658,7 +770,7 @@ var formaterAggByLast = (value, min, max, prototype) => {
658
770
  const tmp = [];
659
771
  const list = Array.isArray(value) ? value : [value];
660
772
  list.some((data) => {
661
- if ((0, import_lodash_es3.isString)(data)) {
773
+ if ((0, import_lodash_es4.isString)(data)) {
662
774
  const result = parseAgg(data);
663
775
  if (result.length === 1 && result[0] instanceof prototype && validate(result[0].value, min, max - 1)) {
664
776
  tmp.push(result[0]);
@@ -666,7 +778,7 @@ var formaterAggByLast = (value, min, max, prototype) => {
666
778
  }
667
779
  } else if (validate(data, min, max)) {
668
780
  tmp.push(
669
- (0, import_lodash_es3.isNumber)(data) ? data : new RangeUnit(data[0], data[1])
781
+ (0, import_lodash_es4.isNumber)(data) ? data : new RangeUnit(data[0], data[1])
670
782
  );
671
783
  return false;
672
784
  }
@@ -904,7 +1016,7 @@ var Cron = class {
904
1016
  };
905
1017
 
906
1018
  // src/desens.ts
907
- var import_lodash_es4 = require("lodash-es");
1019
+ var import_lodash_es5 = require("lodash-es");
908
1020
  var desensEncrypt = (plaintext, encrypt) => {
909
1021
  const rules = [];
910
1022
  let point = -1;
@@ -943,7 +1055,7 @@ var desensReplace = (ciphertext, rules, replacer = "*") => {
943
1055
  return rules.reduce((cache, { range: [start, stop], modify }) => {
944
1056
  const part = ciphertext.slice(start + offset, start + offset + modify);
945
1057
  const size = stop + 1 - start;
946
- const replaceValue = (0, import_lodash_es4.isString)(replacer) ? replacer.repeat(size) : replacer[Symbol.replace](part, size);
1058
+ const replaceValue = (0, import_lodash_es5.isString)(replacer) ? replacer.repeat(size) : replacer[Symbol.replace](part, size);
947
1059
  cache += ciphertext.slice(from, start + offset) + replaceValue;
948
1060
  from = start + offset + modify;
949
1061
  offset += modify - size;
@@ -952,7 +1064,7 @@ var desensReplace = (ciphertext, rules, replacer = "*") => {
952
1064
  };
953
1065
 
954
1066
  // src/dic.ts
955
- var import_lodash_es5 = require("lodash-es");
1067
+ var import_lodash_es6 = require("lodash-es");
956
1068
  var DicRollup = class _DicRollup {
957
1069
  #list;
958
1070
  #default;
@@ -989,7 +1101,7 @@ var DicRollup = class _DicRollup {
989
1101
  if (!data) return;
990
1102
  const custom = this.#customLabel;
991
1103
  if (!custom) return data.label;
992
- if (!mode && (0, import_lodash_es5.isFunction)(custom)) {
1104
+ if (!mode && (0, import_lodash_es6.isFunction)(custom)) {
993
1105
  return custom(data);
994
1106
  } else if (mode) {
995
1107
  const tmp = custom[mode];
@@ -1043,6 +1155,18 @@ var DicRollup = class _DicRollup {
1043
1155
  };
1044
1156
  var dic_default = DicRollup;
1045
1157
 
1158
+ // src/disable-enumerable.ts
1159
+ var disable_enumerable_default = (data, key) => {
1160
+ const descriptor = Object.getOwnPropertyDescriptor(data, key) || {
1161
+ configurable: true,
1162
+ writable: true
1163
+ };
1164
+ Object.defineProperty(data, key, {
1165
+ ...descriptor,
1166
+ enumerable: false
1167
+ });
1168
+ };
1169
+
1046
1170
  // src/encoding.ts
1047
1171
  var utf8_first_prefix = /^1{2,}/g;
1048
1172
  var utf8_other_prefix = /^10/;
@@ -1098,6 +1222,39 @@ var getEncoding = (uint, limit = 1024) => {
1098
1222
  return { encoding, offset };
1099
1223
  };
1100
1224
 
1225
+ // src/index-sort.ts
1226
+ var index_sort_default = (list, key) => {
1227
+ const { length } = list;
1228
+ if (length < 2) return list;
1229
+ const first = list[0][key];
1230
+ const caches = { [first]: first };
1231
+ let isA = false;
1232
+ let max = first;
1233
+ let min = first;
1234
+ for (let i = 1; i < length; i++) {
1235
+ const value = list[i][key];
1236
+ if (value === Math.trunc(value) && value in caches === false) {
1237
+ if (value > max) {
1238
+ max = value;
1239
+ } else if (value < min) {
1240
+ min = value;
1241
+ }
1242
+ caches[value] = value;
1243
+ } else {
1244
+ isA = true;
1245
+ break;
1246
+ }
1247
+ }
1248
+ if (!isA && max - min === length - 1) {
1249
+ return list.reduce((cache, data) => {
1250
+ cache[data[key] - min] = data;
1251
+ return cache;
1252
+ }, []);
1253
+ } else {
1254
+ return list.sort((a, b) => a[key] - b[key]);
1255
+ }
1256
+ };
1257
+
1101
1258
  // src/input-regex.ts
1102
1259
  var RE_REGEX = /[$()*+.[?\\^{|]/g;
1103
1260
  var RE_STRING = /[$()*+.[?\\^{|-]/g;
@@ -1146,38 +1303,53 @@ var loadImage = (src) => {
1146
1303
  };
1147
1304
 
1148
1305
  // src/memory/basic.ts
1149
- var MemoryBasic = class {
1306
+ var PUSH = 1;
1307
+ var RESET = 2;
1308
+ var DELETE = 0;
1309
+ var LIST_SYMBOL = Symbol();
1310
+ var MEMORYS_SYMBOL = Symbol();
1311
+ var MemoryBasic = class _MemoryBasic {
1150
1312
  /**
1151
- * @param key 用于对数据进行分类的key
1152
- * @param config
1313
+ * @param key 用于对数据进行分类的key
1314
+ * @param config 配置项
1153
1315
  */
1154
1316
  constructor(key, config) {
1155
1317
  this.key = key;
1156
1318
  this.#mount = config.mount;
1157
1319
  this.#reflex = config.reflex;
1320
+ this.#emit = config.emit;
1158
1321
  }
1322
+ static PUSH = PUSH;
1323
+ static RESET = RESET;
1324
+ static DELETE = DELETE;
1159
1325
  #mount;
1160
1326
  #reflex;
1161
- list = [];
1162
- memorys = /* @__PURE__ */ new Map();
1327
+ #emit;
1328
+ [LIST_SYMBOL] = [];
1329
+ [MEMORYS_SYMBOL] = /* @__PURE__ */ new Map();
1163
1330
  /**
1164
1331
  * 返回存储长度
1165
1332
  */
1166
1333
  get size() {
1167
- return this.list.length;
1334
+ return this[LIST_SYMBOL].length;
1168
1335
  }
1169
1336
  getType(data) {
1170
1337
  const { key } = this;
1171
1338
  return typeof key === "function" ? key(data) : data[key];
1172
1339
  }
1173
- push(...list) {
1174
- const { memorys } = this;
1175
- list.forEach((data) => {
1340
+ /**
1341
+ * 添加数据
1342
+ */
1343
+ push(...values) {
1344
+ const memorys = this[MEMORYS_SYMBOL];
1345
+ const list = this[LIST_SYMBOL];
1346
+ values.forEach((data) => {
1176
1347
  const type = this.getType(data);
1177
1348
  const memory = memorys.get(type);
1178
- const index = this.list.push(data) - 1;
1349
+ const index = list.push(data) - 1;
1179
1350
  const result = this.#mount(index, memory);
1180
1351
  memory === result || memorys.set(type, result);
1352
+ this.#emit?.(PUSH, data);
1181
1353
  });
1182
1354
  return this;
1183
1355
  }
@@ -1185,24 +1357,25 @@ var MemoryBasic = class {
1185
1357
  * 返回位于指定索引处的项
1186
1358
  */
1187
1359
  at(index) {
1188
- const { list } = this;
1360
+ const list = this[LIST_SYMBOL];
1189
1361
  if (index < 0) {
1190
1362
  index += list.length;
1191
1363
  }
1192
- return this.list.at(index);
1364
+ return list.at(index);
1193
1365
  }
1194
1366
  /**
1195
1367
  * 遍历所有存储数据(按入栈顺序)
1196
1368
  */
1197
1369
  forEach(callback) {
1198
- this.list.forEach(callback);
1370
+ this[LIST_SYMBOL].forEach(callback);
1199
1371
  return this;
1200
1372
  }
1201
1373
  /**
1202
1374
  * 遍历所有存储类型
1203
1375
  */
1204
1376
  forType(callback) {
1205
- const { memorys, list } = this;
1377
+ const memorys = this[MEMORYS_SYMBOL];
1378
+ const list = this[LIST_SYMBOL];
1206
1379
  for (const [type, memory] of memorys) {
1207
1380
  const caches = this.#reflex(memory).map((index) => list[index]);
1208
1381
  callback(caches, type);
@@ -1213,38 +1386,39 @@ var MemoryBasic = class {
1213
1386
  * some(按入栈顺序)
1214
1387
  */
1215
1388
  some(callback) {
1216
- return this.list.some(callback);
1389
+ return this[LIST_SYMBOL].some(callback);
1217
1390
  }
1218
1391
  /**
1219
1392
  * map(按入栈顺序)
1220
1393
  */
1221
1394
  map(callback) {
1222
- return this.list.map(callback);
1395
+ return this[LIST_SYMBOL].map(callback);
1223
1396
  }
1224
1397
  /**
1225
1398
  * reduce(按入栈顺序)
1226
1399
  */
1227
1400
  reduce(callback, initialValue) {
1228
- return this.list.reduce(callback, initialValue);
1401
+ return this[LIST_SYMBOL].reduce(callback, initialValue);
1229
1402
  }
1230
1403
  /**
1231
1404
  * 判断存储是否包含指定类型
1232
1405
  */
1233
1406
  includes(type) {
1234
- return this.memorys.has(type);
1407
+ return this[MEMORYS_SYMBOL].has(type);
1235
1408
  }
1236
1409
  /**
1237
1410
  * 获取指定类型存储数据
1238
1411
  */
1239
1412
  get(type) {
1240
- const memory = this.memorys.get(type);
1241
- return memory === void 0 ? null : this.#reflex(memory).map((count) => this.list[count]);
1413
+ const memory = this[MEMORYS_SYMBOL].get(type);
1414
+ return memory === void 0 ? null : this.#reflex(memory).map((count) => this[LIST_SYMBOL][count]);
1242
1415
  }
1243
1416
  /**
1244
1417
  * 删除指定存储数据
1245
1418
  */
1246
1419
  delete(data) {
1247
- const { memorys, list } = this;
1420
+ const memorys = this[MEMORYS_SYMBOL];
1421
+ const list = this[LIST_SYMBOL];
1248
1422
  let index = -1;
1249
1423
  if (!list.some((value, i) => {
1250
1424
  if (data === value) {
@@ -1280,42 +1454,46 @@ var MemoryBasic = class {
1280
1454
  memorys.set(type, reactor);
1281
1455
  }
1282
1456
  }
1457
+ this.#emit?.(DELETE, index);
1283
1458
  return this;
1284
1459
  }
1285
1460
  /**
1286
1461
  * 删除指定类型存储数据
1287
1462
  */
1288
1463
  deleteType(type) {
1289
- const { memorys, list } = this;
1464
+ const memorys = this[MEMORYS_SYMBOL];
1465
+ const list = this[LIST_SYMBOL];
1290
1466
  if (!memorys.has(type)) return this;
1291
1467
  const local = hash8strings(this.#reflex(memorys.get(type)));
1292
- const Memory2 = this.constructor;
1293
- const imitator = new Memory2(this.key, {
1468
+ const imitator = new _MemoryBasic(this.key, {
1294
1469
  mount: this.#mount,
1295
1470
  reflex: this.#reflex
1296
1471
  });
1297
1472
  list.forEach((data, index) => {
1298
1473
  index in local || imitator.push(data);
1299
1474
  });
1300
- this.list = imitator.list;
1301
- this.memorys = imitator.memorys;
1475
+ const tmp = this[LIST_SYMBOL] = imitator[LIST_SYMBOL];
1476
+ this[MEMORYS_SYMBOL] = imitator[MEMORYS_SYMBOL];
1477
+ this.#emit?.(RESET, tmp.slice(0));
1302
1478
  return this;
1303
1479
  }
1304
1480
  /**
1305
1481
  * 清理存储
1306
1482
  */
1307
1483
  clear() {
1308
- this.list = [];
1309
- this.memorys.clear();
1484
+ this[LIST_SYMBOL] = [];
1485
+ this[MEMORYS_SYMBOL].clear();
1486
+ this.#emit?.(RESET, []);
1310
1487
  }
1311
1488
  };
1312
1489
 
1313
1490
  // src/memory/list.ts
1314
1491
  var MemoryList = class extends MemoryBasic {
1315
- constructor(key) {
1492
+ constructor(key, emit) {
1316
1493
  super(key, {
1317
1494
  mount: (index, reactor) => reactor ? (reactor.push(index), reactor) : [index],
1318
- reflex: (reactor) => reactor
1495
+ reflex: (reactor) => reactor,
1496
+ emit
1319
1497
  });
1320
1498
  }
1321
1499
  };
@@ -1343,10 +1521,11 @@ var deconPowersSum = (sum, sort) => {
1343
1521
 
1344
1522
  // src/memory/power.ts
1345
1523
  var MemoryPower = class extends MemoryBasic {
1346
- constructor(key) {
1524
+ constructor(key, emit) {
1347
1525
  super(key, {
1348
1526
  mount: (index, reactor) => (reactor || 0) + 2 ** index,
1349
- reflex: (reactor) => deconPowersSum(reactor, "asc")
1527
+ reflex: (reactor) => deconPowersSum(reactor, "asc"),
1528
+ emit
1350
1529
  });
1351
1530
  }
1352
1531
  };
@@ -1785,12 +1964,12 @@ var once = (func, thisArg) => {
1785
1964
  };
1786
1965
 
1787
1966
  // src/parse/num.ts
1788
- var import_lodash_es6 = require("lodash-es");
1967
+ var import_lodash_es7 = require("lodash-es");
1789
1968
  var { MAX_SAFE_INTEGER: MAX_SAFE_INTEGER2, NaN } = Number;
1790
1969
  var pow = Math.floor(Math.log10(MAX_SAFE_INTEGER2));
1791
1970
  var re_num2 = /^([-+]?)0*(\d+)(?:(n)|(?:\.(\d+))?(?:[Ee]([-+]?)(\d+))?)$/;
1792
1971
  var parseNum = (num) => {
1793
- if ((0, import_lodash_es6.isNumber)(num) || typeof num === "bigint") return num;
1972
+ if ((0, import_lodash_es7.isNumber)(num) || typeof num === "bigint") return num;
1794
1973
  const match = num.match(re_num2);
1795
1974
  if (!match) return NaN;
1796
1975
  const [, valueSymbol, integer, bigint, decimal, powSymbol, powValue] = match;
@@ -1819,7 +1998,7 @@ var parseNum = (num) => {
1819
1998
  var rotateAngle = (from, angle, visit) => rotateRad(from, angle / 180 * Math.PI, visit);
1820
1999
 
1821
2000
  // src/serialize/url-params.ts
1822
- var import_lodash_es7 = require("lodash-es");
2001
+ var import_lodash_es8 = require("lodash-es");
1823
2002
  var cubes = {
1824
2003
  string: (text) => text,
1825
2004
  boolean: (text) => text === "true",
@@ -1844,7 +2023,7 @@ var cubeURLParams = (text, serializes) => {
1844
2023
  for (const [key, value] of params) {
1845
2024
  const serialize = serializes[key];
1846
2025
  if (!serialize) continue;
1847
- if ((0, import_lodash_es7.isString)(serialize) && isKey(serialize, cubes)) {
2026
+ if ((0, import_lodash_es8.isString)(serialize) && isKey(serialize, cubes)) {
1848
2027
  result[key] = cubes[serialize](value);
1849
2028
  } else {
1850
2029
  result[key] = serialize.cube(value);
@@ -1862,21 +2041,21 @@ var flatURLParams = (data, serializes) => {
1862
2041
  if (!serialize) continue;
1863
2042
  params.append(
1864
2043
  key,
1865
- (0, import_lodash_es7.isString)(serialize) && isKey(serialize, flats) ? flats[serialize](value) : serialize.flat(value)
2044
+ (0, import_lodash_es8.isString)(serialize) && isKey(serialize, flats) ? flats[serialize](value) : serialize.flat(value)
1866
2045
  );
1867
2046
  }
1868
2047
  return params.toString();
1869
2048
  };
1870
2049
 
1871
2050
  // src/style/css.ts
1872
- var import_lodash_es8 = require("lodash-es");
2051
+ var import_lodash_es9 = require("lodash-es");
1873
2052
  var hump = /[A-Z]/g;
1874
2053
  var css = (...args) => {
1875
2054
  const list = [];
1876
2055
  for (let i = 0; i < args.length; i++) {
1877
2056
  const data = args[i];
1878
2057
  if (!data) continue;
1879
- if ((0, import_lodash_es8.isString)(data)) {
2058
+ if ((0, import_lodash_es9.isString)(data)) {
1880
2059
  list.push(data);
1881
2060
  } else if (Array.isArray(data)) {
1882
2061
  const result = css(...data);
@@ -1939,7 +2118,7 @@ var Subscriber = class {
1939
2118
  listeners[name].splice(index, 1);
1940
2119
  return true;
1941
2120
  }
1942
- }) && once2[name].some((value, index) => {
2121
+ }) && once2[name]?.some((value, index) => {
1943
2122
  if (value === count) {
1944
2123
  listeners[name].splice(index, 1);
1945
2124
  return true;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as asyncLock } from './async-lock';
1
2
  export { type Calc, isCalc, default as calc } from './calc';
2
3
  export { clamp } from './clamp';
3
4
  export { classnames } from './classnames';
@@ -9,14 +10,16 @@ export { hash8strings } from './convert/strings';
9
10
  export { weekDic, default_max_second, default_min_second, default_max_minute, default_min_minute, default_max_hour, default_min_hour, default_max_day, default_min_day, default_max_month, default_min_month, default_max_week, default_min_week, createCronRegexText, InvalidUnit, isInvalidUnit, DayLastUnit, isDayLastUnit, WeekLastUnit, isWeekLastUnit, WildcardUnit, isWildcardUnit, RangeUnit, isRangeUnit, AggUnit, isAggUnit, Cron } from './cron';
10
11
  export { type DesensDecrypt, type DesensEncrypt, desensEncrypt, desensDecrypt, desensReplace } from './desens';
11
12
  export { type Dic, default as DicRollup } from './dic';
13
+ export { default as disableEnumerable } from './disable-enumerable';
12
14
  export { getEncoding } from './encoding';
15
+ export { default as indexSort } from './index-sort';
13
16
  export { inputRegex } from './input-regex';
14
17
  export { isClass } from './is/class';
15
18
  export { isEmpty } from './is/empty';
16
19
  export { isKey } from './is/key';
17
20
  export { isNull } from './is/null';
18
21
  export { loadImage } from './load/image';
19
- export { MemoryBasic } from './memory/basic';
22
+ export { type Memory, MemoryBasic } from './memory/basic';
20
23
  export { MemoryList } from './memory/list';
21
24
  export { MemoryPower } from './memory/power';
22
25
  export { MemorySimple } from './memory/simple';