From 0a9c9411f032f462522d579784ea5757d4813df7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 22 Aug 2015 18:54:57 -0700 Subject: [PATCH] Update core builds. --- lodash.core.js | 173 ++++++++++++++------------------------------- lodash.core.min.js | 47 ++++++------ 2 files changed, 76 insertions(+), 144 deletions(-) diff --git a/lodash.core.js b/lodash.core.js index 27548941e..b5cc1f998 100644 --- a/lodash.core.js +++ b/lodash.core.js @@ -283,10 +283,10 @@ * `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`, `escape`, * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, * `findLastIndex`, `findLastKey`, `first`, `floor`, `get`, `gt`, `gte`, - * `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, + * `has`, `hasIn`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, * `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, * `isEqualWith`, `isError`, `isFinite` `isFunction`, `isMatch`, `isMatchWith`, - * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, + * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`, * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, @@ -403,7 +403,14 @@ * @returns {Array} Returns `array`. */ function arrayPush(array, values) { - return array.push.apply(array, values); + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; } /** @@ -726,6 +733,19 @@ : (type == 'object' ? baseMatches : baseProperty)(func); } + /** + * The base implementation of `_.keys` which doesn't skip the constructor + * property of prototypes or treat sparse arrays as dense. + * + * @private + * @type Function + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function baseKeys(object) { + return nativeKeys(Object(object)); + } + /** * The base implementation of `_.keysIn` which doesn't skip the constructor * property of prototypes or treat sparse arrays as dense. @@ -735,6 +755,8 @@ * @returns {Array} Returns the array of property names. */ function baseKeysIn(object) { + object = object == null ? object : Object(object); + var result = []; for (var key in object) { result.push(key); @@ -782,10 +804,10 @@ * @returns {Function} Returns the new function. */ function baseMatches(source) { - return function(object) { - var props = keys(object), - length = props.length; + var props = keys(source), + length = props.length; + return function(object) { if (object == null) { return !length; } @@ -960,16 +982,7 @@ * @param {Array} [array=[]] The array to copy values to. * @returns {Array} Returns `array`. */ - function copyArray(source, array) { - var index = -1, - length = source.length; - - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; - } - return array; - } + var copyArray = baseSlice; /** * Copies properties of `source` to `object`. @@ -981,16 +994,7 @@ * @returns {Object} Returns `object`. */ function copyObject(source, props, object) { - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - assignValue(object, key, source[key], object[key]); - } - return object; + return copyObjectWith(source, props, object); } /** @@ -1000,11 +1004,11 @@ * @private * @param {Object} source The object to copy properties from. * @param {Array} props The property names to copy. - * @param {Function} [customizer] The function to customize copied values. * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. * @returns {Object} Returns `object`. */ - function copyObjectWith(source, props, customizer, object) { + function copyObjectWith(source, props, object, customizer) { object || (object = {}); var index = -1, @@ -1195,8 +1199,7 @@ // Ignore non-index properties. while (++index < arrLength) { var arrValue = array[index], - othValue = other[index], - result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; + othValue = other[index]; if (result !== undefined) { if (result) { @@ -1291,8 +1294,7 @@ while (++index < objLength) { key = objProps[index]; var objValue = object[key], - othValue = other[key], - result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; + othValue = other[key]; // Recursively compare objects (susceptible to call stack limits). if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { @@ -1319,12 +1321,12 @@ * Used by `_.defaults` to customize its `_.assign` use. * * @private - * @param {*} objectValue The destination object property value. - * @param {*} sourceValue The source object property value. + * @param {*} objValue The destination object property value. + * @param {*} srcValue The source object property value. * @returns {*} Returns the value to assign to the destination object. */ - function extendDefaults(objectValue, sourceValue) { - return objectValue === undefined ? sourceValue : objectValue; + function extendDefaults(objValue, srcValue) { + return objValue === undefined ? srcValue : objValue; } /** @@ -1349,7 +1351,7 @@ * @returns {Array} Returns the initialized array of property names. */ function initKeys(object) { - var length = object.length; + var length = object ? object.length : 0; length = (length && isLength(length) && (isArray(object) || isArguments(object) || isString(object)) && length) || 0; @@ -1556,6 +1558,8 @@ var length = array ? array.length : 0; if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; + } else { + fromIndex = 0; } var index = (fromIndex || 0) - 1, isReflexive = value === value; @@ -2037,11 +2041,11 @@ * }); * // => 3 * - * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { - * result[key] = n * 3; + * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); * return result; * }, {}); - * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) + * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) */ function reduce(collection, iteratee, accumulator) { return baseReduce(collection, baseIteratee(iteratee), accumulator, arguments.length < 3, baseEach); @@ -2346,42 +2350,6 @@ return before(2, func); } - /** - * Creates a function that invokes `func` with `partial` arguments prepended - * to those provided to the new function. This method is like `_.bind` except - * it does **not** alter the `this` binding. - * - * The `_.partial.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method doesn't set the "length" property of partially - * applied functions. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var greet = function(greeting, name) { - * return greeting + ' ' + name; - * }; - * - * var sayHelloTo = _.partial(greet, 'hello'); - * sayHelloTo('fred'); - * // => 'hello fred' - * - * // using placeholders - * var greetFred = _.partial(greet, _, 'fred'); - * greetFred('hi'); - * // => 'hi fred' - */ - var partial = restParam(function(func, partials) { - return createPartialWrapper(func, PARTIAL_FLAG, undefined, partials); - }); - /** * Creates a function that invokes `func` with the `this` binding of the * created function and arguments from `start` and beyond provided as an array. @@ -2428,32 +2396,6 @@ }; } - /** - * Creates a function that provides `value` to the wrapper function as its - * first argument. Any additional arguments provided to the function are - * appended to those provided to the wrapper function. The wrapper is invoked - * with the `this` binding of the created function. - * - * @static - * @memberOf _ - * @category Function - * @param {*} value The value to wrap. - * @param {Function} wrapper The wrapper function. - * @returns {Function} Returns the new function. - * @example - * - * var p = _.wrap(_.escape, function(func, text) { - * return '

