Perf/Refactor: processDomainList now returns string[]

This commit is contained in:
SukkaW
2024-05-26 17:27:11 +08:00
parent 816bb9ce2f
commit 21a31e6c1f
5 changed files with 50 additions and 26 deletions

View File

@@ -2,7 +2,12 @@
* In-place adding of elements from an array to a set.
*/
export function setAddFromArray<T>(set: Set<T>, arr: T[]): void {
for (let i = 0, len = arr.length; i < len; i++) {
set.add(arr[i]);
}
// for (let i = 0, len = arr.length; i < len; i++) {
// set.add(arr[i]);
// }
// eslint-disable-next-line @typescript-eslint/unbound-method -- thisArg is passed
arr.forEach(set.add, set);
}
// eslint-disable-next-line @typescript-eslint/unbound-method -- thisArg is passed
export const setAddFromArrayCurried = <T>(set: Set<T>) => (arr: T[]) => arr.forEach(set.add, set);