Filters an array asynchronously using an async predicate function.
Returns a promise that resolves to a new array containing only the elements for which the predicate function returns a truthy value.
使用异步谓词函数对数组进行异步过滤。
返回一个Promise,该Promise解析为一个新数组,仅包含谓词函数返回真值的元素。
The array to filter. 要过滤的数组
An async predicate function to test each element. 用于测试每个元素的异步谓词函数
Optional
The maximum number of concurrent operations. 最大并发操作数
A promise that resolves to the filtered array. 解析为过滤后数组的Promise
const users = [{ id: 1, active: true }, { id: 2, active: false }, { id: 3, active: true }];const activeUsers = await filterAsync(users, async (user) => { return await checkUserStatus(user.id);});// Returns: [{ id: 1, active: true }, { id: 3, active: true }] Copy
const users = [{ id: 1, active: true }, { id: 2, active: false }, { id: 3, active: true }];const activeUsers = await filterAsync(users, async (user) => { return await checkUserStatus(user.id);});// Returns: [{ id: 1, active: true }, { id: 3, active: true }]
Filters an array asynchronously using an async predicate function.
Returns a promise that resolves to a new array containing only the elements for which the predicate function returns a truthy value.
使用异步谓词函数对数组进行异步过滤。
返回一个Promise,该Promise解析为一个新数组,仅包含谓词函数返回真值的元素。