@whitesev/utils 2.9.3 → 2.9.4

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.
@@ -4214,9 +4214,35 @@ var Utils = (function () {
4214
4214
 
4215
4215
  class UtilsDictionary {
4216
4216
  items;
4217
- constructor(key, value) {
4217
+ constructor(...args) {
4218
4218
  this.items = new Map();
4219
- if (key != null) {
4219
+ if (args.length === 1) {
4220
+ // 数组|对象
4221
+ const data = args[0];
4222
+ if (Array.isArray(data)) {
4223
+ // 数组
4224
+ // [[1,2], [3,4], ...]
4225
+ for (let index = 0; index < data.length; index++) {
4226
+ const item = data[index];
4227
+ if (Array.isArray(item)) {
4228
+ const [key, value] = item;
4229
+ this.set(key, value);
4230
+ }
4231
+ }
4232
+ }
4233
+ else if (typeof data === "object" && data != null) {
4234
+ // 对象
4235
+ // {1:2, 3:4}
4236
+ for (const key in data) {
4237
+ if (Reflect.has(data, key)) {
4238
+ this.set(key, data[key]);
4239
+ }
4240
+ }
4241
+ }
4242
+ }
4243
+ else if (args.length === 2) {
4244
+ // 键、值
4245
+ const [key, value] = args;
4220
4246
  this.set(key, value);
4221
4247
  }
4222
4248
  }
@@ -4232,7 +4258,7 @@ var Utils = (function () {
4232
4258
  get entries() {
4233
4259
  const that = this;
4234
4260
  return function* () {
4235
- const itemKeys = Object.keys(that.getItems());
4261
+ const itemKeys = that.keys();
4236
4262
  for (const keyName of itemKeys) {
4237
4263
  yield [keyName, that.get(keyName)];
4238
4264
  }
@@ -4269,7 +4295,7 @@ var Utils = (function () {
4269
4295
  */
4270
4296
  set(key, val) {
4271
4297
  if (key === void 0) {
4272
- throw new Error("Utils.Dictionary().set 参数 key 不能为空");
4298
+ throw new Error("Utils.Dictionary().set 参数 key 不能为undefined");
4273
4299
  }
4274
4300
  this.items.set(key, val);
4275
4301
  }
@@ -5475,7 +5501,7 @@ var Utils = (function () {
5475
5501
  }
5476
5502
  const domUtils = new DOMUtils();
5477
5503
 
5478
- const version = "2.9.3";
5504
+ const version = "2.9.4";
5479
5505
 
5480
5506
  class Utils {
5481
5507
  windowApi;