UNPKG
monk-import-export
Version:
latest (0.0.0)
0.0.0
Simple import & export sorting ESLint plugin
monk-import-export
/
src
/
utils
/
flatMap.ts
5 lines
(4 loc)
•
218 B
text/typescript
View Raw
1
2
3
4
5
// Like `Array.prototype.flatMap`, had it been available.
export
function
flatMap<T>(
array
: T[],
callback
:
(
value: T
) =>
T[]): T[] {
return
array.
reduce
(
(
result: T[], value
) =>
result.
concat
(
callback
(value)), []); }