Skip to content

Instantly share code, notes, and snippets.

View andremury's full-sized avatar

Andre Mury andremury

View GitHub Profile
export const mapFilter = <T = unknown, U = unknown>(
arr: U[],
condition: (item: U) => boolean,
mapTo: (item: U) => T
): T[] => {
const newArray: T[] = [];
for (const item of arr) {
if (condition(item)) {
newArray.push(mapTo(item));