arr-flatten
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The arr-flatten npm package is a utility that recursively flattens arrays. That means it takes an array of arrays (which might contain more arrays inside them and so on), and turns it into a single, flat array. This package was created aiming for maximum speed and effectiveness, covering the vast majority of use cases without added unnecessary features, making it both lightweight and performant.
Arr-flatten is pretty straightforward to use. To get started, you must first install it. Depending on your environment, you may want to install it via npm or bower, using the commands npm install --save arr-flatten
or bower install arr-flatten --save
respectively.
In your JavaScript code, you'd use arr-flatten like this:
var flatten = require('arr-flatten');
var nestedArray = ['a', ['b', ['c']], 'd', ['e']];
var flatArray = flatten(nestedArray);
console.log(flatArray);
// Will output: ['a', 'b', 'c', 'd', 'e']
Here, the flatten
function is used to transform a nested array nestedArray
into a flat one flatArray
, printing it to the console as a result.
The documentation for the arr-flatten package can be found in the package's readme file on its GitHub page, which is located at https://github.com/jonschlinkert/arr-flatten. It provides all the necessary information on how to install and use the package. For potential contributors, it also includes information on running tests and a method for generating the readme file. Any feature requests or bugs can be reported through GitHub issues on the same page.