Math.format
Method to check values and format numbers.
Usage
Math; // Returns 34.53Math; // Returns 35Math; // Returns 30Math; // Returns 34.52Math; // Returns 34Math; // Returns 30Math; // Returns 34.53Math; // Returns 35Math; // Returns 40Math; // Returns 40Math; // Returns 30Math; // Returns 'custom value'Math; // Returns 'custom value'Math; // Returns 'custom value'Math; // Returns 'custom value'Math; // Returns 12Math; // Returns 12Math; // Returns 10Math; // Returns 12Math; // Returns 'hello 2'Math; // Returns '2 times'Math; // Returns 'hello 2 times'
Unit tests
Unit tests are made with Mocha. Just launch npm test
to run it.
Contribute
Be careful that I use Git-flow to organize the repository branches, so make your pull requests to the develop
branch.
$ npm install$ npm test$ npm run watch
Webpack will compile your code in the build
directory.
Source
- Some very usefull functions come from the marvelous Mozilla Developer Network.
- A nice patch from TheIronDeveloper to workaround the lack of support for the toLocaleString function by Safari.