Skip to content

Instantly share code, notes, and snippets.

@msafronov
Created July 3, 2017 20:15
Show Gist options
  • Save msafronov/e0825770cb31efdf4c9df783393e8bb4 to your computer and use it in GitHub Desktop.
Save msafronov/e0825770cb31efdf4c9df783393e8bb4 to your computer and use it in GitHub Desktop.
Number.prototype[Symbol.iterator] = function() {
const end = this;
const inc = this>0;
let i = 0;
console.log(this);
return {
next() {
if (inc?i <= end:i>=end) {
return {
done: false,
value: i+= (inc?1:-1)
};
} else {
return {
done: true
};
}
}
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment