diff --git a/build.js b/build.js index 99c68240c..ccd74f3b2 100644 --- a/build.js +++ b/build.js @@ -106,7 +106,7 @@ 'reUnescapedHtml': ['keys'], // public functions - 'after': [], + 'after': ['isFunction'], 'assign': ['createIterator'], 'at': ['baseFlatten', 'isString'], 'bind': ['createBound'], @@ -116,15 +116,15 @@ 'clone': ['baseClone', 'baseCreateCallback'], 'cloneDeep': ['baseClone', 'baseCreateCallback'], 'compact': [], - 'compose': [], + 'compose': ['isFunction'], 'contains': ['baseEach', 'getIndexOf', 'isString'], 'countBy': ['createAggregator'], 'createCallback': ['baseCreateCallback', 'baseIsEqual', 'isObject', 'keys'], 'curry': ['createBound'], - 'debounce': ['isObject'], + 'debounce': ['isFunction', 'isObject'], 'defaults': ['createIterator'], - 'defer': ['bind'], - 'delay': [], + 'defer': ['isFunction'], + 'delay': ['isFunction'], 'difference': ['baseFlatten', 'cacheIndexOf', 'createCache', 'getIndexOf', 'releaseObject'], 'escape': ['escapeHtmlChar', 'keys'], 'every': ['baseEach', 'createCallback', 'isArray'], @@ -176,13 +176,13 @@ 'lodash': ['isArray', 'lodashWrapper'], 'map': ['baseEach', 'createCallback', 'isArray'], 'max': ['baseEach', 'charAtCallback', 'createCallback', 'isArray', 'isString'], - 'memoize': [], + 'memoize': ['isFunction'], 'merge': ['baseCreateCallback', 'baseMerge', 'getArray', 'isObject', 'releaseArray'], 'min': ['baseEach', 'charAtCallback', 'createCallback', 'isArray', 'isString'], 'mixin': ['forEach', 'functions', 'isFunction', 'lodash'], 'noConflict': [], 'omit': ['baseFlatten', 'createCallback', 'forIn', 'getIndexOf'], - 'once': [], + 'once': ['isFunction'], 'pairs': ['keys'], 'parseInt': ['isString'], 'partial': ['createBound'], @@ -206,7 +206,7 @@ 'sortedIndex': ['createCallback', 'identity'], 'tap': [], 'template': ['defaults', 'escape', 'escapeStringChar', 'keys', 'values'], - 'throttle': ['debounce', 'getObject', 'isObject', 'releaseObject'], + 'throttle': ['debounce', 'getObject', 'isFunction', 'isObject', 'releaseObject'], 'times': ['baseCreateCallback'], 'toArray': ['isString', 'slice', 'values'], 'transform': ['baseCreateCallback', 'baseEach', 'createObject', 'forOwn', 'isArray'], @@ -217,7 +217,7 @@ 'values': ['keys'], 'where': ['filter'], 'without': ['difference'], - 'wrap': [], + 'wrap': ['isFunction'], 'wrapperChain': [], 'wrapperToString': [], 'wrapperValueOf': [], @@ -2812,7 +2812,6 @@ // update dependencies if (isLegacy) { - _.pull(funcDepMap.defer, 'bind'); _.pull(propDepMap.createBound, 'support'); funcDepMap.isPlainObject = funcDepMap.shimIsPlainObject.slice(); @@ -3165,6 +3164,11 @@ source = removeIsFunctionFork(source); source = removeCreateObjectFork(source); + // remove Adobe JS engine fix from `compareAscending` + source = source.replace(matchFunction(source, 'compareAscending'), function(match) { + return match.replace(/(?: *\/\/.*\n)*( *return ai[^:]+:).+/, '$1 1;'); + }); + // remove `shimIsPlainObject` from `_.isPlainObject` source = source.replace(matchFunction(source, 'isPlainObject'), function(match) { return match.replace(/!getPrototypeOf[^:]+:\s*/, ''); diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 7a44d1cad..198536fe4 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -254,7 +254,11 @@ return -1; } } - return ai < bi ? -1 : 1; + // The JS engine embedded in Adobe applications like InDesign has a buggy + // `Array#sort` implementation that causes it, under certain circumstances, + // to return the same value for `a` and `b`. + // See https://github.com/jashkenas/underscore/pull/1247 + return ai < bi ? -1 : (ai > bi ? 1 : 0); } /** @@ -494,8 +498,7 @@ setImmediate = context.setImmediate, setTimeout = context.setTimeout, splice = arrayRef.splice, - toString = objectProto.toString, - unshift = arrayRef.unshift; + toString = objectProto.toString; /* Native method shortcuts for methods with the same name as other `lodash` methods */ var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind, @@ -1385,60 +1388,59 @@ } /** - * Creates a function that, when called, invokes `func` with the `this` binding - * of `thisArg` and prepends any `partialArgs` to the arguments provided to the - * bound function. + * Creates a function that, when called, either curries or invokes `func` + * with an optional `this` binding and partially applied arguments. * * @private - * @param {Function|String} func The function to bind or the method name. - * @param {Mixed} thisArg The `this` binding of `func`. - * @param {Array} partialArgs An array of arguments to be prepended to those provided to the new function. - * @param {Array} partialRightArgs An array of arguments to be appended to those provided to the new function. - * @param {Boolean} [isPartial=false] A flag to indicate performing only partial application. - * @param {Boolean} [isAlt=false] A flag to indicate `_.bindKey` or `_.partialRight` behavior. + * @param {Function|String} func The function or method name to reference. + * @param {Number} bitmask The bitmask of method flags to compose. + * The bitmask may be composed of the following flags: + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` + * 8 - `_.partial` + * 16 - `_.partialRight` + * @param {Array} [partialArgs] An array of arguments to prepend to those + * provided to the new function. + * @param {Array} [partialRightArgs] An array of arguments to append to those + * provided to the new function. + * @param {Mixed} [thisArg] The `this` binding of `func`. + * @param {Number} [arity] The arity of `func`. * @returns {Function} Returns the new bound function. */ - function createBound(func, thisArg, partialArgs, partialRightArgs, isPartial, isAlt) { - var isBindKey = isAlt && !isPartial, - isFunc = isFunction(func); + function createBound(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { + var isBind = bitmask & 1, + isBindKey = bitmask & 2, + isCurry = bitmask & 4, + isPartialRight = bitmask & 16; - // throw if `func` is not a function when not behaving as `_.bindKey` - if (!isFunc && !isBindKey) { + if (!isBindKey && !isFunction(func)) { throw new TypeError; } + var bindData = func && func.__bindData__; + if (bindData) { + if (isBind && !(bindData[1] & 1)) { + bindData[4] = thisArg; + } + if (isCurry && !(bindData[1] & 4)) { + bindData[5] = arity; + } + if (partialArgs) { + push.apply(bindData[2] || (bindData[2] = []), partialArgs); + } + if (partialRightArgs) { + push.apply(bindData[3] || (bindData[3] = []), partialRightArgs); + } + bindData[1] |= bitmask; + return createBound.apply(null, bindData); + } // use `Function#bind` if it exists and is fast // (in V8 `Function#bind` is slower except when partially applied) - if (!isPartial && !isAlt && !partialRightArgs.length && (support.fastBind || (nativeBind && partialArgs.length))) { - var args = [func, thisArg]; - push.apply(args, partialArgs); - var bound = nativeBind.call.apply(nativeBind, args); - } - else { - bound = function() { - // `Function#bind` spec - // http://es5.github.io/#x15.3.4.5 - var args = arguments, - thisBinding = isPartial ? this : thisArg; - - if (isBindKey) { - func = thisArg[key]; - } - if (partialArgs.length || partialRightArgs.length) { - unshift.apply(args, partialArgs); - push.apply(args, partialRightArgs); - } - if (this instanceof bound) { - // ensure `new bound` is an instance of `func` - thisBinding = createObject(func.prototype); - - // mimic the constructor's `return` behavior - // http://es5.github.io/#x13.2.2 - var result = func.apply(thisBinding, args); - return isObject(result) ? result : thisBinding; - } - return func.apply(thisBinding, args); - }; + if (isBind && !(isBindKey || isCurry || isPartialRight) && + (support.fastBind || (nativeBind && partialArgs.length))) {; } + // take a snapshot of `arguments` before juggling + bindData = nativeSlice.call(arguments); if (isBindKey) { var key = thisArg; thisArg = func; @@ -4580,7 +4582,7 @@ */ function range(start, end, step) { start = +start || 0; - step = typeof step == 'number' ? step : 1; + step = typeof step == 'number' ? step : (+step || 1); if (end == null) { end = start; @@ -4965,6 +4967,9 @@ * // `renderNotes` is run once, after all notes have saved */ function after(n, func) { + if (!isFunction(func)) { + throw new TypeError; + } return function() { if (--n < 1) { return func.apply(this, arguments); @@ -4995,7 +5000,7 @@ * // => 'hi moe' */ function bind(func, thisArg) { - return createBound(func, thisArg, nativeSlice.call(arguments, 2), []); + return createBound(func, 9, nativeSlice.call(arguments, 2), null, thisArg); } /** @@ -5069,7 +5074,7 @@ * // => 'hi, moe!' */ function bindKey(object, key) { - return createBound(object, key, nativeSlice.call(arguments, 2), [], false, true); + return createBound(object, 11, nativeSlice.call(arguments, 2), null, key); } /** @@ -5103,7 +5108,14 @@ * // => 'Hiya Jerome!' */ function compose() { - var funcs = arguments; + var funcs = arguments, + length = funcs.length || 1; + + while (length--) { + if (!isFunction(funcs[length])) { + throw new TypeError; + } + } return function() { var args = arguments, length = funcs.length; @@ -5183,6 +5195,39 @@ }; } + /** + * Creates a function which accepts one or more arguments of `func` that when + * invoked either executes `func` returning its result, if all `func` arguments + * have been provided, or returns a function that accepts one or more of the + * remaining `func` arguments, and so on. The arity of `func` can be specified + * if `func.length` is not sufficient. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to curry. + * @param {Number} [arity=func.length] The arity of `func`. + * @returns {Function} Returns the new curried function. + * @example + * + * var curried = _.curry(function(a, b, c) { + * console.log(a + b + c); + * }); + * + * curried(1)(2)(3); + * // => 6 + * + * curried(1, 2)(3); + * // => 6 + * + * curried(1, 2, 3); + * // => 6 + */ + function curry(func, arity) { + arity = typeof arity == 'number' ? arity : (+arity || func.length); + return createBound(func, 4, null, null, null, arity); + } + /** * Creates a function that will delay the execution of `func` until after * `wait` milliseconds have elapsed since the last time it was invoked. @@ -5233,32 +5278,9 @@ timeoutId = null, trailing = true; - function clear() { - clearTimeout(maxTimeoutId); - clearTimeout(timeoutId); - callCount = 0; - maxTimeoutId = timeoutId = null; + if (!isFunction(func)) { + throw new TypeError; } - - function delayed() { - var isCalled = trailing && (!leading || callCount > 1); - clear(); - if (isCalled) { - if (maxWait !== false) { - lastCalled = new Date; - } - result = func.apply(thisArg, args); - } - } - - function maxDelayed() { - clear(); - if (trailing || (maxWait !== wait)) { - lastCalled = new Date; - result = func.apply(thisArg, args); - } - } - wait = nativeMax(0, wait || 0); if (options === true) { var leading = true; @@ -5268,6 +5290,32 @@ maxWait = 'maxWait' in options && nativeMax(wait, options.maxWait || 0); trailing = 'trailing' in options ? options.trailing : trailing; } + var clear = function() { + clearTimeout(maxTimeoutId); + clearTimeout(timeoutId); + callCount = 0; + maxTimeoutId = timeoutId = null; + }; + + var delayed = function() { + var isCalled = trailing && (!leading || callCount > 1); + clear(); + if (isCalled) { + if (maxWait !== false) { + lastCalled = new Date; + } + result = func.apply(thisArg, args); + } + }; + + var maxDelayed = function() { + clear(); + if (trailing || (maxWait !== wait)) { + lastCalled = new Date; + result = func.apply(thisArg, args); + } + }; + return function() { args = arguments; thisArg = this; @@ -5320,12 +5368,20 @@ * // returns from the function before 'deferred' is logged */ function defer(func) { + if (!isFunction(func)) { + throw new TypeError; + } var args = nativeSlice.call(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); } - // use `setImmediate` if it's available in Node.js + // use `setImmediate` if available in Node.js if (isV8 && freeModule && typeof setImmediate == 'function') { - defer = bind(setImmediate, context); + defer = function(func) { + if (!isFunction(func)) { + throw new TypeError; + } + return setImmediate.apply(context, arguments); + }; } /** @@ -5346,6 +5402,9 @@ * // => 'logged later' (Appears after one second.) */ function delay(func, wait) { + if (!isFunction(func)) { + throw new TypeError; + } var args = nativeSlice.call(arguments, 2); return setTimeout(function() { func.apply(undefined, args); }, wait); } @@ -5371,7 +5430,10 @@ * }); */ function memoize(func, resolver) { - function memoized() { + if (!isFunction(func)) { + throw new TypeError; + } + var memoized = function() { var cache = memoized.cache, key = keyPrefix + (resolver ? resolver.apply(this, arguments) : arguments[0]); @@ -5404,6 +5466,9 @@ var ran, result; + if (!isFunction(func)) { + throw new TypeError; + } return function() { if (ran) { return result; @@ -5436,7 +5501,7 @@ * // => 'hi moe' */ function partial(func) { - return createBound(func, null, nativeSlice.call(arguments, 1), [], true); + return createBound(func, 8, nativeSlice.call(arguments, 1)); } /** @@ -5467,7 +5532,7 @@ * // => { '_': _, 'jq': $ } */ function partialRight(func) { - return createBound(func, null, [], nativeSlice.call(arguments, 1), true, true); + return createBound(func, 16, null, nativeSlice.call(arguments, 1)); } /** @@ -5505,6 +5570,9 @@ var leading = true, trailing = true; + if (!isFunction(func)) { + throw new TypeError; + } if (options === false) { leading = false; } else if (isObject(options)) { @@ -5543,6 +5611,9 @@ * // => 'before, hello moe, after' */ function wrap(value, wrapper) { + if (!isFunction(wrapper)) { + throw new TypeError; + } return function() { var args = [value]; push.apply(args, arguments); @@ -6133,6 +6204,7 @@ lodash.compose = compose; lodash.countBy = countBy; lodash.createCallback = createCallback; + lodash.curry = curry; lodash.debounce = debounce; lodash.defaults = defaults; lodash.defer = defer; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 707e20af1..c530b57d9 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -3,52 +3,52 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.compat.js` */ -;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=E&&i===t,v=u||p?f():l; -if(p){var h=a(v);h?(i=e,v=h):(p=b,v=u?v:(s(v),l))}for(;++oi(v,y))&&((u||p)&&v.push(y),l.push(h))}return p?(s(v.b),g(v)):u&&s(v),l}function ot(n){return function(t,e,r){var u={};return e=_.createCallback(e,r,3),Et(t,function(t,r,o){r=te(e(t,r,o)),n(u,t,r,o)}),u}}function at(n,t,e,r,u,o){var a=o&&!u;if(!mt(n)&&!a)throw new ee;if(u||o||r.length||!($e.fastBind||we&&e.length))i=function(){var o=arguments,c=u?this:t;return a&&(n=t[f]),(e.length||r.length)&&(je.apply(o,e),he.apply(o,r)),this instanceof i?(c=ft(n.prototype),o=n.apply(c,o),dt(o)?o:c):n.apply(c,o) -};else{o=[n,t],he.apply(o,e);var i=we.call.apply(we,o)}if(a){var f=t;t=n}return i}function it(){var n=c();n.h=L,n.b=n.c=n.g=n.i="",n.e="t",n.j=m;for(var t,e=0;t=arguments[e];e++)for(var r in t)n[r]=t[r];e=n.a,n.d=/^[^,]+/.exec(e)[0],t=Qt,e="return function("+e+"){",r="var n,t="+n.d+",E="+n.e+";if(!t)return E;"+n.i+";",n.b?(r+="var u=t.length;n=-1;if("+n.b+"){",$e.unindexedChars&&(r+="if(s(t)){t=t.split('')}"),r+="while(++nk;k++)r+="n='"+n.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",n.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+n.g+"}"; -r+="}"}return(n.b||$e.nonEnumArgs)&&(r+="}"),r+=n.c+";return E",t=t("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",e+r+"}"),g(n),t(Y,G,ue,ve,x,gt,ze,_t,n.f,oe,X,De,V,ae,_e)}function ft(n){return dt(n)?ke(n):{}}function ct(n){return Ge[n]}function lt(){var n=(n=_.indexOf)===Rt?t:n;return n}function pt(n){var t,e;return!n||_e.call(n)!=H||(t=n.constructor,mt(t)&&!(t instanceof t))||!$e.argsClass&>(n)||!$e.nodeClass&&l(n)?b:$e.ownLast?(Xe(n,function(n,t,r){return e=ve.call(r,t),b}),e!==false):(Xe(n,function(n,t){e=t -}),e===y||ve.call(n,e))}function st(n){return Je[n]}function gt(n){return n&&typeof n=="object"?_e.call(n)==T:b}function vt(n,t,e){var r=Te(n),u=r.length;for(t=Y(t,e,3);u--&&(e=r[u],!(t(n[e],e,n)===false)););return n}function ht(n){var t=[];return Xe(n,function(n,e){mt(n)&&t.push(e)}),t.sort()}function yt(n){for(var t=-1,e=Te(n),r=e.length,u={};++te?Se(0,o+e):e)||0,o&&typeof o=="number"?a=-1<(_t(n)?n.indexOf(t,e):u(n,t,e)):Ue(n,function(n){return++ro&&(o=i) -}}else t=!t&&_t(n)?u:_.createCallback(t,e,3),Ue(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,o=n)});return o}function It(n,t,e,r){var u=3>arguments.length;if(t=Y(t,r,4),ze(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=Y(t,r,4),Ot(n,function(n,r,o){e=u?(u=b,n):t(e,n,r,o)}),e}function Pt(n,t,e){var r;if(t=_.createCallback(t,e,3),ze(n)){e=-1;for(var u=n.length;++e=E&&u===t;if(c){var l=a(i);l?(u=e,i=l):c=b}for(;++ru(i,l)&&f.push(l);return c&&g(i),f}function Ft(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=d){var o=-1;for(t=_.createCallback(t,e,3);++or?Se(0,u+r):r||0}else if(r)return r=$t(n,e),n[r]===e?r:-1; -return n?t(n,e,r):-1}function Dt(n,t,e){if(typeof t!="number"&&t!=d){var r=0,u=-1,o=n?n.length:0;for(t=_.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tc&&(i=n.apply(f,a));else{var e=new Vt;!s&&!h&&(l=e);var r=p-(e-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:F,variable:"",imports:{_:_}},ke||(ft=function(n){if(dt(n)){p.prototype=n;var t=new p;p.prototype=d}return t||{}}),$e.argsClass||(gt=function(n){return n&&typeof n=="object"?ve.call(n,"callee"):b});var ze=xe||function(n){return n&&typeof n=="object"?_e.call(n)==q:b},Le=it({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),Te=Oe?function(n){return dt(n)?$e.enumPrototypes&&typeof n=="function"||$e.nonEnumArgs&&n.length&>(n)?Le(n):Oe(n):[] -}:Le,qe={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:Te,g:"if(e(t[n],n,g)===false)return E"},Ke={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Je=yt(Ge),Me=ne("("+Te(Je).join("|")+")","g"),He=ne("["+Te(Ge).join("")+"]","g"),Ue=it(qe),Ve=it(Ke,{i:Ke.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),Qe=it(Ke),Xe=it(qe,We,{j:b}),Ye=it(qe,We); -mt(/x/)&&(mt=function(n){return typeof n=="function"&&_e.call(n)==J});var Ze=ge?function(n){if(!n||_e.call(n)!=H||!$e.argsClass&>(n))return b;var t=n.valueOf,e=typeof t=="function"&&(e=ge(t))&&ge(e);return e?n==e||ge(n)==e:pt(n)}:pt,nr=ot(function(n,t,e){ve.call(n,e)?n[e]++:n[e]=1}),tr=ot(function(n,t,e){(ve.call(n,e)?n[e]:n[e]=[]).push(t)}),er=ot(function(n,t,e){n[e]=t}),rr=St;Fe&&nt&&typeof me=="function"&&(Wt=qt(me,r));var ur=8==Ie(S+"08")?Ie:function(n,t){return Ie(_t(n)?n.replace(R,""):n,t||0) -};return _.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},_.assign=Ve,_.at=function(n){var t=-1,e=Z(arguments,m,b,1),r=e.length,u=Ht(r);for($e.unindexedChars&&_t(n)&&(n=n.split(""));++t=E&&a(o?r[o]:h)}n:for(;++c(m?e(m,y):l(h,y))){for(o=u,(m||h).push(y);--o;)if(m=i[o],0>(m?e(m,y):l(r[o],y)))continue n; -v.push(y)}}for(;u--;)(m=i[u])&&g(m);return s(i),s(h),v},_.invert=yt,_.invoke=function(n,t){var e=Pe.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Ht(typeof o=="number"?o:0);return Et(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},_.keys=Te,_.map=St,_.max=At,_.memoize=function(n,t){function e(){var r=e.cache,u=C+(t?t.apply(this,arguments):arguments[0]);return ve.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},_.merge=function(n){var t=arguments,e=2;if(!dt(n))return n; -if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},_.once=function(n){var t,e;return function(){return t?e:(t=m,e=n.apply(this,arguments),n=d,e)}},_.pairs=function(n){for(var t=-1,e=Te(n),r=e.length,u=Ht(r);++te?Se(0,r+e):Ae(e,r-1))+1);r--;)if(n[r]===t)return r; -return-1},_.mixin=Jt,_.noConflict=function(){return r._=ie,this},_.parseInt=ur,_.random=function(n,t){n==d&&t==d&&(t=1),n=+n||0,t==d?(t=n,n=0):t=+t||0;var e=Be();return n%1||t%1?n+Ae(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+se(e*(t-n+1))},_.reduce=It,_.reduceRight=Bt,_.result=function(n,t){var e=n?n[t]:y;return mt(e)?n[t]():e},_.runInContext=h,_.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Te(n).length},_.some=Pt,_.sortedIndex=$t,_.template=function(n,t,e){var r=_.templateSettings; -n||(n=""),e=Qe({},e,r);var u,o=Qe({},e.imports,r.imports),r=Te(o),o=jt(o),a=0,f=e.interpolate||D,c="__p+='",f=ne((e.escape||D).source+"|"+f.source+"|"+(f===F?P:D).source+"|"+(e.evaluate||D).source+"|$","g");n.replace(f,function(t,e,r,o,f,l){return r||(r=o),c+=n.slice(a,l).replace($,i),e&&(c+="'+__e("+e+")+'"),f&&(u=m,c+="';"+f+";__p+='"),r&&(c+="'+((__t=("+r+"))==null?'':__t)+'"),a=l+t.length,t}),c+="';\n",f=e=e.variable,f||(e="obj",c="with("+e+"){"+c+"}"),c=(u?c.replace(A,""):c).replace(I,"$1").replace(B,"$1;"),c="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}"; -try{var l=Qt(r,"return "+c).apply(y,o)}catch(p){throw p.source=c,p}return t?l(t):(l.source=c,l)},_.unescape=function(n){return n==d?"":te(n).replace(Me,st)},_.uniqueId=function(n){var t=++w;return te(n==d?"":n)+t},_.all=kt,_.any=Pt,_.detect=Ct,_.findWhere=Ct,_.foldl=It,_.foldr=Bt,_.include=wt,_.inject=It,Ye(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return he.apply(t,arguments),t=n.apply(_,t),e?new j(t,e):t})}),_.first=Ft,_.last=function(n,t,e){if(n){var r=0,u=n.length; -if(typeof t!="number"&&t!=d){var o=u;for(t=_.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,r==d||e)return n[u-1];return v(n,Se(0,u-r))}},_.take=Ft,_.head=Ft,Ye(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(t,e){var r=this.__chain__,u=n(this.__wrapped__,t,e);return!r&&(t==d||e&&typeof t!="function")?u:new j(u,r)})}),_.VERSION="1.3.1",_.prototype.chain=function(){return this.__chain__=m,this},_.prototype.toString=function(){return te(this.__wrapped__)},_.prototype.value=Mt,_.prototype.valueOf=Mt,Ue(["join","pop","shift"],function(n){var t=re[n]; -_.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new j(e,n):e}}),Ue(["push","reverse","sort","unshift"],function(n){var t=re[n];_.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ue(["concat","slice","splice"],function(n){var t=re[n];_.prototype[n]=function(){return new j(t.apply(this.__wrapped__,arguments),this.__chain__)}}),$e.spliceObjects||Ue(["pop","shift","splice"],function(n){var t=re[n],e="splice"==n;_.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments); -return 0===r.length&&delete r[0],n||e?new j(u,n):u}}),_}var y,m=!0,d=null,b=!1,_=[],j=[],w=0,x={},C=+new Date+"",E=75,O=40,S=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",A=/\b__p\+='';/g,I=/\b(__p\+=)''\+/g,B=/(__e\(.*?\)|\b__t\))\+'';/g,P=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,N=/\w*$/,F=/<%=([\s\S]+?)%>/g,R=RegExp("^["+S+"]*0+(?=.$)"),D=/($^)/,$=/['\n\r\t\u2028\u2029\\]/g,z="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),L="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),T="[object Arguments]",q="[object Array]",K="[object Boolean]",W="[object Date]",G="[object Error]",J="[object Function]",M="[object Number]",H="[object Object]",U="[object RegExp]",V="[object String]",Q={}; -Q[J]=b,Q[T]=Q[q]=Q[K]=Q[W]=Q[M]=Q[H]=Q[U]=Q[V]=m;var X={"boolean":b,"function":m,object:m,number:b,string:b,undefined:b},Y={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Z=X[typeof exports]&&exports,nt=X[typeof module]&&module&&module.exports==Z&&module,tt=X[typeof global]&&global;!tt||tt.global!==tt&&tt.window!==tt||(n=tt);var et=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=et, define(function(){return et})):Z&&!Z.nodeType?nt?(nt.exports=et)._=et:Z._=et:n._=et +;!function(n){function t(n,t,r){r=(r||0)-1;for(var e=n?n.length:0;++rt||typeof n=="undefined")return 1;if(ne?1:0}function a(n){var t=-1,r=n.length,u=n[0],o=n[r-1];if(u&&typeof u=="object"&&o&&typeof o=="object")return b;for(u=c(),u["false"]=u["null"]=u["true"]=u.undefined=b,o=c(),o.b=n,o.k=u,o.push=e;++tr?0:r);++e=E&&i===t,h=u||p?f():l; +if(p){var v=a(h);v?(i=r,h=v):(p=b,h=u?h:(s(h),l))}for(;++oi(h,y))&&((u||p)&&h.push(y),l.push(v))}return p?(s(h.b),g(h)):u&&s(h),l}function ot(n){return function(t,r,e){var u={};return r=_.createCallback(r,e,3),Et(t,function(t,e,o){e=tr(r(t,e,o)),n(u,t,e,o)}),u}}function at(n,t,r,e,u,o){var a=1&t,i=2&t,f=4&t;if(!i&&!mt(n))throw new rr;var c=n&&n.__bindData__;return c?(a&&!(1&c[1])&&(c[4]=u),f&&!(4&c[1])&&(c[5]=o),r&&vr.apply(c[2]||(c[2]=[]),r),e&&vr.apply(c[3]||(c[3]=[]),e),c[1]|=t,at.apply(d,c)):(Br.call(arguments),i&&(u=n),bound) +}function it(){var n=c();n.h=L,n.b=n.c=n.g=n.i="",n.e="t",n.j=m;for(var t,r=0;t=arguments[r];r++)for(var e in t)n[e]=t[e];r=n.a,n.d=/^[^,]+/.exec(r)[0],t=Qt,r="return function("+r+"){",e="var n,t="+n.d+",E="+n.e+";if(!t)return E;"+n.i+";",n.b?(e+="var u=t.length;n=-1;if("+n.b+"){",Rr.unindexedChars&&(e+="if(s(t)){t=t.split('')}"),e+="while(++nk;k++)e+="n='"+n.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",n.j||(e+="||(!x[n]&&t[n]!==A[n])"),e+="){"+n.g+"}"; +e+="}"}return(n.b||Rr.nonEnumArgs)&&(e+="}"),e+=n.c+";return E",t=t("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",r+e+"}"),g(n),t(Y,G,ur,hr,x,gt,$r,_t,n.f,or,X,Fr,V,ar,_r)}function ft(n){return dt(n)?jr(n):{}}function ct(n){return Wr[n]}function lt(){var n=(n=_.indexOf)===Ft?t:n;return n}function pt(n){var t,r;return!n||_r.call(n)!=H||(t=n.constructor,mt(t)&&!(t instanceof t))||!Rr.argsClass&>(n)||!Rr.nodeClass&&l(n)?b:Rr.ownLast?(Qr(n,function(n,t,e){return r=hr.call(e,t),b}),r!==false):(Qr(n,function(n,t){r=t +}),r===y||hr.call(n,r))}function st(n){return Gr[n]}function gt(n){return n&&typeof n=="object"?_r.call(n)==T:b}function ht(n,t,r){var e=Lr(n),u=e.length;for(t=Y(t,r,3);u--&&(r=e[u],!(t(n[r],r,n)===false)););return n}function vt(n){var t=[];return Qr(n,function(n,r){mt(n)&&t.push(r)}),t.sort()}function yt(n){for(var t=-1,r=Lr(n),e=r.length,u={};++tr?Or(0,o+r):r)||0,o&&typeof o=="number"?a=-1<(_t(n)?n.indexOf(t,r):u(n,t,r)):Hr(n,function(n){return++eo&&(o=i) +}}else t=!t&&_t(n)?u:_.createCallback(t,r,3),Hr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function It(n,t,r,e){var u=3>arguments.length;if(t=Y(t,e,4),$r(n)){var o=-1,a=n.length;for(u&&(r=n[++o]);++oarguments.length;return t=Y(t,e,4),Ot(n,function(n,e,o){r=u?(u=b,n):t(r,n,e,o)}),r}function Pt(n,t,r){var e;if(t=_.createCallback(t,r,3),$r(n)){r=-1;for(var u=n.length;++r=E&&u===t;if(c){var l=a(i);l?(u=r,i=l):c=b}for(;++eu(i,l)&&f.push(l);return c&&g(i),f}function Dt(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=d){var o=-1;for(t=_.createCallback(t,r,3);++oe?Or(0,u+e):e||0}else if(e)return e=$t(n,r),n[e]===r?e:-1; +return n?t(n,r,e):-1}function Rt(n,t,r){if(typeof t!="number"&&t!=d){var e=0,u=-1,o=n?n.length:0;for(t=_.createCallback(t,r,3);++u>>1,r(n[e])r?0:r);++tc&&(i=n.apply(f,a));else{var r=new Vt;!s&&!v&&(l=r);var o=p-(r-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:D,variable:"",imports:{_:_}},jr||(ft=function(n){if(dt(n)){p.prototype=n;var t=new p;p.prototype=d}return t||{}}),Rr.argsClass||(gt=function(n){return n&&typeof n=="object"?hr.call(n,"callee"):b});var $r=kr||function(n){return n&&typeof n=="object"?_r.call(n)==q:b},zr=it({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),Lr=Er?function(n){return dt(n)?Rr.enumPrototypes&&typeof n=="function"||Rr.nonEnumArgs&&n.length&>(n)?zr(n):Er(n):[] +}:zr,Tr={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:Lr,g:"if(e(t[n],n,g)===false)return E"},qr={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Gr=yt(Wr),Jr=nr("("+Lr(Gr).join("|")+")","g"),Mr=nr("["+Lr(Wr).join("")+"]","g"),Hr=it(Tr),Ur=it(qr,{i:qr.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),Vr=it(qr),Qr=it(Tr,Kr,{j:b}),Xr=it(Tr,Kr); +mt(/x/)&&(mt=function(n){return typeof n=="function"&&_r.call(n)==J});var Yr=gr?function(n){if(!n||_r.call(n)!=H||!Rr.argsClass&>(n))return b;var t=n.valueOf,r=typeof t=="function"&&(r=gr(t))&&gr(r);return r?n==r||gr(n)==r:pt(n)}:pt,Zr=ot(function(n,t,r){hr.call(n,r)?n[r]++:n[r]=1}),ne=ot(function(n,t,r){(hr.call(n,r)?n[r]:n[r]=[]).push(t)}),te=ot(function(n,t,r){n[r]=t}),re=St;Nr&&nt&&typeof mr=="function"&&(Wt=function(n){if(!mt(n))throw new rr;return mr.apply(e,arguments)});var ee=8==Ar(S+"08")?Ar:function(n,t){return Ar(_t(n)?n.replace(F,""):n,t||0) +};return _.after=function(n,t){if(!mt(t))throw new rr;return function(){return 1>--n?t.apply(this,arguments):void 0}},_.assign=Ur,_.at=function(n){var t=-1,r=Z(arguments,m,b,1),e=r.length,u=Ht(e);for(Rr.unindexedChars&&_t(n)&&(n=n.split(""));++t=E&&a(o?e[o]:v) +}n:for(;++c(m?r(m,y):l(v,y))){for(o=u,(m||v).push(y);--o;)if(m=i[o],0>(m?r(m,y):l(e[o],y)))continue n;h.push(y)}}for(;u--;)(m=i[u])&&g(m);return s(i),s(v),h},_.invert=yt,_.invoke=function(n,t){var r=Br.call(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,a=Ht(typeof o=="number"?o:0);return Et(n,function(n){a[++e]=(u?t:n[t]).apply(n,r)}),a},_.keys=Lr,_.map=St,_.max=At,_.memoize=function(n,t){function r(){var e=r.cache,u=C+(t?t.apply(this,arguments):arguments[0]); +return hr.call(e,u)?e[u]:e[u]=n.apply(this,arguments)}if(!mt(n))throw new rr;return r.cache={},r},_.merge=function(n){var t=arguments,r=2;if(!dt(n))return n;if("number"!=typeof t[2]&&(r=t.length),3e(a,r))&&(o[r]=n)}),o},_.once=function(n){var t,r;if(!mt(n))throw new rr;return function(){return t?r:(t=m,r=n.apply(this,arguments),n=d,r)}},_.pairs=function(n){for(var t=-1,r=Lr(n),e=r.length,u=Ht(e);++tr?Or(0,e+r):Sr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},_.mixin=Jt,_.noConflict=function(){return e._=ir,this},_.parseInt=ee,_.random=function(n,t){n==d&&t==d&&(t=1),n=+n||0,t==d?(t=n,n=0):t=+t||0;var r=Ir();return n%1||t%1?n+Sr(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+sr(r*(t-n+1))},_.reduce=It,_.reduceRight=Bt,_.result=function(n,t){var r=n?n[t]:y; +return mt(r)?n[t]():r},_.runInContext=v,_.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Lr(n).length},_.some=Pt,_.sortedIndex=$t,_.template=function(n,t,r){var e=_.templateSettings;n||(n=""),r=Vr({},r,e);var u,o=Vr({},r.imports,e.imports),e=Lr(o),o=wt(o),a=0,f=r.interpolate||R,c="__p+='",f=nr((r.escape||R).source+"|"+f.source+"|"+(f===D?P:R).source+"|"+(r.evaluate||R).source+"|$","g");n.replace(f,function(t,r,e,o,f,l){return e||(e=o),c+=n.slice(a,l).replace($,i),r&&(c+="'+__e("+r+")+'"),f&&(u=m,c+="';"+f+";__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),a=l+t.length,t +}),c+="';\n",f=r=r.variable,f||(r="obj",c="with("+r+"){"+c+"}"),c=(u?c.replace(A,""):c).replace(I,"$1").replace(B,"$1;"),c="function("+r+"){"+(f?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var l=Qt(e,"return "+c).apply(y,o)}catch(p){throw p.source=c,p}return t?l(t):(l.source=c,l)},_.unescape=function(n){return n==d?"":tr(n).replace(Jr,st)},_.uniqueId=function(n){var t=++j;return tr(n==d?"":n)+t +},_.all=kt,_.any=Pt,_.detect=Ct,_.findWhere=Ct,_.foldl=It,_.foldr=Bt,_.include=jt,_.inject=It,Xr(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(){var t=[this.__wrapped__],r=this.__chain__;return vr.apply(t,arguments),t=n.apply(_,t),r?new w(t,r):t})}),_.first=Dt,_.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=d){var o=u;for(t=_.createCallback(t,r,3);o--&&t(n[o],o,n);)e++}else if(e=t,e==d||r)return n[u-1];return h(n,Or(0,u-e))}},_.take=Dt,_.head=Dt,Xr(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(t,r){var e=this.__chain__,u=n(this.__wrapped__,t,r); +return!e&&(t==d||r&&typeof t!="function")?u:new w(u,e)})}),_.VERSION="1.3.1",_.prototype.chain=function(){return this.__chain__=m,this},_.prototype.toString=function(){return tr(this.__wrapped__)},_.prototype.value=Mt,_.prototype.valueOf=Mt,Hr(["join","pop","shift"],function(n){var t=er[n];_.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new w(r,n):r}}),Hr(["push","reverse","sort","unshift"],function(n){var t=er[n];_.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +}}),Hr(["concat","slice","splice"],function(n){var t=er[n];_.prototype[n]=function(){return new w(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Rr.spliceObjects||Hr(["pop","shift","splice"],function(n){var t=er[n],r="splice"==n;_.prototype[n]=function(){var n=this.__chain__,e=this.__wrapped__,u=t.apply(e,arguments);return 0===e.length&&delete e[0],n||r?new w(u,n):u}}),_}var y,m=!0,d=null,b=!1,_=[],w=[],j=0,x={},C=+new Date+"",E=75,O=40,S=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",A=/\b__p\+='';/g,I=/\b(__p\+=)''\+/g,B=/(__e\(.*?\)|\b__t\))\+'';/g,P=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,N=/\w*$/,D=/<%=([\s\S]+?)%>/g,F=RegExp("^["+S+"]*0+(?=.$)"),R=/($^)/,$=/['\n\r\t\u2028\u2029\\]/g,z="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),L="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),T="[object Arguments]",q="[object Array]",K="[object Boolean]",W="[object Date]",G="[object Error]",J="[object Function]",M="[object Number]",H="[object Object]",U="[object RegExp]",V="[object String]",Q={}; +Q[J]=b,Q[T]=Q[q]=Q[K]=Q[W]=Q[M]=Q[H]=Q[U]=Q[V]=m;var X={"boolean":b,"function":m,object:m,number:b,string:b,undefined:b},Y={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Z=X[typeof exports]&&exports,nt=X[typeof module]&&module&&module.exports==Z&&module,tt=X[typeof global]&&global;!tt||tt.global!==tt&&tt.window!==tt||(n=tt);var rt=v();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=rt, define(function(){return rt})):Z&&!Z.nodeType?nt?(nt.exports=rt)._=rt:Z._=rt:n._=rt }(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index c6632c01b..53f9fc512 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -772,7 +772,7 @@ setBindData(func, bindData); } // exit early if there are no `this` references or `func` is bound - if (bindData !== true && !(bindData && bindData[4])) { + if (bindData !== true && !(bindData && bindData[1] & 1)) { return func; } switch (argCount) { @@ -1129,44 +1129,57 @@ } /** - * Creates a function that, when called, invokes `func` with the `this` binding - * of `thisArg` and prepends any `partialArgs` to the arguments provided to the - * bound function. + * Creates a function that, when called, either curries or invokes `func` + * with an optional `this` binding and partially applied arguments. * * @private - * @param {Function|String} func The function to bind or the method name. - * @param {Mixed} thisArg The `this` binding of `func`. - * @param {Array} partialArgs An array of arguments to be prepended to those provided to the new function. - * @param {Array} partialRightArgs An array of arguments to be appended to those provided to the new function. - * @param {Boolean} [isPartial=false] A flag to indicate performing only partial application. - * @param {Boolean} [isAlt=false] A flag to indicate `_.bindKey` or `_.partialRight` behavior. + * @param {Function|String} func The function or method name to reference. + * @param {Number} bitmask The bitmask of method flags to compose. + * The bitmask may be composed of the following flags: + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` + * 8 - `_.partial` + * 16 - `_.partialRight` + * @param {Array} [partialArgs] An array of arguments to prepend to those + * provided to the new function. + * @param {Array} [partialRightArgs] An array of arguments to append to those + * provided to the new function. + * @param {Mixed} [thisArg] The `this` binding of `func`. + * @param {Number} [arity] The arity of `func`. * @returns {Function} Returns the new bound function. */ - function createBound(func, thisArg, partialArgs, partialRightArgs, isPartial, isAlt) { - var isBindKey = isAlt && !isPartial, - isFunc = isFunction(func); + function createBound(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { + var isBind = bitmask & 1, + isBindKey = bitmask & 2, + isCurry = bitmask & 4, + isPartialRight = bitmask & 16; - // throw if `func` is not a function when not behaving as `_.bindKey` - if (!isFunc && !isBindKey) { + if (!isBindKey && !isFunction(func)) { throw new TypeError; } - var args = func.__bindData__; - if (args) { - push.apply(args[2], partialArgs); - push.apply(args[3], partialRightArgs); - - // add `thisArg` to previous `_.partial` and `_.partialRight` arguments - if (!isPartial && args[4]) { - args[1] = thisArg; - args[4] = false; - args[5] = isAlt; + var bindData = func && func.__bindData__; + if (bindData) { + if (isBind && !(bindData[1] & 1)) { + bindData[4] = thisArg; } - return createBound.apply(null, args); + if (isCurry && !(bindData[1] & 4)) { + bindData[5] = arity; + } + if (partialArgs) { + push.apply(bindData[2] || (bindData[2] = []), partialArgs); + } + if (partialRightArgs) { + push.apply(bindData[3] || (bindData[3] = []), partialRightArgs); + } + bindData[1] |= bitmask; + return createBound.apply(null, bindData); } // use `Function#bind` if it exists and is fast // (in V8 `Function#bind` is slower except when partially applied) - if (!isPartial && !isAlt && !partialRightArgs.length && (support.fastBind || (nativeBind && partialArgs.length))) { - args = [func, thisArg]; + if (isBind && !(isBindKey || isCurry || isPartialRight) && + (support.fastBind || (nativeBind && partialArgs.length))) { + var args = [func, thisArg]; push.apply(args, partialArgs); var bound = nativeBind.call.apply(nativeBind, args); } @@ -1175,15 +1188,22 @@ // `Function#bind` spec // http://es5.github.io/#x15.3.4.5 var args = arguments, - thisBinding = isPartial ? this : thisArg; + thisBinding = isBind ? thisArg : this; - if (isBindKey) { - func = thisArg[key]; - } - if (partialArgs.length || partialRightArgs.length) { + if (partialArgs) { unshift.apply(args, partialArgs); + } + if (partialRightArgs) { push.apply(args, partialRightArgs); } + if (isCurry && args.length < arity) { + bindData[2] = args; + bindData[3] = null; + return createBound(bound, bitmask & ~8 & ~16); + } + if (isBindKey) { + func = thisBinding[key]; + } if (this instanceof bound) { // ensure `new bound` is an instance of `func` thisBinding = createObject(func.prototype); @@ -1197,12 +1217,12 @@ }; } // take a snapshot of `arguments` before juggling - args = nativeSlice.call(arguments); + bindData = nativeSlice.call(arguments); if (isBindKey) { var key = thisArg; thisArg = func; } - setBindData(bound, args); + setBindData(bound, bindData); return bound; } @@ -4267,7 +4287,7 @@ */ function range(start, end, step) { start = +start || 0; - step = typeof step == 'number' ? step : 1; + step = typeof step == 'number' ? step : (+step || 1); if (end == null) { end = start; @@ -4652,6 +4672,9 @@ * // `renderNotes` is run once, after all notes have saved */ function after(n, func) { + if (!isFunction(func)) { + throw new TypeError; + } return function() { if (--n < 1) { return func.apply(this, arguments); @@ -4682,7 +4705,7 @@ * // => 'hi moe' */ function bind(func, thisArg) { - return createBound(func, thisArg, nativeSlice.call(arguments, 2), []); + return createBound(func, 9, nativeSlice.call(arguments, 2), null, thisArg); } /** @@ -4756,7 +4779,7 @@ * // => 'hi, moe!' */ function bindKey(object, key) { - return createBound(object, key, nativeSlice.call(arguments, 2), [], false, true); + return createBound(object, 11, nativeSlice.call(arguments, 2), null, key); } /** @@ -4790,7 +4813,14 @@ * // => 'Hiya Jerome!' */ function compose() { - var funcs = arguments; + var funcs = arguments, + length = funcs.length || 1; + + while (length--) { + if (!isFunction(funcs[length])) { + throw new TypeError; + } + } return function() { var args = arguments, length = funcs.length; @@ -4870,6 +4900,39 @@ }; } + /** + * Creates a function which accepts one or more arguments of `func` that when + * invoked either executes `func` returning its result, if all `func` arguments + * have been provided, or returns a function that accepts one or more of the + * remaining `func` arguments, and so on. The arity of `func` can be specified + * if `func.length` is not sufficient. + * + * @static + * @memberOf _ + * @category Functions + * @param {Function} func The function to curry. + * @param {Number} [arity=func.length] The arity of `func`. + * @returns {Function} Returns the new curried function. + * @example + * + * var curried = _.curry(function(a, b, c) { + * console.log(a + b + c); + * }); + * + * curried(1)(2)(3); + * // => 6 + * + * curried(1, 2)(3); + * // => 6 + * + * curried(1, 2, 3); + * // => 6 + */ + function curry(func, arity) { + arity = typeof arity == 'number' ? arity : (+arity || func.length); + return createBound(func, 4, null, null, null, arity); + } + /** * Creates a function that will delay the execution of `func` until after * `wait` milliseconds have elapsed since the last time it was invoked. @@ -4920,32 +4983,9 @@ timeoutId = null, trailing = true; - function clear() { - clearTimeout(maxTimeoutId); - clearTimeout(timeoutId); - callCount = 0; - maxTimeoutId = timeoutId = null; + if (!isFunction(func)) { + throw new TypeError; } - - function delayed() { - var isCalled = trailing && (!leading || callCount > 1); - clear(); - if (isCalled) { - if (maxWait !== false) { - lastCalled = new Date; - } - result = func.apply(thisArg, args); - } - } - - function maxDelayed() { - clear(); - if (trailing || (maxWait !== wait)) { - lastCalled = new Date; - result = func.apply(thisArg, args); - } - } - wait = nativeMax(0, wait || 0); if (options === true) { var leading = true; @@ -4955,6 +4995,32 @@ maxWait = 'maxWait' in options && nativeMax(wait, options.maxWait || 0); trailing = 'trailing' in options ? options.trailing : trailing; } + var clear = function() { + clearTimeout(maxTimeoutId); + clearTimeout(timeoutId); + callCount = 0; + maxTimeoutId = timeoutId = null; + }; + + var delayed = function() { + var isCalled = trailing && (!leading || callCount > 1); + clear(); + if (isCalled) { + if (maxWait !== false) { + lastCalled = new Date; + } + result = func.apply(thisArg, args); + } + }; + + var maxDelayed = function() { + clear(); + if (trailing || (maxWait !== wait)) { + lastCalled = new Date; + result = func.apply(thisArg, args); + } + }; + return function() { args = arguments; thisArg = this; @@ -5007,12 +5073,20 @@ * // returns from the function before 'deferred' is logged */ function defer(func) { + if (!isFunction(func)) { + throw new TypeError; + } var args = nativeSlice.call(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); } - // use `setImmediate` if it's available in Node.js + // use `setImmediate` if available in Node.js if (isV8 && freeModule && typeof setImmediate == 'function') { - defer = bind(setImmediate, context); + defer = function(func) { + if (!isFunction(func)) { + throw new TypeError; + } + return setImmediate.apply(context, arguments); + }; } /** @@ -5033,6 +5107,9 @@ * // => 'logged later' (Appears after one second.) */ function delay(func, wait) { + if (!isFunction(func)) { + throw new TypeError; + } var args = nativeSlice.call(arguments, 2); return setTimeout(function() { func.apply(undefined, args); }, wait); } @@ -5058,7 +5135,10 @@ * }); */ function memoize(func, resolver) { - function memoized() { + if (!isFunction(func)) { + throw new TypeError; + } + var memoized = function() { var cache = memoized.cache, key = keyPrefix + (resolver ? resolver.apply(this, arguments) : arguments[0]); @@ -5091,6 +5171,9 @@ var ran, result; + if (!isFunction(func)) { + throw new TypeError; + } return function() { if (ran) { return result; @@ -5123,7 +5206,7 @@ * // => 'hi moe' */ function partial(func) { - return createBound(func, null, nativeSlice.call(arguments, 1), [], true); + return createBound(func, 8, nativeSlice.call(arguments, 1)); } /** @@ -5154,7 +5237,7 @@ * // => { '_': _, 'jq': $ } */ function partialRight(func) { - return createBound(func, null, [], nativeSlice.call(arguments, 1), true, true); + return createBound(func, 16, null, nativeSlice.call(arguments, 1)); } /** @@ -5192,6 +5275,9 @@ var leading = true, trailing = true; + if (!isFunction(func)) { + throw new TypeError; + } if (options === false) { leading = false; } else if (isObject(options)) { @@ -5230,6 +5316,9 @@ * // => 'before, hello moe, after' */ function wrap(value, wrapper) { + if (!isFunction(wrapper)) { + throw new TypeError; + } return function() { var args = [value]; push.apply(args, arguments); @@ -5820,6 +5909,7 @@ lodash.compose = compose; lodash.countBy = countBy; lodash.createCallback = createCallback; + lodash.curry = curry; lodash.debounce = debounce; lodash.defaults = defaults; lodash.defer = defer; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 08d9c7f2b..2582f96ae 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -3,48 +3,48 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;!function(n){function t(n,t,r){r=(r||0)-1;for(var e=n?n.length:0;++rt||typeof n=="undefined")return 1;if(nr?0:r);++et||typeof n=="undefined")return 1;if(nr?0:r);++e=k&&i===t,g=u||v?f():l;if(v){var h=a(g);h?(i=r,g=h):(v=m,g=u?g:(p(g),l)) -}for(;++oi(g,y))&&((u||v)&&g.push(y),l.push(h))}return v?(p(g.b),s(g)):u&&p(g),l}function it(n){return function(t,r,e){var u={};return r=Z.createCallback(r,e,3),Ot(t,function(t,e,o){e=rr(r(t,e,o)),n(u,t,e,o)}),u}}function ft(n,t,r,e,u,o){var a=o&&!u;if(!_t(n)&&!a)throw new er;var i=n.__bindData__;if(i)return hr.apply(i[2],r),hr.apply(i[3],e),!u&&i[4]&&(i[1]=t,i[4]=m,i[5]=o),ft.apply(_,i);if(u||o||e.length||!(Dr.fastBind||wr&&r.length))f=function(){var o=arguments,i=u?this:t; -return a&&(n=t[c]),(r.length||e.length)&&(dr.apply(o,r),hr.apply(o,e)),this instanceof f?(i=mt(n.prototype)?jr(n.prototype):{},o=n.apply(i,o),mt(o)?o:i):n.apply(i,o)};else{i=[n,t],hr.apply(i,r);var f=wr.call.apply(wr,i)}if(i=Nr.call(arguments),a){var c=t;t=n}return Fr(f,i),f}function ct(n){return qr[n]}function lt(){var n=(n=Z.indexOf)===Ft?t:n;return n}function pt(n){var t,r;return n&&br.call(n)==L&&(t=n.constructor,!_t(t)||t instanceof t)?(x(n,function(n,t){r=t}),r===h||gr.call(n,r)):m}function st(n){return Wr[n] -}function vt(n){return n&&typeof n=="object"?br.call(n)==T:m}function gt(n,t,r){var e=zr(n),u=e.length;for(t=rt(t,r,3);u--&&(r=e[u],!(t(n[r],r,n)===false)););return n}function ht(n){var t=[];return x(n,function(n,r){_t(n)&&t.push(r)}),t.sort()}function yt(n){for(var t=-1,r=zr(n),e=r.length,u={};++tr?Er(0,o+r):r)||0,o&&typeof o=="number"?a=-1<(dt(n)?n.indexOf(t,r):u(n,t,r)):d(n,function(n){return++eo&&(o=i)}}else t=!t&&dt(n)?u:Z.createCallback(t,r,3),Ot(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n) -});return o}function At(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Ht(e);++rarguments.length;t=rt(t,e,4);var o=-1,a=n.length;if(typeof a=="number")for(u&&(r=n[++o]);++oarguments.length;return t=rt(t,e,4),Et(n,function(n,e,o){r=u?(u=m,n):t(r,n,e,o)}),r}function Bt(n,t,r){var e;t=Z.createCallback(t,r,3),r=-1; -var u=n?n.length:0;if(typeof u=="number")for(;++r=k&&u===t;if(c){var l=a(i);l?(u=r,i=l):c=m}for(;++eu(i,l)&&f.push(l);return c&&s(i),f}function Dt(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=_){var o=-1;for(t=Z.createCallback(t,r,3);++oe?Er(0,u+e):e||0}else if(e)return e=zt(n,r),n[e]===r?e:-1;return n?t(n,r,e):-1}function Tt(n,t,r){if(typeof t!="number"&&t!=_){var e=0,u=-1,o=n?n.length:0;for(t=Z.createCallback(t,r,3);++u>>1,r(n[e])r?0:r);++tc&&(i=n.apply(f,a));else{var r=new Qt;!s&&!h&&(l=r);var e=p-(r-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Z}};var Fr=lr?function(n,t){var r=c();r.value=t,lr(n,"__bindData__",r),s(r)}:l,Tr=kr,zr=Or?function(n){return mt(n)?Or(n):[]}:X,qr={"&":"&","<":"<",">":">",'"':""","'":"'"},Wr=yt(qr),Pr=tr("("+zr(Wr).join("|")+")","g"),Kr=tr("["+zr(qr).join("")+"]","g"),Lr=it(function(n,t,r){gr.call(n,r)?n[r]++:n[r]=1 -}),Mr=it(function(n,t,r){(gr.call(n,r)?n[r]:n[r]=[]).push(t)}),Ur=it(function(n,t,r){n[r]=t});Br&&Q&&typeof yr=="function"&&(Mt=Kt(yr,e));var Vr=8==Sr(C+"08")?Sr:function(n,t){return Sr(dt(n)?n.replace(R,""):n,t||0)};return Z.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=J,Z.at=function(n){for(var t=-1,r=et(arguments,y,m,1),e=r.length,u=Ht(e);++t=k&&a(o?e[o]:h) -}n:for(;++c(_?r(_,y):l(h,y))){for(o=u,(_||h).push(y);--o;)if(_=i[o],0>(_?r(_,y):l(e[o],y)))continue n;g.push(y)}}for(;u--;)(_=i[u])&&s(_);return p(i),p(h),g},Z.invert=yt,Z.invoke=function(n,t){var r=Nr.call(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,a=Ht(typeof o=="number"?o:0);return Ot(n,function(n){a[++e]=(u?t:n[t]).apply(n,r)}),a},Z.keys=zr,Z.map=It,Z.max=St,Z.memoize=function(n,t){function r(){var e=r.cache,u=j+(t?t.apply(this,arguments):arguments[0]); -return gr.call(e,u)?e[u]:e[u]=n.apply(this,arguments)}return r.cache={},r},Z.merge=function(n){var t=arguments,r=2;if(!mt(n))return n;if("number"!=typeof t[2]&&(r=t.length),3e(a,r))&&(o[r]=n)}),o},Z.once=function(n){var t,r;return function(){return t?r:(t=y,r=n.apply(this,arguments),n=_,r)}},Z.pairs=function(n){for(var t=-1,r=zr(n),e=r.length,u=Ht(e);++tr?Er(0,e+r):Ir(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},Z.mixin=Vt,Z.noConflict=function(){return e._=ar,this},Z.parseInt=Vr,Z.random=function(n,t){n==_&&t==_&&(t=1),n=+n||0,t==_?(t=n,n=0):t=+t||0;var r=Ar();return n%1||t%1?n+Ir(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+pr(r*(t-n+1))},Z.reduce=Nt,Z.reduceRight=Rt,Z.result=function(n,t){var r=n?n[t]:h; -return _t(r)?n[t]():r},Z.runInContext=g,Z.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:zr(n).length},Z.some=Bt,Z.sortedIndex=zt,Z.template=function(n,t,r){var e=Z.templateSettings;n||(n=""),r=H({},r,e);var u,o=H({},r.imports,e.imports),e=zr(o),o=wt(o),a=0,f=r.interpolate||B,c="__p+='",f=tr((r.escape||B).source+"|"+f.source+"|"+(f===N?S:B).source+"|"+(r.evaluate||B).source+"|$","g");n.replace(f,function(t,r,e,o,f,l){return e||(e=o),c+=n.slice(a,l).replace(D,i),r&&(c+="'+__e("+r+")+'"),f&&(u=y,c+="';"+f+";__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),a=l+t.length,t -}),c+="';\n",f=r=r.variable,f||(r="obj",c="with("+r+"){"+c+"}"),c=(u?c.replace(O,""):c).replace(E,"$1").replace(I,"$1;"),c="function("+r+"){"+(f?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var l=Xt(e,"return "+c).apply(h,o)}catch(p){throw p.source=c,p}return t?l(t):(l.source=c,l)},Z.unescape=function(n){return n==_?"":rr(n).replace(Pr,st)},Z.uniqueId=function(n){var t=++w;return rr(n==_?"":n)+t -},Z.all=kt,Z.any=Bt,Z.detect=Ct,Z.findWhere=Ct,Z.foldl=Nt,Z.foldr=Rt,Z.include=jt,Z.inject=Nt,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(){var t=[this.__wrapped__],r=this.__chain__;return hr.apply(t,arguments),t=n.apply(Z,t),r?new nt(t,r):t})}),Z.first=Dt,Z.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=_){var o=u;for(t=Z.createCallback(t,r,3);o--&&t(n[o],o,n);)e++}else if(e=t,e==_||r)return n[u-1];return v(n,Er(0,u-e))}},Z.take=Dt,Z.head=Dt,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(t,r){var e=this.__chain__,u=n(this.__wrapped__,t,r); -return!e&&(t==_||r&&typeof t!="function")?u:new nt(u,e)})}),Z.VERSION="1.3.1",Z.prototype.chain=function(){return this.__chain__=y,this},Z.prototype.toString=function(){return rr(this.__wrapped__)},Z.prototype.value=Gt,Z.prototype.valueOf=Gt,Ot(["join","pop","shift"],function(n){var t=ur[n];Z.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new nt(r,n):r}}),Ot(["push","reverse","sort","unshift"],function(n){var t=ur[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this -}}),Ot(["concat","slice","splice"],function(n){var t=ur[n];Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Z}var h,y=!0,_=null,m=!1,b=[],d=[],w=0,j=+new Date+"",k=75,x=40,C=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",O=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,I=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,N=/<%=([\s\S]+?)%>/g,R=RegExp("^["+C+"]*0+(?=.$)"),B=/($^)/,$=($=/\bthis\b/)&&$.test(g)&&$,D=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),T="[object Arguments]",z="[object Array]",q="[object Boolean]",W="[object Date]",P="[object Function]",K="[object Number]",L="[object Object]",M="[object RegExp]",U="[object String]",V={}; -V[P]=m,V[T]=V[z]=V[q]=V[W]=V[K]=V[L]=V[M]=V[U]=y;var G={"boolean":m,"function":y,object:y,number:m,string:m,undefined:m},H={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},J=G[typeof exports]&&exports,Q=G[typeof module]&&module&&module.exports==J&&module,X=G[typeof global]&&global;!X||X.global!==X&&X.window!==X||(n=X);var Y=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=Y, define(function(){return Y})):J&&!J.nodeType?Q?(Q.exports=Y)._=Y:J._=Y:n._=Y +if(!u)return o;var a=arguments,i=0,f=typeof r=="number"?2:a.length;if(3=k&&i===t,h=u||v?f():l;if(v){var g=a(h);g?(i=r,h=g):(v=_,h=u?h:(p(h),l)) +}for(;++oi(h,y))&&((u||v)&&h.push(y),l.push(g))}return v?(p(h.b),s(h)):u&&p(h),l}function it(n){return function(t,r,e){var u={};return r=Z.createCallback(r,e,3),Ot(t,function(t,e,o){e=rr(r(t,e,o)),n(u,t,e,o)}),u}}function ft(n,t,r,e,u,o){var a=1&t,i=2&t,f=4&t,c=16&t;if(!i&&!mt(n))throw new er;var l=n&&n.__bindData__;if(l)return a&&!(1&l[1])&&(l[4]=u),f&&!(4&l[1])&&(l[5]=o),r&&gr.apply(l[2]||(l[2]=[]),r),e&&gr.apply(l[3]||(l[3]=[]),e),l[1]|=t,ft.apply(m,l); +if(!a||i||f||c||!(Dr.fastBind||wr&&r.length))p=function(){var c=arguments,v=a?u:this;return r&&dr.apply(c,r),e&&gr.apply(c,e),f&&c.lengthr?Er(0,o+r):r)||0,o&&typeof o=="number"?a=-1<(dt(n)?n.indexOf(t,r):u(n,t,r)):d(n,function(n){return++eo&&(o=i)}}else t=!t&&dt(n)?u:Z.createCallback(t,r,3),Ot(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n) +});return o}function At(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Ht(e);++rarguments.length;t=rt(t,e,4);var o=-1,a=n.length;if(typeof a=="number")for(u&&(r=n[++o]);++oarguments.length;return t=rt(t,e,4),Et(n,function(n,e,o){r=u?(u=_,n):t(r,n,e,o)}),r}function Bt(n,t,r){var e;t=Z.createCallback(t,r,3),r=-1; +var u=n?n.length:0;if(typeof u=="number")for(;++r=k&&u===t;if(c){var l=a(i);l?(u=r,i=l):c=_}for(;++eu(i,l)&&f.push(l);return c&&s(i),f}function Dt(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=m){var o=-1;for(t=Z.createCallback(t,r,3);++oe?Er(0,u+e):e||0}else if(e)return e=zt(n,r),n[e]===r?e:-1;return n?t(n,r,e):-1}function Tt(n,t,r){if(typeof t!="number"&&t!=m){var e=0,u=-1,o=n?n.length:0;for(t=Z.createCallback(t,r,3);++u>>1,r(n[e])r?0:r);++tc&&(i=n.apply(f,a));else{var r=new Qt;!s&&!g&&(l=r);var o=p-(r-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Z}};var Fr=lr?function(n,t){var r=c();r.value=t,lr(n,"__bindData__",r),s(r)}:l,Tr=kr,zr=Or?function(n){return _t(n)?Or(n):[]}:X,qr={"&":"&","<":"<",">":">",'"':""","'":"'"},Wr=yt(qr),Pr=tr("("+zr(Wr).join("|")+")","g"),Kr=tr("["+zr(qr).join("")+"]","g"),Lr=it(function(n,t,r){hr.call(n,r)?n[r]++:n[r]=1 +}),Mr=it(function(n,t,r){(hr.call(n,r)?n[r]:n[r]=[]).push(t)}),Ur=it(function(n,t,r){n[r]=t});Br&&Q&&typeof yr=="function"&&(Mt=function(n){if(!mt(n))throw new er;return yr.apply(e,arguments)});var Vr=8==Sr(C+"08")?Sr:function(n,t){return Sr(dt(n)?n.replace(R,""):n,t||0)};return Z.after=function(n,t){if(!mt(t))throw new er;return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=J,Z.at=function(n){for(var t=-1,r=et(arguments,y,_,1),e=r.length,u=Ht(e);++t=k&&a(o?e[o]:g)}n:for(;++c(m?r(m,y):l(g,y))){for(o=u,(m||g).push(y);--o;)if(m=i[o],0>(m?r(m,y):l(e[o],y)))continue n;h.push(y)}}for(;u--;)(m=i[u])&&s(m);return p(i),p(g),h},Z.invert=yt,Z.invoke=function(n,t){var r=Nr.call(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,a=Ht(typeof o=="number"?o:0);return Ot(n,function(n){a[++e]=(u?t:n[t]).apply(n,r)}),a},Z.keys=zr,Z.map=It,Z.max=St,Z.memoize=function(n,t){function r(){var e=r.cache,u=j+(t?t.apply(this,arguments):arguments[0]); +return hr.call(e,u)?e[u]:e[u]=n.apply(this,arguments)}if(!mt(n))throw new er;return r.cache={},r},Z.merge=function(n){var t=arguments,r=2;if(!_t(n))return n;if("number"!=typeof t[2]&&(r=t.length),3e(a,r))&&(o[r]=n)}),o},Z.once=function(n){var t,r;if(!mt(n))throw new er;return function(){return t?r:(t=y,r=n.apply(this,arguments),n=m,r)}},Z.pairs=function(n){for(var t=-1,r=zr(n),e=r.length,u=Ht(e);++tr?Er(0,e+r):Ir(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},Z.mixin=Vt,Z.noConflict=function(){return e._=ar,this},Z.parseInt=Vr,Z.random=function(n,t){n==m&&t==m&&(t=1),n=+n||0,t==m?(t=n,n=0):t=+t||0;var r=Ar();return n%1||t%1?n+Ir(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+pr(r*(t-n+1))},Z.reduce=Nt,Z.reduceRight=Rt,Z.result=function(n,t){var r=n?n[t]:g; +return mt(r)?n[t]():r},Z.runInContext=h,Z.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:zr(n).length},Z.some=Bt,Z.sortedIndex=zt,Z.template=function(n,t,r){var e=Z.templateSettings;n||(n=""),r=H({},r,e);var u,o=H({},r.imports,e.imports),e=zr(o),o=wt(o),a=0,f=r.interpolate||B,c="__p+='",f=tr((r.escape||B).source+"|"+f.source+"|"+(f===N?S:B).source+"|"+(r.evaluate||B).source+"|$","g");n.replace(f,function(t,r,e,o,f,l){return e||(e=o),c+=n.slice(a,l).replace(D,i),r&&(c+="'+__e("+r+")+'"),f&&(u=y,c+="';"+f+";__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),a=l+t.length,t +}),c+="';\n",f=r=r.variable,f||(r="obj",c="with("+r+"){"+c+"}"),c=(u?c.replace(O,""):c).replace(E,"$1").replace(I,"$1;"),c="function("+r+"){"+(f?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var l=Xt(e,"return "+c).apply(g,o)}catch(p){throw p.source=c,p}return t?l(t):(l.source=c,l)},Z.unescape=function(n){return n==m?"":rr(n).replace(Pr,st)},Z.uniqueId=function(n){var t=++w;return rr(n==m?"":n)+t +},Z.all=kt,Z.any=Bt,Z.detect=Ct,Z.findWhere=Ct,Z.foldl=Nt,Z.foldr=Rt,Z.include=jt,Z.inject=Nt,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(){var t=[this.__wrapped__],r=this.__chain__;return gr.apply(t,arguments),t=n.apply(Z,t),r?new nt(t,r):t})}),Z.first=Dt,Z.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=m){var o=u;for(t=Z.createCallback(t,r,3);o--&&t(n[o],o,n);)e++}else if(e=t,e==m||r)return n[u-1];return v(n,Er(0,u-e))}},Z.take=Dt,Z.head=Dt,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(t,r){var e=this.__chain__,u=n(this.__wrapped__,t,r); +return!e&&(t==m||r&&typeof t!="function")?u:new nt(u,e)})}),Z.VERSION="1.3.1",Z.prototype.chain=function(){return this.__chain__=y,this},Z.prototype.toString=function(){return rr(this.__wrapped__)},Z.prototype.value=Gt,Z.prototype.valueOf=Gt,Ot(["join","pop","shift"],function(n){var t=ur[n];Z.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new nt(r,n):r}}),Ot(["push","reverse","sort","unshift"],function(n){var t=ur[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +}}),Ot(["concat","slice","splice"],function(n){var t=ur[n];Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Z}var g,y=!0,m=null,_=!1,b=[],d=[],w=0,j=+new Date+"",k=75,x=40,C=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",O=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,I=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,N=/<%=([\s\S]+?)%>/g,R=RegExp("^["+C+"]*0+(?=.$)"),B=/($^)/,$=($=/\bthis\b/)&&$.test(h)&&$,D=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),T="[object Arguments]",z="[object Array]",q="[object Boolean]",W="[object Date]",P="[object Function]",K="[object Number]",L="[object Object]",M="[object RegExp]",U="[object String]",V={}; +V[P]=_,V[T]=V[z]=V[q]=V[W]=V[K]=V[L]=V[M]=V[U]=y;var G={"boolean":_,"function":y,object:y,number:_,string:_,undefined:_},H={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},J=G[typeof exports]&&exports,Q=G[typeof module]&&module&&module.exports==J&&module,X=G[typeof global]&&global;!X||X.global!==X&&X.window!==X||(n=X);var Y=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=Y, define(function(){return Y})):J&&!J.nodeType?Q?(Q.exports=Y)._=Y:J._=Y:n._=Y }(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index eca8f861f..f2b666df8 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -124,7 +124,11 @@ return -1; } } - return ai < bi ? -1 : 1; + // The JS engine embedded in Adobe applications like InDesign has a buggy + // `Array#sort` implementation that causes it, under certain circumstances, + // to return the same value for `a` and `b`. + // See https://github.com/jashkenas/underscore/pull/1247 + return ai < bi ? -1 : (ai > bi ? 1 : 0); } /** @@ -176,8 +180,7 @@ floor = Math.floor, hasOwnProperty = objectProto.hasOwnProperty, push = arrayRef.push, - toString = objectProto.toString, - unshift = arrayRef.unshift; + toString = objectProto.toString; /* Native method shortcuts for methods with the same name as other `lodash` methods */ var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind, @@ -590,60 +593,59 @@ } /** - * Creates a function that, when called, invokes `func` with the `this` binding - * of `thisArg` and prepends any `partialArgs` to the arguments provided to the - * bound function. + * Creates a function that, when called, either curries or invokes `func` + * with an optional `this` binding and partially applied arguments. * * @private - * @param {Function|String} func The function to bind or the method name. - * @param {Mixed} thisArg The `this` binding of `func`. - * @param {Array} partialArgs An array of arguments to be prepended to those provided to the new function. - * @param {Array} partialRightArgs An array of arguments to be appended to those provided to the new function. - * @param {Boolean} [isPartial=false] A flag to indicate performing only partial application. - * @param {Boolean} [isAlt=false] A flag to indicate `_.bindKey` or `_.partialRight` behavior. + * @param {Function|String} func The function or method name to reference. + * @param {Number} bitmask The bitmask of method flags to compose. + * The bitmask may be composed of the following flags: + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` + * 8 - `_.partial` + * 16 - `_.partialRight` + * @param {Array} [partialArgs] An array of arguments to prepend to those + * provided to the new function. + * @param {Array} [partialRightArgs] An array of arguments to append to those + * provided to the new function. + * @param {Mixed} [thisArg] The `this` binding of `func`. + * @param {Number} [arity] The arity of `func`. * @returns {Function} Returns the new bound function. */ - function createBound(func, thisArg, partialArgs, partialRightArgs, isPartial, isAlt) { - var isBindKey = isAlt && !isPartial, - isFunc = isFunction(func); + function createBound(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { + var isBind = bitmask & 1, + isBindKey = bitmask & 2, + isCurry = bitmask & 4, + isPartialRight = bitmask & 16; - // throw if `func` is not a function when not behaving as `_.bindKey` - if (!isFunc && !isBindKey) { + if (!isBindKey && !isFunction(func)) { throw new TypeError; } + var bindData = func && func.__bindData__; + if (bindData) { + if (isBind && !(bindData[1] & 1)) { + bindData[4] = thisArg; + } + if (isCurry && !(bindData[1] & 4)) { + bindData[5] = arity; + } + if (partialArgs) { + push.apply(bindData[2] || (bindData[2] = []), partialArgs); + } + if (partialRightArgs) { + push.apply(bindData[3] || (bindData[3] = []), partialRightArgs); + } + bindData[1] |= bitmask; + return createBound.apply(null, bindData); + } // use `Function#bind` if it exists and is fast // (in V8 `Function#bind` is slower except when partially applied) - if (!isPartial && !isAlt && !partialRightArgs.length && (support.fastBind || (nativeBind && partialArgs.length))) { - var args = [func, thisArg]; - push.apply(args, partialArgs); - var bound = nativeBind.call.apply(nativeBind, args); - } - else { - bound = function() { - // `Function#bind` spec - // http://es5.github.io/#x15.3.4.5 - var args = arguments, - thisBinding = isPartial ? this : thisArg; - - if (isBindKey) { - func = thisArg[key]; - } - if (partialArgs.length || partialRightArgs.length) { - unshift.apply(args, partialArgs); - push.apply(args, partialRightArgs); - } - if (this instanceof bound) { - // ensure `new bound` is an instance of `func` - thisBinding = createObject(func.prototype); - - // mimic the constructor's `return` behavior - // http://es5.github.io/#x13.2.2 - var result = func.apply(thisBinding, args); - return isObject(result) ? result : thisBinding; - } - return func.apply(thisBinding, args); - }; + if (isBind && !(isBindKey || isCurry || isPartialRight) && + (support.fastBind || (nativeBind && partialArgs.length))) {; } + // take a snapshot of `arguments` before juggling + bindData = nativeSlice.call(arguments); if (isBindKey) { var key = thisArg; thisArg = func; @@ -3063,7 +3065,7 @@ */ function range(start, end, step) { start = +start || 0; - step = +step || 1; + step = (+step || 1); if (end == null) { end = start; @@ -3398,6 +3400,9 @@ * // `renderNotes` is run once, after all notes have saved */ function after(n, func) { + if (!isFunction(func)) { + throw new TypeError; + } return function() { if (--n < 1) { return func.apply(this, arguments); @@ -3428,7 +3433,7 @@ * // => 'hi moe' */ function bind(func, thisArg) { - return createBound(func, thisArg, nativeSlice.call(arguments, 2), []); + return createBound(func, 9, nativeSlice.call(arguments, 2), null, thisArg); } /** @@ -3498,7 +3503,14 @@ * // => 'Hiya Jerome!' */ function compose() { - var funcs = arguments; + var funcs = arguments, + length = funcs.length || 1; + + while (length--) { + if (!isFunction(funcs[length])) { + throw new TypeError; + } + } return function() { var args = arguments, length = funcs.length; @@ -3616,32 +3628,9 @@ timeoutId = null, trailing = true; - function clear() { - clearTimeout(maxTimeoutId); - clearTimeout(timeoutId); - callCount = 0; - maxTimeoutId = timeoutId = null; + if (!isFunction(func)) { + throw new TypeError; } - - function delayed() { - var isCalled = trailing && (!leading || callCount > 1); - clear(); - if (isCalled) { - if (maxWait !== false) { - lastCalled = new Date; - } - result = func.apply(thisArg, args); - } - } - - function maxDelayed() { - clear(); - if (trailing || (maxWait !== wait)) { - lastCalled = new Date; - result = func.apply(thisArg, args); - } - } - wait = nativeMax(0, wait || 0); if (options === true) { var leading = true; @@ -3651,6 +3640,32 @@ maxWait = 'maxWait' in options && nativeMax(wait, options.maxWait || 0); trailing = 'trailing' in options ? options.trailing : trailing; } + var clear = function() { + clearTimeout(maxTimeoutId); + clearTimeout(timeoutId); + callCount = 0; + maxTimeoutId = timeoutId = null; + }; + + var delayed = function() { + var isCalled = trailing && (!leading || callCount > 1); + clear(); + if (isCalled) { + if (maxWait !== false) { + lastCalled = new Date; + } + result = func.apply(thisArg, args); + } + }; + + var maxDelayed = function() { + clear(); + if (trailing || (maxWait !== wait)) { + lastCalled = new Date; + result = func.apply(thisArg, args); + } + }; + return function() { args = arguments; thisArg = this; @@ -3703,6 +3718,9 @@ * // returns from the function before 'deferred' is logged */ function defer(func) { + if (!isFunction(func)) { + throw new TypeError; + } var args = nativeSlice.call(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); } @@ -3725,6 +3743,9 @@ * // => 'logged later' (Appears after one second.) */ function delay(func, wait) { + if (!isFunction(func)) { + throw new TypeError; + } var args = nativeSlice.call(arguments, 2); return setTimeout(function() { func.apply(undefined, args); }, wait); } @@ -3780,6 +3801,9 @@ var ran, result; + if (!isFunction(func)) { + throw new TypeError; + } return function() { if (ran) { return result; @@ -3812,7 +3836,7 @@ * // => 'hi moe' */ function partial(func) { - return createBound(func, null, nativeSlice.call(arguments, 1), [], true); + return createBound(func, 8, nativeSlice.call(arguments, 1)); } /** @@ -3886,6 +3910,9 @@ * // => 'before, hello moe, after' */ function wrap(value, wrapper) { + if (!isFunction(wrapper)) { + throw new TypeError; + } return function() { var args = [value]; push.apply(args, arguments); diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index d62634ede..4af7bfd97 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,34 +3,34 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` */ -;!function(n){function t(n,t){var r;if(n&&_t[typeof n])for(r in n)if(Ft.call(n,r)&&t(n[r],r,n)===ot)break}function r(n,t){var r;if(n&&_t[typeof n])for(r in n)if(t(n[r],r,n)===ot)break}function e(n){var t,r=[];if(!n||!_t[typeof n])return r;for(t in n)Ft.call(n,t)&&r.push(t);return r}function u(n,t,r){r=(r||0)-1;for(var e=n?n.length:0;++rt||typeof n=="undefined")return 1;if(nu(a,c))&&(r&&a.push(c),o.push(f))}return o}function g(n){return function(t,r,e){var u={};return r=X(r,e,3),q(t,function(t,e,i){e=r(t,e,i)+"",n(u,t,e,i)}),u}}function h(n,t,r,e){var u=[];if(!E(n))throw new TypeError;if(e||u.length||!(Gt.fastBind||Bt&&r.length))o=function(){var i=arguments,a=e?this:t;return(r.length||u.length)&&(kt.apply(i,r),Nt.apply(i,u)),this instanceof o?(a=y(n.prototype),i=n.apply(a,i),T(i)?i:a):n.apply(a,i)};else{var i=[n,t];Nt.apply(i,r);var o=Bt.call.apply(Bt,i) -}return o}function y(n){return T(n)?Dt(n):{}}function m(n){return Kt[n]}function _(){var n=(n=f.indexOf)===H?u:n;return n}function d(n){return Lt[n]}function b(n){return n&&typeof n=="object"?Rt.call(n)==lt:ut}function j(n){if(!n)return n;for(var t=1,r=arguments.length;te&&(e=r,u=n)});else for(;++iu&&(u=r);return u}function W(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++rarguments.length;r=l(r,u,4);var o=-1,a=n.length;if(typeof a=="number")for(i&&(e=n[++o]);++oarguments.length;return t=l(t,e,4),M(n,function(n,e,i){r=u?(u=ut,n):t(r,n,e,i)}),r}function P(n,r,e){var u;r=X(r,e,3),e=-1;var i=n?n.length:0;if(typeof i=="number")for(;++er(u,o)&&i.push(o) -}return i}function G(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=et){var i=-1;for(t=X(t,r,3);++ir?Wt(0,e+r):r||0}else if(r)return r=K(n,t),n[r]===t?r:-1;return n?u(n,t,r):-1}function J(n,t,r){if(typeof t!="number"&&t!=et){var e=0,u=-1,i=n?n.length:0;for(t=X(t,r,3);++u>>1,r(n[e])c&&(a=n.apply(f,o));else{var r=new Date;!s&&!h&&(l=r);var e=p-(r-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Dt||(y=function(n){if(T(n)){a.prototype=n;var t=new a;a.prototype=et}return t||{}}),b(arguments)||(b=function(n){return n&&typeof n=="object"?Ft.call(n,"callee"):ut});var Ht=qt||function(n){return n&&typeof n=="object"?Rt.call(n)==pt:ut},Jt=It?function(n){return T(n)?It(n):[] -}:e,Kt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Lt=A(Kt),Qt=RegExp("("+Jt(Lt).join("|")+")","g"),Xt=RegExp("["+Jt(Kt).join("")+"]","g");E(/x/)&&(E=function(n){return typeof n=="function"&&"[object Function]"==Rt.call(n)});var Yt=g(function(n,t,r){Ft.call(n,r)?n[r]++:n[r]=1}),Zt=g(function(n,t,r){(Ft.call(n,r)?n[r]:n[r]=[]).push(t)});f.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},f.bind=Q,f.bindAll=function(n){for(var t=1u(o,a)){for(var f=r;--f;)if(0>u(t[f],a))continue n;o.push(a)}}return o},f.invert=A,f.invoke=function(n,t){var r=Pt.call(arguments,2),e=-1,u=typeof t=="function",i=n?n.length:0,o=Array(typeof i=="number"?i:0); -return q(n,function(n){o[++e]=(u?t:n[t]).apply(n,r)}),o},f.keys=Jt,f.map=$,f.max=I,f.memoize=function(n,t){var r={};return function(){var e=at+(t?t.apply(this,arguments):arguments[0]);return Ft.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},f.min=function(n,t,r){var e=1/0,u=e,i=-1,o=n?n.length:0;if(t||typeof o!="number")t=X(t,r,3),q(n,function(n,r,i){r=t(n,r,i),rt(e,r)&&(u[r]=n) -}),u},f.once=function(n){var t,r;return function(){return t?r:(t=rt,r=n.apply(this,arguments),n=et,r)}},f.pairs=function(n){for(var t=-1,r=Jt(n),e=r.length,u=Array(e);++tt?0:t);++nr?Wt(0,e+r):zt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},f.mixin=nt,f.noConflict=function(){return n._=Ot,this},f.random=function(n,t){n==et&&t==et&&(t=1),n=+n||0,t==et?(t=n,n=0):t=+t||0;var r=Ct();return n%1||t%1?n+zt(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+St(r*(t-n+1))},f.reduce=z,f.reduceRight=C,f.result=function(n,t){var r=n?n[t]:tt; -return E(r)?n[t]():r},f.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Jt(n).length},f.some=P,f.sortedIndex=K,f.template=function(n,t,r){var e=f,u=e.templateSettings;n||(n=""),r=w({},r,u);var i=0,a="__p+='",u=r.variable;n.replace(RegExp((r.escape||ft).source+"|"+(r.interpolate||ft).source+"|"+(r.evaluate||ft).source+"|$","g"),function(t,r,e,u,f){return a+=n.slice(i,f).replace(ct,o),r&&(a+="'+_.escape("+r+")+'"),u&&(a+="';"+u+";__p+='"),e&&(a+="'+((__t=("+e+"))==null?'':__t)+'"),i=f+t.length,t -}),a+="';\n",u||(u="obj",a="with("+u+"||{}){"+a+"}"),a="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var c=Function("_","return "+a)(e)}catch(l){throw l.source=a,l}return t?c(t):(c.source=a,c)},f.unescape=function(n){return n==et?"":(n+"").replace(Qt,d)},f.uniqueId=function(n){var t=++it+"";return n?n+t:t},f.all=k,f.any=P,f.detect=D,f.findWhere=function(n,t){return U(n,t,rt)},f.foldl=z,f.foldr=C,f.include=R,f.inject=z,f.first=G,f.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t!="number"&&t!=et){var i=u;for(t=X(t,r,3);i--&&t(n[i],i,n);)e++}else if(e=t,e==et||r)return n[u-1];return Pt.call(n,Wt(0,u-e))}},f.take=G,f.head=G,nt(f),f.VERSION="1.3.1",f.prototype.chain=function(){return this.__chain__=rt,this},f.prototype.value=function(){return this.__wrapped__},q("pop push reverse shift sort splice unshift".split(" "),function(n){var t=xt[n];f.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),!Gt.spliceObjects&&0===n.length&&delete n[0],this -}}),q(["concat","join","slice"],function(n){var t=xt[n];f.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new c(n),n.__chain__=rt),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=f, define(function(){return f})):bt&&!bt.nodeType?jt?(jt.exports=f)._=f:bt._=f:n._=f}(this); \ No newline at end of file +;!function(n){function r(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++tr||typeof n=="undefined")return 1;if(ne?1:0}function e(n){return"\\"+pr[n]}function u(n){return n instanceof u?n:new i(n)}function i(n,r){this.__chain__=!!r,this.__wrapped__=n}function o(n,r,t){if(typeof n!="function")return K;if(typeof r=="undefined")return n;switch(t){case 1:return function(t){return n.call(r,t) +};case 2:return function(t,e){return n.call(r,t,e)};case 3:return function(t,e,u){return n.call(r,t,e,u)};case 4:return function(t,e,u,i){return n.call(r,t,e,u,i)}}return G(n,r)}function a(n,r,t,e){e=(e||0)-1;for(var u=n?n.length:0,i=[];++eu(a,l))&&(t&&a.push(l),o.push(f))}return o}function c(n){return function(r,t,e){var u={};return t=H(t,e,3),N(r,function(r,e,i){e=t(r,e,i)+"",n(u,r,e,i)}),u}}function p(n,r,t,e,u,i){var o=1&r,a=2&r,f=4&r;if(!a&&!w(n))throw new TypeError; +var l=n&&n.__bindData__;return l?(o&&!(1&l[1])&&(l[4]=u),f&&!(4&l[1])&&(l[5]=i),t&&jr.apply(l[2]||(l[2]=[]),t),e&&jr.apply(l[3]||(l[3]=[]),e),l[1]|=r,p.apply(null,l)):(kr.call(arguments),a&&(u=n),bound)}function s(n){return zr[n]}function v(){var n=(n=u.indexOf)===C?r:n;return n}function h(n){return Cr[n]}function g(n){return n&&typeof n=="object"?xr.call(n)==tr:!1}function y(n){if(!n)return n;for(var r=1,t=arguments.length;re&&(e=t,u=n)});else for(;++iu&&(u=t);return u}function B(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++targuments.length;r=o(r,e,4);var i=-1,a=n.length;if(typeof a=="number")for(u&&(t=n[++i]);++iarguments.length;return r=o(r,e,4),R(n,function(n,e,i){t=u?(u=!1,n):r(t,n,e,i)}),t}function $(n,r,t){var e;r=H(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++tt(u,o)&&i.push(o)}return i}function z(n,r,t){if(n){var e=0,u=n.length;if(typeof r!="number"&&null!=r){var i=-1;for(r=H(r,t,3);++ie?Nr(0,u+e):e||0}else if(e)return e=U(n,t),n[e]===t?e:-1;return n?r(n,t,e):-1 +}function P(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,i=n?n.length:0;for(r=H(r,t,3);++u>>1,t(n[e])o&&(u=n.apply(i,e));else{var t=new Date;!l&&!s&&(a=t);var p=f-(t-a);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},g(arguments)||(g=function(n){return n&&typeof n=="object"?wr.call(n,"callee"):!1});var $r=Tr||function(n){return n&&typeof n=="object"?xr.call(n)==er:!1},Ir=function(n){var r,t=[];if(!n||!cr[typeof n])return t;for(r in n)wr.call(n,r)&&t.push(r);return t +},Wr=Fr?function(n){return j(n)?Fr(n):[]}:Ir,zr={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Cr=d(zr),Pr=RegExp("("+Wr(Cr).join("|")+")","g"),Ur=RegExp("["+Wr(zr).join("")+"]","g"),Vr=function(n,r){var t;if(!n||!cr[typeof n])return n;for(t in n)if(r(n[t],t,n)===Y)break;return n},Gr=function(n,r){var t;if(!n||!cr[typeof n])return n;for(t in n)if(wr.call(n,t)&&r(n[t],t,n)===Y)break;return n};w(/x/)&&(w=function(n){return typeof n=="function"&&"[object Function]"==xr.call(n) +});var Hr=c(function(n,r,t){wr.call(n,t)?n[t]++:n[t]=1}),Jr=c(function(n,r,t){(wr.call(n,t)?n[t]:n[t]=[]).push(r)});u.after=function(n,r){if(!w(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=G,u.bindAll=function(n){for(var r=1u(o,a)){for(var f=t;--f;)if(0>u(r[f],a))continue n;o.push(a)}}return o},u.invert=d,u.invoke=function(n,r){var t=kr.call(arguments,2),e=-1,u=typeof r=="function",i=n?n.length:0,o=Array(typeof i=="number"?i:0); +return N(n,function(n){o[++e]=(u?r:n[r]).apply(n,t)}),o},u.keys=Wr,u.map=D,u.max=k,u.memoize=function(n,r){var t={};return function(){var e=Z+(r?r.apply(this,arguments):arguments[0]);return wr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e,i=-1,o=n?n.length:0;if(r||typeof o!="number")r=H(r,t,3),N(n,function(n,t,i){t=r(n,t,i),tr(t,u)&&(e[u]=n) +}),e},u.once=function(n){var r,t;if(!w(n))throw new TypeError;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},u.pairs=function(n){for(var r=-1,t=Wr(n),e=t.length,u=Array(e);++rr?0:r);++nt?Nr(0,e+t):Rr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=L,u.noConflict=function(){return n._=mr,this},u.random=function(n,r){null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0;var t=Dr();return n%1||r%1?n+Rr(t*(r-n+parseFloat("1e-"+((t+"").length-1))),r):n+br(t*(r-n+1)) +},u.reduce=q,u.reduceRight=M,u.result=function(n,r){var t=n?n[r]:Q;return w(t)?n[r]():t},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Wr(n).length},u.some=$,u.sortedIndex=U,u.template=function(n,r,t){var i=u,o=i.templateSettings;n||(n=""),t=m({},t,o);var a=0,f="__p+='",o=t.variable;n.replace(RegExp((t.escape||nr).source+"|"+(t.interpolate||nr).source+"|"+(t.evaluate||nr).source+"|$","g"),function(r,t,u,i,o){return f+=n.slice(a,o).replace(rr,e),t&&(f+="'+_.escape("+t+")+'"),i&&(f+="';"+i+";__p+='"),u&&(f+="'+((__t=("+u+"))==null?'':__t)+'"),a=o+r.length,r +}),f+="';\n",o||(o="obj",f="with("+o+"||{}){"+f+"}"),f="function("+o+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+f+"return __p}";try{var l=Function("_","return "+f)(i)}catch(c){throw c.source=f,c}return r?l(r):(l.source=f,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Pr,h)},u.uniqueId=function(n){var r=++X+"";return n?n+r:r},u.all=O,u.any=$,u.detect=F,u.findWhere=function(n,r){return I(n,r,!0)},u.foldl=q,u.foldr=M,u.include=T,u.inject=q,u.first=z,u.last=function(n,r,t){if(n){var e=0,u=n.length; +if(typeof r!="number"&&null!=r){var i=u;for(r=H(r,t,3);i--&&r(n[i],i,n);)e++}else if(e=r,null==e||t)return n[u-1];return kr.call(n,Nr(0,u-e))}},u.take=z,u.head=z,L(u),u.VERSION="1.3.1",u.prototype.chain=function(){return this.__chain__=!0,this},u.prototype.value=function(){return this.__wrapped__},N("pop push reverse shift sort splice unshift".split(" "),function(n){var r=gr[n];u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),!Mr.spliceObjects&&0===n.length&&delete n[0],this +}}),N(["concat","join","slice"],function(n){var r=gr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new i(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=u, define(function(){return u})):sr&&!sr.nodeType?vr?(vr.exports=u)._=u:sr._=u:n._=u}(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index a4c758bf5..caab8850a 100644 --- a/doc/README.md +++ b/doc/README.md @@ -105,6 +105,7 @@ * [`_.bindKey`](#_bindkeyobject-key--arg1-arg2-) * [`_.compose`](#_composefunc1-func2-) * [`_.createCallback`](#_createcallbackfuncidentity-thisarg-argcount) +* [`_.curry`](#_curryfunc--arityfunclength) * [`_.debounce`](#_debouncefunc-wait-options) * [`_.defer`](#_deferfunc--arg1-arg2-) * [`_.delay`](#_delayfunc-wait--arg1-arg2-) @@ -229,7 +230,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4026 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4050 "View in source") [Ⓣ][1] Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are all falsey. @@ -253,7 +254,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4055 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4079 "View in source") [Ⓣ][1] Creates an array excluding all values of the provided arrays using strict equality for comparisons, i.e. `===`. @@ -278,7 +279,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.findIndex(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4105 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4129 "View in source") [Ⓣ][1] This method is like `_.find` except that it returns the index of the first element that passes the callback check, instead of the element itself. @@ -306,7 +307,7 @@ _.findIndex(['apple', 'banana', 'beet'], function(food) { ### `_.findLastIndex(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4138 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4162 "View in source") [Ⓣ][1] This method is like `_.findIndex` except that it iterates over elements of a `collection` from right to left. @@ -334,7 +335,7 @@ _.findLastIndex(['apple', 'banana', 'beet'], function(food) { ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4206 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4230 "View in source") [Ⓣ][1] Gets the first element of an array. If a number `n` is provided the first `n` elements of the array are returned. If a callback is provided elements at the beginning of the array are returned as long as the callback returns truthy. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -394,7 +395,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array [, isShallow=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4268 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4292 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truthy, the array will only be flattened a single level. If a callback is provided each element of the array is passed through the callback before flattening. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -437,7 +438,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4329 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the array is already sorted providing `true` for `fromIndex` will run a faster binary search. @@ -469,7 +470,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4372 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4396 "View in source") [Ⓣ][1] Gets all but the last element of an array. If a number `n` is provided the last `n` elements are excluded from the result. If a callback is provided elements at the end of the array are excluded from the result as long as the callback returns truthy. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -526,7 +527,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4405 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4429 "View in source") [Ⓣ][1] Creates an array of unique values present in all provided arrays using strict equality for comparisons, i.e. `===`. @@ -550,7 +551,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4507 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4531 "View in source") [Ⓣ][1] Gets the last element of an array. If a number `n` is provided the last `n` elements of the array are returned. If a callback is provided elements at the end of the array are returned as long as the callback returns truthy. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -607,7 +608,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4548 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4572 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -636,7 +637,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.pull(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4578 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4602 "View in source") [Ⓣ][1] Removes all provided values from the given array using strict equality for comparisons, i.e. `===`. @@ -663,7 +664,7 @@ console.log(array); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4629 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4653 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. If `start` is less than `stop` a zero-length range is created unless a negative `step` is specified. @@ -704,7 +705,7 @@ _.range(0); ### `_.remove(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4682 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4706 "View in source") [Ⓣ][1] Removes all elements from an array that the callback returns truthy for and returns an array of removed elements. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -740,7 +741,7 @@ console.log(evens); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4757 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4781 "View in source") [Ⓣ][1] The opposite of `_.initial` this method gets all but the first value of an array. If a number `n` is provided the first `n` values are excluded from the result. If a callback function is provided elements at the beginning of the array are excluded from the result as long as the callback returns truthy. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -800,7 +801,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4821 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4845 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which a value should be inserted into a given sorted array in order to maintain the sort order of the array. If a callback is provided it will be executed for `value` and each element of `array` to compute their sort ranking. The callback is bound to `thisArg` and invoked with one argument; *(value)*. @@ -849,7 +850,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4852 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4876 "View in source") [Ⓣ][1] Creates an array of unique values, in order, of the provided arrays using strict equality for comparisons, i.e. `===`. @@ -873,7 +874,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4900 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4924 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of an array using strict equality for comparisons, i.e. `===`. If the array is sorted, providing `true` for `isSorted` will use a faster algorithm. If a callback is provided each element of `array` is passed through the callback before uniqueness is computed. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -920,7 +921,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4952 "View in source") [Ⓣ][1] Creates an array excluding all provided values using strict equality for comparisons, i.e. `===`. @@ -945,7 +946,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4948 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4972 "View in source") [Ⓣ][1] Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. @@ -972,7 +973,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4978 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5002 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Provide either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` or two arrays, one of `keys` and one of corresponding `values`. @@ -1007,7 +1008,7 @@ _.zipObject(['moe', 'larry'], [30, 40]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L613 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L617 "View in source") [Ⓣ][1] Creates a `lodash` object which wraps the given value to enable method chaining. @@ -1060,7 +1061,7 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6084 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6177 "View in source") [Ⓣ][1] Creates a `lodash` object that wraps the given `value`. @@ -1093,7 +1094,7 @@ var youngest = _.chain(stooges) ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6112 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6205 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument and then returns `value`. The purpose of this method is to "tap into" a method chain in order to perform operations on intermediate results within the chain. @@ -1123,7 +1124,7 @@ _([1, 2, 3, 4]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6132 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6225 "View in source") [Ⓣ][1] Enables method chaining on the wrapper object. @@ -1147,7 +1148,7 @@ var sum = _([1, 2, 3]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6149 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6242 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1168,7 +1169,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6166 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6259 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1199,7 +1200,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2924 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2948 "View in source") [Ⓣ][1] Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -1227,7 +1228,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2966 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2990 "View in source") [Ⓣ][1] Checks if a given value is present in a collection using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -1265,7 +1266,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3022 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3046 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of `collection` through the callback. The corresponding value of each key is the number of times the key was returned by the callback. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1301,7 +1302,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3067 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3091 "View in source") [Ⓣ][1] Checks if the given callback returns truthy value for **all** elements of a collection. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1347,7 +1348,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3128 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1] Iterates over elements of a collection, returning an array of all elements the callback returns truthy for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1393,7 +1394,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3195 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3219 "View in source") [Ⓣ][1] Iterates over elements of a collection, returning the first element that the callback returns truthy for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1442,7 +1443,7 @@ _.find(food, 'organic'); ### `_.findLast(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3240 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3264 "View in source") [Ⓣ][1] This method is like `_.find` except that it iterates over elements of a `collection` from right to left. @@ -1470,7 +1471,7 @@ _.findLast([1, 2, 3, 4], function(num) { ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3274 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3298 "View in source") [Ⓣ][1] Iterates over elements of a collection, executing the callback for each element. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1502,7 +1503,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); ### `_.forEachRight(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3307 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3331 "View in source") [Ⓣ][1] This method is like `_.forEach` except that it iterates over elements of a `collection` from right to left. @@ -1531,7 +1532,7 @@ _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3360 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3384 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of a collection through the callback. The corresponding value of each key is an array of the elements responsible for generating the key. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1568,7 +1569,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.indexBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3403 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3427 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of the collection through the given callback. The corresponding value of each key is the last element responsible for generating the key. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1609,7 +1610,7 @@ _.indexBy(stooges, function(key) { this.fromCharCode(key.code); }, String); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3429 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3453 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection` returning an array of the results of each invoked method. Additional arguments will be provided to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1638,7 +1639,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3481 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3505 "View in source") [Ⓣ][1] Creates an array of values by running each element in the collection through the callback. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1683,7 +1684,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3538 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3562 "View in source") [Ⓣ][1] Retrieves the maximum value of an array. If a callback is provided it will be executed for each value in the array to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1725,7 +1726,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3607 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3631 "View in source") [Ⓣ][1] Retrieves the minimum value of an array. If a callback is provided it will be executed for each value in the array to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1767,7 +1768,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3657 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3681 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1797,7 +1798,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3713 "View in source") [Ⓣ][1] Reduces a collection to a value which is the accumulated result of running each element in the collection through the callback, where each successive callback execution consumes the return value of the previous execution. If `accumulator` is not provided the first element of the collection will be used as the initial `accumulator` value. The callback is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1835,7 +1836,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3732 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3756 "View in source") [Ⓣ][1] This method is like `_.reduce` except that it iterates over elements of a `collection` from right to left. @@ -1866,7 +1867,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3781 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3805 "View in source") [Ⓣ][1] The opposite of `_.filter` this method returns the elements of a collection that the callback does **not** return truthy for. @@ -1909,7 +1910,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3802 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3826 "View in source") [Ⓣ][1] Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1933,7 +1934,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3835 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3859 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1963,7 +1964,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3882 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3906 "View in source") [Ⓣ][1] Checks if the callback returns a truthy value for **any** element of a collection. The function returns as soon as it finds a passing value and does not iterate over the entire collection. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -2009,7 +2010,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3938 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3962 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in a collection through the callback. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -2046,7 +2047,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3974 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3998 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -2070,7 +2071,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4008 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4032 "View in source") [Ⓣ][1] Performs a deep comparison of each element in a `collection` to the given `properties` object, returning an array of all elements that have equivalent property values. @@ -2110,7 +2111,7 @@ _.where(stooges, { 'quotes': ['Poifect!'] }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5015 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5039 "View in source") [Ⓣ][1] Creates a function this is restricted to executing `func` with the `this` binding and arguments of the created function, only after it is called `n` times. @@ -2138,7 +2139,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5045 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5072 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those provided to the bound function. @@ -2169,7 +2170,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5073 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5100 "View in source") [Ⓣ][1] Binds methods of an object to the object itself, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided all the function properties of `object` will be bound. @@ -2200,7 +2201,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5119 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5146 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those provided to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -2241,7 +2242,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5153 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5180 "View in source") [Ⓣ][1] Creates a function that is the composition of the provided functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -2279,7 +2280,7 @@ welcome('curly'); ### `_.createCallback([func=identity, thisArg, argCount])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5197 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5231 "View in source") [Ⓣ][1] Produces a callback bound to an optional `thisArg`. If `func` is a property name the created callback will return the property value for a given element. If `func` is an object the created callback will return `true` for elements that contain the equivalent object properties, otherwise it will return `false`. @@ -2315,10 +2316,45 @@ _.filter(stooges, 'age__gt45'); + + +### `_.curry(func [, arity=func.length])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5296 "View in source") [Ⓣ][1] + +Creates a function which accepts one or more arguments of `func` that when invoked either executes `func` returning its result, if all `func` arguments have been provided, or returns a function that accepts one or more of the remaining `func` arguments, and so on. The arity of `func` can be specified if `func.length` is not sufficient. + +#### Arguments +1. `func` *(Function)*: The function to curry. +2. `[arity=func.length]` *(Number)*: The arity of `func`. + +#### Returns +*(Function)*: Returns the new curried function. + +#### Example +```js +var curried = _.curry(function(a, b, c) { + console.log(a + b + c); +}); + +curried(1)(2)(3); +// => 6 + +curried(1, 2)(3); +// => 6 + +curried(1, 2, 3); +// => 6 +``` + +* * * + + + + ### `_.debounce(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5273 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5340 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2359,7 +2395,7 @@ source.addEventListener('message', _.debounce(batchLog, 250, { ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5370 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5440 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be provided to `func` when it is invoked. @@ -2384,7 +2420,7 @@ _.defer(function() { console.log('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5396 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5474 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be provided to `func` when it is invoked. @@ -2411,7 +2447,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5421 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5502 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is provided it will be used to determine the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. The result cache is exposed as the `cache` property on the memoized function. @@ -2437,7 +2473,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5451 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5535 "View in source") [Ⓣ][1] Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. @@ -2463,7 +2499,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5486 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5573 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those provided to the new function. This method is similar to `_.bind` except it does **not** alter the `this` binding. @@ -2490,7 +2526,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5517 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5604 "View in source") [Ⓣ][1] This method is like `_.partial` except that `partial` arguments are appended to those provided to the new function. @@ -2527,7 +2563,7 @@ options.imports ### `_.throttle(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5552 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5639 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2561,7 +2597,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5593 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5683 "View in source") [Ⓣ][1] Creates a function that provides `value` to the wrapper function as its first argument. Additional arguments provided to the function are appended to those provided to the wrapper function. The wrapper is executed with the `this` binding of the created function. @@ -2597,7 +2633,7 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1874 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a callback is provided it will be executed to produce the assigned values. The callback is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -2635,7 +2671,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1903 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1927 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true` nested objects will also be cloned, otherwise they will be assigned by reference. If a callback is provided it will be executed to produce the cloned values. If the callback returns `undefined` cloning will be handled by the method instead. The callback is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2682,7 +2718,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1955 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1979 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If a callback is provided it will be executed to produce the cloned values. If the callback returns `undefined` cloning will be handled by the method instead. The callback is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2728,7 +2764,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1979 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2003 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -2754,7 +2790,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.findKey(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2001 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2025 "View in source") [Ⓣ][1] This method is like `_.findIndex` except that it returns the key of the first element that passes the callback check, instead of the element itself. @@ -2782,7 +2818,7 @@ _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.findLastKey(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2033 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2057 "View in source") [Ⓣ][1] This method is like `_.findKey` except that it iterates over elements of a `collection` in the opposite order. @@ -2810,7 +2846,7 @@ _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2074 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2098 "View in source") [Ⓣ][1] Iterates over own and inherited enumerable properties of an object, executing the callback for each property. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2846,7 +2882,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forInRight(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2104 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2128 "View in source") [Ⓣ][1] This method is like `_.forIn` except that it iterates over elements of a `collection` in the opposite order. @@ -2882,7 +2918,7 @@ _.forInRight(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2142 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2166 "View in source") [Ⓣ][1] Iterates over own enumerable properties of an object, executing the callback for each property. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2910,7 +2946,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.forOwnRight(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2186 "View in source") [Ⓣ][1] This method is like `_.forOwn` except that it iterates over elements of a `collection` in the opposite order. @@ -2938,7 +2974,7 @@ _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2215 "View in source") [Ⓣ][1] Creates a sorted array of property names of all enumerable properties, own and inherited, of `object` that have function values. @@ -2965,7 +3001,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2216 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2240 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2990,7 +3026,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2257 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given object. @@ -3014,7 +3050,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1678 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1702 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -3041,7 +3077,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1705 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1729 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -3068,7 +3104,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2259 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2283 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -3092,7 +3128,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2276 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2300 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -3116,7 +3152,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2293 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2317 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -3140,7 +3176,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2342 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -3170,7 +3206,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2375 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2399 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If a callback is provided it will be executed to compare values. If the callback returns `undefined` comparisons will be handled by the method instead. The callback is bound to `thisArg` and invoked with two arguments; *(a, b)*. @@ -3215,7 +3251,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2407 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2431 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -3253,7 +3289,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2424 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2448 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -3277,7 +3313,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2487 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2511 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -3312,7 +3348,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2509 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2533 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -3339,7 +3375,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2528 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2552 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -3365,7 +3401,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2454 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2478 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -3395,7 +3431,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2556 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2580 "View in source") [Ⓣ][1] Checks if `value` is an object created by the `Object` constructor. @@ -3430,7 +3466,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2581 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2605 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -3454,7 +3490,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2598 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2622 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3478,7 +3514,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2615 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2639 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3502,7 +3538,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1762 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of an object. @@ -3526,7 +3562,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2694 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined` into the destination object. Subsequent sources will overwrite property assignments of previous sources. If a callback is provided it will be executed to produce the merged values of the destination and source properties. If the callback returns `undefined` merging will be handled by the method instead. The callback is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -3582,7 +3618,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2726 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2750 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a callback is provided it will be executed for each property of `object` omitting the properties the callback returns truthy for. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3613,7 +3649,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2761 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2785 "View in source") [Ⓣ][1] Creates a two dimensional array of an object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3637,7 +3673,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2801 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2825 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a callback is provided it will be executed for each property of `object` picking the properties the callback returns truthy for. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3668,7 +3704,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.transform(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2880 "View in source") [Ⓣ][1] An alternative to `_.reduce` this method transforms `object` to a new `accumulator` object which is the result of running each of its elements through a callback, with each callback execution potentially mutating the `accumulator` object. The callback is bound to `thisArg` and invoked with four arguments; *(accumulator, value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -3705,7 +3741,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2889 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2913 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3736,7 +3772,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5617 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5710 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3760,7 +3796,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5635 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5728 "View in source") [Ⓣ][1] This method returns the first argument provided to it. @@ -3785,7 +3821,7 @@ moe === _.identity(moe); ### `_.mixin(object, object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5662 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5755 "View in source") [Ⓣ][1] Adds function properties of a source object to the `lodash` function and chainable wrapper. @@ -3816,7 +3852,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5793 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3836,7 +3872,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value [, radix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5817 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. If `radix` is `undefined` or `0` a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. @@ -3863,7 +3899,7 @@ _.parseInt('08'); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5748 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5841 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is provided a number between `0` and the given number will be returned. @@ -3891,7 +3927,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5885 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey then `undefined` is returned. @@ -3926,7 +3962,7 @@ _.result(object, 'stuff'); ### `_.runInContext([context=window])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L445 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L449 "View in source") [Ⓣ][1] Create a new `lodash` function using the given `context` object. @@ -3944,7 +3980,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5883 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5976 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -4032,7 +4068,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6008 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6101 "View in source") [Ⓣ][1] Executes the callback `n` times, returning an array of the results of each callback execution. The callback is bound to `thisArg` and invoked with one argument; *(index)*. @@ -4064,7 +4100,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6035 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6128 "View in source") [Ⓣ][1] The inverse of `_.escape` this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -4088,7 +4124,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6055 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6148 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is provided the ID will be appended to it. @@ -4122,7 +4158,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L824 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L828 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -4141,7 +4177,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6360 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6454 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -4153,7 +4189,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L642 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L646 "View in source") [Ⓣ][1] *(Object)*: An object used to flag environments features. @@ -4165,7 +4201,7 @@ A reference to the `lodash` function. ### `_.support.argsClass` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L667 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L671 "View in source") [Ⓣ][1] *(Boolean)*: Detect if an `arguments` object's [[Class]] is resolvable *(all but Firefox < `4`, IE < `9`)*. @@ -4177,7 +4213,7 @@ A reference to the `lodash` function. ### `_.support.argsObject` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L659 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L663 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `arguments` objects are `Object` objects *(all but Narwhal and Opera < `10.5`)*. @@ -4189,7 +4225,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L676 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L680 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `name` or `message` properties of `Error.prototype` are enumerable by default. *(IE < `9`, Safari < `5.1`)* @@ -4201,7 +4237,7 @@ A reference to the `lodash` function. ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L693 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `prototype` properties are enumerable by default. @@ -4215,7 +4251,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.fastBind` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L701 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Function#bind` exists and is inferred to be fast *(all but V8)*. @@ -4227,7 +4263,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumArgs` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L714 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L718 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `arguments` object indexes are non-enumerable *(Firefox < `4`, IE < `9`, PhantomJS, Safari < `5.1`)*. @@ -4239,7 +4275,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L725 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L729 "View in source") [Ⓣ][1] *(Boolean)*: Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -4253,7 +4289,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.ownLast` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L705 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L709 "View in source") [Ⓣ][1] *(Boolean)*: Detect if own properties are iterated after inherited properties *(all but IE < `9`)*. @@ -4265,7 +4301,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L739 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L743 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -4279,7 +4315,7 @@ Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` a ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L750 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L754 "View in source") [Ⓣ][1] *(Boolean)*: Detect lack of support for accessing string characters by index. @@ -4293,7 +4329,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L776 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L780 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -4305,7 +4341,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L784 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L788 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -4317,7 +4353,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L796 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -4329,7 +4365,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L800 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L804 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -4341,7 +4377,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L808 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L812 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -4353,7 +4389,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L816 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L820 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. diff --git a/lodash.js b/lodash.js index fa4395c2b..d41fa0d3a 100644 --- a/lodash.js +++ b/lodash.js @@ -4702,8 +4702,6 @@ * * console.log(evens); * // => [2, 4, 6] - * - * */ function remove(array, callback, thisArg) { var index = -1, @@ -5039,6 +5037,9 @@ * // `renderNotes` is run once, after all notes have saved */ function after(n, func) { + if (!isFunction(func)) { + throw new TypeError; + } return function() { if (--n < 1) { return func.apply(this, arguments); @@ -5177,7 +5178,14 @@ * // => 'Hiya Jerome!' */ function compose() { - var funcs = arguments; + var funcs = arguments, + length = funcs.length || 1; + + while (length--) { + if (!isFunction(funcs[length])) { + throw new TypeError; + } + } return function() { var args = arguments, length = funcs.length; @@ -5340,32 +5348,9 @@ timeoutId = null, trailing = true; - function clear() { - clearTimeout(maxTimeoutId); - clearTimeout(timeoutId); - callCount = 0; - maxTimeoutId = timeoutId = null; + if (!isFunction(func)) { + throw new TypeError; } - - function delayed() { - var isCalled = trailing && (!leading || callCount > 1); - clear(); - if (isCalled) { - if (maxWait !== false) { - lastCalled = new Date; - } - result = func.apply(thisArg, args); - } - } - - function maxDelayed() { - clear(); - if (trailing || (maxWait !== wait)) { - lastCalled = new Date; - result = func.apply(thisArg, args); - } - } - wait = nativeMax(0, wait || 0); if (options === true) { var leading = true; @@ -5375,6 +5360,32 @@ maxWait = 'maxWait' in options && nativeMax(wait, options.maxWait || 0); trailing = 'trailing' in options ? options.trailing : trailing; } + var clear = function() { + clearTimeout(maxTimeoutId); + clearTimeout(timeoutId); + callCount = 0; + maxTimeoutId = timeoutId = null; + }; + + var delayed = function() { + var isCalled = trailing && (!leading || callCount > 1); + clear(); + if (isCalled) { + if (maxWait !== false) { + lastCalled = new Date; + } + result = func.apply(thisArg, args); + } + }; + + var maxDelayed = function() { + clear(); + if (trailing || (maxWait !== wait)) { + lastCalled = new Date; + result = func.apply(thisArg, args); + } + }; + return function() { args = arguments; thisArg = this; @@ -5427,12 +5438,20 @@ * // returns from the function before 'deferred' is logged */ function defer(func) { + if (!isFunction(func)) { + throw new TypeError; + } var args = nativeSlice.call(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); } - // use `setImmediate` if it's available in Node.js + // use `setImmediate` if available in Node.js if (isV8 && freeModule && typeof setImmediate == 'function') { - defer = bind(setImmediate, context); + defer = function(func) { + if (!isFunction(func)) { + throw new TypeError; + } + return setImmediate.apply(context, arguments); + }; } /** @@ -5453,6 +5472,9 @@ * // => 'logged later' (Appears after one second.) */ function delay(func, wait) { + if (!isFunction(func)) { + throw new TypeError; + } var args = nativeSlice.call(arguments, 2); return setTimeout(function() { func.apply(undefined, args); }, wait); } @@ -5478,7 +5500,10 @@ * }); */ function memoize(func, resolver) { - function memoized() { + if (!isFunction(func)) { + throw new TypeError; + } + var memoized = function() { var cache = memoized.cache, key = keyPrefix + (resolver ? resolver.apply(this, arguments) : arguments[0]); @@ -5511,6 +5536,9 @@ var ran, result; + if (!isFunction(func)) { + throw new TypeError; + } return function() { if (ran) { return result; @@ -5612,6 +5640,9 @@ var leading = true, trailing = true; + if (!isFunction(func)) { + throw new TypeError; + } if (options === false) { leading = false; } else if (isObject(options)) { @@ -5650,6 +5681,9 @@ * // => 'before, hello moe, after' */ function wrap(value, wrapper) { + if (!isFunction(wrapper)) { + throw new TypeError; + } return function() { var args = [value]; push.apply(args, arguments);