Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / createRound.js
1 /** Native method references. */
2 var pow = Math.pow;
3
4 /**
5  * Creates a `_.ceil`, `_.floor`, or `_.round` function.
6  *
7  * @private
8  * @param {string} methodName The name of the `Math` method to use when rounding.
9  * @returns {Function} Returns the new round function.
10  */
11 function createRound(methodName) {
12   var func = Math[methodName];
13   return function(number, precision) {
14     precision = precision === undefined ? 0 : (+precision || 0);
15     if (precision) {
16       precision = pow(10, precision);
17       return func(number * precision) / precision;
18     }
19     return func(number);
20   };
21 }
22
23 module.exports = createRound;