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