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:这是 Node.js
11.15.0
及更高版本的内置功能。 查看 Array.prototype.flat
API
oned(arr, res)
将数组扁平化为一个可爱的一维array
arr
类型:Array
要展平的输入数组
res
类型:Array
默认值:[]
初始数组。
注意:初始数组未被展平
License
MIT © Terkel Gjervig
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