0.0.1 • Published 6 years ago

concat-2d-array v0.0.1

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

concat-2d-array

npm.io npm npm

https://github.com/lihang90/concat-2d-array

Split 2d array items to concat to new 2d array

Just like

[
    [1, 2],
    [3, 4],
    [5, 6]
]

convert to

[
    [1, 3, 5],
    [1, 3, 6],
    [1, 4, 5],
    [1, 4, 6],
    [2, 3, 5],
    [2, 3, 6],
    [2, 4, 5],
    [2, 4, 6]
]

How to use

  • npm install
$ npm install concat-2d-array --save
  • use
const concat2dArray = require('concat-2d-array');

const tempArr = [
                    [1, 2],
                    [3, 4],
                    [5, 6]
                ];

const result = concat2dArray(tempArr);

console.log(result);
/*
    [
        [1, 3, 5],
        [1, 3, 6],
        [1, 4, 5],
        [1, 4, 6],
        [2, 3, 5],
        [2, 3, 6],
        [2, 4, 5],
        [2, 4, 6]
    ]
*/

How to test

$ npm install && npm test