We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3d3fba commit 45fe36fCopy full SHA for 45fe36f
src/language/filter.ts
@@ -1,4 +1,4 @@
1
-export type FilterCallback<T> = (
+export type FilterCallback<T = never> = (
2
item: T,
3
index: number,
4
array: readonly T[],
src/language/map.ts
@@ -0,0 +1,17 @@
+export type MapCallback<T = never> = (
+ value: T,
+ index: number,
+ array: T[],
5
+) => unknown;
6
+
7
+export function map<T>(array: T[], transform: MapCallback<T>) {
8
+ const result: unknown[] = [];
9
10
+ for (const [index, value] of array.entries()) {
11
+ result.push(transform(value, index, array));
12
+ }
13
14
+ return result;
15
+}
16
17
+[].map;
0 commit comments