@whitesev/utils 2.11.8 → 2.11.9

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.umd.js CHANGED
@@ -243,7 +243,7 @@
243
243
  const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
244
244
  const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
245
245
 
246
- const version = "2.11.8";
246
+ const version = "2.11.9";
247
247
 
248
248
  /* eslint-disable */
249
249
  // ==UserScript==
@@ -8345,6 +8345,20 @@
8345
8345
  * 深度获取对象的某个属性
8346
8346
  * @param target 待获取的对象
8347
8347
  * @param handler 获取属性的回调
8348
+ * @example
8349
+ * Utils.queryProperty(window,(target)=>{
8350
+ * if(target.xxx){
8351
+ * return {
8352
+ * isFind: true,
8353
+ * data: target.xxx,
8354
+ * }
8355
+ * }else{
8356
+ * return {
8357
+ * isFind: false,
8358
+ * data: target.aabbcc,
8359
+ * }
8360
+ * }
8361
+ * })
8348
8362
  */
8349
8363
  queryProperty(target, handler) {
8350
8364
  if (target == null) {
@@ -8360,10 +8374,23 @@
8360
8374
  * 异步-深度获取对象属性
8361
8375
  * @param target 待获取的对象
8362
8376
  * @param handler 获取属性的回调
8377
+ * @example
8378
+ * Utils.asyncQueryProperty(window, async (target)=>{
8379
+ * if(target.xxx){
8380
+ * return {
8381
+ * isFind: true,
8382
+ * data: target.xxx,
8383
+ * }
8384
+ * }else{
8385
+ * return {
8386
+ * isFind: false,
8387
+ * data: target.aabbcc,
8388
+ * }
8389
+ * }
8390
+ * })
8363
8391
  */
8364
8392
  async asyncQueryProperty(target, handler) {
8365
8393
  if (target == null) {
8366
- // @ts-expect-error 空返回
8367
8394
  return;
8368
8395
  }
8369
8396
  const handleResult = await handler(target);
@@ -8375,7 +8402,8 @@
8375
8402
  /**
8376
8403
  * 创建一个新的Utils实例
8377
8404
  * @param option
8378
- * @returns
8405
+ * @example
8406
+ * Utils.createUtils();
8379
8407
  */
8380
8408
  createUtils(option) {
8381
8409
  return new Utils(option);
@@ -8443,7 +8471,9 @@
8443
8471
  /**
8444
8472
  * 覆盖对象中的函数this指向
8445
8473
  * @param target 需要覆盖的对象
8446
- * @param [objectThis] 覆盖的this指向,如果为传入,则默认为对象本身
8474
+ * @param objectThis 覆盖的this指向,如果为传入,则默认为对象本身
8475
+ * @example
8476
+ * Utils.coverObjectFunctionThis({})
8447
8477
  */
8448
8478
  coverObjectFunctionThis = commonUtil.coverObjectFunctionThis.bind(commonUtil);
8449
8479
  /**
@@ -8494,7 +8524,7 @@
8494
8524
  /**
8495
8525
  * 自动使用 Worker 执行 setTimeout
8496
8526
  * @param callback 回调函数
8497
- * @param [timeout=0] 延迟时间,默认为0
8527
+ * @param timeout 延迟时间,默认为0
8498
8528
  */
8499
8529
  workerSetTimeout(callback, timeout = 0) {
8500
8530
  try {
@@ -8565,6 +8595,10 @@
8565
8595
  /**
8566
8596
  * 判断页面中是否存在`worker-src`的CSP规则
8567
8597
  * @param timeout 超时时间,默认为`1500ms`
8598
+ * @example
8599
+ * Utils.hasWorkerCSP().then((hasCSP) => {
8600
+ * console.log(hasCSP);
8601
+ * })
8568
8602
  */
8569
8603
  hasWorkerCSP(timeout = 1500) {
8570
8604
  return new Promise((resolve) => {