@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.amd.js +16 -4
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +16 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +16 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +16 -4
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +16 -4
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +16 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Dictionary.d.ts +13 -2
- package/package.json +1 -1
- package/src/Dictionary.ts +24 -3
|
@@ -83,9 +83,20 @@ export declare class UtilsDictionary<K, V> {
|
|
|
83
83
|
concat(data: UtilsDictionary<K, V>): void;
|
|
84
84
|
/**
|
|
85
85
|
* 迭代字典
|
|
86
|
-
* @param
|
|
86
|
+
* @param cb 回调函数
|
|
87
87
|
*/
|
|
88
|
-
forEach(
|
|
88
|
+
forEach(cb: (value: V, key: K, dictionary: UtilsDictionary<K, V>) => void): void;
|
|
89
|
+
/**
|
|
90
|
+
* 找到字典中对应的键和值
|
|
91
|
+
* @param cb 回调函数
|
|
92
|
+
*/
|
|
93
|
+
find(cb: (value: V, key: K, dictionary: UtilsDictionary<K, V>) => {
|
|
94
|
+
key: K;
|
|
95
|
+
value: V;
|
|
96
|
+
} | void): {
|
|
97
|
+
key: K;
|
|
98
|
+
value: V;
|
|
99
|
+
} | undefined;
|
|
89
100
|
/**
|
|
90
101
|
* 检查已有的键中是否以xx开头
|
|
91
102
|
* @param key 需要匹配的键
|
package/package.json
CHANGED
package/src/Dictionary.ts
CHANGED
|
@@ -167,13 +167,34 @@ export class UtilsDictionary<K, V> {
|
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* 迭代字典
|
|
170
|
-
* @param
|
|
170
|
+
* @param cb 回调函数
|
|
171
171
|
*/
|
|
172
|
-
forEach(
|
|
172
|
+
forEach(cb: (value: V, key: K, dictionary: UtilsDictionary<K, V>) => void) {
|
|
173
173
|
this.items.forEach((value, key) => {
|
|
174
|
-
|
|
174
|
+
cb(value, key, this);
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* 找到字典中对应的键和值
|
|
179
|
+
* @param cb 回调函数
|
|
180
|
+
*/
|
|
181
|
+
find(
|
|
182
|
+
cb: (
|
|
183
|
+
value: V,
|
|
184
|
+
key: K,
|
|
185
|
+
dictionary: UtilsDictionary<K, V>
|
|
186
|
+
) => {
|
|
187
|
+
key: K;
|
|
188
|
+
value: V;
|
|
189
|
+
} | void
|
|
190
|
+
) {
|
|
191
|
+
for (const [key, value] of this.items.entries()) {
|
|
192
|
+
const result = cb(value, key, this);
|
|
193
|
+
if (result) {
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
177
198
|
/**
|
|
178
199
|
* 检查已有的键中是否以xx开头
|
|
179
200
|
* @param key 需要匹配的键
|