diff options
Diffstat (limited to 'deps/npm/node_modules/cli-table2/node_modules/lodash/internal/createRound.js')
-rw-r--r-- | deps/npm/node_modules/cli-table2/node_modules/lodash/internal/createRound.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/deps/npm/node_modules/cli-table2/node_modules/lodash/internal/createRound.js b/deps/npm/node_modules/cli-table2/node_modules/lodash/internal/createRound.js new file mode 100644 index 0000000000..21240efb62 --- /dev/null +++ b/deps/npm/node_modules/cli-table2/node_modules/lodash/internal/createRound.js @@ -0,0 +1,23 @@ +/** Native method references. */ +var pow = Math.pow; + +/** + * Creates a `_.ceil`, `_.floor`, or `_.round` function. + * + * @private + * @param {string} methodName The name of the `Math` method to use when rounding. + * @returns {Function} Returns the new round function. + */ +function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + precision = precision === undefined ? 0 : (+precision || 0); + if (precision) { + precision = pow(10, precision); + return func(number * precision) / precision; + } + return func(number); + }; +} + +module.exports = createRound; |