Counting
Helper function for consuming iterables with a running count, for those cases where you want a counter variable but don't feel like using a for-loop or callback function.
;
API
counting
;
Generates a new iterable from the input that yields an index along with each value from the iterable.
Examples
const array = "a" "b" "c";for const i value of console; // 0: a // 1: b // 2: c ; // Map { 0 => "a", 1 => "b", 2 => "c" } const map = "a" "A" "b" "B" "c" "C";for const i key value of console; // 0: a -> A // 1: b -> B // 2: c -> Cfor const i key of console; // 0: a // 1: b // 2: cfor const i value of console; // 0: A // 1: B // 2: C
LICENSE
The MIT license.