1.0.2 • Published 8 years ago

array-spread v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

array-spread

Why

Concat a matrix array into one flattened array.

Installation

$ npm install --save array-spread

Usage

var arraySpread = require('array-spread');

var matrix = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
];

console.log(arraySpread(matrix));

// Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9]

Test

npm test

How does it work?

var matrix = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
];

console.log([].concat.apply([], matrix));

// Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9]

ES6

let matrix = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
];

console.log([...matrix]);
// Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9]

Contribution

Contributions are appreciated.

License

MIT-licensed. See LICENSE.