UNPKG

com-tools

Version:

com-tools 提供了一些通用的工具函数;

86 lines (40 loc) 1.5 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [com-tools](./com-tools.md) &gt; [array\_safelyFilter](./com-tools.array_safelyfilter.md) ## array\_safelyFilter() function array\_safelyFilter(operation, thisValue) 安全地操作并过滤所有元素;与 forEach 和 filter 的区别是: safelyFilter 能保证会遍历数组中所有已存在的元素,不会受 operation 中的行为的影响; **Signature:** ```typescript export declare function array_safelyFilter<T, ThisValue = T[]>(array: T[], operation: ArrayCallbackFun<ThisValue, T, any>, thisValue?: ThisValue): T[]; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> array </td><td> T\[\] </td><td> </td></tr> <tr><td> operation </td><td> [ArrayCallbackFun](./com-tools.arraycallbackfun.md)<!-- -->&lt;ThisValue, T, any&gt; </td><td> : (currentValue,currentIndex,currentArray)=<!-- -->&gt;<!-- -->boolean \| undefined 执行的操作, 该函数的返回值表示是否要过滤出该元素 </td></tr> <tr><td> thisValue </td><td> ThisValue </td><td> _(Optional)_ ? : any 可选,默认值是被操作的数组,即调用者;操作 operation 的 this 值 </td></tr> </tbody></table> **Returns:** T\[\] boolean \| undefined 表示是否要过滤出 currentValue ;