@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.amd.js CHANGED
@@ -239,7 +239,7 @@ define((function () { 'use strict';
239
239
  const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
240
240
  const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
241
241
 
242
- const version = "2.11.8";
242
+ const version = "2.11.9";
243
243
 
244
244
  /* eslint-disable */
245
245
  // ==UserScript==
@@ -8341,6 +8341,20 @@ define((function () { 'use strict';
8341
8341
  * 深度获取对象的某个属性
8342
8342
  * @param target 待获取的对象
8343
8343
  * @param handler 获取属性的回调
8344
+ * @example
8345
+ * Utils.queryProperty(window,(target)=>{
8346
+ * if(target.xxx){
8347
+ * return {
8348
+ * isFind: true,
8349
+ * data: target.xxx,
8350
+ * }
8351
+ * }else{
8352
+ * return {
8353
+ * isFind: false,
8354
+ * data: target.aabbcc,
8355
+ * }
8356
+ * }
8357
+ * })
8344
8358
  */
8345
8359
  queryProperty(target, handler) {
8346
8360
  if (target == null) {
@@ -8356,10 +8370,23 @@ define((function () { 'use strict';
8356
8370
  * 异步-深度获取对象属性
8357
8371
  * @param target 待获取的对象
8358
8372
  * @param handler 获取属性的回调
8373
+ * @example
8374
+ * Utils.asyncQueryProperty(window, async (target)=>{
8375
+ * if(target.xxx){
8376
+ * return {
8377
+ * isFind: true,
8378
+ * data: target.xxx,
8379
+ * }
8380
+ * }else{
8381
+ * return {
8382
+ * isFind: false,
8383
+ * data: target.aabbcc,
8384
+ * }
8385
+ * }
8386
+ * })
8359
8387
  */
8360
8388
  async asyncQueryProperty(target, handler) {
8361
8389
  if (target == null) {
8362
- // @ts-expect-error 空返回
8363
8390
  return;
8364
8391
  }
8365
8392
  const handleResult = await handler(target);
@@ -8371,7 +8398,8 @@ define((function () { 'use strict';
8371
8398
  /**
8372
8399
  * 创建一个新的Utils实例
8373
8400
  * @param option
8374
- * @returns
8401
+ * @example
8402
+ * Utils.createUtils();
8375
8403
  */
8376
8404
  createUtils(option) {
8377
8405
  return new Utils(option);
@@ -8439,7 +8467,9 @@ define((function () { 'use strict';
8439
8467
  /**
8440
8468
  * 覆盖对象中的函数this指向
8441
8469
  * @param target 需要覆盖的对象
8442
- * @param [objectThis] 覆盖的this指向,如果为传入,则默认为对象本身
8470
+ * @param objectThis 覆盖的this指向,如果为传入,则默认为对象本身
8471
+ * @example
8472
+ * Utils.coverObjectFunctionThis({})
8443
8473
  */
8444
8474
  coverObjectFunctionThis = commonUtil.coverObjectFunctionThis.bind(commonUtil);
8445
8475
  /**
@@ -8490,7 +8520,7 @@ define((function () { 'use strict';
8490
8520
  /**
8491
8521
  * 自动使用 Worker 执行 setTimeout
8492
8522
  * @param callback 回调函数
8493
- * @param [timeout=0] 延迟时间,默认为0
8523
+ * @param timeout 延迟时间,默认为0
8494
8524
  */
8495
8525
  workerSetTimeout(callback, timeout = 0) {
8496
8526
  try {
@@ -8561,6 +8591,10 @@ define((function () { 'use strict';
8561
8591
  /**
8562
8592
  * 判断页面中是否存在`worker-src`的CSP规则
8563
8593
  * @param timeout 超时时间,默认为`1500ms`
8594
+ * @example
8595
+ * Utils.hasWorkerCSP().then((hasCSP) => {
8596
+ * console.log(hasCSP);
8597
+ * })
8564
8598
  */
8565
8599
  hasWorkerCSP(timeout = 1500) {
8566
8600
  return new Promise((resolve) => {