@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.
- package/dist/index.amd.js +31 -5
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +31 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +31 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +31 -5
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +31 -5
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +31 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Dictionary.d.ts +14 -0
- package/package.json +5 -5
- package/src/Dictionary.ts +41 -5
package/dist/index.esm.js
CHANGED
|
@@ -4211,9 +4211,35 @@ class Progress {
|
|
|
4211
4211
|
|
|
4212
4212
|
class UtilsDictionary {
|
|
4213
4213
|
items;
|
|
4214
|
-
constructor(
|
|
4214
|
+
constructor(...args) {
|
|
4215
4215
|
this.items = new Map();
|
|
4216
|
-
if (
|
|
4216
|
+
if (args.length === 1) {
|
|
4217
|
+
// 数组|对象
|
|
4218
|
+
const data = args[0];
|
|
4219
|
+
if (Array.isArray(data)) {
|
|
4220
|
+
// 数组
|
|
4221
|
+
// [[1,2], [3,4], ...]
|
|
4222
|
+
for (let index = 0; index < data.length; index++) {
|
|
4223
|
+
const item = data[index];
|
|
4224
|
+
if (Array.isArray(item)) {
|
|
4225
|
+
const [key, value] = item;
|
|
4226
|
+
this.set(key, value);
|
|
4227
|
+
}
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4230
|
+
else if (typeof data === "object" && data != null) {
|
|
4231
|
+
// 对象
|
|
4232
|
+
// {1:2, 3:4}
|
|
4233
|
+
for (const key in data) {
|
|
4234
|
+
if (Reflect.has(data, key)) {
|
|
4235
|
+
this.set(key, data[key]);
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
else if (args.length === 2) {
|
|
4241
|
+
// 键、值
|
|
4242
|
+
const [key, value] = args;
|
|
4217
4243
|
this.set(key, value);
|
|
4218
4244
|
}
|
|
4219
4245
|
}
|
|
@@ -4229,7 +4255,7 @@ class UtilsDictionary {
|
|
|
4229
4255
|
get entries() {
|
|
4230
4256
|
const that = this;
|
|
4231
4257
|
return function* () {
|
|
4232
|
-
const itemKeys =
|
|
4258
|
+
const itemKeys = that.keys();
|
|
4233
4259
|
for (const keyName of itemKeys) {
|
|
4234
4260
|
yield [keyName, that.get(keyName)];
|
|
4235
4261
|
}
|
|
@@ -4266,7 +4292,7 @@ class UtilsDictionary {
|
|
|
4266
4292
|
*/
|
|
4267
4293
|
set(key, val) {
|
|
4268
4294
|
if (key === void 0) {
|
|
4269
|
-
throw new Error("Utils.Dictionary().set 参数 key
|
|
4295
|
+
throw new Error("Utils.Dictionary().set 参数 key 不能为undefined");
|
|
4270
4296
|
}
|
|
4271
4297
|
this.items.set(key, val);
|
|
4272
4298
|
}
|
|
@@ -5472,7 +5498,7 @@ class DOMUtils {
|
|
|
5472
5498
|
}
|
|
5473
5499
|
const domUtils = new DOMUtils();
|
|
5474
5500
|
|
|
5475
|
-
const version = "2.9.
|
|
5501
|
+
const version = "2.9.4";
|
|
5476
5502
|
|
|
5477
5503
|
class Utils {
|
|
5478
5504
|
windowApi;
|