Rebuild dist.

This commit is contained in:
John-David Dalton
2014-04-20 13:41:36 -07:00
parent eda9484413
commit 31747dfecd
6 changed files with 432 additions and 457 deletions

240
dist/lodash.compat.js vendored
View File

@@ -26,6 +26,9 @@
/** Used as the property name for wrapper metadata */
var expando = '__lodash@' + version + '__';
/** Used as the TypeError message for "Functions" methods */
var funcErrorText = 'Expected a function';
/** Used to generate unique IDs */
var idCounter = 0;
@@ -464,69 +467,6 @@
return typeof value.toString != 'function' && typeof (value + '') == 'string';
}
/**
* A fallback implementation of `String#trim` to remove leading and trailing
* whitespace or specified characters from `string`.
*
* @private
* @param {string} string The string to trim.
* @param {string} [chars=whitespace] The characters to trim.
* @returns {string} Returns the trimmed string.
*/
function shimTrim(string, chars) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
if (chars == null) {
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
}
chars = String(chars);
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
}
/**
* A fallback implementation of `String#trimLeft` to remove leading whitespace
* or specified characters from `string`.
*
* @private
* @param {string} string The string to trim.
* @param {string} [chars=whitespace] The characters to trim.
* @returns {string} Returns the trimmed string.
*/
function shimTrimLeft(string, chars) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
if (chars == null) {
return string.slice(trimmedLeftIndex(string))
}
chars = String(chars);
return string.slice(charsLeftIndex(string, chars));
}
/**
* A fallback implementation of `String#trimRight` to remove trailing whitespace
* or specified characters from `string`.
*
* @private
* @param {string} string The string to trim.
* @param {string} [chars=whitespace] The characters to trim.
* @returns {string} Returns the trimmed string.
*/
function shimTrimRight(string, chars) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
if (chars == null) {
return string.slice(0, trimmedRightIndex(string) + 1)
}
chars = String(chars);
return string.slice(0, charsRightIndex(string, chars) + 1);
}
/**
* Gets the index of the first non-whitespace character of `string`.
*
@@ -673,10 +613,7 @@
nativeMin = Math.min,
nativeNow = isNative(nativeNow = Date.now) && nativeNow,
nativeParseInt = context.parseInt,
nativeRandom = Math.random,
nativeTrim = isNative(nativeTrim = stringProto.trim) && !nativeTrim.call(whitespace) && nativeTrim,
nativeTrimLeft = isNative(nativeTrimLeft = stringProto.trimLeft) && !nativeTrimLeft.call(whitespace) && nativeTrimLeft,
nativeTrimRight = isNative(nativeTrimRight = stringProto.trimRight) && !nativeTrimRight.call(whitespace) && nativeTrimRight;
nativeRandom = Math.random;
/** Used to lookup built-in constructors by `[[Class]]` */
var ctorByClass = {};
@@ -2141,7 +2078,7 @@
isPartialRight = bitmask & PARTIAL_RIGHT_FLAG;
if (!isBindKey && !isFunction(func)) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
if (isPartial && !partialArgs.length) {
bitmask &= ~PARTIAL_FLAG;
@@ -2224,8 +2161,8 @@
* @returns {Function} Returns the "indexOf" function.
*/
function getIndexOf() {
var result = (result = lodash.indexOf) === indexOf ? baseIndexOf : result;
return result;
var result = lodash.indexOf || indexOf;
return result === indexOf ? baseIndexOf : result;
}
/**
@@ -2369,7 +2306,16 @@
* // => [1, 3]
*/
function difference() {
return baseDifference(arguments[0], baseFlatten(arguments, true, true, 1));
var index = -1,
length = arguments.length;
while (++index < length) {
var value = arguments[index];
if (isArray(value) || isArguments(value)) {
break;
}
}
return baseDifference(arguments[index], baseFlatten(arguments, true, true, ++index));
}
/**
@@ -4870,7 +4816,7 @@
*/
function after(n, func) {
if (!isFunction(func)) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
n = nativeIsFinite(n = +n) ? n : 0;
return function() {
@@ -5034,7 +4980,7 @@
while (length--) {
if (!isFunction(funcs[length])) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
}
return function() {
@@ -5137,7 +5083,7 @@
trailing = true;
if (!isFunction(func)) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
wait = wait < 0 ? 0 : wait;
if (options === true) {
@@ -5242,7 +5188,7 @@
*/
function defer(func) {
if (!isFunction(func)) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
var args = slice(arguments, 1);
return setTimeout(function() { func.apply(undefined, args); }, 1);
@@ -5266,7 +5212,7 @@
*/
function delay(func, wait) {
if (!isFunction(func)) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
var args = slice(arguments, 2);
return setTimeout(function() { func.apply(undefined, args); }, wait);
@@ -5311,7 +5257,7 @@
*/
function memoize(func, resolver) {
if (!isFunction(func) || (resolver && !isFunction(resolver))) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
var memoized = function() {
var cache = memoized.cache,
@@ -5346,7 +5292,7 @@
*/
function negate(predicate) {
if (!isFunction(predicate)) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
return function() {
return !predicate.apply(this, arguments);
@@ -5375,7 +5321,7 @@
result;
if (!isFunction(func)) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
return function() {
if (ran) {
@@ -5497,7 +5443,7 @@
trailing = true;
if (!isFunction(func)) {
throw new TypeError;
throw new TypeError(funcErrorText);
}
if (options === false) {
leading = false;
@@ -6086,14 +6032,14 @@
* // => false
*/
function isArguments(value) {
return value && typeof value == 'object' && typeof value.length == 'number' &&
toString.call(value) == argsClass || false;
return (value && typeof value == 'object' && typeof value.length == 'number' &&
toString.call(value) == argsClass) || false;
}
// fallback for environments without a `[[Class]]` for `arguments` objects
if (!support.argsClass) {
isArguments = function(value) {
return value && typeof value == 'object' && typeof value.length == 'number' &&
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee') || false;
return (value && typeof value == 'object' && typeof value.length == 'number' &&
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee')) || false;
};
}
@@ -6114,8 +6060,8 @@
* // => false
*/
var isArray = nativeIsArray || function(value) {
return value && typeof value == 'object' && typeof value.length == 'number' &&
toString.call(value) == arrayClass || false;
return (value && typeof value == 'object' && typeof value.length == 'number' &&
toString.call(value) == arrayClass) || false;
};
/**
@@ -6135,28 +6081,28 @@
* // => false
*/
function isBoolean(value) {
return value === true || value === false ||
value && typeof value == 'object' && toString.call(value) == boolClass || false;
return (value === true || value === false ||
value && typeof value == 'object' && toString.call(value) == boolClass) || false;
}
/**
* Checks if `value` is a date.
* Checks if `value` is a `Date` object.
*
* @static
* @memberOf _
* @category Objects
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a date, else `false`.
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
* @example
*
* _.isDate(new Date);
* // => true
*
* _.isDate('Wed May 23 2012');
* _.isDate('Mon April 23 2012');
* // => false
*/
function isDate(value) {
return value && typeof value == 'object' && toString.call(value) == dateClass || false;
return (value && typeof value == 'object' && toString.call(value) == dateClass) || false;
}
/**
@@ -6176,14 +6122,14 @@
* // => false
*/
function isElement(value) {
return value && typeof value == 'object' && value.nodeType === 1 &&
(support.nodeClass ? toString.call(value).indexOf('Element') > -1 : isNode(value)) || false;
return (value && typeof value == 'object' && value.nodeType === 1 &&
(support.nodeClass ? toString.call(value).indexOf('Element') > -1 : isNode(value))) || false;
}
// fallback for environments without DOM support
if (!support.dom) {
isElement = function(value) {
return value && typeof value == 'object' && value.nodeType === 1 &&
!isPlainObject(value) || false;
return (value && typeof value == 'object' && value.nodeType === 1 &&
!isPlainObject(value)) || false;
};
}
@@ -6220,7 +6166,7 @@
return result;
}
var length = value.length;
if (length > -1 && length <= maxSafeInteger &&
if ((length > -1 && length <= maxSafeInteger) &&
(isArray(value) || isString(value) || isArguments(value) ||
(typeof value == 'object' && isFunction(value.splice)))) {
return !length;
@@ -6291,6 +6237,27 @@
return baseIsEqual(value, other, callback);
}
/**
* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
* `SyntaxError`, `TypeError`, or `URIError` object.
*
* @static
* @memberOf _
* @category Objects
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an error object, else `false`.
* @example
*
* _.isError(new Error);
* // => true
*
* _.isError(Error);
* // => false
*/
function isError(value) {
return (value && typeof value == 'object' && toString.call(value) == errorClass) || false;
}
/**
* Checks if `value` is, or can be coerced to, a finite number.
*
@@ -6376,7 +6343,7 @@
// and avoid a V8 bug
// https://code.google.com/p/v8/issues/detail?id=2291
var type = typeof value;
return value && (type == 'function' || type == 'object') || false;
return (value && (type == 'function' || type == 'object')) || false;
}
/**
@@ -6432,7 +6399,7 @@
}
/**
* Checks if `value` is a number.
* Checks if `value` is a `Number` primitive or object.
*
* Note: `NaN` is considered a number. See the [ES5 spec](http://es5.github.io/#x8.5)
* for more details.
@@ -6456,7 +6423,7 @@
function isNumber(value) {
var type = typeof value;
return type == 'number' ||
value && type == 'object' && toString.call(value) == numberClass || false;
(value && type == 'object' && toString.call(value) == numberClass) || false;
}
/**
@@ -6503,13 +6470,13 @@
};
/**
* Checks if `value` is a regular expression.
* Checks if `value` is a `RegExp` object.
*
* @static
* @memberOf _
* @category Objects
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a regular expression, else `false`.
* @returns {boolean} Returns `true` if `value` is a regexp object, else `false`.
* @example
*
* _.isRegExp(/abc/);
@@ -6520,12 +6487,12 @@
*/
function isRegExp(value) {
var type = typeof value;
return value && (type == 'function' || type == 'object') &&
toString.call(value) == regexpClass || false;
return (value && (type == 'function' || type == 'object') &&
toString.call(value) == regexpClass) || false;
}
/**
* Checks if `value` is a string.
* Checks if `value` is a `String` primitive or object.
*
* @static
* @memberOf _
@@ -6542,7 +6509,7 @@
*/
function isString(value) {
return typeof value == 'string' ||
value && typeof value == 'object' && toString.call(value) == stringClass || false;
(value && typeof value == 'object' && toString.call(value) == stringClass) || false;
}
/**
@@ -6586,8 +6553,11 @@
* // => ['x', 'y'] (property order is not guaranteed across environments)
*/
var keys = !nativeKeys ? shimKeys : function(object) {
var length = object ? object.length : 0;
if (typeof length == 'number' && length > 0) {
var ctor = object && object.constructor,
length = object ? object.length : 0;
if ((typeof length == 'number' && length > 0) ||
(ctor && object === ctor.prototype)) {
return shimKeys(object);
}
return isObject(object) ? nativeKeys(object) : [];
@@ -6623,7 +6593,9 @@
(support.nonEnumArgs && isArguments(object))) && length) >>> 0;
var keyIndex,
ctor = object.constructor,
index = -1,
isProto = ctor && object === ctor.prototype,
maxIndex = length - 1,
result = Array(length),
skipIndexes = length > 0,
@@ -6634,7 +6606,8 @@
result[index] = String(index);
}
for (var key in object) {
if (!(skipProto && key == 'prototype') &&
if (!(isProto && key == 'constructor') &&
!(skipProto && key == 'prototype') &&
!(skipErrorProps && (key == 'message' || key == 'name')) &&
!(skipIndexes && (keyIndex = +key, keyIndex > -1 && keyIndex <= maxIndex && keyIndex % 1 == 0))) {
result.push(key);
@@ -6645,11 +6618,10 @@
// attribute of an existing property and the `constructor` property of a
// prototype defaults to non-enumerable.
if (support.nonEnumShadows && object !== objectProto) {
var ctor = object.constructor;
index = -1;
length = shadowedProps.length;
if (object === (ctor && ctor.prototype)) {
if (isProto) {
var className = object === stringProto ? stringClass : object === errorProto ? errorClass : toString.call(object),
nonEnum = nonEnumProps[className];
}
@@ -7554,12 +7526,17 @@
* _.trim('-_-fred-_-', '_-');
* // => 'fred'
*/
var trim = !nativeTrim ? shimTrim : function(string, chars) {
if (string == null) {
return '';
function trim(string, chars) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
return chars == null ? nativeTrim.call(string) : shimTrim(string, chars);
};
if (chars == null) {
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
}
chars = String(chars);
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
}
/**
* Removes leading whitespace or specified characters from `string`.
@@ -7578,12 +7555,17 @@
* _.trimLeft('-_-fred-_-', '_-');
* // => 'fred-_-'
*/
var trimLeft = !nativeTrimLeft ? shimTrimLeft : function(string, chars) {
if (string == null) {
return '';
function trimLeft(string, chars) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
return chars == null ? nativeTrimLeft.call(string) : shimTrimLeft(string, chars);
};
if (chars == null) {
return string.slice(trimmedLeftIndex(string))
}
chars = String(chars);
return string.slice(charsLeftIndex(string, chars));
}
/**
* Removes trailing whitespace or specified characters from `string`.
@@ -7602,12 +7584,17 @@
* _.trimRight('-_-fred-_-', '_-');
* // => '-_-fred'
*/
var trimRight = !nativeTrimRight ? shimTrimRight : function(string, chars) {
if (string == null) {
return '';
function trimRight(string, chars) {
string = string == null ? '' : String(string);
if (!string) {
return string;
}
return chars == null ? nativeTrimRight.call(string) : shimTrimRight(string, chars);
};
if (chars == null) {
return string.slice(0, trimmedRightIndex(string) + 1)
}
chars = String(chars);
return string.slice(0, charsRightIndex(string, chars) + 1);
}
/**
* Truncates `string` if it is longer than the given maximum string length.
@@ -8385,6 +8372,7 @@
lodash.isElement = isElement;
lodash.isEmpty = isEmpty;
lodash.isEqual = isEqual;
lodash.isError = isError;
lodash.isFinite = isFinite;
lodash.isFunction = isFunction;
lodash.isNaN = isNaN;