Step Generator NPM Package


Using generator functions to automate producing a sequence of numbers.

Published to NPM/step-generator

Installation

npm install --save step-generator

Test

npm test

Usage

Generate a sequence of stepping numbers.

const stepGenerator = require('step-generator')

const evenGenerator = stepGenerator({ start: 2, step: 2 })

const evens = [
  evenGenerator.next().value,
  evenGenerator.next().value,
  evenGenerator.next().value,
  evenGenerator.next().value,
]

console.log(evens)

Output

[2, 4, 6, 8]