' + func(text) + '

'; - * }); - * - * p('fred, barney, & pebbles'); - * // => '

fred, barney, & pebbles

' - */ - function wrap(value, wrapper) { - wrapper = wrapper == null ? identity : wrapper; - return partial(wrapper, value); - } - /*------------------------------------------------------------------------*/ /** @@ -2868,7 +2810,7 @@ * // => { 'user': 'barney', 'age': 36 } */ var extendWith = createAssigner(function(object, source, customizer) { - copyObjectWith(source, keysIn(source), customizer, object); + copyObjectWith(source, keysIn(source), object, customizer); }); /** @@ -2890,17 +2832,18 @@ } /** - * Checks if `path` is a direct property. + * Checks if `path` is a direct property of `object`. * * @static * @memberOf _ * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` is a direct property, else `false`. + * @returns {boolean} Returns `true` if `path` exists, else `false`. * @example * - * var object = { 'a': { 'b': { 'c': 3 } } }; + * var object = { 'a': { 'b': { 'c': 3 } } }, + * other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) }); * * _.has(object, 'a'); * // => true @@ -2910,6 +2853,9 @@ * * _.has(object, ['a', 'b', 'c']); * // => true + * + * _.has(other, 'a'); + * // => false */ function has(object, path) { return object != null && hasOwnProperty.call(object, path); @@ -2943,11 +2889,9 @@ * // => ['0', '1'] */ function keys(object) { - object = Object(object); - var isProto = isPrototype(object); if (!(isProto || isArrayLike(object))) { - return nativeKeys(object); + return baseKeys(object); } var result = initKeys(object), length = result.length, @@ -2986,8 +2930,6 @@ * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ function keysIn(object) { - object = Object(object); - var index = -1, isProto = isPrototype(object), props = baseKeysIn(object), @@ -3380,7 +3322,6 @@ lodash.defer = defer; lodash.delay = delay; lodash.extend = extend; - lodash.extendWith = extendWith; lodash.filter = filter; lodash.flatten = flatten; lodash.flattenDeep = flattenDeep; @@ -3393,16 +3334,13 @@ lodash.mixin = mixin; lodash.negate = negate; lodash.once = once; - lodash.partial = partial; lodash.pick = pick; - lodash.restParam = restParam; lodash.slice = slice; lodash.sortBy = sortBy; lodash.tap = tap; lodash.thru = thru; lodash.toArray = toArray; lodash.values = values; - lodash.wrap = wrap; // Add aliases. lodash.each = forEach; @@ -3419,7 +3357,6 @@ lodash.find = find; lodash.first = first; lodash.forEach = forEach; - lodash.gt = gt; lodash.has = has; lodash.identity = identity; lodash.indexOf = indexOf; @@ -3434,7 +3371,6 @@ lodash.isRegExp = isRegExp; lodash.isString = isString; lodash.last = last; - lodash.lt = lt; lodash.max = max; lodash.min = min; lodash.noConflict = noConflict; @@ -3485,9 +3421,6 @@ }); // Add chaining functions to the `lodash` wrapper. - lodash.prototype.chain = wrapperChain; - lodash.prototype.concat = wrapperConcat; - lodash.prototype.toString = wrapperToString; lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; /*--------------------------------------------------------------------------*/ diff --git a/lodash.core.min.js b/lodash.core.min.js index 2c00c0455..bb92dd799 100644 --- a/lodash.core.min.js +++ b/lodash.core.min.js @@ -3,27 +3,26 @@ * lodash 3.10.1 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE * Build: `lodash core exports="global,amd" -o ./lodash.core.js` */ -;(function(){function n(n){return n&&n.Object===Object?n:null}function t(n){return _n[n]}function r(n){var t=false;if(null!=n&&typeof n.toString!="function")try{t=!!(n+"")}catch(r){}return t}function e(n){return!!n&&typeof n=="object"}function u(n){if(e(n)&&!Xn(n)){if(n instanceof o)return n;if(In.call(n,"__wrapped__"))return new o(n.__wrapped__,n.__chain__,A(n.__actions__))}return new o(n)}function o(n,t,r){this.__wrapped__=n,this.__actions__=r||[],this.__chain__=!!t}function i(n,t,r,e){for(var u=-1,o=n.length,i=e,c=i;++u=n&&(t=nn),r}}function z(n,t){if(typeof n!="function")throw new TypeError(rn); -return t=Bn(t===nn?n.length-1:Rn(t)||0,0),function(){for(var r=arguments,e=-1,u=Bn(r.length-t,0),o=Array(u);++et}function G(n){return e(n)&&R(n)&&In.call(n,"callee")&&!Dn.call(n,"callee")}function J(n){return W(n)&&kn.call(n)==an}function W(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function H(n){return typeof n=="string"||e(n)&&kn.call(n)==hn}function K(n,t){return n"'`]/g,yn=RegExp(vn.source),gn=/^\d+$/,_n={ -"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},bn={"function":true,object:true},mn=bn[typeof module]&&module&&!module.nodeType?module:null,wn=n(bn[typeof self]&&self),dn=n(bn[typeof window]&&window),jn=n(bn[typeof this]&&this),On=n((bn[typeof exports]&&exports&&!exports.nodeType?exports:null)&&mn&&typeof global=="object"&&global)||dn!==(jn&&jn.window)&&dn||wn||jn||Function("return this")(),An=Array.prototype,En=Object.prototype,xn=String.prototype,In=En.hasOwnProperty,Tn=0,kn=En.toString,Nn=On._,Sn=On.d,Fn=Sn?Sn.e:nn,Dn=En.propertyIsEnumerable,Rn=Math.floor,$n=On.isFinite,qn=Object.keys,Bn=Math.max,Pn=Number.NEGATIVE_INFINITY,Vn=Number.POSITIVE_INFINITY,Mn=9007199254740991,Yn=function(){ -function n(){}return function(t){if(W(t)){n.prototype=t;var r=new n;n.prototype=nn}return r||{}}}(),zn=function(n,t){return function(r,e){if(null==r)return r;if(!R(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++ot&&(t=-t>u?0:u+t),e=e===nn||e>u?u:Rn(e)||0,0>e&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0,e=Array(u);++re&&!c||!i||u&&!f&&a||o&&a){r=1;break n}if(rr?Bn(e+r,0):r),r=(r||0)-1;for(var u=t===t;++rarguments.length,zn)},u.result=function(n,t,r){return t=null==n?nn:n[t],t===nn&&(t=r),J(t)?t.call(n):t},u.size=M,u.some=function(n,t,r){return t=r?nn:t,O(n,_(t))},u.uniqueId=function(n){ -var t=++Tn;return(null==n?"":n+"")+t},Z(u,function(){var n={};return v(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),{chain:false}),u.VERSION="3.10.1",zn("join pop push replace reverse shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?xn:An)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);u.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n); -})}}),u.prototype.chain=function(){return P(this)},u.prototype.concat=Jn,u.prototype.toString=function(){return this.value()+""},u.prototype.run=u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=function(){for(var n=this.__actions__,t=this.__wrapped__,r=-1,e=n.length;++rt&&(t=-t>u?0:u+t),r=r===Z||r>u?u:Dn(r)||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e1?r[u-1]:Z,o=typeof o=="function"?(u--,o):Z;for(t=Object(t);++ef))return false;for(;++c-1&&0==n%1&&t>n}function $(n){return typeof n=="number"&&n>-1&&0==n%1&&Mn>=n}function q(n){var t=!!n&&n.constructor;return n===(typeof t=="function"&&t.prototype||An)}function B(n,t){return Yn(n,typeof t=="function"?t:W)}function V(n){return null==n?0:(n=D(n)?n:K(n),n.length)}function M(n,t){ +var r;if(typeof t!="function")throw new TypeError(tn);return function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=Z),r}}function P(n){var t;if(typeof n!="function")throw new TypeError(tn);return t=qn(t===Z?n.length-1:Dn(t)||0,0),function(){for(var r=arguments,e=-1,u=qn(r.length-t,0),o=Array(u);++et}function z(n){return e(n)&&D(n)&&xn.call(n,"callee")&&!Fn.call(n,"callee")}function C(n){ +return G(n)&&Tn.call(n)==fn}function G(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function J(n){return typeof n=="string"||e(n)&&Tn.call(n)==sn}function H(n,t){return t>n}function K(n){var t=q(n);if(!t&&!D(n))return $n(Object(n));var r,e=F(n),u=e.length,o=!!u;for(r in n)!xn.call(n,r)||o&&R(r,u)||t&&"constructor"==r||e.push(r);return e}function L(n){for(var t=-1,r=q(n),e=g(n),u=e.length,o=F(n),i=o.length,c=!!i;++t"'`]/g,vn=RegExp(hn.source),yn=/^\d+$/,_n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},gn={"function":true,object:true},bn=gn[typeof module]&&module&&!module.nodeType?module:null,mn=n(gn[typeof self]&&self),wn=n(gn[typeof window]&&window),dn=n(gn[typeof this]&&this),jn=n((gn[typeof exports]&&exports&&!exports.nodeType?exports:null)&&bn&&typeof global=="object"&&global)||wn!==(dn&&dn.window)&&wn||mn||dn||Function("return this")(),On=Array.prototype,An=Object.prototype,En=String.prototype,xn=An.hasOwnProperty,In=0,Tn=An.toString,kn=jn._,Nn=jn.d,Sn=Nn?Nn.e:Z,Fn=An.propertyIsEnumerable,Dn=Math.floor,Rn=jn.isFinite,$n=Object.keys,qn=Math.max,Bn=Number.NEGATIVE_INFINITY,Vn=Number.POSITIVE_INFINITY,Mn=9007199254740991,Pn=function(){ +function n(){}return function(t){if(G(t)){n.prototype=t;var r=new n;n.prototype=Z}return r||{}}}(),Yn=function(n,t){return function(r,e){if(null==r)return r;if(!D(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++oe&&!c||!i||u&&!f&&a||o&&a){r=1;break n}if(e>r&&!u||!a||c&&!o&&i||f&&i){r=-1;break n}}r=0}return r||n.b-t.b}),w("c"))},u.tap=function(n,t){return t(n),n},u.thru=function(n,t){return t(n)},u.toArray=function(n){return D(n)?n.length?Cn(n):[]:U(n)},u.values=U,u.each=B,X(u,u),u.clone=function(n){if(G(n))if(Un(n))n=Cn(n);else{var t=K(n);n=A(n,t,void 0)}return n},u.escape=function(n){return(n=null==n?"":n+"")&&vn.test(n)?n.replace(hn,t):n; +},u.every=function(n,t,r){return t=r?Z:t,a(n,_(t))},u.find=function(n,t){return p(n,_(t),Yn)},u.first=function(n){return n?n[0]:Z},u.forEach=B,u.has=function(n,t){return null!=n&&xn.call(n,t)},u.identity=W,u.indexOf=function(n,t,r){var e=n?n.length:0;r=typeof r=="number"?0>r?qn(e+r,0):r:0,r=(r||0)-1;for(var u=t===t;++rarguments.length,Yn)},u.result=Q, +u.size=V,u.some=function(n,t,r){return t=r?Z:t,O(n,_(t))},u.uniqueId=function(n){var t=++In;return(null==n?"":n+"")+t},X(u,function(){var n={};return h(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),{chain:false}),u.VERSION="3.10.1",Yn("join pop push replace reverse shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?En:On)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);u.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){ +return t.apply(r,n)})}}),u.prototype.run=u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=function(){for(var n=this.__actions__,t=this.__wrapped__,r=-1,e=n.length;++r