UNPKG
array-map-ts
Version:
latest (1.1.2)
1.1.2
1.1.1
1.1.0
1.0.0
array map method in ts
array-map-ts
/
array-map-ts.ts
10 lines
(9 loc)
•
273 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
export
= <T, U>(
array
: T[],
callback
:
(
item
: T,
index
:
number
,
arr
:
ReadonlyArray
<T>
) =>
U): U[] => {
let
i = -
1
;
const
resArr = [];
const
length = array.
length
;
while
(++i < length) { resArr.
push
(
callback
(array[i], i, array)); }
return
resArr; };