Package Exports
- add-counter
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (add-counter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
add-counter
Adds a counter integer to iterated values.
Installation
Requires Node.js 6.0.0 or above.
npm i add-counter
API
The module exports a single function.
Parameters
iter
(iterable): The underlying iterable.- Optional:
i
(integer): The starting value of the counter. Normally this would be either0
or1
. Defaults to0
.
Return Value
A generator that, for each iterated value x
, yields [i++, x]
Example
const addCounter = require('add-counter')
for (const [i, x] of addCounter(['a', 'b', 'c'])) {
// [0, 'a']
// [1, 'b']
// [2, 'c']
}