i(r,p)&&l.push(p);return f&&c(r),l}function ot(n,t,e,r){r=(r||0)-1;for(var u=n?n.length:0,o=[];++r=b&&f===n,h=u||v?a():s;
+if(v){var g=o(h);g?(f=t,h=g):(v=false,h=u?h:(l(h),s))}for(;++if(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(l(h.k),c(h)):u&&l(h),s}function ct(n){return function(t,e,r){var u={};e=Q.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++re?Ne(0,o+e):e)||0,$e(n)?i=-1o&&(o=a)}}else t=null==t&&kt(n)?r:Q.createCallback(t,e,3),St(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Dt(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=Q.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;return t=Q.createCallback(t,r,4),Et(n,function(n,r,o){e=u?(u=false,n):t(e,n,r,o)
+}),e}function Tt(n){var t=-1,e=n?n.length:0,r=Xt(typeof e=="number"?e:0);return St(n,function(n){var e=ft(0,++t);r[t]=r[e],r[e]=n}),r}function Ft(n,t,e){var r;t=Q.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++er?Ne(0,u+r):r||0}else if(r)return r=zt(t,e),t[r]===e?r:-1;return n(t,e,r)}function qt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=Q.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t=v;m?(i&&(i=ve(i)),s=f,a=n.apply(l,o)):i||(i=_e(r,v))}return m&&c?c=ve(c):c||t===h||(c=_e(u,t)),e&&(m=true,a=n.apply(l,o)),!m||c||i||(o=l=null),a}}function Ut(n){return n}function Gt(n,t,e){var r=true,u=t&&bt(t);
+t&&(e||u.length)||(null==e&&(e=t),o=X,t=n,n=Q,u=bt(t)),false===e?r=false:wt(e)&&"chain"in e&&(r=e.chain);var o=n,i=dt(o);St(u,function(e){var u=n[e]=t[e];i&&(o.prototype[e]=function(){var t=this.__chain__,e=this.__wrapped__,i=[e];if(be.apply(i,arguments),i=u.apply(n,i),r||t){if(e===i&&wt(i))return this;i=new o(i),i.__chain__=t}return i})})}function Ht(){}function Jt(n){return function(t){return t[n]}}function Qt(){return this.__wrapped__}e=e?Y.defaults(G.Object(),e,Y.pick(G,A)):G;var Xt=e.Array,Yt=e.Boolean,Zt=e.Date,ne=e.Function,te=e.Math,ee=e.Number,re=e.Object,ue=e.RegExp,oe=e.String,ie=e.TypeError,ae=[],fe=re.prototype,le=e._,ce=fe.toString,pe=ue("^"+oe(ce).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),se=te.ceil,ve=e.clearTimeout,he=te.floor,ge=ne.prototype.toString,ye=pe.test(ye=re.getPrototypeOf)&&ye,me=fe.hasOwnProperty,be=ae.push,_e=e.setTimeout,de=ae.splice,we=function(){try{var n={},t=pe.test(t=re.defineProperty)&&t,e=t(n,n,n)&&t
+}catch(r){}return e}(),je=pe.test(je=re.create)&&je,ke=pe.test(ke=Xt.isArray)&&ke,xe=e.isFinite,Ce=e.isNaN,Oe=pe.test(Oe=re.keys)&&Oe,Ne=te.max,Ie=te.min,Se=e.parseInt,Ee=te.random,Re={};Re[$]=Xt,Re[T]=Yt,Re[F]=Zt,Re[B]=ne,Re[q]=re,Re[W]=ee,Re[z]=ue,Re[P]=oe,X.prototype=Q.prototype;var Ae=Q.support={};Ae.funcDecomp=!pe.test(e.a)&&E.test(s),Ae.funcNames=typeof ne.name=="string",Q.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Q}},je||(tt=function(){function n(){}return function(t){if(wt(t)){n.prototype=t;
+var r=new n;n.prototype=null}return r||e.Object()}}());var De=we?function(n,t){M.value=t,we(n,"__bindData__",M)}:Ht,$e=ke||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ce.call(n)==$||false},Te=Oe?function(n){return wt(n)?Oe(n):[]}:J,Fe={"&":"&","<":"<",">":">",'"':""","'":"'"},Be=_t(Fe),We=ue("("+Te(Be).join("|")+")","g"),qe=ue("["+Te(Fe).join("")+"]","g"),ze=ct(function(n,t,e){me.call(n,e)?n[e]++:n[e]=1}),Pe=ct(function(n,t,e){(me.call(n,e)?n[e]:n[e]=[]).push(t)
+}),Ke=ct(function(n,t,e){n[e]=t}),Le=Rt,Me=pe.test(Me=Zt.now)&&Me||function(){return(new Zt).getTime()},Ve=8==Se(d+"08")?Se:function(n,t){return Se(kt(n)?n.replace(I,""):n,t||0)};return Q.after=function(n,t){if(!dt(t))throw new ie;return function(){return 1>--n?t.apply(this,arguments):void 0}},Q.assign=H,Q.at=function(n){for(var t=arguments,e=-1,r=ot(t,true,false,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Xt(t);++e=b&&o(r?e[r]:s)))
+}var p=e[0],h=-1,g=p?p.length:0,y=[];n:for(;++h(m?t(m,v):f(s,v))){for(r=u,(m||s).push(v);--r;)if(m=i[r],0>(m?t(m,v):f(e[r],v)))continue n;y.push(v)}}for(;u--;)(m=i[u])&&c(m);return l(i),l(s),y},Q.invert=_t,Q.invoke=function(n,t){var e=p(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,i=Xt(typeof o=="number"?o:0);return St(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},Q.keys=Te,Q.map=Rt,Q.mapValues=function(n,t,e){var r={};return t=Q.createCallback(t,e,3),g(n,function(n,e,u){r[e]=t(n,e,u)
+}),r},Q.max=At,Q.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):m+arguments[0];return me.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!dt(n))throw new ie;return e.cache={},e},Q.merge=function(n){var t=arguments,e=2;if(!wt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3e?Ne(0,r+e):Ie(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Q.mixin=Gt,Q.noConflict=function(){return e._=le,this},Q.noop=Ht,Q.now=Me,Q.parseInt=Ve,Q.random=function(n,t,e){var r=null==n,u=null==t;return null==e&&(typeof n=="boolean"&&u?(e=n,n=1):u||typeof t!="boolean"||(e=t,u=true)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=Ee(),Ie(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):ft(n,t)
+},Q.reduce=Dt,Q.reduceRight=$t,Q.result=function(n,t){if(n){var e=n[t];return dt(e)?n[t]():e}},Q.runInContext=s,Q.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Te(n).length},Q.some=Ft,Q.sortedIndex=zt,Q.template=function(n,t,e){var r=Q.templateSettings;n=oe(n||""),e=U({},e,r);var u,o=U({},e.imports,r.imports),r=Te(o),o=xt(o),a=0,f=e.interpolate||S,l="__p+='",f=ue((e.escape||S).source+"|"+f.source+"|"+(f===N?x:S).source+"|"+(e.evaluate||S).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(a,c).replace(R,i),e&&(l+="'+__e("+e+")+'"),f&&(u=true,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),a=c+t.length,t
+}),l+="';",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(w,""):l).replace(j,"$1").replace(k,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=ne(r,"return "+l).apply(v,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},Q.unescape=function(n){return null==n?"":oe(n).replace(We,gt)},Q.uniqueId=function(n){var t=++y;return oe(null==n?"":n)+t
+},Q.all=Ot,Q.any=Ft,Q.detect=It,Q.findWhere=It,Q.foldl=Dt,Q.foldr=$t,Q.include=Ct,Q.inject=Dt,Gt(function(){var n={};return g(Q,function(t,e){Q.prototype[e]||(n[e]=t)}),n}(),false),Q.first=Bt,Q.last=function(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u;for(t=Q.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:v;return p(n,Ne(0,u-r))},Q.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=xt(n)),null==t||e?n?n[ft(0,n.length-1)]:v:(n=Tt(n),n.length=Ie(Ne(0,t),n.length),n)
+},Q.take=Bt,Q.head=Bt,g(Q,function(n,t){var e="sample"!==t;Q.prototype[t]||(Q.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new X(o,u):o})}),Q.VERSION="2.4.0",Q.prototype.chain=function(){return this.__chain__=true,this},Q.prototype.toString=function(){return oe(this.__wrapped__)},Q.prototype.value=Qt,Q.prototype.valueOf=Qt,St(["join","pop","shift"],function(n){var t=ae[n];Q.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);
+return n?new X(e,n):e}}),St(["push","reverse","sort","unshift"],function(n){var t=ae[n];Q.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),St(["concat","slice","splice"],function(n){var t=ae[n];Q.prototype[n]=function(){return new X(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Q}var v,h=[],g=[],y=0,m=+new Date+"",b=75,_=40,d=" \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",w=/\b__p\+='';/g,j=/\b(__p\+=)''\+/g,k=/(__e\(.*?\)|\b__t\))\+'';/g,x=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,C=/\w*$/,O=/^\s*function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,I=RegExp("^["+d+"]*0+(?=.$)"),S=/($^)/,E=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,A="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setTimeout".split(" "),D="[object Arguments]",$="[object Array]",T="[object Boolean]",F="[object Date]",B="[object Function]",W="[object Number]",q="[object Object]",z="[object RegExp]",P="[object String]",K={};
+K[B]=false,K[D]=K[$]=K[T]=K[F]=K[W]=K[q]=K[z]=K[P]=true;var L={leading:false,maxWait:0,trailing:false},M={configurable:false,enumerable:false,value:null,writable:false},V={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},U={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},G=V[typeof window]&&window||this,H=V[typeof exports]&&exports&&!exports.nodeType&&exports,J=V[typeof module]&&module&&!module.nodeType&&module,Q=J&&J.exports===H&&H,X=V[typeof global]&&global;!X||X.global!==X&&X.window!==X||(G=X);
var Y=s();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(G._=Y, define(function(){return Y})):H&&J?Q?(J.exports=Y)._=Y:H._=Y:G._=Y}).call(this);
\ No newline at end of file
diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js
index ae0b08cdde..26f8977586 100644
--- a/dist/lodash.underscore.js
+++ b/dist/lodash.underscore.js
@@ -1,6 +1,6 @@
/**
* @license
- * Lo-Dash 2.3.0 (Custom Build)
+ * Lo-Dash 2.4.0 (Custom Build)
* Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js`
* Copyright 2012-2013 The Dojo Foundation
* Based on Underscore.js 1.5.2
@@ -115,22 +115,29 @@
*/
function compareAscending(a, b) {
var ac = a.criteria,
- bc = b.criteria;
+ bc = b.criteria,
+ index = -1,
+ length = ac.length;
- // ensure a stable sort in V8 and other engines
- // http://code.google.com/p/v8/issues/detail?id=90
- if (ac !== bc) {
- if (ac > bc || typeof ac == 'undefined') {
- return 1;
- }
- if (ac < bc || typeof bc == 'undefined') {
- return -1;
+ while (++index < length) {
+ var value = ac[index],
+ other = bc[index];
+
+ if (value !== other) {
+ if (value > other || typeof value == 'undefined') {
+ return 1;
+ }
+ if (value < other || typeof other == 'undefined') {
+ return -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
+ // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
+ // that causes it, under certain circumstances, to return the same value for
+ // `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247
+ //
+ // This also ensures a stable sort in V8 and other engines.
+ // See http://code.google.com/p/v8/issues/detail?id=90
return a.index - b.index;
}
@@ -204,7 +211,6 @@
var ceil = Math.ceil,
floor = Math.floor,
hasOwnProperty = objectProto.hasOwnProperty,
- now = reNative.test(now = Date.now) && now || function() { return +new Date; },
push = arrayRef.push,
propertyIsEnumerable = objectProto.propertyIsEnumerable;
@@ -1209,22 +1215,22 @@
}
/**
- * Checks if the specified object `property` exists and is a direct property,
+ * Checks if the specified property name exists as a direct property of `object`,
* instead of an inherited property.
*
* @static
* @memberOf _
* @category Objects
- * @param {Object} object The object to check.
- * @param {string} property The property to check for.
+ * @param {Object} object The object to inspect.
+ * @param {string} key The name of the property to check.
* @returns {boolean} Returns `true` if key is a direct property, else `false`.
* @example
*
* _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
* // => true
*/
- function has(object, property) {
- return object ? hasOwnProperty.call(object, property) : false;
+ function has(object, key) {
+ return object ? hasOwnProperty.call(object, key) : false;
}
/**
@@ -1237,7 +1243,7 @@
* @returns {Object} Returns the created inverted object.
* @example
*
- * _.invert({ 'first': 'fred', 'second': 'barney' });
+ * _.invert({ 'first': 'fred', 'second': 'barney' });
* // => { 'fred': 'first', 'barney': 'second' }
*/
function invert(object) {
@@ -2435,7 +2441,7 @@
* @type Function
* @category Collections
* @param {Array|Object|string} collection The collection to iterate over.
- * @param {string} property The property to pluck.
+ * @param {string} property The name of the property to pluck.
* @returns {Array} Returns a new array of property values.
* @example
*
@@ -2447,18 +2453,7 @@
* _.pluck(characters, 'name');
* // => ['barney', 'fred']
*/
- function pluck(collection, property) {
- var index = -1,
- length = collection ? collection.length : 0;
-
- if (typeof length == 'number') {
- var result = Array(length);
- while (++index < length) {
- result[index] = collection[index][property];
- }
- }
- return result || map(collection, property);
- }
+ var pluck = map;
/**
* Reduces a collection to a value which is the accumulated result of running
@@ -2666,7 +2661,7 @@
* // => 3
*
* _.size('pebbles');
- * // => 5
+ * // => 7
*/
function size(collection) {
var length = collection ? collection.length : 0;
@@ -2746,6 +2741,9 @@
* If a property name is provided for `callback` the created "_.pluck" style
* callback will return the property value of the given element.
*
+ * If an array of property names is provided for `callback` the collection
+ * will be sorted by each property value.
+ *
* If an object is provided for `callback` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
@@ -2754,7 +2752,7 @@
* @memberOf _
* @category Collections
* @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [callback=identity] The function called
+ * @param {Array|Function|Object|string} [callback=identity] The function called
* per iteration. If a property name or object is provided it will be used
* to create a "_.pluck" or "_.where" style callback, respectively.
* @param {*} [thisArg] The `this` binding of `callback`.
@@ -2767,9 +2765,20 @@
* _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
* // => [3, 1, 2]
*
+ * var characters = [
+ * { 'name': 'barney', 'age': 36 },
+ * { 'name': 'fred', 'age': 40 },
+ * { 'name': 'barney', 'age': 26 },
+ * { 'name': 'fred', 'age': 30 }
+ * ];
+ *
* // using "_.pluck" callback shorthand
- * _.sortBy(['banana', 'strawberry', 'apple'], 'length');
- * // => ['apple', 'banana', 'strawberry']
+ * _.map(_.sortBy(characters, 'age'), _.values);
+ * // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]]
+ *
+ * // sorting by multiple properties
+ * _.map(_.sortBy(characters, ['name', 'age']), _.values);
+ * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
*/
function sortBy(collection, callback, thisArg) {
var index = -1,
@@ -2779,7 +2788,7 @@
callback = createCallback(callback, thisArg, 3);
forEach(collection, function(value, key, collection) {
result[++index] = {
- 'criteria': callback(value, key, collection),
+ 'criteria': [callback(value, key, collection)],
'index': index,
'value': value
};
@@ -2826,7 +2835,7 @@
* @type Function
* @category Collections
* @param {Array|Object|string} collection The collection to iterate over.
- * @param {Object} properties The object of property values to filter by.
+ * @param {Object} props The object of property values to filter by.
* @returns {Array} Returns a new array of elements that have the given properties.
* @example
*
@@ -3120,15 +3129,24 @@
* @memberOf _
* @category Arrays
* @param {...Array} [array] The arrays to inspect.
- * @returns {Array} Returns an array of composite values.
+ * @returns {Array} Returns an array of shared values.
* @example
*
- * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
+ * _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
* // => [1, 2]
*/
- function intersection(array) {
- var args = arguments,
- argsLength = args.length,
+ function intersection() {
+ var args = [],
+ argsIndex = -1,
+ argsLength = arguments.length;
+
+ while (++argsIndex < argsLength) {
+ var value = arguments[argsIndex];
+ if (isArray(value) || isArguments(value)) {
+ args.push(value);
+ }
+ }
+ var array = args[0],
index = -1,
indexOf = getIndexOf(),
length = array ? array.length : 0,
@@ -3136,7 +3154,7 @@
outer:
while (++index < length) {
- var value = array[index];
+ value = array[index];
if (indexOf(result, value) < 0) {
var argsIndex = argsLength;
while (--argsIndex) {
@@ -3453,13 +3471,13 @@
* @memberOf _
* @category Arrays
* @param {...Array} [array] The arrays to inspect.
- * @returns {Array} Returns an array of composite values.
+ * @returns {Array} Returns an array of combined values.
* @example
*
- * _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
- * // => [1, 2, 3, 101, 10]
+ * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]);
+ * // => [1, 2, 3, 5, 4]
*/
- function union(array) {
+ function union() {
return baseUniq(baseFlatten(arguments, true, true));
}
@@ -3589,6 +3607,9 @@
length = keys ? keys.length : 0,
result = {};
+ if (!values && length && !isArray(keys[0])) {
+ values = [];
+ }
while (++index < length) {
var key = keys[index];
if (values) {
@@ -3681,8 +3702,8 @@
* @example
*
* var view = {
- * 'label': 'docs',
- * 'onClick': function() { console.log('clicked ' + this.label); }
+ * 'label': 'docs',
+ * 'onClick': function() { console.log('clicked ' + this.label); }
* };
*
* _.bindAll(view);
@@ -3751,62 +3772,6 @@
};
}
- /**
- * 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`.
- *
- * @static
- * @memberOf _
- * @category Functions
- * @param {*} [func=identity] The value to convert to a callback.
- * @param {*} [thisArg] The `this` binding of the created callback.
- * @param {number} [argCount] The number of arguments the callback accepts.
- * @returns {Function} Returns a callback function.
- * @example
- *
- * var characters = [
- * { 'name': 'barney', 'age': 36 },
- * { 'name': 'fred', 'age': 40 }
- * ];
- *
- * // wrap to create custom callback shorthands
- * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
- * var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
- * return !match ? func(callback, thisArg) : function(object) {
- * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
- * };
- * });
- *
- * _.filter(characters, 'age__gt38');
- * // => [{ 'name': 'fred', 'age': 40 }]
- */
- function createCallback(func, thisArg, argCount) {
- var type = typeof func;
- if (func == null || type == 'function') {
- return baseCreateCallback(func, thisArg, argCount);
- }
- // handle "_.pluck" style callback shorthands
- if (type != 'object') {
- return function(object) {
- return object[func];
- };
- }
- var props = keys(func);
- return function(object) {
- var length = props.length,
- result = false;
-
- while (length--) {
- if (!(result = object[props[length]] === func[props[length]])) {
- break;
- }
- }
- return result;
- };
- }
-
/**
* Creates a function that will delay the execution of `func` until after
* `wait` milliseconds have elapsed since the last time it was invoked.
@@ -3959,8 +3924,8 @@
* @returns {number} Returns the timer id.
* @example
*
- * _.defer(function() { console.log('deferred'); });
- * // returns from the function before 'deferred' is logged
+ * _.defer(function(text) { console.log(text); }, 'deferred');
+ * // logs 'deferred' after one or more milliseconds
*/
function defer(func) {
if (!isFunction(func)) {
@@ -3983,9 +3948,8 @@
* @returns {number} Returns the timer id.
* @example
*
- * var log = _.bind(console.log, console);
- * _.delay(log, 1000, 'logged later');
- * // => 'logged later' (Appears after one second.)
+ * _.delay(function(text) { console.log(text); }, 1000, 'later');
+ * // => logs 'later' after one second
*/
function delay(func, wait) {
if (!isFunction(func)) {
@@ -4180,6 +4144,60 @@
/*--------------------------------------------------------------------------*/
+ /**
+ * 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`.
+ *
+ * @static
+ * @memberOf _
+ * @category Utilities
+ * @param {*} [func=identity] The value to convert to a callback.
+ * @param {*} [thisArg] The `this` binding of the created callback.
+ * @param {number} [argCount] The number of arguments the callback accepts.
+ * @returns {Function} Returns a callback function.
+ * @example
+ *
+ * var characters = [
+ * { 'name': 'barney', 'age': 36 },
+ * { 'name': 'fred', 'age': 40 }
+ * ];
+ *
+ * // wrap to create custom callback shorthands
+ * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
+ * var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
+ * return !match ? func(callback, thisArg) : function(object) {
+ * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
+ * };
+ * });
+ *
+ * _.filter(characters, 'age__gt38');
+ * // => [{ 'name': 'fred', 'age': 40 }]
+ */
+ function createCallback(func, thisArg, argCount) {
+ var type = typeof func;
+ if (func == null || type == 'function') {
+ return baseCreateCallback(func, thisArg, argCount);
+ }
+ // handle "_.pluck" style callback shorthands
+ if (type != 'object') {
+ return property(func);
+ }
+ var props = keys(func);
+ return function(object) {
+ var length = props.length,
+ result = false;
+
+ while (length--) {
+ if (!(result = object[props[length]] === func[props[length]])) {
+ break;
+ }
+ }
+ return result;
+ };
+ }
+
/**
* Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their
* corresponding HTML entities.
@@ -4217,25 +4235,30 @@
}
/**
- * Adds function properties of a source object to the `lodash` function and
- * chainable wrapper.
+ * Adds function properties of a source object to the destination object.
+ * If `object` is a function methods will be added to its prototype as well.
*
* @static
* @memberOf _
* @category Utilities
- * @param {Object} object The object of function properties to add to `lodash`.
- * @param {Object} object The object of function properties to add to `lodash`.
+ * @param {Function|Object} [object=lodash] object The destination object.
+ * @param {Object} source The object of functions to add.
+ * @param {Object} [options] The options object.
+ * @param {boolean} [options.chain=true] Specify whether the functions added are chainable.
* @example
*
- * _.mixin({
- * 'capitalize': function(string) {
- * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
- * }
- * });
+ * function capitalize(string) {
+ * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
+ * }
*
+ * _.mixin({ 'capitalize': capitalize });
* _.capitalize('fred');
* // => 'Fred'
*
+ * _('fred').capitalize().value();
+ * // => 'Fred'
+ *
+ * _.mixin({ 'capitalize': capitalize }, { 'chain': false });
* _('fred').capitalize();
* // => 'Fred'
*/
@@ -4288,6 +4311,53 @@
// no operation performed
}
+ /**
+ * Gets the number of milliseconds that have elapsed since the Unix epoch
+ * (1 January 1970 00:00:00 UTC).
+ *
+ * @static
+ * @memberOf _
+ * @category Utilities
+ * @example
+ *
+ * var stamp = _.now();
+ * _.defer(function() { console.log(_.now() - stamp); });
+ * // => logs the number of milliseconds it took for the deferred function to be called
+ */
+ var now = reNative.test(now = Date.now) && now || function() {
+ return new Date().getTime();
+ };
+
+ /**
+ * Creates a "_.pluck" style function, which returns the `key` value of a
+ * given object.
+ *
+ * @static
+ * @memberOf _
+ * @category Utilities
+ * @param {string} key The name of the property to retrieve.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var characters = [
+ * { 'name': 'fred', 'age': 40 },
+ * { 'name': 'barney', 'age': 36 }
+ * ];
+ *
+ * var getName = _.property('name');
+ *
+ * _.map(characters, getName);
+ * // => ['barney', 'fred']
+ *
+ * _.sortBy(characters, getName);
+ * // => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }]
+ */
+ function property(key) {
+ return function(object) {
+ return object[key];
+ };
+ }
+
/**
* 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
@@ -4330,7 +4400,7 @@
}
/**
- * Resolves the value of `property` on `object`. If `property` is a function
+ * Resolves the value of property `key` on `object`. If `key` 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.
@@ -4339,7 +4409,7 @@
* @memberOf _
* @category Utilities
* @param {Object} object The object to inspect.
- * @param {string} property The property to get the value of.
+ * @param {string} key The name of the property to resolve.
* @returns {*} Returns the resolved value.
* @example
*
@@ -4356,10 +4426,10 @@
* _.result(object, 'stuff');
* // => 'nonsense'
*/
- function result(object, property) {
+ function result(object, key) {
if (object) {
- var value = object[property];
- return isFunction(value) ? object[property]() : value;
+ var value = object[key];
+ return isFunction(value) ? object[key]() : value;
}
}
@@ -4423,8 +4493,8 @@
* // => 'hello mustache!'
*
* // using the `imports` option to import jQuery
- * var list = '<% $.each(people, function(name) { %><%- name %><% }); %>';
- * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } });
+ * var list = '<% jq.each(people, function(name) { %><%- name %><% }); %>';
+ * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } });
* // => 'fredbarney'
*
* // using the `sourceURL` option to specify a custom sourceURL for the template
@@ -4659,7 +4729,7 @@
* _(characters).chain()
* .first()
* .pick('age')
- * .value()
+ * .value();
* // => { 'age': 36 }
*/
function wrapperChain() {
@@ -4822,7 +4892,7 @@
* @memberOf _
* @type string
*/
- lodash.VERSION = '2.3.0';
+ lodash.VERSION = '2.4.0';
// add "Chaining" functions to the wrapper
lodash.prototype.chain = wrapperChain;
@@ -4864,9 +4934,8 @@
// some AMD build optimizers like r.js check for condition patterns like the following:
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
// Expose Lo-Dash to the global object even when an AMD loader is present in
- // case Lo-Dash was injected by a third-party script and not intended to be
- // loaded as a module. The global assignment can be reverted in the Lo-Dash
- // module by its `noConflict()` method.
+ // case Lo-Dash is loaded with a RequireJS shim config.
+ // See http://requirejs.org/docs/api.html#config-shim
root._ = lodash;
// define as an anonymous module so, through path mapping, it can be
diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js
index 53f56367b5..6f9fcd8a82 100644
--- a/dist/lodash.underscore.min.js
+++ b/dist/lodash.underscore.min.js
@@ -1,39 +1,39 @@
/**
* @license
- * Lo-Dash 2.3.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE
+ * Lo-Dash 2.4.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE
* Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js`
*/
-;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined")return 1;if(tt?0:t);++ee(r,i)&&o.push(i)}return o}function p(n,r,t,e){e=(e||0)-1;for(var u=n?n.length:0,o=[];++ef||typeof i=="undefined")return 1;if(it?0:t);++ee(r,i)&&o.push(i)}return o}function p(n,r,t,e){e=(e||0)-1;for(var u=n?n.length:0,o=[];++eu(f,l))&&(t&&f.push(l),i.push(a))}return i}function h(n){return function(r,t,e){var u={};t=Q(t,e,3),e=-1;var o=r?r.length:0;if(typeof o=="number")for(;++eu&&(u=t);
-else r=Q(r,t,3),q(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function $(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++targuments.length;r=Q(r,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(t=n[++o]);++oarguments.length;return r=Q(r,e,4),D(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)
-}),t}function C(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return q(n,function(n){var t;t=++r,t=0+Or(Wr()*(t-0+1)),e[r]=e[t],e[t]=n}),e}function P(n,r,t){var e;r=Q(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++te?Mr(0,u+e):e||0}else if(e)return e=J(r,t),r[e]===t?e:-1;return n(r,t,e)}function H(n,r,t){if(typeof r!="number"&&null!=r){var u=0,o=-1,i=n?n.length:0;for(r=Q(r,t,3);++o>>1,t(n[e])=y;m?(u&&(u=clearTimeout(u)),c=i,o=n.apply(f,e)):u||(u=setTimeout(v,y))}return m&&a?a=clearTimeout(a):a||r===p||(a=setTimeout(h,r)),t&&(m=true,o=n.apply(f,e)),!m||a||u||(e=f=null),o
-}}function Y(n){return n}function Z(n){q(j(n),function(r){var t=u[r]=n[r];u.prototype[r]=function(){var n=[this.__wrapped__];return Rr.apply(n,arguments),n=t.apply(u,n),this.__chain__?new o(n,true):n}})}var nr,rr=0,tr={},er=+new Date+"",ur=/($^)/,or=/['\n\r\t\u2028\u2029\\]/g,ir="[object Arguments]",fr="[object Array]",ar="[object Boolean]",lr="[object Date]",cr="[object Number]",pr="[object Object]",sr="[object RegExp]",gr="[object String]",hr={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},vr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},yr=hr[typeof window]&&window||this,mr=hr[typeof exports]&&exports&&!exports.nodeType&&exports,_r=hr[typeof module]&&module&&!module.nodeType&&module,dr=_r&&_r.exports===mr&&mr,br=hr[typeof global]&&global;
-!br||br.global!==br&&br.window!==br||(yr=br);var wr=[],jr=Object.prototype,xr=yr._,Ar=jr.toString,Er=RegExp("^"+(Ar+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Tr=Math.ceil,Or=Math.floor,Sr=jr.hasOwnProperty,Nr=Er.test(Nr=Date.now)&&Nr||function(){return+new Date},Rr=wr.push,kr=jr.propertyIsEnumerable,Br=Er.test(Br=Object.create)&&Br,Fr=Er.test(Fr=Array.isArray)&&Fr,qr=yr.isFinite,Dr=yr.isNaN,Ir=Er.test(Ir=Object.keys)&&Ir,Mr=Math.max,$r=Math.min,Wr=Math.random;
-o.prototype=u.prototype;var zr={};!function(){var n={0:1,length:1};zr.spliceObjects=(wr.splice.call(n,0,1),!n[0])}(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Br||(f=function(){function n(){}return function(r){if(T(r)){n.prototype=r;var t=new n;n.prototype=null}return t||yr.Object()}}()),d(arguments)||(d=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Sr.call(n,"callee")&&!kr.call(n,"callee")||false});var Cr=Fr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ar.call(n)==fr||false
-},Pr=function(n){var r,t=[];if(!n||!hr[typeof n])return t;for(r in n)Sr.call(n,r)&&t.push(r);return t},Ur=Ir?function(n){return T(n)?Ir(n):[]}:Pr,Vr={"&":"&","<":"<",">":">",'"':""","'":"'"},Gr=x(Vr),Hr=RegExp("("+Ur(Gr).join("|")+")","g"),Jr=RegExp("["+Ur(Vr).join("")+"]","g"),Kr=function(n,r){var t;if(!n||!hr[typeof n])return n;for(t in n)if(r(n[t],t,n)===tr)break;return n},Lr=function(n,r){var t;if(!n||!hr[typeof n])return n;for(t in n)if(Sr.call(n,t)&&r(n[t],t,n)===tr)break;
-return n};E(/x/)&&(E=function(n){return typeof n=="function"&&"[object Function]"==Ar.call(n)});var Qr=h(function(n,r,t){Sr.call(n,t)?n[t]++:n[t]=1}),Xr=h(function(n,r,t){(Sr.call(n,t)?n[t]:n[t]=[]).push(r)}),Yr=h(function(n,r,t){n[t]=r});u.after=function(n,r){if(!E(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=L,u.bindAll=function(n){for(var r=1u(i,f)){for(var a=t;--a;)if(0>u(r[a],f))continue n;i.push(f)}}return i},u.invert=x,u.invoke=function(n,r){var t=e(arguments,2),u=-1,o=typeof r=="function",i=n?n.length:0,f=Array(typeof i=="number"?i:0);return q(n,function(n){f[++u]=(o?r:n[r]).apply(n,t)}),f},u.keys=Ur,u.map=I,u.max=M,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):er+arguments[0];return Sr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e;typeof r!="function"&&t&&t[r]===n&&(r=null);
-var o=-1,i=n?n.length:0;if(null==r&&typeof i=="number")for(;++or?0:r);++nt?Mr(0,e+t):$r(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=Z,u.noConflict=function(){return yr._=xr,this},u.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Or(Wr()*(r-n+1))
-},u.reduce=W,u.reduceRight=z,u.result=function(n,r){if(n){var t=n[r];return E(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Ur(n).length},u.some=P,u.sortedIndex=J,u.template=function(n,r,e){var o=u,i=o.templateSettings;n=(n||"")+"",e=w({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||ur).source+"|"+(e.interpolate||ur).source+"|"+(e.evaluate||ur).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(or,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";\n__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r
-}),a+="';",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Hr,_)},u.uniqueId=function(n){var r=++rr+"";return n?n+r:r},u.all=k,u.any=P,u.detect=F,u.findWhere=function(n,r){return U(n,r,true)},u.foldl=W,u.foldr=z,u.include=R,u.inject=W,u.first=V,u.last=function(n,r,t){var u=0,o=n?n.length:0;
-if(typeof r!="number"&&null!=r){var i=o;for(r=Q(r,t,3);i--&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[o-1]:nr;return e(n,Mr(0,o-u))},u.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=N(n)),null==r||t?n?n[0+Or(Wr()*(n.length-1-0+1))]:nr:(n=C(n),n.length=$r(Mr(0,r),n.length),n)},u.take=V,u.head=V,Z(u),u.VERSION="2.3.0",u.prototype.chain=function(){return this.__chain__=true,this},u.prototype.value=function(){return this.__wrapped__},q("pop push reverse shift sort splice unshift".split(" "),function(n){var r=wr[n];
-u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),zr.spliceObjects||0!==n.length||delete n[0],this}}),q(["concat","join","slice"],function(n){var r=wr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(yr._=u, define(function(){return u})):mr&&_r?dr?(_r.exports=u)._=u:mr._=u:yr._=u}).call(this);
\ No newline at end of file
+}return Jr(r,function(r,u,o){return Sr.call(o,u)?(c++,!(l=Sr.call(n,u)&&s(n[u],r,t,e))&&tr):void 0}),l&&Jr(n,function(n,r,t){return Sr.call(t,r)?!(l=-1<--c)&&tr:void 0}),l}function g(n,r,t){for(var e=-1,u=m(),o=n?n.length:0,i=[],f=t?[]:i;++eu(f,l))&&(t&&f.push(l),i.push(a))}return i}function h(n){return function(r,t,e){var u={};t=Q(t,e,3),e=-1;var o=r?r.length:0;if(typeof o=="number")for(;++eu&&(u=t);
+else r=Q(r,t,3),q(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function $(n,r,t,e){if(!n)return t;var u=3>arguments.length;r=Q(r,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(t=n[++o]);++oarguments.length;return r=Q(r,e,4),D(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function z(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return q(n,function(n){var t;t=++r,t=0+Or($r()*(t-0+1)),e[r]=e[t],e[t]=n
+}),e}function C(n,r,t){var e;r=Q(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++te?Ir(0,u+e):e||0}else if(e)return e=H(r,t),r[e]===t?e:-1;
+return n(r,t,e)}function G(n,r,t){if(typeof r!="number"&&null!=r){var u=0,o=-1,i=n?n.length:0;for(r=Q(r,t,3);++o>>1,t(n[e])=y;m?(u&&(u=clearTimeout(u)),c=i,o=n.apply(f,e)):u||(u=setTimeout(v,y))}return m&&a?a=clearTimeout(a):a||r===p||(a=setTimeout(h,r)),t&&(m=true,o=n.apply(f,e)),!m||a||u||(e=f=null),o}}function Q(n,r,t){var e=typeof n;if(null==n||"function"==e)return a(n,r,t);if("object"!=e)return Z(n);var u=Pr(n);return function(r){for(var t=u.length,e=false;t--&&(e=r[u[t]]===n[u[t]]););return e}}function X(n){return n}function Y(n){q(j(n),function(r){var t=u[r]=n[r];u.prototype[r]=function(){var n=[this.__wrapped__];
+return Nr.apply(n,arguments),n=t.apply(u,n),this.__chain__?new o(n,true):n}})}function Z(n){return function(r){return r[n]}}var nr,rr=0,tr={},er=+new Date+"",ur=/($^)/,or=/['\n\r\t\u2028\u2029\\]/g,ir="[object Arguments]",fr="[object Array]",ar="[object Boolean]",lr="[object Date]",cr="[object Number]",pr="[object Object]",sr="[object RegExp]",gr="[object String]",hr={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},vr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},yr=hr[typeof window]&&window||this,mr=hr[typeof exports]&&exports&&!exports.nodeType&&exports,_r=hr[typeof module]&&module&&!module.nodeType&&module,dr=_r&&_r.exports===mr&&mr,br=hr[typeof global]&&global;
+!br||br.global!==br&&br.window!==br||(yr=br);var wr=[],jr=Object.prototype,xr=yr._,Tr=jr.toString,Er=RegExp("^"+(Tr+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Ar=Math.ceil,Or=Math.floor,Sr=jr.hasOwnProperty,Nr=wr.push,Rr=jr.propertyIsEnumerable,kr=Er.test(kr=Object.create)&&kr,Br=Er.test(Br=Array.isArray)&&Br,Fr=yr.isFinite,qr=yr.isNaN,Dr=Er.test(Dr=Object.keys)&&Dr,Ir=Math.max,Mr=Math.min,$r=Math.random;o.prototype=u.prototype;var Wr={};!function(){var n={0:1,length:1};
+Wr.spliceObjects=(wr.splice.call(n,0,1),!n[0])}(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},kr||(f=function(){function n(){}return function(r){if(A(r)){n.prototype=r;var t=new n;n.prototype=null}return t||yr.Object()}}()),d(arguments)||(d=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Sr.call(n,"callee")&&!Rr.call(n,"callee")||false});var zr=Br||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Tr.call(n)==fr||false
+},Cr=function(n){var r,t=[];if(!n||!hr[typeof n])return t;for(r in n)Sr.call(n,r)&&t.push(r);return t},Pr=Dr?function(n){return A(n)?Dr(n):[]}:Cr,Ur={"&":"&","<":"<",">":">",'"':""","'":"'"},Vr=x(Ur),Gr=RegExp("("+Pr(Vr).join("|")+")","g"),Hr=RegExp("["+Pr(Ur).join("")+"]","g"),Jr=function(n,r){var t;if(!n||!hr[typeof n])return n;for(t in n)if(r(n[t],t,n)===tr)break;return n},Kr=function(n,r){var t;if(!n||!hr[typeof n])return n;for(t in n)if(Sr.call(n,t)&&r(n[t],t,n)===tr)break;
+return n};E(/x/)&&(E=function(n){return typeof n=="function"&&"[object Function]"==Tr.call(n)});var Lr=h(function(n,r,t){Sr.call(n,t)?n[t]++:n[t]=1}),Qr=h(function(n,r,t){(Sr.call(n,t)?n[t]:n[t]=[]).push(r)}),Xr=h(function(n,r,t){n[t]=r}),Yr=I,Zr=Er.test(Zr=Date.now)&&Zr||function(){return(new Date).getTime()};u.after=function(n,r){if(!E(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=K,u.bindAll=function(n){for(var r=1i(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},u.invert=x,u.invoke=function(n,r){var t=e(arguments,2),u=-1,o=typeof r=="function",i=n?n.length:0,f=Array(typeof i=="number"?i:0);return q(n,function(n){f[++u]=(o?r:n[r]).apply(n,t)}),f},u.keys=Pr,u.map=I,u.max=M,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):er+arguments[0];return Sr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)
+}},u.min=function(n,r,t){var e=1/0,u=e;typeof r!="function"&&t&&t[r]===n&&(r=null);var o=-1,i=n?n.length:0;if(null==r&&typeof i=="number")for(;++or?0:r);++nt?Ir(0,e+t):Mr(t,e-1))+1);e--;)if(n[e]===r)return e;
+return-1},u.mixin=Y,u.noConflict=function(){return yr._=xr,this},u.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Or($r()*(r-n+1))},u.reduce=$,u.reduceRight=W,u.result=function(n,r){if(n){var t=n[r];return E(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Pr(n).length},u.some=C,u.sortedIndex=H,u.template=function(n,r,e){var o=u,i=o.templateSettings;n=(n||"")+"",e=w({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||ur).source+"|"+(e.interpolate||ur).source+"|"+(e.evaluate||ur).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(or,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";\n__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r
+}),a+="';",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Gr,_)},u.uniqueId=function(n){var r=++rr+"";return n?n+r:r},u.all=k,u.any=C,u.detect=F,u.findWhere=function(n,r){return P(n,r,true)},u.foldl=$,u.foldr=W,u.include=R,u.inject=$,u.first=U,u.last=function(n,r,t){var u=0,o=n?n.length:0;
+if(typeof r!="number"&&null!=r){var i=o;for(r=Q(r,t,3);i--&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[o-1]:nr;return e(n,Ir(0,o-u))},u.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=N(n)),null==r||t?n?n[0+Or($r()*(n.length-1-0+1))]:nr:(n=z(n),n.length=Mr(Ir(0,r),n.length),n)},u.take=U,u.head=U,Y(u),u.VERSION="2.4.0",u.prototype.chain=function(){return this.__chain__=true,this},u.prototype.value=function(){return this.__wrapped__},q("pop push reverse shift sort splice unshift".split(" "),function(n){var r=wr[n];
+u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Wr.spliceObjects||0!==n.length||delete n[0],this}}),q(["concat","join","slice"],function(n){var r=wr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(yr._=u, define(function(){return u})):mr&&_r?dr?(_r.exports=u)._=u:mr._=u:yr._=u}).call(this);
\ No newline at end of file
diff --git a/doc/README.md b/doc/README.md
index 1331ebe800..af6d392da6 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -1,4 +1,4 @@
-# Lo-Dash v2.3.0
+# Lo-Dash v2.4.0
@@ -6,34 +6,35 @@
## `Arrays`
-* [`_.compact`](#_compactarray)
-* [`_.difference`](#_differencearray-values)
-* [`_.drop`](#_restarray-callback1-thisarg)
-* [`_.findIndex`](#_findindexarray-callbackidentity-thisarg)
-* [`_.findLastIndex`](#_findlastindexarray-callbackidentity-thisarg)
-* [`_.first`](#_firstarray-callback-thisarg)
-* [`_.flatten`](#_flattenarray-isshallowfalse-callbackidentity-thisarg)
-* [`_.head`](#_firstarray-callback-thisarg)
-* [`_.indexOf`](#_indexofarray-value-fromindex0)
-* [`_.initial`](#_initialarray-callback1-thisarg)
-* [`_.intersection`](#_intersectionarray)
-* [`_.last`](#_lastarray-callback-thisarg)
-* [`_.lastIndexOf`](#_lastindexofarray-value-fromindexarraylength-1)
-* [`_.object`](#_zipobjectkeys-values)
-* [`_.pull`](#_pullarray-value)
-* [`_.range`](#_rangestart0-end-step1)
-* [`_.remove`](#_removearray-callbackidentity-thisarg)
-* [`_.rest`](#_restarray-callback1-thisarg)
-* [`_.sortedIndex`](#_sortedindexarray-value-callbackidentity-thisarg)
-* [`_.tail`](#_restarray-callback1-thisarg)
-* [`_.take`](#_firstarray-callback-thisarg)
-* [`_.union`](#_unionarray)
-* [`_.uniq`](#_uniqarray-issortedfalse-callbackidentity-thisarg)
-* [`_.unique`](#_uniqarray-issortedfalse-callbackidentity-thisarg)
-* [`_.unzip`](#_ziparray)
-* [`_.without`](#_withoutarray-value)
-* [`_.zip`](#_ziparray)
-* [`_.zipObject`](#_zipobjectkeys-values)
+* `_.compact`
+* `_.difference`
+* `_.drop` -> `rest`
+* `_.findIndex`
+* `_.findLastIndex`
+* `_.first`
+* `_.flatten`
+* `_.head` -> `first`
+* `_.indexOf`
+* `_.initial`
+* `_.intersection`
+* `_.last`
+* `_.lastIndexOf`
+* `_.object` -> `zipObject`
+* `_.pull`
+* `_.range`
+* `_.remove`
+* `_.rest`
+* `_.sortedIndex`
+* `_.tail` -> `rest`
+* `_.take` -> `first`
+* `_.union`
+* `_.uniq`
+* `_.unique` -> `uniq`
+* `_.unzip` -> `zip`
+* `_.without`
+* `_.xor`
+* `_.zip`
+* `_.zipObject`
@@ -41,13 +42,13 @@
## `Chaining`
-* [`_`](#_value)
-* [`_.chain`](#_chainvalue)
-* [`_.tap`](#_tapvalue-interceptor)
-* [`_.prototype.chain`](#_prototypechain)
-* [`_.prototype.toString`](#_prototypetostring)
-* [`_.prototype.value`](#_prototypevalueof)
-* [`_.prototype.valueOf`](#_prototypevalueof)
+* `_`
+* `_.chain`
+* `_.tap`
+* `_.prototype.chain`
+* `_.prototype.toString`
+* `_.prototype.value` -> `valueOf`
+* `_.prototype.valueOf`
@@ -55,44 +56,44 @@
## `Collections`
-* [`_.all`](#_everycollection-callbackidentity-thisarg)
-* [`_.any`](#_somecollection-callbackidentity-thisarg)
-* [`_.at`](#_atcollection-index)
-* [`_.collect`](#_mapcollection-callbackidentity-thisarg)
-* [`_.contains`](#_containscollection-target-fromindex0)
-* [`_.countBy`](#_countbycollection-callbackidentity-thisarg)
-* [`_.detect`](#_findcollection-callbackidentity-thisarg)
-* [`_.each`](#_foreachcollection-callbackidentity-thisarg)
-* [`_.eachRight`](#_foreachrightcollection-callbackidentity-thisarg)
-* [`_.every`](#_everycollection-callbackidentity-thisarg)
-* [`_.filter`](#_filtercollection-callbackidentity-thisarg)
-* [`_.find`](#_findcollection-callbackidentity-thisarg)
-* [`_.findLast`](#_findlastcollection-callbackidentity-thisarg)
-* [`_.findWhere`](#_findcollection-callbackidentity-thisarg)
-* [`_.foldl`](#_reducecollection-callbackidentity-accumulator-thisarg)
-* [`_.foldr`](#_reducerightcollection-callbackidentity-accumulator-thisarg)
-* [`_.forEach`](#_foreachcollection-callbackidentity-thisarg)
-* [`_.forEachRight`](#_foreachrightcollection-callbackidentity-thisarg)
-* [`_.groupBy`](#_groupbycollection-callbackidentity-thisarg)
-* [`_.include`](#_containscollection-target-fromindex0)
-* [`_.indexBy`](#_indexbycollection-callbackidentity-thisarg)
-* [`_.inject`](#_reducecollection-callbackidentity-accumulator-thisarg)
-* [`_.invoke`](#_invokecollection-methodname-arg)
-* [`_.map`](#_mapcollection-callbackidentity-thisarg)
-* [`_.max`](#_maxcollection-callbackidentity-thisarg)
-* [`_.min`](#_mincollection-callbackidentity-thisarg)
-* [`_.pluck`](#_pluckcollection-property)
-* [`_.reduce`](#_reducecollection-callbackidentity-accumulator-thisarg)
-* [`_.reduceRight`](#_reducerightcollection-callbackidentity-accumulator-thisarg)
-* [`_.reject`](#_rejectcollection-callbackidentity-thisarg)
-* [`_.sample`](#_samplecollection-n)
-* [`_.select`](#_filtercollection-callbackidentity-thisarg)
-* [`_.shuffle`](#_shufflecollection)
-* [`_.size`](#_sizecollection)
-* [`_.some`](#_somecollection-callbackidentity-thisarg)
-* [`_.sortBy`](#_sortbycollection-callbackidentity-thisarg)
-* [`_.toArray`](#_toarraycollection)
-* [`_.where`](#_wherecollection-properties)
+* `_.all` -> `every`
+* `_.any` -> `some`
+* `_.at`
+* `_.collect` -> `map`
+* `_.contains`
+* `_.countBy`
+* `_.detect` -> `find`
+* `_.each` -> `forEach`
+* `_.eachRight` -> `forEachRight`
+* `_.every`
+* `_.filter`
+* `_.find`
+* `_.findLast`
+* `_.findWhere` -> `find`
+* `_.foldl` -> `reduce`
+* `_.foldr` -> `reduceRight`
+* `_.forEach`
+* `_.forEachRight`
+* `_.groupBy`
+* `_.include` -> `contains`
+* `_.indexBy`
+* `_.inject` -> `reduce`
+* `_.invoke`
+* `_.map`
+* `_.max`
+* `_.min`
+* `_.pluck`
+* `_.reduce`
+* `_.reduceRight`
+* `_.reject`
+* `_.sample`
+* `_.select` -> `filter`
+* `_.shuffle`
+* `_.size`
+* `_.some`
+* `_.sortBy`
+* `_.toArray`
+* `_.where`
@@ -100,22 +101,21 @@
## `Functions`
-* [`_.after`](#_aftern-func)
-* [`_.bind`](#_bindfunc-thisarg-arg)
-* [`_.bindAll`](#_bindallobject-methodname)
-* [`_.bindKey`](#_bindkeyobject-key-arg)
-* [`_.compose`](#_composefunc)
-* [`_.createCallback`](#_createcallbackfuncidentity-thisarg-argcount)
-* [`_.curry`](#_curryfunc-arityfunclength)
-* [`_.debounce`](#_debouncefunc-wait-options-optionsmaxwait)
-* [`_.defer`](#_deferfunc-arg)
-* [`_.delay`](#_delayfunc-wait-arg)
-* [`_.memoize`](#_memoizefunc-resolver)
-* [`_.once`](#_oncefunc)
-* [`_.partial`](#_partialfunc-arg)
-* [`_.partialRight`](#_partialrightfunc-arg)
-* [`_.throttle`](#_throttlefunc-wait-options)
-* [`_.wrap`](#_wrapvalue-wrapper)
+* `_.after`
+* `_.bind`
+* `_.bindAll`
+* `_.bindKey`
+* `_.compose`
+* `_.curry`
+* `_.debounce`
+* `_.defer`
+* `_.delay`
+* `_.memoize`
+* `_.once`
+* `_.partial`
+* `_.partialRight`
+* `_.throttle`
+* `_.wrap`
@@ -123,46 +123,47 @@
## `Objects`
-* [`_.assign`](#_assignobject-source-callback-thisarg)
-* [`_.clone`](#_clonevalue-isdeepfalse-callback-thisarg)
-* [`_.cloneDeep`](#_clonedeepvalue-callback-thisarg)
-* [`_.create`](#_createprototype-properties)
-* [`_.defaults`](#_defaultsobject-source)
-* [`_.extend`](#_assignobject-source-callback-thisarg)
-* [`_.findKey`](#_findkeyobject-callbackidentity-thisarg)
-* [`_.findLastKey`](#_findlastkeyobject-callbackidentity-thisarg)
-* [`_.forIn`](#_forinobject-callbackidentity-thisarg)
-* [`_.forInRight`](#_forinrightobject-callbackidentity-thisarg)
-* [`_.forOwn`](#_forownobject-callbackidentity-thisarg)
-* [`_.forOwnRight`](#_forownrightobject-callbackidentity-thisarg)
-* [`_.functions`](#_functionsobject)
-* [`_.has`](#_hasobject-property)
-* [`_.invert`](#_invertobject)
-* [`_.isArguments`](#_isargumentsvalue)
-* [`_.isArray`](#_isarrayvalue)
-* [`_.isBoolean`](#_isbooleanvalue)
-* [`_.isDate`](#_isdatevalue)
-* [`_.isElement`](#_iselementvalue)
-* [`_.isEmpty`](#_isemptyvalue)
-* [`_.isEqual`](#_isequala-b-callback-thisarg)
-* [`_.isFinite`](#_isfinitevalue)
-* [`_.isFunction`](#_isfunctionvalue)
-* [`_.isNaN`](#_isnanvalue)
-* [`_.isNull`](#_isnullvalue)
-* [`_.isNumber`](#_isnumbervalue)
-* [`_.isObject`](#_isobjectvalue)
-* [`_.isPlainObject`](#_isplainobjectvalue)
-* [`_.isRegExp`](#_isregexpvalue)
-* [`_.isString`](#_isstringvalue)
-* [`_.isUndefined`](#_isundefinedvalue)
-* [`_.keys`](#_keysobject)
-* [`_.merge`](#_mergeobject-source-callback-thisarg)
-* [`_.methods`](#_functionsobject)
-* [`_.omit`](#_omitobject-callback-thisarg)
-* [`_.pairs`](#_pairsobject)
-* [`_.pick`](#_pickobject-callback-thisarg)
-* [`_.transform`](#_transformobject-callbackidentity-accumulator-thisarg)
-* [`_.values`](#_valuesobject)
+* `_.assign`
+* `_.clone`
+* `_.cloneDeep`
+* `_.create`
+* `_.defaults`
+* `_.extend` -> `assign`
+* `_.findKey`
+* `_.findLastKey`
+* `_.forIn`
+* `_.forInRight`
+* `_.forOwn`
+* `_.forOwnRight`
+* `_.functions`
+* `_.has`
+* `_.invert`
+* `_.isArguments`
+* `_.isArray`
+* `_.isBoolean`
+* `_.isDate`
+* `_.isElement`
+* `_.isEmpty`
+* `_.isEqual`
+* `_.isFinite`
+* `_.isFunction`
+* `_.isNaN`
+* `_.isNull`
+* `_.isNumber`
+* `_.isObject`
+* `_.isPlainObject`
+* `_.isRegExp`
+* `_.isString`
+* `_.isUndefined`
+* `_.keys`
+* `_.mapValues`
+* `_.merge`
+* `_.methods` -> `functions`
+* `_.omit`
+* `_.pairs`
+* `_.pick`
+* `_.transform`
+* `_.values`
@@ -170,19 +171,23 @@
## `Utilities`
-* [`_.noop`](#_noop)
-* [`_.escape`](#_escapestring)
-* [`_.identity`](#_identityvalue)
-* [`_.mixin`](#_mixinobject-object)
-* [`_.noConflict`](#_noconflict)
-* [`_.parseInt`](#_parseintvalue-radix)
-* [`_.random`](#_randommin0-max1-floatingfalse)
-* [`_.result`](#_resultobject-property)
-* [`_.runInContext`](#_runincontextcontextroot)
-* [`_.template`](#_templatetext-data-options-optionsescape-optionsevaluate-optionsimports-optionsinterpolate-sourceurl-variable)
-* [`_.times`](#_timesn-callback-thisarg)
-* [`_.unescape`](#_unescapestring)
-* [`_.uniqueId`](#_uniqueidprefix)
+* `_.now`
+* `_.constant`
+* `_.createCallback`
+* `_.escape`
+* `_.identity`
+* `_.mixin`
+* `_.noConflict`
+* `_.noop`
+* `_.parseInt`
+* `_.property`
+* `_.random`
+* `_.result`
+* `_.runInContext`
+* `_.template`
+* `_.times`
+* `_.unescape`
+* `_.uniqueId`
@@ -190,7 +195,7 @@
## `Methods`
-* [`_.templateSettings.imports._`](#_templatesettingsimports_)
+* `_.templateSettings.imports._`
@@ -198,25 +203,25 @@
## `Properties`
-* [`_.VERSION`](#_version)
-* [`_.support`](#_support)
-* [`_.support.argsClass`](#_supportargsclass)
-* [`_.support.argsObject`](#_supportargsobject)
-* [`_.support.enumErrorProps`](#_supportenumerrorprops)
-* [`_.support.enumPrototypes`](#_supportenumprototypes)
-* [`_.support.funcDecomp`](#_supportfuncdecomp)
-* [`_.support.funcNames`](#_supportfuncnames)
-* [`_.support.nonEnumArgs`](#_supportnonenumargs)
-* [`_.support.nonEnumShadows`](#_supportnonenumshadows)
-* [`_.support.ownLast`](#_supportownlast)
-* [`_.support.spliceObjects`](#_supportspliceobjects)
-* [`_.support.unindexedChars`](#_supportunindexedchars)
-* [`_.templateSettings`](#_templatesettings)
-* [`_.templateSettings.escape`](#_templatesettingsescape)
-* [`_.templateSettings.evaluate`](#_templatesettingsevaluate)
-* [`_.templateSettings.interpolate`](#_templatesettingsinterpolate)
-* [`_.templateSettings.variable`](#_templatesettingsvariable)
-* [`_.templateSettings.imports`](#_templatesettingsimports)
+* `_.VERSION`
+* `_.support`
+* `_.support.argsClass`
+* `_.support.argsObject`
+* `_.support.enumErrorProps`
+* `_.support.enumPrototypes`
+* `_.support.funcDecomp`
+* `_.support.funcNames`
+* `_.support.nonEnumArgs`
+* `_.support.nonEnumShadows`
+* `_.support.ownLast`
+* `_.support.spliceObjects`
+* `_.support.unindexedChars`
+* `_.templateSettings`
+* `_.templateSettings.escape`
+* `_.templateSettings.evaluate`
+* `_.templateSettings.interpolate`
+* `_.templateSettings.variable`
+* `_.templateSettings.imports`
@@ -234,7 +239,7 @@
### `_.compact(array)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4390 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4461 "View in source") [Ⓣ][1]
Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are all falsey.
@@ -258,7 +263,7 @@ _.compact([0, 1, false, 2, '', 3]);
### `_.difference(array, [values])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4419 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4490 "View in source") [Ⓣ][1]
Creates an array excluding all values of the provided arrays using strict equality for comparisons, i.e. `===`.
@@ -283,7 +288,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
### `_.findIndex(array, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4464 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4535 "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.
@@ -329,7 +334,7 @@ _.findIndex(characters, 'blocked');
### `_.findLastIndex(array, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4518 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4589 "View in source") [Ⓣ][1]
This method is like `_.findIndex` except that it iterates over elements of a `collection` from right to left.
@@ -375,7 +380,7 @@ _.findLastIndex(characters, 'blocked');
### `_.first(array, [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4580 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4651 "View in source") [Ⓣ][1]
Gets the first element or first `n` elements of an array. If a callback is provided elements at the beginning of the array are returned as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
@@ -430,7 +435,7 @@ _.pluck(_.first(characters, { 'employer': 'slate' }), 'name');
### `_.flatten(array, [isShallow=false], [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4640 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4711 "View in source") [Ⓣ][1]
Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truey, 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)*.
@@ -473,7 +478,7 @@ _.flatten(characters, 'pets');
### `_.indexOf(array, value, [fromIndex=0])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4677 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4748 "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.
@@ -505,7 +510,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
### `_.initial(array, [callback=1], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4738 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4809 "View in source") [Ⓣ][1]
Gets all but the last element or last `n` elements of an array. If a callback is provided elements at the end of the array are excluded from the result as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
@@ -557,7 +562,7 @@ _.pluck(_.initial(characters, { 'employer': 'na' }), 'name');
### `_.intersection([array])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4768 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4839 "View in source") [Ⓣ][1]
Creates an array of unique values present in all provided arrays using strict equality for comparisons, i.e. `===`.
@@ -565,11 +570,11 @@ Creates an array of unique values present in all provided arrays using strict eq
1. `[array]` *(...Array)*: The arrays to inspect.
#### Returns
-*(Array)*: Returns an array of composite values.
+*(Array)*: Returns an array of shared values.
#### Example
```js
-_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
+_.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
// => [1, 2]
```
@@ -581,7 +586,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
### `_.last(array, [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4863 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4939 "View in source") [Ⓣ][1]
Gets the last element or last `n` elements of an array. If a callback is provided elements at the end of the array are returned as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
@@ -633,7 +638,7 @@ _.last(characters, { 'employer': 'na' });
### `_.lastIndexOf(array, value, [fromIndex=array.length-1])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4909 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4985 "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.
@@ -666,7 +671,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
### `_.pull(array, [value])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4939 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5015 "View in source") [Ⓣ][1]
Removes all provided values from the given array using strict equality for comparisons, i.e. `===`.
@@ -693,7 +698,7 @@ console.log(array);
### `_.range([start=0], end, [step=1])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4990 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5066 "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.
@@ -734,7 +739,7 @@ _.range(0);
### `_.remove(array, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5043 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5119 "View in source") [Ⓣ][1]
Removes all elements from an array that the callback returns truey for and returns an array of removed elements. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
@@ -770,7 +775,7 @@ console.log(evens);
### `_.rest(array, [callback=1], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5112 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5188 "View in source") [Ⓣ][1]
The opposite of `_.initial` this method gets all but the first element or first `n` elements of an array. If a callback function is provided elements at the beginning of the array are excluded from the result as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
@@ -825,7 +830,7 @@ _.rest(characters, { 'employer': 'slate' });
### `_.sortedIndex(array, value, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5176 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5252 "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)*.
@@ -874,7 +879,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
### `_.union([array])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5207 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5283 "View in source") [Ⓣ][1]
Creates an array of unique values, in order, of the provided arrays using strict equality for comparisons, i.e. `===`.
@@ -882,12 +887,12 @@ Creates an array of unique values, in order, of the provided arrays using strict
1. `[array]` *(...Array)*: The arrays to inspect.
#### Returns
-*(Array)*: Returns an array of composite values.
+*(Array)*: Returns an array of combined values.
#### Example
```js
-_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
-// => [1, 2, 3, 101, 10]
+_.union([1, 2, 3], [5, 2, 1, 4], [2, 1]);
+// => [1, 2, 3, 5, 4]
```
* * *
@@ -898,7 +903,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
### `_.uniq(array, [isSorted=false], [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5255 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5331 "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)*.
@@ -945,7 +950,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
### `_.without(array, [value])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5283 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5359 "View in source") [Ⓣ][1]
Creates an array excluding all provided values using strict equality for comparisons, i.e. `===`.
@@ -967,10 +972,37 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
+
+
+### `_.xor([array])`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5380 "View in source") [Ⓣ][1]
+
+Creates an array that is the smymetric difference of the provided arrays. See http://en.wikipedia.org/wiki/Symmetric_difference.
+
+#### Arguments
+1. `[array]` *(...Array)*: The arrays to inspect.
+
+#### Returns
+*(Array)*: Returns an array of values.
+
+#### Example
+```js
+_.xor([1, 2, 3], [5, 2, 1, 4]);
+// => [3, 5, 4]
+
+_.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]);
+// => [1, 4, 5]
+```
+
+* * *
+
+
+
+
### `_.zip([array])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5303 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5411 "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.
@@ -997,9 +1029,9 @@ _.zip(['fred', 'barney'], [30, 40], [true, false]);
### `_.zipObject(keys, [values=[]])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5333 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5441 "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`.
+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`.
#### Aliases
*_.object*
@@ -1032,7 +1064,7 @@ _.zipObject(['fred', 'barney'], [30, 40]);
### `_(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L645 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L647 "View in source") [Ⓣ][1]
Creates a `lodash` object which wraps the given value to enable intuitive method chaining.
@@ -1087,7 +1119,7 @@ _.isArray(squares.value());
### `_.chain(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6583 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6770 "View in source") [Ⓣ][1]
Creates a `lodash` object that wraps the given value with explicit method chaining enabled.
@@ -1121,7 +1153,7 @@ var youngest = _.chain(characters)
### `_.tap(value, interceptor)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6609 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6796 "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.
@@ -1149,7 +1181,7 @@ _([1, 2, 3, 4])
### `_.prototype.chain()`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6639 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6826 "View in source") [Ⓣ][1]
Enables explicit method chaining on the wrapper object.
@@ -1171,7 +1203,7 @@ _(characters).first();
_(characters).chain()
.first()
.pick('age')
- .value()
+ .value();
// => { 'age': 36 }
```
@@ -1183,7 +1215,7 @@ _(characters).chain()
### `_.prototype.toString()`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6656 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6843 "View in source") [Ⓣ][1]
Produces the `toString` result of the wrapped value.
@@ -1204,7 +1236,7 @@ _([1, 2, 3]).toString();
### `_.prototype.valueOf()`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6673 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6860 "View in source") [Ⓣ][1]
Extracts the wrapped value.
@@ -1235,7 +1267,7 @@ _([1, 2, 3]).valueOf();
### `_.at(collection, [index])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3231 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3278 "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.
@@ -1263,7 +1295,7 @@ _.at(['fred', 'barney', 'pebbles'], 0, 2);
### `_.contains(collection, target, [fromIndex=0])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3274 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3321 "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.
@@ -1301,7 +1333,7 @@ _.contains('pebbles', 'eb');
### `_.countBy(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3329 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3376 "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)*.
@@ -1337,7 +1369,7 @@ _.countBy(['one', 'two', 'three'], 'length');
### `_.every(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3374 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3421 "View in source") [Ⓣ][1]
Checks if the given callback returns truey value for **all** elements of a collection. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
@@ -1383,7 +1415,7 @@ _.every(characters, { 'age': 36 });
### `_.filter(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3435 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3482 "View in source") [Ⓣ][1]
Iterates over elements of a collection, returning an array of all elements the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
@@ -1429,7 +1461,7 @@ _.filter(characters, { 'age': 36 });
### `_.find(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3502 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3549 "View in source") [Ⓣ][1]
Iterates over elements of a collection, returning the first element that the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
@@ -1478,7 +1510,7 @@ _.find(characters, 'blocked');
### `_.findLast(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3547 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3594 "View in source") [Ⓣ][1]
This method is like `_.find` except that it iterates over elements of a `collection` from right to left.
@@ -1506,7 +1538,7 @@ _.findLast([1, 2, 3, 4], function(num) {
### `_.forEach(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3585 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3632 "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`.
@@ -1540,7 +1572,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num);
### `_.forEachRight(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3618 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3665 "View in source") [Ⓣ][1]
This method is like `_.forEach` except that it iterates over elements of a `collection` from right to left.
@@ -1569,7 +1601,7 @@ _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(',');
### `_.groupBy(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3679 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3726 "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)*.
@@ -1606,7 +1638,7 @@ _.groupBy(['one', 'two', 'three'], 'length');
### `_.indexBy(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3722 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3769 "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)*.
@@ -1647,7 +1679,7 @@ _.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String);
### `_.invoke(collection, methodName, [arg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3748 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3795 "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`.
@@ -1676,7 +1708,7 @@ _.invoke([123, 456], String.prototype.split, '');
### `_.map(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3800 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3847 "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)*.
@@ -1721,7 +1753,7 @@ _.map(characters, 'name');
### `_.max(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3858 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3905 "View in source") [Ⓣ][1]
Retrieves the maximum value of a collection. If the collection is empty or falsey `-Infinity` is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*.
@@ -1763,7 +1795,7 @@ _.max(characters, 'age');
### `_.min(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3933 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3980 "View in source") [Ⓣ][1]
Retrieves the minimum value of a collection. If the collection is empty or falsey `Infinity` is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*.
@@ -1805,13 +1837,13 @@ _.min(characters, 'age');
### `_.pluck(collection, property)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3988 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4035 "View in source") [Ⓣ][1]
Retrieves the value of a specified property from all elements in the collection.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
-2. `property` *(string)*: The property to pluck.
+2. `property` *(string)*: The name of the property to pluck.
#### Returns
*(Array)*: Returns a new array of property values.
@@ -1835,7 +1867,7 @@ _.pluck(characters, 'name');
### `_.reduce(collection, [callback=identity], [accumulator], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4020 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4067 "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)*.
@@ -1873,7 +1905,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
### `_.reduceRight(collection, [callback=identity], [accumulator], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4063 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4110 "View in source") [Ⓣ][1]
This method is like `_.reduce` except that it iterates over elements of a `collection` from right to left.
@@ -1904,7 +1936,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
### `_.reject(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4112 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4159 "View in source") [Ⓣ][1]
The opposite of `_.filter` this method returns the elements of a collection that the callback does **not** return truey for.
@@ -1947,7 +1979,7 @@ _.reject(characters, { 'age': 36 });
### `_.sample(collection, [n])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4138 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4185 "View in source") [Ⓣ][1]
Retrieves a random element or `n` random elements from a collection.
@@ -1975,7 +2007,7 @@ _.sample([1, 2, 3, 4], 2);
### `_.shuffle(collection)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4166 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4213 "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.
@@ -1999,7 +2031,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]);
### `_.size(collection)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4199 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4246 "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.
@@ -2018,7 +2050,7 @@ _.size({ 'one': 1, 'two': 2, 'three': 3 });
// => 3
_.size('pebbles');
-// => 5
+// => 7
```
* * *
@@ -2029,7 +2061,7 @@ _.size('pebbles');
### `_.some(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4246 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4293 "View in source") [Ⓣ][1]
Checks if the callback returns a truey 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)*.
@@ -2075,17 +2107,19 @@ _.some(characters, { 'age': 1 });
### `_.sortBy(collection, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4302 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4363 "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)*.
If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
+If an array of property names is provided for `callback` the collection will be sorted by each property value.
+
If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
-2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
+2. `[callback=identity]` *(Array|Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
3. `[thisArg]` *(*)*: The `this` binding of `callback`.
#### Returns
@@ -2099,9 +2133,20 @@ _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
_.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
// => [3, 1, 2]
+var characters = [
+ { 'name': 'barney', 'age': 36 },
+ { 'name': 'fred', 'age': 40 },
+ { 'name': 'barney', 'age': 26 },
+ { 'name': 'fred', 'age': 30 }
+];
+
// using "_.pluck" callback shorthand
-_.sortBy(['banana', 'strawberry', 'apple'], 'length');
-// => ['apple', 'banana', 'strawberry']
+_.map(_.sortBy(characters, 'age'), _.values);
+// => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]]
+
+// sorting by multiple properties
+_.map(_.sortBy(characters, ['name', 'age']), _.values);
+// = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
```
* * *
@@ -2112,7 +2157,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length');
### `_.toArray(collection)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4338 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4409 "View in source") [Ⓣ][1]
Converts the `collection` to an array.
@@ -2135,14 +2180,14 @@ Converts the `collection` to an array.
-### `_.where(collection, properties)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4372 "View in source") [Ⓣ][1]
+### `_.where(collection, props)`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L4443 "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.
#### Arguments
1. `collection` *(Array|Object|string)*: The collection to iterate over.
-2. `properties` *(Object)*: The object of property values to filter by.
+2. `props` *(Object)*: The object of property values to filter by.
#### Returns
*(Array)*: Returns a new array of elements that have the given properties.
@@ -2176,7 +2221,7 @@ _.where(characters, { 'pets': ['dino'] });
### `_.after(n, func)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5375 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5486 "View in source") [Ⓣ][1]
Creates a function that executes `func`, with the `this` binding and arguments of the created function, only after being called `n` times.
@@ -2209,7 +2254,7 @@ _.forEach(saves, function(type) {
### `_.bind(func, [thisArg], [arg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5408 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5519 "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.
@@ -2240,7 +2285,7 @@ func();
### `_.bindAll(object, [methodName])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5438 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5549 "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.
@@ -2254,8 +2299,8 @@ Binds methods of an object to the object itself, overwriting the existing method
#### Example
```js
var view = {
- 'label': 'docs',
- 'onClick': function() { console.log('clicked ' + this.label); }
+ 'label': 'docs',
+ 'onClick': function() { console.log('clicked ' + this.label); }
};
_.bindAll(view);
@@ -2271,9 +2316,9 @@ jQuery('#docs').on('click', view.onClick);
### `_.bindKey(object, key, [arg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5484 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5595 "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.
+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.
#### Arguments
1. `object` *(Object)*: The object the method belongs to.
@@ -2312,7 +2357,7 @@ func();
### `_.compose([func])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5520 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5631 "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.
@@ -2347,49 +2392,10 @@ welcome('pebbles');
-
-
-### `_.createCallback([func=identity], [thisArg], [argCount])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5571 "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`.
-
-#### Arguments
-1. `[func=identity]` *(*)*: The value to convert to a callback.
-2. `[thisArg]` *(*)*: The `this` binding of the created callback.
-3. `[argCount]` *(number)*: The number of arguments the callback accepts.
-
-#### Returns
-*(Function)*: Returns a callback function.
-
-#### Example
-```js
-var characters = [
- { 'name': 'barney', 'age': 36 },
- { 'name': 'fred', 'age': 40 }
-];
-
-// wrap to create custom callback shorthands
-_.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
- var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
- return !match ? func(callback, thisArg) : function(object) {
- return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
- };
-});
-
-_.filter(characters, 'age__gt38');
-// => [{ 'name': 'fred', 'age': 40 }]
-```
-
-* * *
-
-
-
-
### `_.curry(func, [arity=func.length])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5636 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5679 "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.
@@ -2424,7 +2430,7 @@ curried(1, 2, 3);
### `_.debounce(func, wait, [options], [options.maxWait])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5680 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5723 "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.
@@ -2468,7 +2474,7 @@ source.addEventListener('message', _.debounce(batchLog, 250, {
### `_.defer(func, [arg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5796 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5839 "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.
@@ -2481,8 +2487,8 @@ Defers executing the `func` function until the current call stack has cleared. A
#### Example
```js
-_.defer(function() { console.log('deferred'); });
-// returns from the function before 'deferred' is logged
+_.defer(function(text) { console.log(text); }, 'deferred');
+// logs 'deferred' after one or more milliseconds
```
* * *
@@ -2493,7 +2499,7 @@ _.defer(function() { console.log('deferred'); });
### `_.delay(func, wait, [arg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5830 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5863 "View in source") [Ⓣ][1]
Executes the `func` function after `wait` milliseconds. Additional arguments will be provided to `func` when it is invoked.
@@ -2507,9 +2513,8 @@ Executes the `func` function after `wait` milliseconds. Additional arguments wil
#### Example
```js
-var log = _.bind(console.log, console);
-_.delay(log, 1000, 'logged later');
-// => 'logged later' (Appears after one second.)
+_.delay(function(text) { console.log(text); }, 1000, 'later');
+// => logs 'later' after one second
```
* * *
@@ -2520,7 +2525,7 @@ _.delay(log, 1000, 'logged later');
### `_.memoize(func, [resolver])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5875 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5908 "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.
@@ -2563,7 +2568,7 @@ get('pebbles');
### `_.once(func)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5908 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5941 "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.
@@ -2589,7 +2594,7 @@ initialize();
### `_.partial(func, [arg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5946 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L5979 "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.
@@ -2616,7 +2621,7 @@ hi('fred');
### `_.partialRight(func, [arg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5977 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6010 "View in source") [Ⓣ][1]
This method is like `_.partial` except that `partial` arguments are appended to those provided to the new function.
@@ -2653,7 +2658,7 @@ options.imports
### `_.throttle(func, wait, [options])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6012 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6045 "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.
@@ -2689,7 +2694,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
### `_.wrap(value, wrapper)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6053 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6086 "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.
@@ -2725,7 +2730,7 @@ p('Fred, Wilma, & Pebbles');
### `_.assign(object, [source], [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2064 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2066 "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)*.
@@ -2763,7 +2768,7 @@ defaults(object, { 'name': 'fred', 'employer': 'slate' });
### `_.clone(value, [isDeep=false], [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2117 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2119 "View in source") [Ⓣ][1]
Creates a clone of `value`. If `isDeep` 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)*.
@@ -2810,7 +2815,7 @@ clone.childNodes.length;
### `_.cloneDeep(value, [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2169 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2171 "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)*.
@@ -2856,7 +2861,7 @@ clone.node == view.node;
### `_.create(prototype, [properties])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2204 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2206 "View in source") [Ⓣ][1]
Creates an object that inherits from the given `prototype` object. If a `properties` object is provided its own enumerable properties are assigned to the created object.
@@ -2896,7 +2901,7 @@ circle instanceof Shape;
### `_.defaults(object, [source])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2229 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2231 "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.
@@ -2922,7 +2927,7 @@ _.defaults(object, { 'name': 'fred', 'employer': 'slate' });
### `_.findKey(object, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2272 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2274 "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.
@@ -2968,7 +2973,7 @@ _.findKey(characters, 'blocked');
### `_.findLastKey(object, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2325 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2327 "View in source") [Ⓣ][1]
This method is like `_.findKey` except that it iterates over elements of a `collection` in the opposite order.
@@ -3014,7 +3019,7 @@ _.findLastKey(characters, 'blocked');
### `_.forIn(object, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2368 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2370 "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`.
@@ -3052,7 +3057,7 @@ _.forIn(new Shape, function(value, key) {
### `_.forInRight(object, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2400 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2402 "View in source") [Ⓣ][1]
This method is like `_.forIn` except that it iterates over elements of a `collection` in the opposite order.
@@ -3090,7 +3095,7 @@ _.forInRight(new Shape, function(value, key) {
### `_.forOwn(object, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2438 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2440 "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`.
@@ -3118,7 +3123,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
### `_.forOwnRight(object, [callback=identity], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2458 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2460 "View in source") [Ⓣ][1]
This method is like `_.forOwn` except that it iterates over elements of a `collection` in the opposite order.
@@ -3146,7 +3151,7 @@ _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
### `_.functions(object)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2487 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2489 "View in source") [Ⓣ][1]
Creates a sorted array of property names of all enumerable properties, own and inherited, of `object` that have function values.
@@ -3172,14 +3177,14 @@ _.functions(_);
-### `_.has(object, property)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2512 "View in source") [Ⓣ][1]
+### `_.has(object, key)`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2514 "View in source") [Ⓣ][1]
-Checks if the specified object `property` exists and is a direct property, instead of an inherited property.
+Checks if the specified property name exists as a direct property of `object`, instead of an inherited property.
#### Arguments
-1. `object` *(Object)*: The object to check.
-2. `property` *(string)*: The property to check for.
+1. `object` *(Object)*: The object to inspect.
+2. `key` *(string)*: The name of the property to check.
#### Returns
*(boolean)*: Returns `true` if key is a direct property, else `false`.
@@ -3198,7 +3203,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
### `_.invert(object)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2529 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2531 "View in source") [Ⓣ][1]
Creates an object composed of the inverted keys and values of the given object.
@@ -3222,7 +3227,7 @@ _.invert({ 'first': 'fred', 'second': 'barney' });
### `_.isArguments(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L1889 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L1891 "View in source") [Ⓣ][1]
Checks if `value` is an `arguments` object.
@@ -3249,7 +3254,7 @@ _.isArguments([1, 2, 3]);
### `_.isArray(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L1918 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L1920 "View in source") [Ⓣ][1]
Checks if `value` is an array.
@@ -3276,7 +3281,7 @@ _.isArray([1, 2, 3]);
### `_.isBoolean(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2555 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2557 "View in source") [Ⓣ][1]
Checks if `value` is a boolean value.
@@ -3300,7 +3305,7 @@ _.isBoolean(null);
### `_.isDate(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2573 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2575 "View in source") [Ⓣ][1]
Checks if `value` is a date.
@@ -3324,7 +3329,7 @@ _.isDate(new Date);
### `_.isElement(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2590 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2592 "View in source") [Ⓣ][1]
Checks if `value` is a DOM element.
@@ -3348,7 +3353,7 @@ _.isElement(document.body);
### `_.isEmpty(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2615 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2617 "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".
@@ -3378,7 +3383,7 @@ _.isEmpty('');
### `_.isEqual(a, b, [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2672 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2674 "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)*.
@@ -3423,7 +3428,7 @@ _.isEqual(words, otherWords, function(a, b) {
### `_.isFinite(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2704 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2706 "View in source") [Ⓣ][1]
Checks if `value` is, or can be coerced to, a finite number.
@@ -3461,7 +3466,7 @@ _.isFinite(Infinity);
### `_.isFunction(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2721 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2723 "View in source") [Ⓣ][1]
Checks if `value` is a function.
@@ -3485,7 +3490,7 @@ _.isFunction(_);
### `_.isNaN(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2784 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2786 "View in source") [Ⓣ][1]
Checks if `value` is `NaN`.
@@ -3520,7 +3525,7 @@ _.isNaN(undefined);
### `_.isNull(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2806 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2808 "View in source") [Ⓣ][1]
Checks if `value` is `null`.
@@ -3547,7 +3552,7 @@ _.isNull(undefined);
### `_.isNumber(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2825 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2827 "View in source") [Ⓣ][1]
Checks if `value` is a number.
@@ -3573,7 +3578,7 @@ _.isNumber(8.4 * 5);
### `_.isObject(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2751 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2753 "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('')`)*
@@ -3603,7 +3608,7 @@ _.isObject(1);
### `_.isPlainObject(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2854 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2856 "View in source") [Ⓣ][1]
Checks if `value` is an object created by the `Object` constructor.
@@ -3638,7 +3643,7 @@ _.isPlainObject({ 'x': 0, 'y': 0 });
### `_.isRegExp(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2879 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2881 "View in source") [Ⓣ][1]
Checks if `value` is a regular expression.
@@ -3662,7 +3667,7 @@ _.isRegExp(/fred/);
### `_.isString(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2896 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2898 "View in source") [Ⓣ][1]
Checks if `value` is a string.
@@ -3686,7 +3691,7 @@ _.isString('fred');
### `_.isUndefined(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2914 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2916 "View in source") [Ⓣ][1]
Checks if `value` is `undefined`.
@@ -3710,7 +3715,7 @@ _.isUndefined(void 0);
### `_.keys(object)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L1952 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L1954 "View in source") [Ⓣ][1]
Creates an array composed of the own enumerable property names of an object.
@@ -3731,10 +3736,49 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 });
+
+
+### `_.mapValues(object, [callback=identity], [thisArg])`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L2956 "View in source") [Ⓣ][1]
+
+Creates an object with the same keys as `object` and values generated by running each own enumerable property of `object` through the callback. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*.
+
+If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element.
+
+If an object is provided for `callback` the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
+
+#### Arguments
+1. `object` *(Object)*: The object to iterate over.
+2. `[callback=identity]` *(Function|Object|string)*: The function called per iteration. If a property name or object is provided it will be used to create a "_.pluck" or "_.where" style callback, respectively.
+3. `[thisArg]` *(*)*: The `this` binding of `callback`.
+
+#### Returns
+*(Array)*: Returns a new object with values of the results of each `callback` execution.
+
+#### Example
+```js
+_.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; });
+// => { 'a': 3, 'b': 6, 'c': 9 }
+
+var characters = {
+ 'fred': { 'name': 'fred', 'age': 40 },
+ 'pebbles': { 'name': 'pebbles', 'age': 1 }
+};
+
+// using "_.pluck" callback shorthand
+_.mapValues(characters, 'age');
+// => { 'fred': 40, 'pebbles': 1 }
+```
+
+* * *
+
+
+
+
### `_.merge(object, [source], [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2969 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3017 "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)*.
@@ -3790,7 +3834,7 @@ _.merge(food, otherFood, function(a, b) {
### `_.omit(object, [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3026 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3073 "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 truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*.
@@ -3821,9 +3865,9 @@ _.omit({ 'name': 'fred', 'age': 40 }, function(value) {
### `_.pairs(object)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3067 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3114 "View in source") [Ⓣ][1]
-Creates a two dimensional array of an object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`.
+Creates a two dimensional array of an object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`.
#### Arguments
1. `object` *(Object)*: The object to inspect.
@@ -3845,7 +3889,7 @@ _.pairs({ 'barney': 36, 'fred': 40 });
### `_.pick(object, [callback], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3107 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3154 "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 truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*.
@@ -3876,9 +3920,9 @@ _.pick({ 'name': 'fred', '_userid': 'fred1' }, function(value, key) {
### `_.transform(object, [callback=identity], [accumulator], [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3162 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3209 "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`.
+An alternative to `_.reduce` this method transforms `object` to a new `accumulator` object which is the result of running each of its own enumerable properties 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`.
#### Arguments
1. `object` *(Array|Object)*: The object to iterate over.
@@ -3913,7 +3957,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key)
### `_.values(object)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3196 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L3243 "View in source") [Ⓣ][1]
Creates an array composed of the own enumerable property values of `object`.
@@ -3943,15 +3987,41 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 });
-### `_.noop`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6176 "View in source") [Ⓣ][1]
+### `_.now`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6333 "View in source") [Ⓣ][1]
-*(unknown)*: A no-operation function.
+*(unknown)*: Gets the number of milliseconds that have elapsed since the Unix epoch *(1 January `1970 00`:00:00 UTC)*.
+
+#### Example
+```js
+var stamp = _.now();
+_.defer(function() { console.log(_.now() - stamp); });
+// => logs the number of milliseconds it took for the deferred function to be called
+```
+
+* * *
+
+
+
+
+
+
+### `_.constant(value)`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6107 "View in source") [Ⓣ][1]
+
+Creates a function that returns `value`.
+
+#### Arguments
+1. `value` *(*)*: The value to return from the new function.
+
+#### Returns
+*(Function)*: Returns the new function.
#### Example
```js
var object = { 'name': 'fred' };
-_.noop(object) === undefined;
+var getter = _.constant(object);
+getter() === object;
// => true
```
@@ -3960,10 +4030,49 @@ _.noop(object) === undefined;
+
+
+### `_.createCallback([func=identity], [thisArg], [argCount])`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6144 "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`.
+
+#### Arguments
+1. `[func=identity]` *(*)*: The value to convert to a callback.
+2. `[thisArg]` *(*)*: The `this` binding of the created callback.
+3. `[argCount]` *(number)*: The number of arguments the callback accepts.
+
+#### Returns
+*(Function)*: Returns a callback function.
+
+#### Example
+```js
+var characters = [
+ { 'name': 'barney', 'age': 36 },
+ { 'name': 'fred', 'age': 40 }
+];
+
+// wrap to create custom callback shorthands
+_.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
+ var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
+ return !match ? func(callback, thisArg) : function(object) {
+ return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
+ };
+});
+
+_.filter(characters, 'age__gt38');
+// => [{ 'name': 'fred', 'age': 40 }]
+```
+
+* * *
+
+
+
+
### `_.escape(string)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6073 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6193 "View in source") [Ⓣ][1]
Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities.
@@ -3987,7 +4096,7 @@ _.escape('Fred, Wilma, & Pebbles');
### `_.identity(value)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6091 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6211 "View in source") [Ⓣ][1]
This method returns the first argument provided to it.
@@ -4011,26 +4120,31 @@ _.identity(object) === object;
-### `_.mixin(object, object)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6118 "View in source") [Ⓣ][1]
+### `_.mixin([object=lodash], source, [options])`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6243 "View in source") [Ⓣ][1]
-Adds function properties of a source object to the `lodash` function and chainable wrapper.
+Adds function properties of a source object to the destination object. If `object` is a function methods will be added to its prototype as well.
#### Arguments
-1. `object` *(Object)*: The object of function properties to add to `lodash`.
-2. `object` *(Object)*: The object of function properties to add to `lodash`.
+1. `[object=lodash]` *(Function|Object)*: object The destination object.
+2. `source` *(Object)*: The object of functions to add.
+3. `[options]` *(Object)*: The options object.
+4. `[options.chain=true]` *(boolean)*: Specify whether the functions added are chainable.
#### Example
```js
-_.mixin({
- 'capitalize': function(string) {
- return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
- }
-});
+function capitalize(string) {
+ return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
+}
+_.mixin({ 'capitalize': capitalize });
_.capitalize('fred');
// => 'Fred'
+_('fred').capitalize().value();
+// => 'Fred'
+
+_.mixin({ 'capitalize': capitalize }, { 'chain': false });
_('fred').capitalize();
// => 'Fred'
```
@@ -4043,7 +4157,7 @@ _('fred').capitalize();
### `_.noConflict()`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6159 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6299 "View in source") [Ⓣ][1]
Reverts the '_' variable to its previous value and returns a reference to the `lodash` function.
@@ -4060,10 +4174,29 @@ var lodash = _.noConflict();
+
+
+### `_.noop()`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6316 "View in source") [Ⓣ][1]
+
+A no-operation function.
+
+#### Example
+```js
+var object = { 'name': 'fred' };
+_.noop(object) === undefined;
+// => true
+```
+
+* * *
+
+
+
+
### `_.parseInt(value, [radix])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6199 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6356 "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.
@@ -4087,10 +4220,44 @@ _.parseInt('08');
+
+
+### `_.property(key)`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6385 "View in source") [Ⓣ][1]
+
+Creates a "_.pluck" style function, which returns the `key` value of a given object.
+
+#### Arguments
+1. `key` *(string)*: The name of the property to retrieve.
+
+#### Returns
+*(Function)*: Returns the new function.
+
+#### Example
+```js
+var characters = [
+ { 'name': 'fred', 'age': 40 },
+ { 'name': 'barney', 'age': 36 }
+];
+
+var getName = _.property('name');
+
+_.map(characters, getName);
+// => ['barney', 'fred']
+
+_.sortBy(characters, getName);
+// => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }]
+```
+
+* * *
+
+
+
+
### `_.random([min=0], [max=1], [floating=false])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6231 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6418 "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. If `floating` is truey or either `min` or `max` are floats a floating-point number will be returned instead of an integer.
@@ -4124,14 +4291,14 @@ _.random(1.2, 5.2);
-### `_.result(object, property)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6289 "View in source") [Ⓣ][1]
+### `_.result(object, key)`
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6476 "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.
+Resolves the value of property `key` on `object`. If `key` 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.
#### Arguments
1. `object` *(Object)*: The object to inspect.
-2. `property` *(string)*: The property to get the value of.
+2. `key` *(string)*: The name of the property to resolve.
#### Returns
*(*)*: Returns the resolved value.
@@ -4160,7 +4327,7 @@ _.result(object, 'stuff');
### `_.runInContext([context=root])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L462 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L469 "View in source") [Ⓣ][1]
Create a new `lodash` function using the given context object.
@@ -4178,7 +4345,7 @@ Create a new `lodash` function using the given context object.
### `_.template(text, data, [options], [options.escape], [options.evaluate], [options.imports], [options.interpolate], [sourceURL], [variable])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6382 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6569 "View in source") [Ⓣ][1]
A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.
@@ -4237,8 +4404,8 @@ _.template('hello {{ name }}!', { 'name': 'mustache' });
// => 'hello mustache!'
// using the `imports` option to import jQuery
-var list = '<% $.each(people, function(name) { %><%- name %><% }); %>';
-_.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } });
+var list = '<% jq.each(people, function(name) { %><%- name %><% }); %>';
+_.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } });
// => 'fredbarney'
// using the `sourceURL` option to specify a custom sourceURL for the template
@@ -4272,7 +4439,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\
### `_.times(n, callback, [thisArg])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6505 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6692 "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)*.
@@ -4304,7 +4471,7 @@ _.times(3, function(n) { this.cast(n); }, mage);
### `_.unescape(string)`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6532 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6719 "View in source") [Ⓣ][1]
The inverse of `_.escape` this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters.
@@ -4328,7 +4495,7 @@ _.unescape('Fred, Barney & Pebbles');
### `_.uniqueId([prefix])`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6552 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L6739 "View in source") [Ⓣ][1]
Generates a unique ID. If `prefix` is provided the ID will be appended to it.
@@ -4362,7 +4529,7 @@ _.uniqueId();
### `_.templateSettings.imports._`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L865 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L867 "View in source") [Ⓣ][1]
A reference to the `lodash` function.
@@ -4381,7 +4548,7 @@ A reference to the `lodash` function.
### `_.VERSION`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6873 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L7060 "View in source") [Ⓣ][1]
*(string)*: The semantic version number.
@@ -4393,7 +4560,7 @@ A reference to the `lodash` function.
### `_.support`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L674 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L676 "View in source") [Ⓣ][1]
*(Object)*: An object used to flag environments features.
@@ -4405,7 +4572,7 @@ A reference to the `lodash` function.
### `_.support.argsClass`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L691 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L693 "View in source") [Ⓣ][1]
*(boolean)*: Detect if an `arguments` object's [[Class]] is resolvable *(all but Firefox < `4`, IE < `9`)*.
@@ -4417,7 +4584,7 @@ A reference to the `lodash` function.
### `_.support.argsObject`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L699 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L701 "View in source") [Ⓣ][1]
*(boolean)*: Detect if `arguments` objects are `Object` objects *(all but Narwhal and Opera < `10.5`)*.
@@ -4429,7 +4596,7 @@ A reference to the `lodash` function.
### `_.support.enumErrorProps`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L708 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L710 "View in source") [Ⓣ][1]
*(boolean)*: Detect if `name` or `message` properties of `Error.prototype` are enumerable by default. *(IE < `9`, Safari < `5.1`)*
@@ -4441,7 +4608,7 @@ A reference to the `lodash` function.
### `_.support.enumPrototypes`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L721 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L723 "View in source") [Ⓣ][1]
*(boolean)*: Detect if `prototype` properties are enumerable by default.
@@ -4455,7 +4622,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p
### `_.support.funcDecomp`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L730 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L732 "View in source") [Ⓣ][1]
*(boolean)*: Detect if functions can be decompiled by `Function#toString` *(all but PS3 and older Opera mobile browsers & avoided in Windows `8` apps)*.
@@ -4467,7 +4634,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p
### `_.support.funcNames`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L738 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L740 "View in source") [Ⓣ][1]
*(boolean)*: Detect if `Function#name` is supported *(all but IE)*.
@@ -4479,7 +4646,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p
### `_.support.nonEnumArgs`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L747 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L749 "View in source") [Ⓣ][1]
*(boolean)*: Detect if `arguments` object indexes are non-enumerable *(Firefox < `4`, IE < `9`, PhantomJS, Safari < `5.1`)*.
@@ -4491,7 +4658,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p
### `_.support.nonEnumShadows`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L758 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L760 "View in source") [Ⓣ][1]
*(boolean)*: Detect if properties shadowing those on `Object.prototype` are non-enumerable.
@@ -4505,7 +4672,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n
### `_.support.ownLast`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L766 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L768 "View in source") [Ⓣ][1]
*(boolean)*: Detect if own properties are iterated after inherited properties *(all but IE < `9`)*.
@@ -4517,11 +4684,11 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n
### `_.support.spliceObjects`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L780 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L782 "View in source") [Ⓣ][1]
*(boolean)*: Detect if `Array#shift` and `Array#splice` augment array-like objects correctly.
-Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` and `splice()` functions that fail to remove the last element, `value[0]`, of array-like objects even though the `length` property is set to `0`. The `shift()` method is buggy in IE `8` compatibility mode, while `splice()` is buggy regardless of mode in IE < `9` and buggy in compatibility mode in IE `9`.
+Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` and `splice()` functions that fail to remove the last element, `value[0]`, of array-like objects even though the `length` property is set to `0`. The `shift()` method is buggy in IE `8` compatibility mode, while `splice()` is buggy regardless of mode in IE < `9` and buggy in compatibility mode in IE `9`.
* * *
@@ -4531,7 +4698,7 @@ Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` a
### `_.support.unindexedChars`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L791 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L793 "View in source") [Ⓣ][1]
*(boolean)*: Detect lack of support for accessing string characters by index.
@@ -4545,7 +4712,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters
### `_.templateSettings`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L817 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L819 "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.
@@ -4557,7 +4724,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters
### `_.templateSettings.escape`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L825 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L827 "View in source") [Ⓣ][1]
*(RegExp)*: Used to detect `data` property values to be HTML-escaped.
@@ -4569,7 +4736,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters
### `_.templateSettings.evaluate`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L833 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L835 "View in source") [Ⓣ][1]
*(RegExp)*: Used to detect code to be evaluated.
@@ -4581,7 +4748,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters
### `_.templateSettings.interpolate`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L841 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L843 "View in source") [Ⓣ][1]
*(RegExp)*: Used to detect `data` property values to inject.
@@ -4593,7 +4760,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters
### `_.templateSettings.variable`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L849 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L851 "View in source") [Ⓣ][1]
*(string)*: Used to reference the data object in the template text.
@@ -4605,7 +4772,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters
### `_.templateSettings.imports`
-# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L857 "View in source") [Ⓣ][1]
+# [Ⓢ](https://github.com/lodash/lodash/blob/2.4.0/lodash.js#L859 "View in source") [Ⓣ][1]
*(Object)*: Used to import variables into the compiled template.
@@ -4620,4 +4787,4 @@ IE < `8` can't access characters by index and IE `8` can only access characters
- [1]: #arrays "Jump back to the TOC."
\ No newline at end of file
+ [1]: #arrays "Jump back to the TOC."
diff --git a/doc/parse.php b/doc/parse.php
index 681d6e92e1..1dad09d1a9 100644
--- a/doc/parse.php
+++ b/doc/parse.php
@@ -26,7 +26,7 @@
'path' => '../' . $filePath,
'title' => 'Lo-Dash v' . $version . '',
'toc' => 'categories',
- 'url' => 'https://github.com/lodash/lodash/blob/master/lodash.js'
+ 'url' => 'https://github.com/lodash/lodash/blob/' . $version . '/lodash.js'
));
// save to a `.md` file
@@ -35,4 +35,4 @@
// print
header('Content-Type: text/plain;charset=utf-8');
echo $markdown . PHP_EOL;
-?>
\ No newline at end of file
+?>
diff --git a/lodash.js b/lodash.js
index a3de6e032a..363ec82e31 100644
--- a/lodash.js
+++ b/lodash.js
@@ -1,6 +1,6 @@
/**
* @license
- * Lo-Dash 2.3.0
+ * Lo-Dash 2.4.0
* Copyright 2012-2013 The Dojo Foundation
* Based on Underscore.js 1.5.2
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
@@ -49,7 +49,7 @@
/**
* Used to match ES6 template delimiters
- * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6
+ * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals
*/
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
@@ -78,7 +78,7 @@
var contextProps = [
'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object',
'RegExp', 'String', '_', 'attachEvent', 'clearTimeout', 'isFinite', 'isNaN',
- 'parseInt', 'setImmediate', 'setTimeout'
+ 'parseInt', 'setTimeout'
];
/** Used to fix the JScript [[DontEnum]] bug */
@@ -280,22 +280,29 @@
*/
function compareAscending(a, b) {
var ac = a.criteria,
- bc = b.criteria;
+ bc = b.criteria,
+ index = -1,
+ length = ac.length;
- // ensure a stable sort in V8 and other engines
- // http://code.google.com/p/v8/issues/detail?id=90
- if (ac !== bc) {
- if (ac > bc || typeof ac == 'undefined') {
- return 1;
- }
- if (ac < bc || typeof bc == 'undefined') {
- return -1;
+ while (++index < length) {
+ var value = ac[index],
+ other = bc[index];
+
+ if (value !== other) {
+ if (value > other || typeof value == 'undefined') {
+ return 1;
+ }
+ if (value < other || typeof other == 'undefined') {
+ return -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
+ // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
+ // that causes it, under certain circumstances, to return the same value for
+ // `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247
+ //
+ // This also ensures a stable sort in V8 and other engines.
+ // See http://code.google.com/p/v8/issues/detail?id=90
return a.index - b.index;
}
@@ -512,17 +519,12 @@
fnToString = Function.prototype.toString,
getPrototypeOf = reNative.test(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
hasOwnProperty = objectProto.hasOwnProperty,
- now = reNative.test(now = Date.now) && now || function() { return +new Date; },
push = arrayRef.push,
propertyIsEnumerable = objectProto.propertyIsEnumerable,
setTimeout = context.setTimeout,
splice = arrayRef.splice,
unshift = arrayRef.unshift;
- /** Used to detect `setImmediate` in Node.js */
- var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
- !reNative.test(setImmediate) && setImmediate;
-
/** Used to set meta data on functions */
var defineProperty = (function() {
// IE 8 only accepts DOM elements
@@ -2495,22 +2497,22 @@
}
/**
- * Checks if the specified object `property` exists and is a direct property,
+ * Checks if the specified property name exists as a direct property of `object`,
* instead of an inherited property.
*
* @static
* @memberOf _
* @category Objects
- * @param {Object} object The object to check.
- * @param {string} property The property to check for.
+ * @param {Object} object The object to inspect.
+ * @param {string} key The name of the property to check.
* @returns {boolean} Returns `true` if key is a direct property, else `false`.
* @example
*
* _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
* // => true
*/
- function has(object, property) {
- return object ? hasOwnProperty.call(object, property) : false;
+ function has(object, key) {
+ return object ? hasOwnProperty.call(object, key) : false;
}
/**
@@ -2523,7 +2525,7 @@
* @returns {Object} Returns the created inverted object.
* @example
*
- * _.invert({ 'first': 'fred', 'second': 'barney' });
+ * _.invert({ 'first': 'fred', 'second': 'barney' });
* // => { 'fred': 'first', 'barney': 'second' }
*/
function invert(object) {
@@ -2915,6 +2917,52 @@
return typeof value == 'undefined';
}
+ /**
+ * Creates an object with the same keys as `object` and values generated by
+ * running each own enumerable property of `object` through the callback.
+ * The callback is bound to `thisArg` and invoked with three arguments;
+ * (value, key, object).
+ *
+ * If a property name is provided for `callback` the created "_.pluck" style
+ * callback will return the property value of the given element.
+ *
+ * If an object is provided for `callback` the created "_.where" style callback
+ * will return `true` for elements that have the properties of the given object,
+ * else `false`.
+ *
+ * @static
+ * @memberOf _
+ * @category Objects
+ * @param {Object} object The object to iterate over.
+ * @param {Function|Object|string} [callback=identity] The function called
+ * per iteration. If a property name or object is provided it will be used
+ * to create a "_.pluck" or "_.where" style callback, respectively.
+ * @param {*} [thisArg] The `this` binding of `callback`.
+ * @returns {Array} Returns a new object with values of the results of each `callback` execution.
+ * @example
+ *
+ * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; });
+ * // => { 'a': 3, 'b': 6, 'c': 9 }
+ *
+ * var characters = {
+ * 'fred': { 'name': 'fred', 'age': 40 },
+ * 'pebbles': { 'name': 'pebbles', 'age': 1 }
+ * };
+ *
+ * // using "_.pluck" callback shorthand
+ * _.mapValues(characters, 'age');
+ * // => { 'fred': 40, 'pebbles': 1 }
+ */
+ function mapValues(object, callback, thisArg) {
+ var result = {};
+ callback = lodash.createCallback(callback, thisArg, 3);
+
+ forOwn(object, function(value, key, object) {
+ result[key] = callback(value, key, object);
+ });
+ return result;
+ }
+
/**
* Recursively merges own enumerable properties of the source object(s), that
* don't resolve to `undefined` into the destination object. Subsequent sources
@@ -2973,7 +3021,6 @@
if (!isObject(object)) {
return object;
}
-
// allows working with `_.reduce` and `_.reduceRight` without using
// their `index` and `collection` arguments
if (typeof args[2] != 'number') {
@@ -3130,11 +3177,11 @@
/**
* 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`.
+ * `accumulator` object which is the result of running each of its own
+ * enumerable properties 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`.
*
* @static
* @memberOf _
@@ -3973,7 +4020,7 @@
* @type Function
* @category Collections
* @param {Array|Object|string} collection The collection to iterate over.
- * @param {string} property The property to pluck.
+ * @param {string} property The name of the property to pluck.
* @returns {Array} Returns a new array of property values.
* @example
*
@@ -4194,7 +4241,7 @@
* // => 3
*
* _.size('pebbles');
- * // => 5
+ * // => 7
*/
function size(collection) {
var length = collection ? collection.length : 0;
@@ -4274,6 +4321,9 @@
* If a property name is provided for `callback` the created "_.pluck" style
* callback will return the property value of the given element.
*
+ * If an array of property names is provided for `callback` the collection
+ * will be sorted by each property value.
+ *
* If an object is provided for `callback` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
@@ -4282,7 +4332,7 @@
* @memberOf _
* @category Collections
* @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [callback=identity] The function called
+ * @param {Array|Function|Object|string} [callback=identity] The function called
* per iteration. If a property name or object is provided it will be used
* to create a "_.pluck" or "_.where" style callback, respectively.
* @param {*} [thisArg] The `this` binding of `callback`.
@@ -4295,19 +4345,37 @@
* _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
* // => [3, 1, 2]
*
+ * var characters = [
+ * { 'name': 'barney', 'age': 36 },
+ * { 'name': 'fred', 'age': 40 },
+ * { 'name': 'barney', 'age': 26 },
+ * { 'name': 'fred', 'age': 30 }
+ * ];
+ *
* // using "_.pluck" callback shorthand
- * _.sortBy(['banana', 'strawberry', 'apple'], 'length');
- * // => ['apple', 'banana', 'strawberry']
+ * _.map(_.sortBy(characters, 'age'), _.values);
+ * // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]]
+ *
+ * // sorting by multiple properties
+ * _.map(_.sortBy(characters, ['name', 'age']), _.values);
+ * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
*/
function sortBy(collection, callback, thisArg) {
var index = -1,
+ isArr = isArray(callback),
length = collection ? collection.length : 0,
result = Array(typeof length == 'number' ? length : 0);
- callback = lodash.createCallback(callback, thisArg, 3);
+ if (!isArr) {
+ callback = lodash.createCallback(callback, thisArg, 3);
+ }
forEach(collection, function(value, key, collection) {
var object = result[++index] = getObject();
- object.criteria = callback(value, key, collection);
+ if (isArr) {
+ object.criteria = map(callback, function(key) { return value[key]; });
+ } else {
+ (object.criteria = getArray())[0] = callback(value, key, collection);
+ }
object.index = index;
object.value = value;
});
@@ -4317,6 +4385,9 @@
while (length--) {
var object = result[length];
result[length] = object.value;
+ if (!isArr) {
+ releaseArray(object.criteria);
+ }
releaseObject(object);
}
return result;
@@ -4354,7 +4425,7 @@
* @type Function
* @category Collections
* @param {Array|Object|string} collection The collection to iterate over.
- * @param {Object} properties The object of property values to filter by.
+ * @param {Object} props The object of property values to filter by.
* @returns {Array} Returns a new array of elements that have the given properties.
* @example
*
@@ -4759,29 +4830,34 @@
* @memberOf _
* @category Arrays
* @param {...Array} [array] The arrays to inspect.
- * @returns {Array} Returns an array of composite values.
+ * @returns {Array} Returns an array of shared values.
* @example
*
- * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
+ * _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
* // => [1, 2]
*/
- function intersection(array) {
- var args = arguments,
- argsLength = args.length,
+ function intersection() {
+ var args = [],
argsIndex = -1,
+ argsLength = arguments.length,
caches = getArray(),
- index = -1,
indexOf = getIndexOf(),
- length = array ? array.length : 0,
- result = [],
+ trustIndexOf = indexOf === baseIndexOf,
seen = getArray();
while (++argsIndex < argsLength) {
- var value = args[argsIndex];
- caches[argsIndex] = indexOf === baseIndexOf &&
- (value ? value.length : 0) >= largeArraySize &&
- createCache(argsIndex ? args[argsIndex] : seen);
+ var value = arguments[argsIndex];
+ if (isArray(value) || isArguments(value)) {
+ args.push(value);
+ caches.push(trustIndexOf && value.length >= largeArraySize &&
+ createCache(argsIndex ? args[argsIndex] : seen));
+ }
}
+ var array = args[0],
+ index = -1,
+ length = array ? array.length : 0,
+ result = [];
+
outer:
while (++index < length) {
var cache = caches[0];
@@ -5198,13 +5274,13 @@
* @memberOf _
* @category Arrays
* @param {...Array} [array] The arrays to inspect.
- * @returns {Array} Returns an array of composite values.
+ * @returns {Array} Returns an array of combined values.
* @example
*
- * _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
- * // => [1, 2, 3, 101, 10]
+ * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]);
+ * // => [1, 2, 3, 5, 4]
*/
- function union(array) {
+ function union() {
return baseUniq(baseFlatten(arguments, true, true));
}
@@ -5284,6 +5360,38 @@
return baseDifference(array, slice(arguments, 1));
}
+ /**
+ * Creates an array that is the smymetric difference of the provided arrays.
+ * See http://en.wikipedia.org/wiki/Symmetric_difference.
+ *
+ * @static
+ * @memberOf _
+ * @category Arrays
+ * @param {...Array} [array] The arrays to inspect.
+ * @returns {Array} Returns an array of values.
+ * @example
+ *
+ * _.xor([1, 2, 3], [5, 2, 1, 4]);
+ * // => [3, 5, 4]
+ *
+ * _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]);
+ * // => [1, 4, 5]
+ */
+ function xor() {
+ var index = -1,
+ length = arguments.length;
+
+ while (++index < length) {
+ var array = arguments[index];
+ if (isArray(array) || isArguments(array)) {
+ var result = result
+ ? baseUniq(baseDifference(result, array).concat(baseDifference(array, result)))
+ : array;
+ }
+ }
+ return result || [];
+ }
+
/**
* 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
@@ -5335,6 +5443,9 @@
length = keys ? keys.length : 0,
result = {};
+ if (!values && length && !isArray(keys[0])) {
+ values = [];
+ }
while (++index < length) {
var key = keys[index];
if (values) {
@@ -5427,8 +5538,8 @@
* @example
*
* var view = {
- * 'label': 'docs',
- * 'onClick': function() { console.log('clicked ' + this.label); }
+ * 'label': 'docs',
+ * 'onClick': function() { console.log('clicked ' + this.label); }
* };
*
* _.bindAll(view);
@@ -5537,74 +5648,6 @@
};
}
- /**
- * 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`.
- *
- * @static
- * @memberOf _
- * @category Functions
- * @param {*} [func=identity] The value to convert to a callback.
- * @param {*} [thisArg] The `this` binding of the created callback.
- * @param {number} [argCount] The number of arguments the callback accepts.
- * @returns {Function} Returns a callback function.
- * @example
- *
- * var characters = [
- * { 'name': 'barney', 'age': 36 },
- * { 'name': 'fred', 'age': 40 }
- * ];
- *
- * // wrap to create custom callback shorthands
- * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
- * var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
- * return !match ? func(callback, thisArg) : function(object) {
- * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
- * };
- * });
- *
- * _.filter(characters, 'age__gt38');
- * // => [{ 'name': 'fred', 'age': 40 }]
- */
- function createCallback(func, thisArg, argCount) {
- var type = typeof func;
- if (func == null || type == 'function') {
- return baseCreateCallback(func, thisArg, argCount);
- }
- // handle "_.pluck" style callback shorthands
- if (type != 'object') {
- return function(object) {
- return object[func];
- };
- }
- var props = keys(func),
- key = props[0],
- a = func[key];
-
- // handle "_.where" style callback shorthands
- if (props.length == 1 && a === a && !isObject(a)) {
- // fast path the common case of providing an object with a single
- // property containing a primitive value
- return function(object) {
- var b = object[key];
- return a === b && (a !== 0 || (1 / a == 1 / b));
- };
- }
- return function(object) {
- var length = props.length,
- result = false;
-
- while (length--) {
- if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) {
- break;
- }
- }
- return result;
- };
- }
-
/**
* Creates a function which accepts one or more arguments of `func` that when
* invoked either executes `func` returning its result, if all `func` arguments
@@ -5790,8 +5833,8 @@
* @returns {number} Returns the timer id.
* @example
*
- * _.defer(function() { console.log('deferred'); });
- * // returns from the function before 'deferred' is logged
+ * _.defer(function(text) { console.log(text); }, 'deferred');
+ * // logs 'deferred' after one or more milliseconds
*/
function defer(func) {
if (!isFunction(func)) {
@@ -5800,15 +5843,6 @@
var args = slice(arguments, 1);
return setTimeout(function() { func.apply(undefined, args); }, 1);
}
- // use `setImmediate` if available in Node.js
- if (setImmediate) {
- defer = function(func) {
- if (!isFunction(func)) {
- throw new TypeError;
- }
- return setImmediate.apply(context, arguments);
- };
- }
/**
* Executes the `func` function after `wait` milliseconds. Additional arguments
@@ -5823,9 +5857,8 @@
* @returns {number} Returns the timer id.
* @example
*
- * var log = _.bind(console.log, console);
- * _.delay(log, 1000, 'logged later');
- * // => 'logged later' (Appears after one second.)
+ * _.delay(function(text) { console.log(text); }, 1000, 'later');
+ * // => logs 'later' after one second
*/
function delay(func, wait) {
if (!isFunction(func)) {
@@ -6056,6 +6089,93 @@
/*--------------------------------------------------------------------------*/
+ /**
+ * Creates a function that returns `value`.
+ *
+ * @static
+ * @memberOf _
+ * @category Utilities
+ * @param {*} value The value to return from the new function.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var object = { 'name': 'fred' };
+ * var getter = _.constant(object);
+ * getter() === object;
+ * // => true
+ */
+ function constant(value) {
+ return function() {
+ return value;
+ };
+ }
+
+ /**
+ * 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`.
+ *
+ * @static
+ * @memberOf _
+ * @category Utilities
+ * @param {*} [func=identity] The value to convert to a callback.
+ * @param {*} [thisArg] The `this` binding of the created callback.
+ * @param {number} [argCount] The number of arguments the callback accepts.
+ * @returns {Function} Returns a callback function.
+ * @example
+ *
+ * var characters = [
+ * { 'name': 'barney', 'age': 36 },
+ * { 'name': 'fred', 'age': 40 }
+ * ];
+ *
+ * // wrap to create custom callback shorthands
+ * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
+ * var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
+ * return !match ? func(callback, thisArg) : function(object) {
+ * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
+ * };
+ * });
+ *
+ * _.filter(characters, 'age__gt38');
+ * // => [{ 'name': 'fred', 'age': 40 }]
+ */
+ function createCallback(func, thisArg, argCount) {
+ var type = typeof func;
+ if (func == null || type == 'function') {
+ return baseCreateCallback(func, thisArg, argCount);
+ }
+ // handle "_.pluck" style callback shorthands
+ if (type != 'object') {
+ return property(func);
+ }
+ var props = keys(func),
+ key = props[0],
+ a = func[key];
+
+ // handle "_.where" style callback shorthands
+ if (props.length == 1 && a === a && !isObject(a)) {
+ // fast path the common case of providing an object with a single
+ // property containing a primitive value
+ return function(object) {
+ var b = object[key];
+ return a === b && (a !== 0 || (1 / a == 1 / b));
+ };
+ }
+ return function(object) {
+ var length = props.length,
+ result = false;
+
+ while (length--) {
+ if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) {
+ break;
+ }
+ }
+ return result;
+ };
+ }
+
/**
* Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their
* corresponding HTML entities.
@@ -6093,51 +6213,71 @@
}
/**
- * Adds function properties of a source object to the `lodash` function and
- * chainable wrapper.
+ * Adds function properties of a source object to the destination object.
+ * If `object` is a function methods will be added to its prototype as well.
*
* @static
* @memberOf _
* @category Utilities
- * @param {Object} object The object of function properties to add to `lodash`.
- * @param {Object} object The object of function properties to add to `lodash`.
+ * @param {Function|Object} [object=lodash] object The destination object.
+ * @param {Object} source The object of functions to add.
+ * @param {Object} [options] The options object.
+ * @param {boolean} [options.chain=true] Specify whether the functions added are chainable.
* @example
*
- * _.mixin({
- * 'capitalize': function(string) {
- * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
- * }
- * });
+ * function capitalize(string) {
+ * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
+ * }
*
+ * _.mixin({ 'capitalize': capitalize });
* _.capitalize('fred');
* // => 'Fred'
*
+ * _('fred').capitalize().value();
+ * // => 'Fred'
+ *
+ * _.mixin({ 'capitalize': capitalize }, { 'chain': false });
* _('fred').capitalize();
* // => 'Fred'
*/
- function mixin(object, source) {
- var ctor = object,
- isFunc = !source || isFunction(ctor);
+ function mixin(object, source, options) {
+ var chain = true,
+ methodNames = source && functions(source);
- if (!source) {
+ if (!source || (!options && !methodNames.length)) {
+ if (options == null) {
+ options = source;
+ }
ctor = lodashWrapper;
source = object;
object = lodash;
+ methodNames = functions(source);
}
- forEach(functions(source), function(methodName) {
+ if (options === false) {
+ chain = false;
+ } else if (isObject(options) && 'chain' in options) {
+ chain = options.chain;
+ }
+ var ctor = object,
+ isFunc = isFunction(ctor);
+
+ forEach(methodNames, function(methodName) {
var func = object[methodName] = source[methodName];
if (isFunc) {
ctor.prototype[methodName] = function() {
- var value = this.__wrapped__,
+ var chainAll = this.__chain__,
+ value = this.__wrapped__,
args = [value];
push.apply(args, arguments);
var result = func.apply(object, args);
- if (value && typeof value == 'object' && value === result) {
- return this;
+ if (chain || chainAll) {
+ if (value === result && isObject(result)) {
+ return this;
+ }
+ result = new ctor(result);
+ result.__chain__ = chainAll;
}
- result = new ctor(result);
- result.__chain__ = this.__chain__;
return result;
};
}
@@ -6177,6 +6317,23 @@
// no operation performed
}
+ /**
+ * Gets the number of milliseconds that have elapsed since the Unix epoch
+ * (1 January 1970 00:00:00 UTC).
+ *
+ * @static
+ * @memberOf _
+ * @category Utilities
+ * @example
+ *
+ * var stamp = _.now();
+ * _.defer(function() { console.log(_.now() - stamp); });
+ * // => logs the number of milliseconds it took for the deferred function to be called
+ */
+ var now = reNative.test(now = Date.now) && now || function() {
+ return new Date().getTime();
+ };
+
/**
* 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
@@ -6201,6 +6358,36 @@
return nativeParseInt(isString(value) ? value.replace(reLeadingSpacesAndZeros, '') : value, radix || 0);
};
+ /**
+ * Creates a "_.pluck" style function, which returns the `key` value of a
+ * given object.
+ *
+ * @static
+ * @memberOf _
+ * @category Utilities
+ * @param {string} key The name of the property to retrieve.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var characters = [
+ * { 'name': 'fred', 'age': 40 },
+ * { 'name': 'barney', 'age': 36 }
+ * ];
+ *
+ * var getName = _.property('name');
+ *
+ * _.map(characters, getName);
+ * // => ['barney', 'fred']
+ *
+ * _.sortBy(characters, getName);
+ * // => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }]
+ */
+ function property(key) {
+ return function(object) {
+ return object[key];
+ };
+ }
+
/**
* 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
@@ -6260,7 +6447,7 @@
}
/**
- * Resolves the value of `property` on `object`. If `property` is a function
+ * Resolves the value of property `key` on `object`. If `key` 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.
@@ -6269,7 +6456,7 @@
* @memberOf _
* @category Utilities
* @param {Object} object The object to inspect.
- * @param {string} property The property to get the value of.
+ * @param {string} key The name of the property to resolve.
* @returns {*} Returns the resolved value.
* @example
*
@@ -6286,10 +6473,10 @@
* _.result(object, 'stuff');
* // => 'nonsense'
*/
- function result(object, property) {
+ function result(object, key) {
if (object) {
- var value = object[property];
- return isFunction(value) ? object[property]() : value;
+ var value = object[key];
+ return isFunction(value) ? object[key]() : value;
}
}
@@ -6353,8 +6540,8 @@
* // => 'hello mustache!'
*
* // using the `imports` option to import jQuery
- * var list = '<% $.each(people, function(name) { %><%- name %><% }); %>';
- * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } });
+ * var list = '<% jq.each(people, function(name) { %><%- name %><% }); %>';
+ * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } });
* // => 'fredbarney'
*
* // using the `sourceURL` option to specify a custom sourceURL for the template
@@ -6633,7 +6820,7 @@
* _(characters).chain()
* .first()
* .pick('age')
- * .value()
+ * .value();
* // => { 'age': 36 }
*/
function wrapperChain() {
@@ -6686,6 +6873,7 @@
lodash.chain = chain;
lodash.compact = compact;
lodash.compose = compose;
+ lodash.constant = constant;
lodash.countBy = countBy;
lodash.create = create;
lodash.createCallback = createCallback;
@@ -6712,6 +6900,7 @@
lodash.invoke = invoke;
lodash.keys = keys;
lodash.map = map;
+ lodash.mapValues = mapValues;
lodash.max = max;
lodash.memoize = memoize;
lodash.merge = merge;
@@ -6723,6 +6912,7 @@
lodash.partialRight = partialRight;
lodash.pick = pick;
lodash.pluck = pluck;
+ lodash.property = property;
lodash.pull = pull;
lodash.range = range;
lodash.reject = reject;
@@ -6741,6 +6931,7 @@
lodash.where = where;
lodash.without = without;
lodash.wrap = wrap;
+ lodash.xor = xor;
lodash.zip = zip;
lodash.zipObject = zipObject;
@@ -6798,6 +6989,7 @@
lodash.mixin = mixin;
lodash.noConflict = noConflict;
lodash.noop = noop;
+ lodash.now = now;
lodash.parseInt = parseInt;
lodash.random = random;
lodash.reduce = reduce;
@@ -6821,20 +7013,15 @@
lodash.include = contains;
lodash.inject = reduce;
- forOwn(lodash, function(func, methodName) {
- if (!lodash.prototype[methodName]) {
- lodash.prototype[methodName] = function() {
- var args = [this.__wrapped__],
- chainAll = this.__chain__;
-
- push.apply(args, arguments);
- var result = func.apply(lodash, args);
- return chainAll
- ? new lodashWrapper(result, chainAll)
- : result;
- };
- }
- });
+ mixin(function() {
+ var source = {}
+ forOwn(lodash, function(func, methodName) {
+ if (!lodash.prototype[methodName]) {
+ source[methodName] = func;
+ }
+ });
+ return source;
+ }(), false);
/*--------------------------------------------------------------------------*/
@@ -6870,7 +7057,7 @@
* @memberOf _
* @type string
*/
- lodash.VERSION = '2.3.0';
+ lodash.VERSION = '2.4.0';
// add "Chaining" functions to the wrapper
lodash.prototype.chain = wrapperChain;
@@ -6891,7 +7078,7 @@
};
});
- // add `Array` functions that return the wrapped value
+ // add `Array` functions that return the existing wrapped value
baseEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) {
var func = arrayRef[methodName];
lodash.prototype[methodName] = function() {
@@ -6946,9 +7133,8 @@
// some AMD build optimizers like r.js check for condition patterns like the following:
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
// Expose Lo-Dash to the global object even when an AMD loader is present in
- // case Lo-Dash was injected by a third-party script and not intended to be
- // loaded as a module. The global assignment can be reverted in the Lo-Dash
- // module by its `noConflict()` method.
+ // case Lo-Dash is loaded with a RequireJS shim config.
+ // See http://requirejs.org/docs/api.html#config-shim
root._ = _;
// define as an anonymous module so, through path mapping, it can be
diff --git a/package.json b/package.json
index cc04b94bca..bec82e5179 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lodash",
- "version": "2.3.0",
+ "version": "2.4.0",
"description": "A utility library delivering consistency, customization, performance, & extras.",
"homepage": "http://lodash.com/",
"license": "MIT",
diff --git a/test/asset/qunit-extras.js b/test/asset/qunit-extras.js
new file mode 100644
index 0000000000..3f54a89396
--- /dev/null
+++ b/test/asset/qunit-extras.js
@@ -0,0 +1,198 @@
+;(function(root, undefined) {
+ 'use strict';
+
+ /** Native method shortcut */
+ var unshift = Array.prototype.unshift;
+
+ /** Used to match HTML entities */
+ var reEscapedHtml = /(&|<|>|"|')/g;
+
+ /** Used to match parts of the assert message */
+ var reDied = /^Died on test #\d+/,
+ reExpected = /Expected: *<\/th>([\s\S]*?)<\/pre>/,
+ reMessage = /^([\s\S]*?)<\/span>/;
+
+ /** Used to convert HTML entities to characters */
+ var htmlUnescapes = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ ''': "'"
+ };
+
+ /** Detect free variable `exports` */
+ var freeExports = typeof exports == 'object' && exports;
+
+ /** Detect free variable `global`, from Node.js or Browserified code, and use it as `root` */
+ var freeGlobal = typeof global == 'object' && global;
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
+ root = freeGlobal;
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * Checks if a given value is present in an array using strict equality
+ * for comparisons, i.e. `===`.
+ *
+ * @oruvate
+ * @param {Array} array The array to iterate over.
+ * @param {*} target The value to check for.
+ * @returns {boolean} Returns `true` if the `target` element is found, else `false`.
+ */
+ function contains(array, value) {
+ var index = -1,
+ length = array ? array.length : 0;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Resolves the value of `property` on `object`. If `object` is falsey then
+ * `undefined` is returned.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {string} property The property to get the value of.
+ * @returns {*} Returns the resolved value.
+ */
+ function result(object, property) {
+ return object ? object[property] : undefined;
+ }
+
+ /**
+ * Converts the HTML entities `&`, `<`, `>`, `"`, and `'`
+ * in `string` to their corresponding characters.
+ *
+ * @private
+ * @param {string} string The string to unescape.
+ * @returns {string} Returns the unescaped string.
+ */
+ function unescape(string) {
+ return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar);
+ }
+
+ /**
+ * Used by `unescape` to convert HTML entities to characters.
+ *
+ * @private
+ * @param {string} match The matched character to unescape.
+ * @returns {string} Returns the unescaped character.
+ */
+ function unescapeHtmlChar(match) {
+ return htmlUnescapes[match];
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * Installs the QUnit additions on the given `context` object.
+ *
+ * @memberOf exports
+ * @param {Object} context The context object.
+ */
+ function runInContext(context) {
+ // exit early if no `context` is provided or if `QUnit` does not exist
+ if (!context || !context.QUnit) {
+ return;
+ }
+
+ /** Shorten `context.QUnit.QUnit` to `context.QUnit` */
+ var QUnit = context.QUnit = context.QUnit.QUnit || context.QUnit;
+
+ /** The number of retries async tests have to succeed */
+ QUnit.config.asyncRetries = 0;
+
+ /** An object of excused tests and assertions */
+ QUnit.config.excused = {};
+
+ /**
+ * A callback triggered at the start of every test.
+ *
+ * @memberOf QUnit
+ * @param {Object} details An object with `module` and `name` properties.
+ */
+ QUnit.testStart(function(details) {
+ var excused = QUnit.config.excused || {},
+ excusedTests = excused[details.module],
+ excusedAsserts = excusedTests && excusedTests[details.name];
+
+ var test = QUnit.config.current,
+ finish = test.finish;
+
+ // allow async tests to retry
+ if (test.async && !test.retries) {
+ test.retries = 0;
+ test.finish = function() {
+ var asserts = this.assertions,
+ index = -1,
+ length = asserts.length,
+ queue = QUnit.config.queue;
+
+ while (++index < length) {
+ var assert = asserts[index];
+ if (!assert.result && this.retries < QUnit.config.asyncRetries) {
+ this.retries++;
+ asserts.length = 0;
+
+ var oldLength = queue.length;
+ this.queue();
+ unshift.apply(queue, queue.splice(oldLength, queue.length - oldLength));
+ return;
+ }
+ }
+ finish.call(this);
+ };
+ }
+ // nothing to excuse
+ if (!excusedAsserts) {
+ return;
+ }
+ // excuse the entire test
+ if (excusedAsserts === true) {
+ test.async = false;
+ test.callback = function() {};
+ test.expected = 0;
+ return;
+ }
+ // excuse specific assertions
+ test.finish = function() {
+ var asserts = this.assertions,
+ index = -1,
+ length = asserts.length;
+
+ while (++index < length) {
+ var assert = asserts[index],
+ message = unescape(result(reMessage.exec(assert.message), 1)),
+ died = result(reDied.exec(message), 0),
+ expected = unescape(result(reExpected.exec(assert.message), 1));
+
+ if ((message && contains(excusedAsserts, message)) ||
+ (died && contains(excusedAsserts, died)) ||
+ (expected && (
+ contains(excusedAsserts, expected) ||
+ contains(excusedAsserts, expected.replace(/\s+/g, ''))
+ ))) {
+ assert.result = true;
+ }
+ }
+ finish.call(this);
+ };
+ });
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ // expose QUnit extras
+ if (freeExports && !freeExports.nodeType) {
+ freeExports.runInContext = runInContext;
+ } else {
+ runInContext(root);
+ }
+}(this));
diff --git a/test/backbone.html b/test/backbone.html
index 8b9fa6be66..e3ebac16ac 100644
--- a/test/backbone.html
+++ b/test/backbone.html
@@ -22,76 +22,38 @@ Test
+
+
@@ -80,12 +81,12 @@
global_test_results = results;
});
- // load Lo-Dash again to overwrite the existing `_` value
- document.write('
@@ -155,8 +156,8 @@
underscoreModule = underscore.noConflict();
underscoreModule.moduleName = 'underscore';
}
- if (lodash && lodash.noConflict) {
- lodashModule = lodash.noConflict();
+ if (lodash) {
+ lodashModule = lodash;
lodashModule.moduleName = 'lodash';
}
if (ui.isModularize) {
diff --git a/test/saucelabs.js b/test/saucelabs.js
index 63b4209366..e32e0034bb 100644
--- a/test/saucelabs.js
+++ b/test/saucelabs.js
@@ -1,48 +1,75 @@
;(function() {
'use strict';
- var ecstatic = require('ecstatic'),
- http = require('http'),
+ /** Environment shortcut */
+ var env = process.env;
+
+ if (isFinite(env.TRAVIS_PULL_REQUEST)) {
+ console.error('Testing skipped for pull requests');
+ process.exit(0);
+ }
+
+ /** Load Node.js modules */
+ var http = require('http'),
path = require('path'),
- request = require('request'),
- SauceTunnel = require('sauce-tunnel'),
url = require('url');
- var attempts = -1,
- prevLine = '';
+ /** Load other modules */
+ var _ = require('../lodash.js'),
+ ecstatic = require('ecstatic'),
+ request = require('request'),
+ SauceTunnel = require('sauce-tunnel');
- var port = 8081,
- username = process.env.SAUCE_USERNAME,
- accessKey = process.env.SAUCE_ACCESS_KEY,
- tunnelId = 'lodash_' + process.env.TRAVIS_JOB_NUMBER;
+ /** Used by `logInline` to clear previously logged messages */
+ var prevLine = '';
- if (isFinite(process.env.TRAVIS_PULL_REQUEST)) {
- console.error('Testing skipped for pull requests');
- process.exit(0);
- }
+ /** Used to display the wait throbber */
+ var throbberId,
+ throbberDelay = 500,
+ waitCount = -1;
- var runnerPathname = (function() {
- var args = process.argv;
- return args.length > 2
- ? '/' + args[args.length - 1].replace(/^\W+/, '')
- : '/test/index.html';
- }());
+ /** Used as request `auth` and `options` values */
+ var accessKey = env.SAUCE_ACCESS_KEY,
+ build = env.TRAVIS_COMMIT.slice(0, 10),
+ port = 9001,
+ tunnelId = 'lodash_' + env.TRAVIS_JOB_NUMBER,
+ username = env.SAUCE_USERNAME;
- var runnerQuery = url.parse(runnerPathname, true).query,
- isBackbone = /\bbackbone\b/i.test(runnerPathname),
- isMobile = /\bmobile\b/i.test(runnerQuery.build),
- isModern = /\bmodern\b/i.test(runnerQuery.build);
+ var compatMode = process.argv.reduce(function(result, value) {
+ return optionToValue('compatMode', value) || result;
+ }, null);
+
+ var runner = process.argv.reduce(function(result, value) {
+ value = optionToValue('runner', value);
+ return value == null
+ ? result
+ : '/' + value.replace(/^\W+/, '');
+ }, '/test/index.html');
+ var sessionName = process.argv.reduce(function(result, value) {
+ return optionToValue('name', value) || result;
+ }, 'lodash tests');
+
+ var tags = process.argv.reduce(function(result, value) {
+ value = optionToArray('tags', value);
+ return value.length
+ ? _.union(result, value)
+ : result;
+ }, []);
+
+ /** List of platforms to load the runner on */
var platforms = [
- ['Windows 7', 'chrome', ''],
- ['Windows 7', 'firefox', '25'],
- ['Windows 7', 'firefox', '20'],
- ['Windows 7', 'firefox', '10'],
- ['Windows 7', 'firefox', '6'],
- ['Windows 7', 'firefox', '4'],
- ['Windows 7', 'firefox', '3'],
- ['WIN8.1', 'internet explorer', '11'],
- ['Windows 7', 'internet explorer', '10'],
+ ['Windows 8.1', 'chrome', '31'],
+ ['Windows 8.1', 'chrome', '28'],
+ ['Windows 8.1', 'chrome', '26'],
+ ['OS X 10.6', 'firefox', '25'],
+ ['OS X 10.6', 'firefox', '20'],
+ ['OS X 10.6', 'firefox', '10'],
+ ['OS X 10.6', 'firefox', '6'],
+ ['OS X 10.6', 'firefox', '4'],
+ ['Windows 7', 'firefox', '3.6'],
+ ['Windows 8.1', 'internet explorer', '11'],
+ ['Windows 8', 'internet explorer', '10'],
['Windows 7', 'internet explorer', '9'],
['Windows 7', 'internet explorer', '8'],
['Windows XP', 'internet explorer', '7'],
@@ -50,14 +77,21 @@
//['Windows 7', 'opera', '12'],
//['Windows 7', 'opera', '11'],
['OS X 10.8', 'safari', '6'],
- ['Windows 7', 'safari', '5']
+ ['Windows 7', 'safari', '5'],
+ ['Windows XP', 'safari', '4']
];
+ /** Used to tailor the `platforms` array */
+ var runnerQuery = url.parse(runner, true).query,
+ isBackbone = /\bbackbone\b/i.test(runner),
+ isMobile = /\bmobile\b/i.test(runnerQuery.build),
+ isModern = /\bmodern\b/i.test(runnerQuery.build);
+
// platforms to test IE compat mode
- if (runnerQuery.compat) {
+ if (compatMode) {
platforms = [
- ['WIN8.1', 'internet explorer', '11'],
- ['Windows 7', 'internet explorer', '10'],
+ ['Windows 8.1', 'internet explorer', '11'],
+ ['Windows 8', 'internet explorer', '10'],
['Windows 7', 'internet explorer', '9'],
['Windows 7', 'internet explorer', '8']
];
@@ -85,45 +119,20 @@
case 'firefox': return version >= 10;
case 'internet explorer': return version >= 9;
case 'opera': return version >= 12;
- case 'safari': return version >= (isMobile ? 5 : 6);
+ case 'safari': return version >= (isMobile ? 3 : 6);
}
return true;
});
}
- // create a web server for the local dir
- var mount = ecstatic({
- 'root': process.cwd(),
- 'cache': false
- });
-
- http.createServer(function(req, res) {
- var compat = url.parse(req.url, true).query.compat;
- if (compat) {
- // see http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx
- res.setHeader('X-UA-Compatible', 'IE=' + compat);
- }
- mount(req, res);
- }).listen(port);
-
- // set up Sauce Connect so we can use this server from Sauce Labs
- var tunnelTimeout = 10000,
- tunnel = new SauceTunnel(username, accessKey, tunnelId, true, tunnelTimeout);
-
- console.log('Opening Sauce Connect tunnel...');
-
- tunnel.start(function(success) {
- if (success) {
- console.log('Sauce Connect tunnel opened');
- runTests();
- } else {
- console.error('Failed to open Sauce Connect tunnel');
- process.exit(2);
- }
- });
-
/*--------------------------------------------------------------------------*/
+ /**
+ * Writes an inline message to standard output.
+ *
+ * @private
+ * @param {string} text The text to log.
+ */
function logInline(text) {
var blankLine = repeat(' ', prevLine.length);
if (text.length > 40) {
@@ -133,25 +142,124 @@
process.stdout.write(text + blankLine.slice(text.length) + '\r');
}
- function repeat(text, times) {
- return Array(times + 1).join(text);
+ /**
+ * Writes the wait throbber to standard output.
+ *
+ * @private
+ */
+ function logThrobber() {
+ logInline('Please wait' + repeat('.', (++waitCount % 3) + 1));
+ }
+
+ /**
+ * Converts a comma separated option value into an array.
+ *
+ * @private
+ * @param {string} name The name of the option to inspect.
+ * @param {string} string The options string.
+ * @returns {Array} Returns the new converted array.
+ */
+ function optionToArray(name, string) {
+ return _.compact(_.isArray(string)
+ ? string
+ : _.invoke((optionToValue(name, string) || '').split(/, */), 'trim')
+ );
+ }
+
+ /**
+ * Extracts the option value from an option string.
+ *
+ * @private
+ * @param {string} name The name of the option to inspect.
+ * @param {string} string The options string.
+ * @returns {string|undefined} Returns the option value, else `undefined`.
+ */
+ function optionToValue(name, string) {
+ var result = (result = string.match(RegExp('^' + name + '=([\\s\\S]+)$'))) && result[1].trim();
+ return result || undefined;
+ }
+
+ /**
+ * Creates a string with `text` repeated `n` number of times.
+ *
+ * @private
+ * @param {string} text The text to repeat.
+ * @param {number} n The number of times to repeat `text`.
+ * @returns {string} The created string.
+ */
+ function repeat(text, n) {
+ return Array(n + 1).join(text);
}
/*--------------------------------------------------------------------------*/
+ /**
+ * Processes the result object of the test session.
+ *
+ * @private
+ * @param {Object} results The result object to process.
+ */
+ function handleTestResults(results) {
+ var failingTests = results.filter(function(test) {
+ var result = test.result;
+ return !result || result.failed || /\berror\b/i.test(result.message);
+ });
+
+ var failingPlatforms = failingTests.map(function(test) {
+ return test.platform;
+ });
+
+ if (!failingTests.length) {
+ console.log('Tests passed');
+ }
+ else {
+ console.error('Tests failed on platforms: ' + JSON.stringify(failingPlatforms));
+
+ failingTests.forEach(function(test) {
+ var details = 'See ' + test.url + ' for details.',
+ platform = JSON.stringify(test.platform),
+ result = test.result;
+
+ if (result && result.failed) {
+ console.error(result.failed + ' failures on ' + platform + '. ' + details);
+ } else {
+ console.error('Testing on ' + platform + ' failed; no results available. ' + details);
+ }
+ });
+ }
+
+ clearInterval(throbberId);
+ console.log('Shutting down Sauce Connect tunnel...');
+
+ tunnel.stop(function() {
+ process.exit(failingTests.length ? 1 : 0);
+ });
+ }
+
+ /**
+ * Makes a request for Sauce Labs to start the test session.
+ *
+ * @private
+ */
function runTests() {
- var testDefinition = {
+ var options = {
+ 'build': build,
'framework': 'qunit',
+ 'name': sessionName,
+ 'public': 'public',
'platforms': platforms,
+ 'record-screenshots': false,
+ 'tags': tags,
'tunnel': 'tunnel-identifier:' + tunnelId,
- 'url': 'http://localhost:' + port + runnerPathname
+ 'url': 'http://localhost:' + port + runner,
+ 'video-upload-on-pass': false
};
- console.log('Starting saucelabs tests: ' + JSON.stringify(testDefinition));
+ console.log('Starting saucelabs tests: ' + JSON.stringify(options));
request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests', {
'auth': { 'user': username, 'pass': accessKey },
- 'json': testDefinition
+ 'json': options
}, function(error, response, body) {
var statusCode = response && response.statusCode;
if (statusCode == 200) {
@@ -164,8 +272,22 @@
process.exit(3);
}
});
+
+ // initialize the wait throbber
+ if (!throbberId) {
+ throbberId = setInterval(logThrobber, throbberDelay);
+ logThrobber();
+ }
}
+ /**
+ * Checks the status of the test session. If the session has completed it
+ * passes the result object to `handleTestResults`, else it checks the status
+ * again in five seconds.
+ *
+ * @private
+ * @param {Object} testIdentifier The object used to identify the session.
+ */
function waitForTestCompletion(testIdentifier) {
request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests/status', {
'auth': { 'user': username, 'pass': accessKey },
@@ -178,7 +300,6 @@
handleTestResults(body['js tests']);
}
else {
- logInline('Please wait' + repeat('.', (++attempts % 3) + 1));
setTimeout(function() {
waitForTestCompletion(testIdentifier);
}, 5000);
@@ -194,39 +315,35 @@
});
}
- function handleTestResults(results) {
- var failingTests = results.filter(function(test) {
- var result = test.result;
- return !result || result.failed || /\berror\b/i.test(result.message);
- });
+ /*--------------------------------------------------------------------------*/
- var failingPlatforms = failingTests.map(function(test) {
- return test.platform;
- });
+ // create a web server for the local dir
+ var mount = ecstatic({
+ 'cache': false,
+ 'root': process.cwd()
+ });
- if (!failingTests.length) {
- console.log('Tests passed');
+ http.createServer(function(req, res) {
+ // see http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx
+ if (compatMode && path.extname(url.parse(req.url).pathname) == '.html') {
+ res.setHeader('X-UA-Compatible', 'IE=' + compatMode);
}
- else {
- console.error('Tests failed on platforms: ' + JSON.stringify(failingPlatforms));
-
- failingTests.forEach(function(test) {
- var details = 'See ' + test.url + ' for details.',
- platform = JSON.stringify(test.platform),
- result = test.result;
+ mount(req, res);
+ }).listen(port);
- if (result && result.failed) {
- console.error(result.failed + ' failures on ' + platform + '. ' + details);
- } else {
- console.error('Testing on ' + platform + ' failed; no results available. ' + details);
- }
- });
- }
+ // set up Sauce Connect so we can use this server from Sauce Labs
+ var tunnelTimeout = 10000,
+ tunnel = new SauceTunnel(username, accessKey, tunnelId, true, tunnelTimeout);
- console.log('Shutting down Sauce Connect tunnel...');
+ console.log('Opening Sauce Connect tunnel...');
- tunnel.stop(function() {
- process.exit(failingTests.length ? 1 : 0);
- });
- }
+ tunnel.start(function(success) {
+ if (success) {
+ console.log('Sauce Connect tunnel opened');
+ runTests();
+ } else {
+ console.error('Failed to open Sauce Connect tunnel');
+ process.exit(2);
+ }
+ });
}());
diff --git a/test/test.js b/test/test.js
index ae34ef654f..b548d315bc 100644
--- a/test/test.js
+++ b/test/test.js
@@ -8,6 +8,7 @@
body = document && document.body,
create = Object.create,
freeze = Object.freeze,
+ noop = function() {},
params = root.arguments,
process = root.process,
push = Array.prototype.push,
@@ -35,12 +36,11 @@
var last = result[result.length - 1];
result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js';
- try {
- if (!amd) {
+ if (!amd) {
+ try {
return require('fs').realpathSync(result);
- }
- } catch(e) { }
-
+ } catch(e) { }
+ }
return result;
}());
@@ -60,18 +60,22 @@
/** Detect if testing `npm` modules */
var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]);
+ /** Detect if running in Java */
+ var isJava = !document && !!root.java;
+
/** Detects if running in a PhantomJS web page */
var isPhantomPage = typeof callPhantom == 'function';
/** Detect if running in Rhino */
- var isRhino = root.java && typeof global == 'function' && global().Array === root.Array;
+ var isRhino = isJava && typeof global == 'function' && global().Array === root.Array;
/** Use a single "load" function */
- var load = !amd && typeof require == 'function' ? require : root.load;
+ var load = (typeof require == 'function' && !amd)
+ ? require
+ : (isJava && root.load);
/** The unit testing framework */
var QUnit = (function() {
- var noop = Function.prototype;
return root.QUnit || (
root.addEventListener || (root.addEventListener = noop),
root.setTimeout || (root.setTimeout = noop),
@@ -84,6 +88,10 @@
/*--------------------------------------------------------------------------*/
+ // load QUnit extras
+ if (load) {
+ (load('./asset/qunit-extras.js') || { 'runInContext': noop }).runInContext(root);
+ }
// log params passed to `test.js`
if (params) {
console.log('test.js invoked with arguments: ' + JSON.stringify(slice.call(params)));
@@ -183,34 +191,53 @@
/*--------------------------------------------------------------------------*/
- // add object from iframe
+ // add values from other realms
(function() {
- if (!document) {
- return;
+ if (!amd) {
+ try {
+ _.extend(_, require('vm').runInNewContext([
+ '({',
+ "'_arguments': (function() { return arguments; }(1, 2, 3)),",
+ "'_array': [1, 2, 3],",
+ "'_boolean': new Boolean(false),",
+ "'_date': new Date,",
+ "'_function': function() {},",
+ "'_nan': NaN,",
+ "'_null': null,",
+ "'_number': new Number(0),",
+ "'_object': { 'a': 1, 'b': 2, 'c': 3 },",
+ "'_regexp': /x/,",
+ "'_string': new String('a'),",
+ "'_undefined': undefined,",
+ '})'
+ ].join('\n')));
+ } catch(e) { }
+ }
+ if (!_._object && document) {
+ var iframe = document.createElement('iframe');
+ iframe.frameBorder = iframe.height = iframe.width = 0;
+ body.appendChild(iframe);
+
+ var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc;
+ idoc.write([
+ '
+
|