sharvit-flatten-js

1.0.0 • Public • Published

flatten-js

Flatten any dimensional array

Package Version semantic-release Downloads Status Build Status: Linux Coverage Status PRs Welcome dependencies Status devDependencies Status code style: prettier MIT License

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

Readme

Keywords

none

Package Sidebar

Install

npm i sharvit-flatten-js

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.22 kB

Total Files

4

Last publish

Collaborators

  • sharvita