Bump to v4.0.0.

This commit is contained in:
John-David Dalton
2015-12-16 17:53:20 -08:00
parent 94d714007e
commit 8c26e6fd4c
656 changed files with 16423 additions and 11602 deletions

View File

@@ -1,13 +1,7 @@
define([], function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Native method references. */
var pow = Math.pow;
define(['../toInteger', '../toNumber', '../toString'], function(toInteger, toNumber, toString) {
/**
* Creates a `_.ceil`, `_.floor`, or `_.round` function.
* Creates a function like `_.round`.
*
* @private
* @param {string} methodName The name of the `Math` method to use when rounding.
@@ -16,10 +10,16 @@ define([], function() {
function createRound(methodName) {
var func = Math[methodName];
return function(number, precision) {
precision = precision === undefined ? 0 : (+precision || 0);
number = toNumber(number);
precision = toInteger(precision);
if (precision) {
precision = pow(10, precision);
return func(number * precision) / precision;
// Shift with exponential notation to avoid floating-point issues.
// See [MDN](https://mdn.io/round#Examples) for more details.
var pair = (toString(number) + 'e').split('e'),
value = func(pair[0] + 'e' + (+pair[1] + precision));
pair = (toString(value) + 'e').split('e');
return +(pair[0] + 'e' + (+pair[1] - precision));
}
return func(number);
};