Skip to content

Commit e556943

Browse files
bichikimktsn
authored andcommitted
Update util find (#1205)
perf: update util find
1 parent f5ff95e commit e556943

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/util.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
* @return {*}
88
*/
99
export function find (list, f) {
10-
return list.filter(f)[0]
10+
const { length } = list
11+
let index = 0
12+
let value
13+
while (++index < length) {
14+
value = list[index]
15+
if (f(value, index, list)) {
16+
return value
17+
}
18+
}
1119
}
1220

1321
/**

0 commit comments

Comments
 (0)