@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.iife.js
CHANGED
|
@@ -4214,9 +4214,35 @@ var Utils = (function () {
|
|
|
4214
4214
|
|
|
4215
4215
|
class UtilsDictionary {
|
|
4216
4216
|
items;
|
|
4217
|
-
constructor(
|
|
4217
|
+
constructor(...args) {
|
|
4218
4218
|
this.items = new Map();
|
|
4219
|
-
if (
|
|
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 =
|
|
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.
|
|
5504
|
+
const version = "2.9.4";
|
|
5479
5505
|
|
|
5480
5506
|
class Utils {
|
|
5481
5507
|
windowApi;
|