@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.umd.js
CHANGED
|
@@ -4217,9 +4217,35 @@
|
|
|
4217
4217
|
|
|
4218
4218
|
class UtilsDictionary {
|
|
4219
4219
|
items;
|
|
4220
|
-
constructor(
|
|
4220
|
+
constructor(...args) {
|
|
4221
4221
|
this.items = new Map();
|
|
4222
|
-
if (
|
|
4222
|
+
if (args.length === 1) {
|
|
4223
|
+
// 数组|对象
|
|
4224
|
+
const data = args[0];
|
|
4225
|
+
if (Array.isArray(data)) {
|
|
4226
|
+
// 数组
|
|
4227
|
+
// [[1,2], [3,4], ...]
|
|
4228
|
+
for (let index = 0; index < data.length; index++) {
|
|
4229
|
+
const item = data[index];
|
|
4230
|
+
if (Array.isArray(item)) {
|
|
4231
|
+
const [key, value] = item;
|
|
4232
|
+
this.set(key, value);
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
else if (typeof data === "object" && data != null) {
|
|
4237
|
+
// 对象
|
|
4238
|
+
// {1:2, 3:4}
|
|
4239
|
+
for (const key in data) {
|
|
4240
|
+
if (Reflect.has(data, key)) {
|
|
4241
|
+
this.set(key, data[key]);
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
else if (args.length === 2) {
|
|
4247
|
+
// 键、值
|
|
4248
|
+
const [key, value] = args;
|
|
4223
4249
|
this.set(key, value);
|
|
4224
4250
|
}
|
|
4225
4251
|
}
|
|
@@ -4235,7 +4261,7 @@
|
|
|
4235
4261
|
get entries() {
|
|
4236
4262
|
const that = this;
|
|
4237
4263
|
return function* () {
|
|
4238
|
-
const itemKeys =
|
|
4264
|
+
const itemKeys = that.keys();
|
|
4239
4265
|
for (const keyName of itemKeys) {
|
|
4240
4266
|
yield [keyName, that.get(keyName)];
|
|
4241
4267
|
}
|
|
@@ -4272,7 +4298,7 @@
|
|
|
4272
4298
|
*/
|
|
4273
4299
|
set(key, val) {
|
|
4274
4300
|
if (key === void 0) {
|
|
4275
|
-
throw new Error("Utils.Dictionary().set 参数 key
|
|
4301
|
+
throw new Error("Utils.Dictionary().set 参数 key 不能为undefined");
|
|
4276
4302
|
}
|
|
4277
4303
|
this.items.set(key, val);
|
|
4278
4304
|
}
|
|
@@ -5478,7 +5504,7 @@
|
|
|
5478
5504
|
}
|
|
5479
5505
|
const domUtils = new DOMUtils();
|
|
5480
5506
|
|
|
5481
|
-
const version = "2.9.
|
|
5507
|
+
const version = "2.9.4";
|
|
5482
5508
|
|
|
5483
5509
|
class Utils {
|
|
5484
5510
|
windowApi;
|