@whitesev/utils 2.11.12 → 2.11.14

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.cjs.js CHANGED
@@ -239,7 +239,7 @@ const clearTimeout$1 = (timerId) => loadOrReturnBroker().clearTimeout(timerId);
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.12";
242
+ const version = "2.11.14";
243
243
 
244
244
  /* eslint-disable */
245
245
  // ==UserScript==
@@ -1920,13 +1920,25 @@ class UtilsDictionary {
1920
1920
  }
1921
1921
  /**
1922
1922
  * 迭代字典
1923
- * @param callbackfn 回调函数
1923
+ * @param cb 回调函数
1924
1924
  */
1925
- forEach(callbackfn) {
1925
+ forEach(cb) {
1926
1926
  this.items.forEach((value, key) => {
1927
- callbackfn(value, key, this);
1927
+ cb(value, key, this);
1928
1928
  });
1929
1929
  }
1930
+ /**
1931
+ * 找到字典中对应的键和值
1932
+ * @param cb 回调函数
1933
+ */
1934
+ find(cb) {
1935
+ for (const [key, value] of this.items.entries()) {
1936
+ const result = cb(value, key, this);
1937
+ if (result) {
1938
+ return result;
1939
+ }
1940
+ }
1941
+ }
1930
1942
  /**
1931
1943
  * 检查已有的键中是否以xx开头
1932
1944
  * @param key 需要匹配的键