Last active
March 2, 2018 04:25
-
-
Save etale/56d57e7cdd4d43ed55fbdeb2775680d5 to your computer and use it in GitHub Desktop.
an extension for Number
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
(({ ownKeys, defineProperty }, { prototype }) => ownKeys(Math).forEach(property => defineProperty( prototype, property, (value => typeof value === 'function' ? value.length < 2 ? { get() { return value(this) } } : { value(a) { return value(this, a) } } : { value })(Math[property]) ) ))(Reflect, Number) |
Author
etale
commented
Mar 28, 2017
•
Reflect.set(Number.prototype, Symbol.iterator, function* () {
let i = 0; while (i < this) yield i++
})
;(({ ownKeys, defineProperty }, { prototype }) =>
ownKeys(Math).forEach(property =>
defineProperty(
prototype,
property,
(value =>
typeof value === 'function'
? value.length < 2
? {
get() {
return value(this)
}
}
: {
value(a) {
return value(this, a)
}
}
: { value })(Math[property])
)
))(Reflect, Number)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment