Created
July 3, 2017 20:15
-
-
Save msafronov/e0825770cb31efdf4c9df783393e8bb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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