NPM Smell 🍑💨

trivial and outdated NPM packages

arr-flatten outdated npm logo

Recursively flattens an array.

Weekly Downloads
5,205,224
Dependencies
0
Latest Release
9 years ago
Switch to the native implementation.
Outdated
natively supported
since 7 years (chrome, firefox, safari, nodejs)

This dependency recursively flattens an array:

var flatten = require("arr-flatten");
flatten([1, [2, [3, [4]], 5], 6]);
//=> [1, 2, 3, 4, 5, 6]

You can achieve the same functionality natively in JavaScript using the flat method with Infinity as the depth argument:

const array = [1, [2, [3, [4]], 5], 6];
const flattened = array.flat(Infinity); // [1, 2, 3, 4, 5, 6]

This is supported in all modern JavaScript environments