https://github.com/ecrmnn/extract-index
Extract values from an array of arrays by index
https://github.com/ecrmnn/extract-index
array-manipulations array-processing arrays extract extract-data
Last synced: 2 months ago
JSON representation
Extract values from an array of arrays by index
- Host: GitHub
- URL: https://github.com/ecrmnn/extract-index
- Owner: ecrmnn
- License: mit
- Created: 2017-04-04T17:38:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-04T17:41:20.000Z (almost 9 years ago)
- Last Synced: 2025-08-30T16:48:02.010Z (4 months ago)
- Topics: array-manipulations, array-processing, arrays, extract, extract-data
- Language: JavaScript
- Homepage: https://npmjs.com/extract-index
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# extract-index
> Extract values from an array of arrays by index
[](https://travis-ci.org/ecrmnn/extract-index.svg?branch=master)
[](http://badge.fury.io/js/extract-index)
[](http://badge.fury.io/js/extract-index)
[](http://badge.fury.io/js/extract-index)
### Installation
```bash
npm install extract-index --save
```
### Usage
```javascript
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](http://danieleckermann.com)