@whitesev/utils 2.11.12 → 2.11.13

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.12";
246
+ const version = "2.11.13";
247
247
 
248
248
  /* eslint-disable */
249
249
  // ==UserScript==
@@ -1924,13 +1924,25 @@
1924
1924
  }
1925
1925
  /**
1926
1926
  * 迭代字典
1927
- * @param callbackfn 回调函数
1927
+ * @param cb 回调函数
1928
1928
  */
1929
- forEach(callbackfn) {
1929
+ forEach(cb) {
1930
1930
  this.items.forEach((value, key) => {
1931
- callbackfn(value, key, this);
1931
+ cb(value, key, this);
1932
1932
  });
1933
1933
  }
1934
+ /**
1935
+ * 找到字典中对应的键和值
1936
+ * @param cb 回调函数
1937
+ */
1938
+ find(cb) {
1939
+ for (const [key, value] of this.items.entries()) {
1940
+ const result = cb(value, key, this);
1941
+ if (result) {
1942
+ return result;
1943
+ }
1944
+ }
1945
+ }
1934
1946
  /**
1935
1947
  * 检查已有的键中是否以xx开头
1936
1948
  * @param key 需要匹配的键