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