extract-index
v1.0.0
Published
Extract values from an array of arrays by index
Downloads
2
Readme
extract-index
Extract values from an array of arrays by index
Installation
npm install extract-index --save
Usage
const extract = require('extract-index');
const data = [
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5]
];
extract(data, [0]);
//=> [[1, 1, 1, 1, 1]]
extract(data, [2]);
//=> [[3, 3, 3, 3, 3]]
extract(data, [0, 4]);
//=> [
//=> [1, 1, 1, 1, 1],
//=> [5, 5, 5, 5, 5]
//=> ]
extract(data, [0, 4, 3]);
//=> [
//=> [1, 1, 1, 1, 1],
//=> [5, 5, 5, 5, 5],
//=> [4, 4, 4, 4, 4]
//=> ]
License
MIT © Daniel Eckermann