πPutout plugin adds ability to apply 'flatMap()'
npm install @putout/plugin-apply-flat-map[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-apply-flat-map.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-apply-flat-map "npm"
> The flatMap() method returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level.
> It is identical to a map() followed by a flat() of depth 1 (arr.map(...args).flat()), but slightly more efficient than calling those two methods separately.
>
> (c) MDN
πPutout plugin adds ability to apply flatMap(). Check out in πPutout Editor.
```
npm i @putout/plugin-apply-flat-map
`json`
{
"rules": {
"apply-flat-map": "on"
}
}
`js`
array
.map(getId)
.flat();
`js`
array.flatMap(getId);
Linter | Rule | Fix
--------|-------|------------|
π Putout | apply-flat-map | β
β£ ESLint | unicorn/prefer-flat-map | β
π Rome | useFlatMap` | β
MIT