Get start/end positions where a given value consecutively appears in the array
npm install repetition-ranges


Get start/end positions where a given value consecutively appears in the array
``javascript
import repetitionRanges from 'repetition-ranges';
repetitionRanges(['a', 'b', 'a', 'a', 'b', 'a', 'a', 'a'], 'a');
//=> [{start: 2, end: 3}, {start: 5, end: 7}]
`
| index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| :--------------------------|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
| array | a | b | a | a | b | a | a | a |
| (a appeared) | ○ | | ○ | ○ | | ○ | ○ | ○ |a
| consecutively appeared | | | ○ | ○ | | ○ | ○ | ○ |
``
npm install repetition-ranges
`javascript`
import repetitionRanges from 'repetition-ranges';
array: Array Array
searchValue: any type (the value to resolve its repetition ranges)
Return: of objects with start and end properties
`javascript
repetitionRanges([1, 1, 1], 1); //=> [{start: 0, end: 2}]
repetitionRanges([1, 1, '1', 1, 1, Symbol('1')], 1); //=> [{start: 0, end: 1}, {start: 3, end: 4}]
repetitionRanges(['a', 'b'], 'c'); //=> []
repetitionRanges(['a', 'b', 'a'], 'a'); //=> []
repetitionRanges([], 'a']); //=> []
``
ISC License © 2018 Shinnosuke Watanabe