(a)
| 571 | * @return {Array} An array of objects containing the original value and its identifier |
| 572 | */ |
| 573 | export function identify (a) { |
| 574 | if (!Array.isArray(a)) { |
| 575 | throw new TypeError('Array input expected') |
| 576 | } |
| 577 | |
| 578 | if (a.length === 0) { |
| 579 | return a |
| 580 | } |
| 581 | |
| 582 | const b = [] |
| 583 | let count = 0 |
| 584 | b[0] = { value: a[0], identifier: 0 } |
| 585 | for (let i = 1; i < a.length; i++) { |
| 586 | if (a[i] === a[i - 1]) { |
| 587 | count++ |
| 588 | } else { |
| 589 | count = 0 |
| 590 | } |
| 591 | b.push({ value: a[i], identifier: count }) |
| 592 | } |
| 593 | return b |
| 594 | } |
| 595 | |
| 596 | /** |
| 597 | * Remove the numeric identifier from the elements |
no outgoing calls
no test coverage detected
searching dependent graphs…