number
Number utility functions. Inspired by the ruby Integer object.
install
node
$ npm install --save number
component
$ component install --save jwerle/number
bower
$ bower install number
browser
usage
var number = ; var i = 0;4;; // .downto5;; // .upto5;; // .next; // .even;; // .odd;; // .pred;;
api
.extend(name, isGetter, fn)
You can extend the Number
prototype with number.extend()
name
- A string name of the function being added to theNumber
prototypeisGetter
- ABoolean
indicating whether thefn
handle is a getter functionfn
- A function handle to add to theNumber
prototype
example
Setter the isGetter
flag to true
will define the property as a getter:
number; console; // 2
We can create a function that calculates the GCD (Greatest Common Divisor:
number; 3; // 1
license
MIT