JSPM

array-spread

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q29268F
  • License MIT

Concat a matrix array into one flattened array.

Package Exports

  • array-spread

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (array-spread) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.