Skip to content
/ 1d Public

🥞Make multi-dimensional arrays as flat as a pancake.

License

Notifications You must be signed in to change notification settings

terkelg/1d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1D

1D

Make multi-dimensional arrays as flat as a pancake

Installation

npm install 1d

Usage

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

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

About

🥞Make multi-dimensional arrays as flat as a pancake.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages