Skip to content

Instantly share code, notes, and snippets.

@tildebyte
Last active November 11, 2016 22:51
Show Gist options
  • Save tildebyte/82cc5f284417d6e765f5be41dbc3cc3d to your computer and use it in GitHub Desktop.
Save tildebyte/82cc5f284417d6e765f5be41dbc3cc3d to your computer and use it in GitHub Desktop.
Damn good JS implementation of Python's `range`, using ES6 Generator.
let range = function * (start = 0, end = null, step = 1) {
if (end === null) {
end = start
start = 0
}
let value = start
while (value < end || end < value) {
yield value
value += step
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment