This commit is contained in:
8
src/collection/mapNotNull.ts
Normal file
8
src/collection/mapNotNull.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export function mapNotNull<T, R>(value: T[], transform: (it: T) => R | null): R[] {
|
||||
const result: R[] = [];
|
||||
for (const it of value) {
|
||||
const transformed = transform(it);
|
||||
if (transformed !== null) result.push(transformed);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user