Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/indexes-of-sequence
Find all indexes at which a given sequence of elements can be found in the array
https://github.com/shinnn/indexes-of-sequence
Last synced: 27 days ago
JSON representation
Find all indexes at which a given sequence of elements can be found in the array
- Host: GitHub
- URL: https://github.com/shinnn/indexes-of-sequence
- Owner: shinnn
- Created: 2016-12-14T12:24:05.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-14T10:33:15.000Z (over 7 years ago)
- Last Synced: 2024-04-24T17:06:13.850Z (7 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# indexes-of-sequence
[![NPM version](https://img.shields.io/npm/v/indexes-of-sequence.svg)](https://www.npmjs.com/package/indexes-of-sequence)
[![Bower version](https://img.shields.io/bower/v/indexes-of-sequence.svg)](https://github.com/shinnn/indexes-of-sequence/releases)
[![Build Status](https://travis-ci.org/shinnn/indexes-of-sequence.svg?branch=master)](https://travis-ci.org/shinnn/indexes-of-sequence)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/indexes-of-sequence.svg)](https://coveralls.io/r/shinnn/indexes-of-sequence)
[![dependencies Status](https://david-dm.org/shinnn/indexes-of-sequence/status.svg)](https://david-dm.org/shinnn/indexes-of-sequence)
[![devDependencies Status](https://david-dm.org/shinnn/indexes-of-sequence/dev-status.svg)](https://david-dm.org/shinnn/indexes-of-sequence?type=dev)Find all indexes at which a given sequence of elements can be found in the array
```javascript
import indexesOfSequence from 'indexes-of-sequence';indexOfSequence(['a', 'b', 'a', 'b', 'c', 'd', 'a', 'b', 'c'], ['a', 'b', 'c']); //=> [2, 6]
```## Installation
### [npm](https://www.npmjs.com/)
```
npm install indexes-of-sequence
```### [bower](https://bower.io/)
```
bower install indexes-of-sequence
```## API
### indexesOfSequence(*array*, *searchArray* [, *fromIndex*])
*array*: `Array`
*searchArray*: `Array` (the sequence of values to search for)
*fromIndex*: `Number` (index in the array where to begin searching)
Return: `Array` of `Number` (indexes of the sequence of values)```javascript
indexOfSequence([1, '1', true, '1', 1, Buffer.from('1'), '1', 1, '1'], [1, '1']); //=> [0, 7]
indexOfSequence([1, '1', true, '1', 1, Buffer.from('1'), '1', 1, '1'], [1, '1'], 1); //=> [7]indexOfSequence(['a'], ['b']); //=> []
indexOfSequence(['a'], []); //=> []
indexOfSequence([], ['b']); //=> []
```## Related project
[index-of-sequence](https://github.com/shinnn/index-of-sequence) - Find the first index instead
## License
[Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/deed)