sharvit-flatten-js
v1.0.0
Published
Flatten any dimensional array
Downloads
3
Readme
flatten-js
Flatten any dimensional array
Returns a new array that is a one-dimensional flattening of the input array (recursively). That is, for every element that is an array, extract its elements into the new array.
Installation
npm install --save sharvit-flatten-js
Usage
import flatten from 'sharvit-flatten-js';
flatten([[1,2,[3]],4]);
//=> [1, 2, 3, 4]
If you are not able to use es-modules
, you can use require
instead of import
const { default: flattenJs } = require('sharvit-flatten-js');
To use it directly inside a browser, load it via a script tag
:
<script type="text/javascript" src="./node_modules/sharvit-flatten-js/dist/index.js"></script>
<script type="text/javascript">
const { default: flattenJs } = window.flattenJs;
</script>
License
MIT © Avi Sharvit