@whitesev/utils 2.7.4 → 2.7.6
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 +62 -64
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +62 -64
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +62 -64
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +62 -64
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +62 -64
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +62 -64
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Dictionary.d.ts +22 -23
- package/package.json +1 -1
- package/src/Dictionary.ts +54 -60
- package/src/Utils.ts +9 -10
- package/src/WindowApi.ts +4 -4
package/dist/index.system.js
CHANGED
|
@@ -4210,7 +4210,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4210
4210
|
class UtilsDictionary {
|
|
4211
4211
|
items;
|
|
4212
4212
|
constructor(key, value) {
|
|
4213
|
-
this.items =
|
|
4213
|
+
this.items = new Map();
|
|
4214
4214
|
if (key != null) {
|
|
4215
4215
|
this.set(key, value);
|
|
4216
4216
|
}
|
|
@@ -4247,35 +4247,16 @@ System.register('Utils', [], (function (exports) {
|
|
|
4247
4247
|
* @param key 键
|
|
4248
4248
|
*/
|
|
4249
4249
|
has(key) {
|
|
4250
|
-
return
|
|
4250
|
+
return this.items.has(key);
|
|
4251
4251
|
}
|
|
4252
4252
|
/**
|
|
4253
|
-
*
|
|
4254
|
-
*
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
let allKeys = this.keys();
|
|
4258
|
-
for (const keyName of allKeys) {
|
|
4259
|
-
if (String(keyName).startsWith(String(key))) {
|
|
4260
|
-
return true;
|
|
4261
|
-
}
|
|
4262
|
-
}
|
|
4263
|
-
return false;
|
|
4264
|
-
}
|
|
4265
|
-
/**
|
|
4266
|
-
* 获取以xx开头的键的值
|
|
4267
|
-
* @param key 需要匹配的键
|
|
4253
|
+
* 获取某个键的值
|
|
4254
|
+
* https://github.com/microsoft/TypeScript/issues/9619
|
|
4255
|
+
* 微软到现在都没有实现has和get的联动
|
|
4256
|
+
* @param key 键
|
|
4268
4257
|
*/
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
let result = void 0;
|
|
4272
|
-
for (const keyName of allKeys) {
|
|
4273
|
-
if (String(keyName).startsWith(String(key))) {
|
|
4274
|
-
result = this.get(keyName);
|
|
4275
|
-
break;
|
|
4276
|
-
}
|
|
4277
|
-
}
|
|
4278
|
-
return result;
|
|
4258
|
+
get(key) {
|
|
4259
|
+
return this.items.get(key);
|
|
4279
4260
|
}
|
|
4280
4261
|
/**
|
|
4281
4262
|
* 为字典添加某一个值
|
|
@@ -4286,57 +4267,44 @@ System.register('Utils', [], (function (exports) {
|
|
|
4286
4267
|
if (key === void 0) {
|
|
4287
4268
|
throw new Error("Utils.Dictionary().set 参数 key 不能为空");
|
|
4288
4269
|
}
|
|
4289
|
-
|
|
4270
|
+
this.items.set(key, val);
|
|
4290
4271
|
}
|
|
4291
4272
|
/**
|
|
4292
4273
|
* 删除某一个键
|
|
4293
4274
|
* @param key 键
|
|
4275
|
+
* @returns
|
|
4276
|
+
* + true:键存在且成功删除
|
|
4277
|
+
* + false:键不存在
|
|
4294
4278
|
*/
|
|
4295
4279
|
delete(key) {
|
|
4296
4280
|
if (this.has(key)) {
|
|
4297
|
-
return
|
|
4281
|
+
return this.items.delete(key);
|
|
4298
4282
|
}
|
|
4299
4283
|
return false;
|
|
4300
4284
|
}
|
|
4301
4285
|
/**
|
|
4302
|
-
*
|
|
4303
|
-
* https://github.com/microsoft/TypeScript/issues/9619
|
|
4304
|
-
* 微软到现在都没有修复has和get的联动
|
|
4305
|
-
* @param key 键
|
|
4286
|
+
* 获取字典所有的键
|
|
4306
4287
|
*/
|
|
4307
|
-
|
|
4308
|
-
return
|
|
4288
|
+
keys() {
|
|
4289
|
+
return this.items.keys().toArray();
|
|
4309
4290
|
}
|
|
4310
4291
|
/**
|
|
4311
4292
|
* 返回字典中的所有值
|
|
4312
4293
|
*/
|
|
4313
4294
|
values() {
|
|
4314
|
-
|
|
4315
|
-
for (let prop in this.getItems()) {
|
|
4316
|
-
if (this.has(prop)) {
|
|
4317
|
-
resultList.push(this.get(prop));
|
|
4318
|
-
}
|
|
4319
|
-
}
|
|
4320
|
-
return resultList;
|
|
4295
|
+
return this.items.values().toArray();
|
|
4321
4296
|
}
|
|
4322
4297
|
/**
|
|
4323
4298
|
* 清空字典
|
|
4324
4299
|
*/
|
|
4325
4300
|
clear() {
|
|
4326
|
-
this.items
|
|
4327
|
-
this.items = {};
|
|
4301
|
+
this.items.clear();
|
|
4328
4302
|
}
|
|
4329
4303
|
/**
|
|
4330
4304
|
* 获取字典的长度
|
|
4331
4305
|
*/
|
|
4332
4306
|
size() {
|
|
4333
|
-
return
|
|
4334
|
-
}
|
|
4335
|
-
/**
|
|
4336
|
-
* 获取字典所有的键
|
|
4337
|
-
*/
|
|
4338
|
-
keys() {
|
|
4339
|
-
return Reflect.ownKeys(this.items);
|
|
4307
|
+
return this.items.size;
|
|
4340
4308
|
}
|
|
4341
4309
|
/**
|
|
4342
4310
|
* 返回字典本身
|
|
@@ -4349,16 +4317,46 @@ System.register('Utils', [], (function (exports) {
|
|
|
4349
4317
|
* @param data 需要合并的字典
|
|
4350
4318
|
*/
|
|
4351
4319
|
concat(data) {
|
|
4352
|
-
|
|
4320
|
+
data.forEach((value, key) => {
|
|
4321
|
+
this.items.set(key, value);
|
|
4322
|
+
});
|
|
4353
4323
|
}
|
|
4354
4324
|
/**
|
|
4355
4325
|
* 迭代字典
|
|
4356
4326
|
* @param callbackfn 回调函数
|
|
4357
4327
|
*/
|
|
4358
4328
|
forEach(callbackfn) {
|
|
4359
|
-
|
|
4360
|
-
callbackfn(
|
|
4329
|
+
this.items.forEach((value, key, self) => {
|
|
4330
|
+
callbackfn(value, key, this);
|
|
4331
|
+
});
|
|
4332
|
+
}
|
|
4333
|
+
/**
|
|
4334
|
+
* 检查已有的键中是否以xx开头
|
|
4335
|
+
* @param key 需要匹配的键
|
|
4336
|
+
*/
|
|
4337
|
+
startsWith(key) {
|
|
4338
|
+
const keys = this.keys();
|
|
4339
|
+
for (const keyName of keys) {
|
|
4340
|
+
if (String(keyName).startsWith(key)) {
|
|
4341
|
+
return true;
|
|
4342
|
+
}
|
|
4361
4343
|
}
|
|
4344
|
+
return false;
|
|
4345
|
+
}
|
|
4346
|
+
/**
|
|
4347
|
+
* 获取以xx开头的键的值
|
|
4348
|
+
* @param key 需要匹配的键
|
|
4349
|
+
*/
|
|
4350
|
+
getStartsWith(key) {
|
|
4351
|
+
let result = void 0;
|
|
4352
|
+
const keys = this.keys();
|
|
4353
|
+
for (const keyName of keys) {
|
|
4354
|
+
if (String(keyName).startsWith(String(key))) {
|
|
4355
|
+
result = this.get(keyName);
|
|
4356
|
+
break;
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
return result;
|
|
4362
4360
|
}
|
|
4363
4361
|
}
|
|
4364
4362
|
|
|
@@ -4370,10 +4368,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
4370
4368
|
globalThis: globalThis,
|
|
4371
4369
|
self: self,
|
|
4372
4370
|
top: top,
|
|
4373
|
-
setTimeout: globalThis.setTimeout,
|
|
4374
|
-
setInterval: globalThis.setInterval,
|
|
4375
|
-
clearTimeout: globalThis.clearTimeout,
|
|
4376
|
-
clearInterval: globalThis.clearInterval,
|
|
4371
|
+
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
4372
|
+
setInterval: globalThis.setInterval.bind(globalThis),
|
|
4373
|
+
clearTimeout: globalThis.clearTimeout.bind(globalThis),
|
|
4374
|
+
clearInterval: globalThis.clearInterval.bind(globalThis),
|
|
4377
4375
|
};
|
|
4378
4376
|
/** 使用的配置 */
|
|
4379
4377
|
api;
|
|
@@ -5480,7 +5478,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5480
5478
|
this.windowApi = new WindowApi(option);
|
|
5481
5479
|
}
|
|
5482
5480
|
/** 版本号 */
|
|
5483
|
-
version = "2025.8
|
|
5481
|
+
version = "2025.9.8";
|
|
5484
5482
|
addStyle(cssText) {
|
|
5485
5483
|
if (typeof cssText !== "string") {
|
|
5486
5484
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5810,19 +5808,19 @@ System.register('Utils', [], (function (exports) {
|
|
|
5810
5808
|
}
|
|
5811
5809
|
else {
|
|
5812
5810
|
let textElement = Array.from(element.childNodes).filter((ele) => ele.nodeType === Node.TEXT_NODE);
|
|
5813
|
-
for (let
|
|
5814
|
-
if (
|
|
5811
|
+
for (let $child of textElement) {
|
|
5812
|
+
if ($child.textContent.includes(text)) {
|
|
5815
5813
|
let filterResult = typeof filter === "function" ? filter(element) : false;
|
|
5816
5814
|
if (!filterResult) {
|
|
5817
|
-
yield
|
|
5815
|
+
yield $child;
|
|
5818
5816
|
}
|
|
5819
5817
|
}
|
|
5820
5818
|
}
|
|
5821
5819
|
}
|
|
5822
5820
|
}
|
|
5823
5821
|
for (let index = 0; index < element.children.length; index++) {
|
|
5824
|
-
let
|
|
5825
|
-
yield* that.findElementsWithText(
|
|
5822
|
+
let $child = element.children[index];
|
|
5823
|
+
yield* that.findElementsWithText($child, text, filter);
|
|
5826
5824
|
}
|
|
5827
5825
|
}
|
|
5828
5826
|
/**
|