Skip to content

Instantly share code, notes, and snippets.

@kebien6020
Last active October 11, 2017 04:57
Show Gist options
  • Save kebien6020/e7b1b74239dfbc8e1911b9a9312c5197 to your computer and use it in GitHub Desktop.
Save kebien6020/e7b1b74239dfbc8e1911b9a9312c5197 to your computer and use it in GitHub Desktop.
function* range(...args) {
let start, stop, step
if (args.length === 0) return
if (args.length === 1)
start = 0, stop = args[0], step=1
else
[start, stop, step = 1] = args
for (let i = start; step > 0 ? i < stop : i > stop; i += step)
yield i
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment