Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/terkelg/1d
🥞Make multi-dimensional arrays as flat as a pancake.
https://github.com/terkelg/1d
array multidimensional-arrays one-dimensional reduce
Last synced: 2 days ago
JSON representation
🥞Make multi-dimensional arrays as flat as a pancake.
- Host: GitHub
- URL: https://github.com/terkelg/1d
- Owner: terkelg
- License: mit
- Created: 2018-02-18T21:37:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-23T14:10:13.000Z (over 4 years ago)
- Last Synced: 2024-11-11T21:53:30.468Z (9 days ago)
- Topics: array, multidimensional-arrays, one-dimensional, reduce
- Language: JavaScript
- Homepage:
- Size: 178 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
Awesome Lists containing this project
README
1D
Make multi-dimensional arrays as flat as a pancake
## Installation
```
npm install 1d
```## Usage
```js
const flatten = require('1d');flatten( [['a'], 'b', ['c', ['d']]] );
// ['a', 'b', 'c', 'd']
```> **OBS**: This is a built-in feature from Node.js `11.15.0` and up. Check out
[Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)## API
### oned(arr, res)
Flatten an array into a sweet 1D array
#### arr
Type: `Array`
Input array to flatten
#### res
Type: `Array`
Default: `[]`Initial array.
> **Note**: The inital array is not being flattened
## License
MIT © [Terkel Gjervig](https://terkel.com)