mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Add callback and thisArg arguments to _.flatten. [closes #204]
Former-commit-id: 166d6af35c3905c87498ee74abd143f6fdba451d
This commit is contained in:
24
build.js
24
build.js
@@ -99,7 +99,7 @@
|
||||
'filter': ['createCallback', 'isArray'],
|
||||
'find': ['createCallback', 'forEach'],
|
||||
'first': [],
|
||||
'flatten': ['isArray'],
|
||||
'flatten': ['createCallback', 'isArray'],
|
||||
'forEach': ['createCallback', 'isArguments', 'isArray', 'isString'],
|
||||
'forIn': ['createCallback', 'isArguments'],
|
||||
'forOwn': ['createCallback', 'isArguments'],
|
||||
@@ -1667,6 +1667,7 @@
|
||||
}
|
||||
if (isUnderscore) {
|
||||
dependencyMap.contains = _.without(dependencyMap.contains, 'isString');
|
||||
dependencyMap.flatten = _.without(dependencyMap.flatten, 'createCallback');
|
||||
dependencyMap.isEmpty = ['isArray', 'isString'];
|
||||
dependencyMap.isEqual = _.without(dependencyMap.isEqual, 'forIn', 'isArguments');
|
||||
dependencyMap.max = _.without(dependencyMap.max, 'isString');
|
||||
@@ -1843,7 +1844,26 @@
|
||||
' result.push(value);',
|
||||
' }',
|
||||
' }',
|
||||
' return result',
|
||||
' return result;',
|
||||
'}'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.flatten`
|
||||
source = replaceFunction(source, 'flatten', [
|
||||
'function flatten(array, isShallow) {',
|
||||
' var index = -1,',
|
||||
' length = array ? array.length : 0,',
|
||||
' result = [];',
|
||||
'' ,
|
||||
' while (++index < length) {',
|
||||
' var value = array[index];',
|
||||
' if (isArray(value)) {',
|
||||
' push.apply(result, isShallow ? value : flatten(value));',
|
||||
' } else {',
|
||||
' result.push(value);',
|
||||
' }',
|
||||
' }',
|
||||
' return result;',
|
||||
'}'
|
||||
].join('\n'));
|
||||
|
||||
|
||||
46
dist/lodash.compat.js
vendored
46
dist/lodash.compat.js
vendored
@@ -3320,14 +3320,28 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens a nested array (the nesting can be to any depth). If `shallow` is
|
||||
* truthy, `array` will only be flattened a single level.
|
||||
* Flattens a nested array (the nesting can be to any depth). If `isShallow`
|
||||
* is truthy, `array` will only be flattened a single level. If `callback`
|
||||
* is passed, each element of `array` is passed through a callback` before
|
||||
* flattening. The `callback` is bound to `thisArg` and invoked with three
|
||||
* arguments; (value, index, array).
|
||||
*
|
||||
* If a property name is passed for `callback`, the created "_.pluck" style
|
||||
* callback will return the property value of the given element.
|
||||
*
|
||||
* If an object is passed 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 Arrays
|
||||
* @param {Array} array The array to compact.
|
||||
* @param {Boolean} shallow A flag to indicate only flattening a single level.
|
||||
* @param {Boolean} [isShallow=false] A flag to indicate only flattening a single level.
|
||||
* @param {Function|Object|String} [callback=identity] The function called per
|
||||
* iteration. If a property name or object is passed, it will be used to create
|
||||
* a "_.pluck" or "_.where" style callback, respectively.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a new flattened array.
|
||||
* @example
|
||||
*
|
||||
@@ -3336,18 +3350,38 @@
|
||||
*
|
||||
* _.flatten([1, [2], [3, [[4]]]], true);
|
||||
* // => [1, 2, 3, [[4]]];
|
||||
*
|
||||
* var stooges = [
|
||||
* { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
|
||||
* { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] }
|
||||
* ];
|
||||
*
|
||||
* // using "_.pluck" callback shorthand
|
||||
* _.flatten(stooges, 'quotes');
|
||||
* // => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!']
|
||||
*/
|
||||
function flatten(array, shallow) {
|
||||
function flatten(array, isShallow, callback, thisArg) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0,
|
||||
result = [];
|
||||
|
||||
// juggle arguments
|
||||
if (typeof isShallow != 'boolean' && isShallow != null) {
|
||||
thisArg = callback;
|
||||
callback = isShallow;
|
||||
isShallow = false;
|
||||
}
|
||||
if (callback != null) {
|
||||
callback = lodash.createCallback(callback, thisArg);
|
||||
}
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
|
||||
if (callback) {
|
||||
value = callback(value, index, array);
|
||||
}
|
||||
// recursively flatten arrays (susceptible to call stack limits)
|
||||
if (isArray(value)) {
|
||||
push.apply(result, shallow ? value : flatten(value));
|
||||
push.apply(result, isShallow ? value : flatten(value));
|
||||
} else {
|
||||
result.push(value);
|
||||
}
|
||||
|
||||
7
dist/lodash.compat.min.js
vendored
7
dist/lodash.compat.min.js
vendored
@@ -17,9 +17,10 @@ n[e]=o});return n}function ut(n){for(var t=-1,e=Ne(n),r=e.length,u=Nt(r);++t<r;)
|
||||
for(var u=n.length;++e<u;){var o=n[e];t(o,e,n)&&r.push(o)}}else Oe(n,function(n,e,u){t(n,e,u)&&r.push(n)});return r}function ft(n,t,e){var r;return t=a.createCallback(t,e),ct(n,function(n,e,u){return t(n,e,u)?(r=n,!1):void 0}),r}function ct(n,t,e){if(t&&typeof e=="undefined"&&Ie(n)){e=-1;for(var r=n.length;++e<r&&!1!==t(n[e],e,n););}else Oe(n,t,e);return n}function lt(n,t,e){var r=-1,u=n?n.length:0,o=Nt(typeof u=="number"?u:0);if(t=a.createCallback(t,e),Ie(n))for(;++r<u;)o[r]=t(n[r],r,n);else Oe(n,function(n,e,u){o[++r]=t(n,e,u)
|
||||
});return o}function pt(n,t,e){var r=-1/0,u=r;if(!t&&Ie(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];i>u&&(u=i)}}else t=!t&&et(n)?B:a.createCallback(t,e),Oe(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function st(n,t,e,r){var u=3>arguments.length;if(t=a.createCallback(t,r,4),Ie(n)){var o=-1,i=n.length;for(u&&(e=n[++o]);++o<i;)e=t(e,n[o],o,n)}else Oe(n,function(n,r,a){e=u?(u=!1,n):t(e,n,r,a)});return e}function vt(n,t,e,r){var u=n,o=n?n.length:0,i=3>arguments.length;if(typeof o!="number")var f=Ne(n),o=f.length;
|
||||
else de&&et(n)&&(u=n.split(""));return t=a.createCallback(t,r,4),ct(n,function(n,r,a){r=f?f[--o]:--o,e=i?(i=!1,u[r]):t(e,u[r],r,a)}),e}function gt(n,t,e){var r;if(t=a.createCallback(t,e),Ie(n)){e=-1;for(var u=n.length;++e<u&&!(r=t(n[e],e,n)););}else Oe(n,function(n,e,u){return!(r=t(n,e,u))});return!!r}function ht(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=a.createCallback(t,e);++o<u&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[0];return U(n,0,oe(ae(0,r),u))
|
||||
}}function yt(n,t){for(var e=-1,r=n?n.length:0,u=[];++e<r;){var a=n[e];Ie(a)?Qt.apply(u,t?a:yt(a)):u.push(a)}return u}function mt(n,t,e){var r=-1,u=n?n.length:0;if(typeof e=="number")r=(0>e?ae(0,u+e):e||0)-1;else if(e)return r=bt(n,t),n[r]===t?r:-1;for(;++r<u;)if(n[r]===t)return r;return-1}function dt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=a.createCallback(t,e);++u<o&&t(n[u],u,n);)r++}else r=null==t||e?1:ae(0,t);return U(n,r)}function bt(n,t,e,r){var u=0,o=n?n.length:u;
|
||||
for(e=e?a.createCallback(e,r,1):xt,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;return u}function _t(n,t,e,r){var u=-1,o=n?n.length:0,i=[],f=i;typeof t!="boolean"&&null!=t&&(r=e,e=t,t=!1);var c=!t&&75<=o;if(c)var l={};for(null!=e&&(f=[],e=a.createCallback(e,r));++u<o;){r=n[u];var p=e?e(r,u,n):r;if(c)var s=p+"",s=Jt.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>mt(f,p))&&((e||c)&&f.push(p),i.push(r))}return i}function kt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var a=n[e];t?u[a]=t[e]:u[a[0]]=a[1]
|
||||
}return u}function jt(n,t){return se||Zt&&2<arguments.length?Zt.call.apply(Zt,arguments):T(n,t,U(arguments,2))}function wt(n){var t=U(arguments,1);return Xt(function(){n.apply(e,t)},1)}function xt(n){return n}function Ct(n){ct(W(n),function(t){var e=a[t]=n[t];a.prototype[t]=function(){var n=this.__wrapped__,t=[n];return Qt.apply(t,arguments),t=e.apply(a,t),n&&typeof n=="object"&&n==t?this:P(t)}})}function Ot(){return this.__wrapped__}r=r?F.defaults(n.Object(),r,F.pick(n,b)):n;var St,Et,It,Nt=r.Array,At=r.Boolean,$t=r.Date,Ft=r.Function,qt=r.Math,Bt=r.Number,Rt=r.Object,Tt=r.RegExp,Dt=r.String,Pt=Nt(),zt=Rt(),Mt=r._,Kt=Tt("^"+(zt.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Lt=qt.ceil,Ut=r.clearTimeout,Vt=Pt.concat,Gt=qt.floor,Ht=Kt.test(Ht=Rt.getPrototypeOf)&&Ht,Jt=zt.hasOwnProperty,Qt=Pt.push,Wt=r.setImmediate,Xt=r.setTimeout,Yt=zt.toString,Zt=Kt.test(Zt=U.bind)&&Zt,ne=Kt.test(ne=Rt.create)&&ne,te=Kt.test(te=Nt.isArray)&&te,ee=r.isFinite,re=r.isNaN,ue=Kt.test(ue=Rt.keys)&&ue,ae=qt.max,oe=qt.min,ie=r.parseInt,fe=qt.random,ce=Kt.test(r.attachEvent),le=!/\n{2,}/.test(Ft()),pe=Zt&&!/\n|true/.test(Zt+ce),se=Zt&&!pe,ve=ue&&(ce||pe||!le),ge=(ge={0:1,length:1},Pt.splice.call(ge,0,1),ge[0]),he=!0;
|
||||
}}function yt(n,t,e,r){var u=-1,o=n?n.length:0,i=[];for(typeof t!="boolean"&&null!=t&&(r=e,e=t,t=!1),null!=e&&(e=a.createCallback(e,r));++u<o;)r=n[u],e&&(r=e(r,u,n)),Ie(r)?Qt.apply(i,t?r:yt(r)):i.push(r);return i}function mt(n,t,e){var r=-1,u=n?n.length:0;if(typeof e=="number")r=(0>e?ae(0,u+e):e||0)-1;else if(e)return r=bt(n,t),n[r]===t?r:-1;for(;++r<u;)if(n[r]===t)return r;return-1}function dt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=a.createCallback(t,e);++u<o&&t(n[u],u,n);)r++
|
||||
}else r=null==t||e?1:ae(0,t);return U(n,r)}function bt(n,t,e,r){var u=0,o=n?n.length:u;for(e=e?a.createCallback(e,r,1):xt,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;return u}function _t(n,t,e,r){var u=-1,o=n?n.length:0,i=[],f=i;typeof t!="boolean"&&null!=t&&(r=e,e=t,t=!1);var c=!t&&75<=o;if(c)var l={};for(null!=e&&(f=[],e=a.createCallback(e,r));++u<o;){r=n[u];var p=e?e(r,u,n):r;if(c)var s=p+"",s=Jt.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>mt(f,p))&&((e||c)&&f.push(p),i.push(r))}return i
|
||||
}function kt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var a=n[e];t?u[a]=t[e]:u[a[0]]=a[1]}return u}function jt(n,t){return se||Zt&&2<arguments.length?Zt.call.apply(Zt,arguments):T(n,t,U(arguments,2))}function wt(n){var t=U(arguments,1);return Xt(function(){n.apply(e,t)},1)}function xt(n){return n}function Ct(n){ct(W(n),function(t){var e=a[t]=n[t];a.prototype[t]=function(){var n=this.__wrapped__,t=[n];return Qt.apply(t,arguments),t=e.apply(a,t),n&&typeof n=="object"&&n==t?this:P(t)}})}function Ot(){return this.__wrapped__
|
||||
}r=r?F.defaults(n.Object(),r,F.pick(n,b)):n;var St,Et,It,Nt=r.Array,At=r.Boolean,$t=r.Date,Ft=r.Function,qt=r.Math,Bt=r.Number,Rt=r.Object,Tt=r.RegExp,Dt=r.String,Pt=Nt(),zt=Rt(),Mt=r._,Kt=Tt("^"+(zt.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Lt=qt.ceil,Ut=r.clearTimeout,Vt=Pt.concat,Gt=qt.floor,Ht=Kt.test(Ht=Rt.getPrototypeOf)&&Ht,Jt=zt.hasOwnProperty,Qt=Pt.push,Wt=r.setImmediate,Xt=r.setTimeout,Yt=zt.toString,Zt=Kt.test(Zt=U.bind)&&Zt,ne=Kt.test(ne=Rt.create)&&ne,te=Kt.test(te=Nt.isArray)&&te,ee=r.isFinite,re=r.isNaN,ue=Kt.test(ue=Rt.keys)&&ue,ae=qt.max,oe=qt.min,ie=r.parseInt,fe=qt.random,ce=Kt.test(r.attachEvent),le=!/\n{2,}/.test(Ft()),pe=Zt&&!/\n|true/.test(Zt+ce),se=Zt&&!pe,ve=ue&&(ce||pe||!le),ge=(ge={0:1,length:1},Pt.splice.call(ge,0,1),ge[0]),he=!0;
|
||||
(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var e in new n)t.push(e);for(e in arguments)he=!e;St=!/valueOf/.test(t),Et=n.propertyIsEnumerable("prototype"),It="x"!=t[0]})(1);var ye=arguments.constructor==Rt,me=!G(arguments),de="xx"!="x"[0]+Rt("x")[0];try{var be=Yt.call(document)==S&&!({toString:0}+"")}catch(_e){}var ke={};ke[j]=Nt,ke[w]=At,ke[x]=$t,ke[S]=Rt,ke[O]=Bt,ke[E]=Tt,ke[I]=Dt,a.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:h,variable:"",imports:{_:a}};
|
||||
var je={a:"q,w,g",l:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b<c){m=a[b];if(m&&r[typeof m]){",h:"if(typeof u[i]=='undefined')u[i]=m[i]",c:"}}"},we={a:"e,d,x",l:"d=d&&typeof x=='undefined'?d:o['createCallback'](d,x)",b:"typeof n=='number'",h:"if(d(m[i],i,e)===false)return u"},xe={l:"if(!r[typeof m])return u;"+we.l,b:!1},Ce=ne||function(n){return L.prototype=n,n=new L,L.prototype=null,n},Oe=D(we);me&&(G=function(n){return n?Jt.call(n,"callee"):!1});var Se=D(we,xe,{m:!1}),Ee=D(we,xe),Ie=te||function(n){return ye&&n instanceof Nt||Yt.call(n)==j
|
||||
},Ne=ue?function(n){return nt(n)?Et&&typeof n=="function"||he&&n.length&&G(n)?J(n):ue(n):[]}:J,Ae={"&":"&","<":"<",">":">",'"':""","'":"'"},$e=X(Ae),Fe=D(je,{l:je.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=o.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[i]=d?d(u[i],m[i]):m[i]"}),qe=D(je);Z(/x/)&&(Z=function(n){return n instanceof Ft||Yt.call(n)==C});var Be=Ht?function(n){if(!n||typeof n!="object")return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Ht(t))&&Ht(e);
|
||||
|
||||
46
dist/lodash.js
vendored
46
dist/lodash.js
vendored
@@ -3164,14 +3164,28 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens a nested array (the nesting can be to any depth). If `shallow` is
|
||||
* truthy, `array` will only be flattened a single level.
|
||||
* Flattens a nested array (the nesting can be to any depth). If `isShallow`
|
||||
* is truthy, `array` will only be flattened a single level. If `callback`
|
||||
* is passed, each element of `array` is passed through a callback` before
|
||||
* flattening. The `callback` is bound to `thisArg` and invoked with three
|
||||
* arguments; (value, index, array).
|
||||
*
|
||||
* If a property name is passed for `callback`, the created "_.pluck" style
|
||||
* callback will return the property value of the given element.
|
||||
*
|
||||
* If an object is passed 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 Arrays
|
||||
* @param {Array} array The array to compact.
|
||||
* @param {Boolean} shallow A flag to indicate only flattening a single level.
|
||||
* @param {Boolean} [isShallow=false] A flag to indicate only flattening a single level.
|
||||
* @param {Function|Object|String} [callback=identity] The function called per
|
||||
* iteration. If a property name or object is passed, it will be used to create
|
||||
* a "_.pluck" or "_.where" style callback, respectively.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a new flattened array.
|
||||
* @example
|
||||
*
|
||||
@@ -3180,18 +3194,38 @@
|
||||
*
|
||||
* _.flatten([1, [2], [3, [[4]]]], true);
|
||||
* // => [1, 2, 3, [[4]]];
|
||||
*
|
||||
* var stooges = [
|
||||
* { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
|
||||
* { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] }
|
||||
* ];
|
||||
*
|
||||
* // using "_.pluck" callback shorthand
|
||||
* _.flatten(stooges, 'quotes');
|
||||
* // => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!']
|
||||
*/
|
||||
function flatten(array, shallow) {
|
||||
function flatten(array, isShallow, callback, thisArg) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0,
|
||||
result = [];
|
||||
|
||||
// juggle arguments
|
||||
if (typeof isShallow != 'boolean' && isShallow != null) {
|
||||
thisArg = callback;
|
||||
callback = isShallow;
|
||||
isShallow = false;
|
||||
}
|
||||
if (callback != null) {
|
||||
callback = lodash.createCallback(callback, thisArg);
|
||||
}
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
|
||||
if (callback) {
|
||||
value = callback(value, index, array);
|
||||
}
|
||||
// recursively flatten arrays (susceptible to call stack limits)
|
||||
if (isArray(value)) {
|
||||
push.apply(result, shallow ? value : flatten(value));
|
||||
push.apply(result, isShallow ? value : flatten(value));
|
||||
} else {
|
||||
result.push(value);
|
||||
}
|
||||
|
||||
28
dist/lodash.min.js
vendored
28
dist/lodash.min.js
vendored
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&Mt.call(n,"__wrapped__")?n:this instanceof a?(this.__wrapped__=n,void 0):new a(n)}function $(n,t,e){t||(t=0);var r=n.length,u=r-t>=(e||f);if(u){var a={};for(e=t-1;++e<r;){var o=n[e]+"";(Mt.call(a,o)?a[o]:a[o]=[]).push(n[e])}}return function(e){if(u){var r=e+"";return Mt.call(a,r)&&-1<vt(a[r],e)}return-1<vt(n,e,t)}}function F(n){return n.charCodeAt(0)}function q(n,t){var e=n.b,r=t.b;if(n=n.a,t=t.a,n!==t){if(n>t||typeof n=="undefined")return 1;
|
||||
if(n<t||typeof t=="undefined")return-1}return e<r?-1:1}function B(n,t,e,r){function u(){var f=arguments,c=o?this:t;return a||(n=t[i]),e.length&&(f=f.length?(f=M(f),r?f.concat(e):e.concat(f)):e),this instanceof u?(c=pe(n.prototype),f=n.apply(c,f),W(f)?f:c):n.apply(c,f)}var a=Q(n),o=!e,i=t;return o&&(e=t),a||(t=n),u}function R(){for(var n,t={g:oe,b:"k(m)",c:"",h:"",l:"",m:!0},e=0;n=arguments[e];e++)for(var r in n)t[r]=n[r];return n=t.a,t.d=/^[^,]+/.exec(n)[0],e=Ot,r="var i,m="+t.d+",u=m;if(!m)return u;"+t.l+";",t.b&&(r+="var n=m.length;i=-1;if("+t.b+"){while(++i<n){"+t.h+"}}else{"),t.g&&t.m?r+="var s=-1,t=r[typeof m]?p(m):[],n=t.length;while(++s<n){i=t[s];"+t.h+"}":(r+="for(i in m){",t.m&&(r+="if(",t.m&&(r+="h.call(m,i)"),r+="){"),r+=t.h+";",t.m&&(r+="}"),r+="}"),t.b&&(r+="}"),r+=t.c+";return u",e("h,j,k,l,o,r,p","return function("+n+"){"+r+"}")(Mt,U,he,Y,a,A,Xt)
|
||||
}function T(n){var t=pe(a.prototype);return t.__wrapped__=n,t}function D(n){return"\\"+E[n]}function z(n){return me[n]}function P(){}function M(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1;e=e-t||0;for(var u=wt(0>e?0:e);++r<e;)u[r]=n[t+r];return u}function K(n){return de[n]}function U(n){return Gt.call(n)==_}function V(n){var t=[];return ge(n,function(n,e){t.push(e)}),t}function G(n,t,r,u,o,i){var f=n;if(typeof t=="function"&&(u=r,r=t,t=!1),typeof r=="function"){if(r=typeof u=="undefined"?r:a.createCallback(r,u,1),f=r(f),typeof f!="undefined")return f;
|
||||
f=n}if(u=W(f)){var c=Gt.call(f);if(!S[c])return f;var l=he(f)}if(!u||!t)return u?l?M(f):be({},f):f;switch(u=ie[c],c){case j:case w:return new u(+f);case C:case N:return new u(f);case O:return u(f.source,v.exec(f))}for(o||(o=[]),i||(i=[]),c=o.length;c--;)if(o[c]==n)return i[c];return f=l?u(f.length):{},l&&(Mt.call(n,"index")&&(f.index=n.index),Mt.call(n,"input")&&(f.input=n.input)),o.push(n),i.push(f),(l?at:ge)(n,function(n,u){f[u]=G(n,t,r,e,o,i)}),f}function H(n){var t=[];return ve(n,function(n,e){Q(n)&&t.push(e)
|
||||
}function T(n){var t=pe(a.prototype);return t.__wrapped__=n,t}function D(n){return"\\"+E[n]}function z(n){return me[n]}function P(){}function M(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1;e=e-t||0;for(var u=wt(0>e?0:e);++r<e;)u[r]=n[t+r];return u}function K(n){return be[n]}function U(n){return Gt.call(n)==_}function V(n){var t=[];return ge(n,function(n,e){t.push(e)}),t}function G(n,t,r,u,o,i){var f=n;if(typeof t=="function"&&(u=r,r=t,t=!1),typeof r=="function"){if(r=typeof u=="undefined"?r:a.createCallback(r,u,1),f=r(f),typeof f!="undefined")return f;
|
||||
f=n}if(u=W(f)){var c=Gt.call(f);if(!S[c])return f;var l=he(f)}if(!u||!t)return u?l?M(f):de({},f):f;switch(u=ie[c],c){case j:case w:return new u(+f);case C:case N:return new u(f);case O:return u(f.source,v.exec(f))}for(o||(o=[]),i||(i=[]),c=o.length;c--;)if(o[c]==n)return i[c];return f=l?u(f.length):{},l&&(Mt.call(n,"index")&&(f.index=n.index),Mt.call(n,"input")&&(f.input=n.input)),o.push(n),i.push(f),(l?at:ge)(n,function(n,u){f[u]=G(n,t,r,e,o,i)}),f}function H(n){var t=[];return ve(n,function(n,e){Q(n)&&t.push(e)
|
||||
}),t.sort()}function J(n){for(var t=-1,e=ye(n),r=e.length,u={};++t<r;){var a=e[t];u[n[a]]=a}return u}function L(n,t,e,r,u,o){var f=e===i;if(e&&!f){e=typeof r=="undefined"?e:a.createCallback(e,r,2);var c=e(n,t);if(typeof c!="undefined")return!!c}if(n===t)return 0!==n||1/n==1/t;var l=typeof n,p=typeof t;if(n===n&&(!n||"function"!=l&&"object"!=l)&&(!t||"function"!=p&&"object"!=p))return!1;if(null==n||null==t)return n===t;if(p=Gt.call(n),l=Gt.call(t),p==_&&(p=x),l==_&&(l=x),p!=l)return!1;switch(p){case j:case w:return+n==+t;
|
||||
case C:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case O:case N:return n==t+""}if(l=p==k,!l){if(Mt.call(n,"__wrapped__")||Mt.call(t,"__wrapped__"))return L(n.__wrapped__||n,t.__wrapped__||t,e,r,u,o);if(p!=x)return!1;var p=n.constructor,s=t.constructor;if(p!=s&&(!Q(p)||!(p instanceof p&&Q(s)&&s instanceof s)))return!1}for(u||(u=[]),o||(o=[]),p=u.length;p--;)if(u[p]==n)return o[p]==t;var v=0,c=!0;if(u.push(n),o.push(t),l){if(p=n.length,v=t.length,c=v==n.length,!c&&!f)return c;for(;v--;)if(l=p,s=t[v],f)for(;l--&&!(c=L(n[l],s,e,r,u,o)););else if(!(c=L(n[v],s,e,r,u,o)))break;
|
||||
return c}return ve(t,function(t,a,i){return Mt.call(i,a)?(v++,c=Mt.call(n,a)&&L(n[a],t,e,r,u,o)):void 0}),c&&!f&&ve(n,function(n,t,e){return Mt.call(e,t)?c=-1<--v:void 0}),c}function Q(n){return typeof n=="function"}function W(n){return n?A[typeof n]:!1}function X(n){return typeof n=="number"||Gt.call(n)==C}function Y(n){return typeof n=="string"||Gt.call(n)==N}function Z(n,t,e){var r=arguments,u=0,o=2;if(!W(n))return n;if(e===i)var f=r[3],c=r[4],l=r[5];else c=[],l=[],typeof e!="number"&&(o=r.length),3<o&&"function"==typeof r[o-2]?f=a.createCallback(r[--o-1],r[o--],2):2<o&&"function"==typeof r[o-1]&&(f=r[--o]);
|
||||
@@ -15,27 +15,27 @@ for(;++u<o;)(he(r[u])?at:ge)(r[u],function(t,e){var r,u,a=t,o=n[e];if(t&&((u=he(
|
||||
}),a}function et(n,t,e){var r=!0;if(t=a.createCallback(t,e),he(n)){e=-1;for(var u=n.length;++e<u&&(r=!!t(n[e],e,n)););}else se(n,function(n,e,u){return r=!!t(n,e,u)});return r}function rt(n,t,e){var r=[];if(t=a.createCallback(t,e),he(n)){e=-1;for(var u=n.length;++e<u;){var o=n[e];t(o,e,n)&&r.push(o)}}else se(n,function(n,e,u){t(n,e,u)&&r.push(n)});return r}function ut(n,t,e){var r;return t=a.createCallback(t,e),at(n,function(n,e,u){return t(n,e,u)?(r=n,!1):void 0}),r}function at(n,t,e){if(t&&typeof e=="undefined"&&he(n)){e=-1;
|
||||
for(var r=n.length;++e<r&&!1!==t(n[e],e,n););}else se(n,t,e);return n}function ot(n,t,e){var r=-1,u=n?n.length:0,o=wt(typeof u=="number"?u:0);if(t=a.createCallback(t,e),he(n))for(;++r<u;)o[r]=t(n[r],r,n);else se(n,function(n,e,u){o[++r]=t(n,e,u)});return o}function it(n,t,e){var r=-1/0,u=r;if(!t&&he(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];i>u&&(u=i)}}else t=!t&&Y(n)?F:a.createCallback(t,e),se(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function ft(n,t,e,r){var u=3>arguments.length;
|
||||
if(t=a.createCallback(t,r,4),he(n)){var o=-1,i=n.length;for(u&&(e=n[++o]);++o<i;)e=t(e,n[o],o,n)}else se(n,function(n,r,a){e=u?(u=!1,n):t(e,n,r,a)});return e}function ct(n,t,e,r){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=ye(n),u=i.length;return t=a.createCallback(t,r,4),at(n,function(r,a,f){a=i?i[--u]:--u,e=o?(o=!1,n[a]):t(e,n[a],a,f)}),e}function lt(n,t,e){var r;if(t=a.createCallback(t,e),he(n)){e=-1;for(var u=n.length;++e<u&&!(r=t(n[e],e,n)););}else se(n,function(n,e,u){return!(r=t(n,e,u))
|
||||
});return!!r}function pt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=a.createCallback(t,e);++o<u&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[0];return M(n,0,Zt(Yt(0,r),u))}}function st(n,t){for(var e=-1,r=n?n.length:0,u=[];++e<r;){var a=n[e];he(a)?Kt.apply(u,t?a:st(a)):u.push(a)}return u}function vt(n,t,e){var r=-1,u=n?n.length:0;if(typeof e=="number")r=(0>e?Yt(0,u+e):e||0)-1;else if(e)return r=ht(n,t),n[r]===t?r:-1;for(;++r<u;)if(n[r]===t)return r;return-1
|
||||
}function gt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=a.createCallback(t,e);++u<o&&t(n[u],u,n);)r++}else r=null==t||e?1:Yt(0,t);return M(n,r)}function ht(n,t,e,r){var u=0,o=n?n.length:u;for(e=e?a.createCallback(e,r,1):_t,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;return u}function yt(n,t,e,r){var u=-1,o=n?n.length:0,i=[],f=i;typeof t!="boolean"&&null!=t&&(r=e,e=t,t=!1);var c=!t&&75<=o;if(c)var l={};for(null!=e&&(f=[],e=a.createCallback(e,r));++u<o;){r=n[u];var p=e?e(r,u,n):r;
|
||||
if(c)var s=p+"",s=Mt.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>vt(f,p))&&((e||c)&&f.push(p),i.push(r))}return i}function mt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var a=n[e];t?u[a]=t[e]:u[a[0]]=a[1]}return u}function dt(n,t){return ae||Ht&&2<arguments.length?Ht.call.apply(Ht,arguments):B(n,t,M(arguments,2))}function bt(n){var t=M(arguments,1);return Vt(function(){n.apply(e,t)},1)}function _t(n){return n}function kt(n){at(H(n),function(t){var e=a[t]=n[t];a.prototype[t]=function(){var n=this.__wrapped__,t=[n];
|
||||
return Kt.apply(t,arguments),t=e.apply(a,t),n&&typeof n=="object"&&n==t?this:T(t)}})}function jt(){return this.__wrapped__}r=r?I.defaults(n.Object(),r,I.pick(n,b)):n;var wt=r.Array,Ct=r.Boolean,xt=r.Date,Ot=r.Function,Nt=r.Math,St=r.Number,At=r.Object,Et=r.RegExp,It=r.String,$t=wt(),Ft=At(),qt=r._,Bt=Et("^"+(Ft.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Rt=Nt.ceil,Tt=r.clearTimeout,Dt=$t.concat,zt=Nt.floor,Pt=Bt.test(Pt=At.getPrototypeOf)&&Pt,Mt=Ft.hasOwnProperty,Kt=$t.push,Ut=r.setImmediate,Vt=r.setTimeout,Gt=Ft.toString,Ht=Bt.test(Ht=M.bind)&&Ht,Jt=Bt.test(Jt=At.create)&&Jt,Lt=Bt.test(Lt=wt.isArray)&&Lt,Qt=r.isFinite,Wt=r.isNaN,Xt=Bt.test(Xt=At.keys)&&Xt,Yt=Nt.max,Zt=Nt.min,ne=r.parseInt,te=Nt.random,ee=Bt.test(r.attachEvent),re=!/\n{2,}/.test(Ot()),ue=Ht&&!/\n|true/.test(Ht+ee),ae=Ht&&!ue,oe=Xt&&(ee||ue||!re),ie={};
|
||||
});return!!r}function pt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=a.createCallback(t,e);++o<u&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[0];return M(n,0,Zt(Yt(0,r),u))}}function st(n,t,e,r){var u=-1,o=n?n.length:0,i=[];for(typeof t!="boolean"&&null!=t&&(r=e,e=t,t=!1),null!=e&&(e=a.createCallback(e,r));++u<o;)r=n[u],e&&(r=e(r,u,n)),he(r)?Kt.apply(i,t?r:st(r)):i.push(r);return i}function vt(n,t,e){var r=-1,u=n?n.length:0;if(typeof e=="number")r=(0>e?Yt(0,u+e):e||0)-1;
|
||||
else if(e)return r=ht(n,t),n[r]===t?r:-1;for(;++r<u;)if(n[r]===t)return r;return-1}function gt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=a.createCallback(t,e);++u<o&&t(n[u],u,n);)r++}else r=null==t||e?1:Yt(0,t);return M(n,r)}function ht(n,t,e,r){var u=0,o=n?n.length:u;for(e=e?a.createCallback(e,r,1):_t,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;return u}function yt(n,t,e,r){var u=-1,o=n?n.length:0,i=[],f=i;typeof t!="boolean"&&null!=t&&(r=e,e=t,t=!1);var c=!t&&75<=o;
|
||||
if(c)var l={};for(null!=e&&(f=[],e=a.createCallback(e,r));++u<o;){r=n[u];var p=e?e(r,u,n):r;if(c)var s=p+"",s=Mt.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>vt(f,p))&&((e||c)&&f.push(p),i.push(r))}return i}function mt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var a=n[e];t?u[a]=t[e]:u[a[0]]=a[1]}return u}function bt(n,t){return ae||Ht&&2<arguments.length?Ht.call.apply(Ht,arguments):B(n,t,M(arguments,2))}function dt(n){var t=M(arguments,1);return Vt(function(){n.apply(e,t)},1)}function _t(n){return n
|
||||
}function kt(n){at(H(n),function(t){var e=a[t]=n[t];a.prototype[t]=function(){var n=this.__wrapped__,t=[n];return Kt.apply(t,arguments),t=e.apply(a,t),n&&typeof n=="object"&&n==t?this:T(t)}})}function jt(){return this.__wrapped__}r=r?I.defaults(n.Object(),r,I.pick(n,d)):n;var wt=r.Array,Ct=r.Boolean,xt=r.Date,Ot=r.Function,Nt=r.Math,St=r.Number,At=r.Object,Et=r.RegExp,It=r.String,$t=wt(),Ft=At(),qt=r._,Bt=Et("^"+(Ft.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Rt=Nt.ceil,Tt=r.clearTimeout,Dt=$t.concat,zt=Nt.floor,Pt=Bt.test(Pt=At.getPrototypeOf)&&Pt,Mt=Ft.hasOwnProperty,Kt=$t.push,Ut=r.setImmediate,Vt=r.setTimeout,Gt=Ft.toString,Ht=Bt.test(Ht=M.bind)&&Ht,Jt=Bt.test(Jt=At.create)&&Jt,Lt=Bt.test(Lt=wt.isArray)&&Lt,Qt=r.isFinite,Wt=r.isNaN,Xt=Bt.test(Xt=At.keys)&&Xt,Yt=Nt.max,Zt=Nt.min,ne=r.parseInt,te=Nt.random,ee=Bt.test(r.attachEvent),re=!/\n{2,}/.test(Ot()),ue=Ht&&!/\n|true/.test(Ht+ee),ae=Ht&&!ue,oe=Xt&&(ee||ue||!re),ie={};
|
||||
ie[k]=wt,ie[j]=Ct,ie[w]=xt,ie[x]=At,ie[C]=St,ie[O]=Et,ie[N]=It,a.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:h,variable:"",imports:{_:a}};var fe={a:"q,w,g",l:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b<c){m=a[b];if(m&&r[typeof m]){",h:"if(typeof u[i]=='undefined')u[i]=m[i]",c:"}}"},ce={a:"e,d,x",l:"d=d&&typeof x=='undefined'?d:o['createCallback'](d,x)",b:"typeof n=='number'",h:"if(d(m[i],i,e)===false)return u"},le={l:"if(!r[typeof m])return u;"+ce.l,b:!1},pe=Jt||function(n){return P.prototype=n,n=new P,P.prototype=null,n
|
||||
},se=R(ce),ve=R(ce,le,{m:!1}),ge=R(ce,le),he=Lt||function(n){return n instanceof wt||Gt.call(n)==k},ye=Xt?function(n){return W(n)?Xt(n):[]}:V,me={"&":"&","<":"<",">":">",'"':""","'":"'"},de=J(me),be=R(fe,{l:fe.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=o.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[i]=d?d(u[i],m[i]):m[i]"}),_e=R(fe),ke=function(n){if(!n||typeof n!="object")return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Pt(t))&&Pt(e);
|
||||
if(e)n=n==e||Pt(n)==e&&!U(n);else{var r=!1;!n||typeof n!="object"||U(n)?n=r:(t=n.constructor,!Q(t)||t instanceof t?(ve(n,function(n,t){r=t}),n=!1===r||Mt.call(n,r)):n=r)}return n},je=8==ne("08")?ne:function(n,t){return ne(Y(n)?n.replace(/^0+(?=.$)/,""):n,t||0)};return ue&&u&&typeof Ut=="function"&&(bt=dt(Ut,r)),a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=be,a.at=function(n){for(var t=-1,e=Dt.apply($t,M(arguments,1)),r=e.length,u=wt(r);++t<r;)u[t]=n[e[t]];
|
||||
return u},a.bind=dt,a.bindAll=function(n){for(var t=Dt.apply($t,arguments),e=1<t.length?0:(t=H(n),-1),r=t.length;++e<r;){var u=t[e];n[u]=dt(n[u],n)}return n},a.bindKey=function(n,t){return B(n,t,M(arguments,2))},a.compact=function(n){for(var t=-1,e=n?n.length:0,r=[];++t<e;){var u=n[t];u&&r.push(u)}return r},a.compose=function(){var n=arguments;return function(){for(var t=arguments,e=n.length;e--;)t=[n[e].apply(this,t)];return t[0]}},a.countBy=function(n,t,e){var r={};return t=a.createCallback(t,e),at(n,function(n,e,u){e=t(n,e,u)+"",Mt.call(r,e)?r[e]++:r[e]=1
|
||||
},se=R(ce),ve=R(ce,le,{m:!1}),ge=R(ce,le),he=Lt||function(n){return n instanceof wt||Gt.call(n)==k},ye=Xt?function(n){return W(n)?Xt(n):[]}:V,me={"&":"&","<":"<",">":">",'"':""","'":"'"},be=J(me),de=R(fe,{l:fe.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=o.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[i]=d?d(u[i],m[i]):m[i]"}),_e=R(fe),ke=function(n){if(!n||typeof n!="object")return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Pt(t))&&Pt(e);
|
||||
if(e)n=n==e||Pt(n)==e&&!U(n);else{var r=!1;!n||typeof n!="object"||U(n)?n=r:(t=n.constructor,!Q(t)||t instanceof t?(ve(n,function(n,t){r=t}),n=!1===r||Mt.call(n,r)):n=r)}return n},je=8==ne("08")?ne:function(n,t){return ne(Y(n)?n.replace(/^0+(?=.$)/,""):n,t||0)};return ue&&u&&typeof Ut=="function"&&(dt=bt(Ut,r)),a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=de,a.at=function(n){for(var t=-1,e=Dt.apply($t,M(arguments,1)),r=e.length,u=wt(r);++t<r;)u[t]=n[e[t]];
|
||||
return u},a.bind=bt,a.bindAll=function(n){for(var t=Dt.apply($t,arguments),e=1<t.length?0:(t=H(n),-1),r=t.length;++e<r;){var u=t[e];n[u]=bt(n[u],n)}return n},a.bindKey=function(n,t){return B(n,t,M(arguments,2))},a.compact=function(n){for(var t=-1,e=n?n.length:0,r=[];++t<e;){var u=n[t];u&&r.push(u)}return r},a.compose=function(){var n=arguments;return function(){for(var t=arguments,e=n.length;e--;)t=[n[e].apply(this,t)];return t[0]}},a.countBy=function(n,t,e){var r={};return t=a.createCallback(t,e),at(n,function(n,e,u){e=t(n,e,u)+"",Mt.call(r,e)?r[e]++:r[e]=1
|
||||
}),r},a.createCallback=function(n,t,e){if(null==n)return _t;var r=typeof n;if("function"!=r){if("object"!=r)return function(t){return t[n]};var u=ye(n);return function(t){for(var e=u.length,r=!1;e--&&(r=L(t[u[e]],n[u[e]],i)););return r}}return typeof t!="undefined"?1===e?function(e){return n.call(t,e)}:2===e?function(e,r){return n.call(t,e,r)}:4===e?function(e,r,u,a){return n.call(t,e,r,u,a)}:function(e,r,u){return n.call(t,e,r,u)}:n},a.debounce=function(n,t,e){function r(){i=null,e||(a=n.apply(o,u))
|
||||
}var u,a,o,i;return function(){var f=e&&!i;return u=arguments,o=this,Tt(i),i=Vt(r,t),f&&(a=n.apply(o,u)),a}},a.defaults=_e,a.defer=bt,a.delay=function(n,t){var r=M(arguments,2);return Vt(function(){n.apply(e,r)},t)},a.difference=function(n){for(var t=-1,e=n?n.length:0,r=Dt.apply($t,arguments),r=$(r,e),u=[];++t<e;){var a=n[t];r(a)||u.push(a)}return u},a.filter=rt,a.flatten=st,a.forEach=at,a.forIn=ve,a.forOwn=ge,a.functions=H,a.groupBy=function(n,t,e){var r={};return t=a.createCallback(t,e),at(n,function(n,e,u){e=t(n,e,u)+"",(Mt.call(r,e)?r[e]:r[e]=[]).push(n)
|
||||
}var u,a,o,i;return function(){var f=e&&!i;return u=arguments,o=this,Tt(i),i=Vt(r,t),f&&(a=n.apply(o,u)),a}},a.defaults=_e,a.defer=dt,a.delay=function(n,t){var r=M(arguments,2);return Vt(function(){n.apply(e,r)},t)},a.difference=function(n){for(var t=-1,e=n?n.length:0,r=Dt.apply($t,arguments),r=$(r,e),u=[];++t<e;){var a=n[t];r(a)||u.push(a)}return u},a.filter=rt,a.flatten=st,a.forEach=at,a.forIn=ve,a.forOwn=ge,a.functions=H,a.groupBy=function(n,t,e){var r={};return t=a.createCallback(t,e),at(n,function(n,e,u){e=t(n,e,u)+"",(Mt.call(r,e)?r[e]:r[e]=[]).push(n)
|
||||
}),r},a.initial=function(n,t,e){if(!n)return[];var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else r=null==t||e?1:t||r;return M(n,0,Zt(Yt(0,u-r),u))},a.intersection=function(n){var t=arguments,e=t.length,r={0:{}},u=-1,a=n?n.length:0,o=100<=a,i=[],f=i;n:for(;++u<a;){var c=n[u];if(o)var l=c+"",l=Mt.call(r[0],l)?!(f=r[0][l]):f=r[0][l]=[];if(l||0>vt(f,c)){o&&f.push(c);for(var p=e;--p;)if(!(r[p]||(r[p]=$(t[p],0,100)))(c))continue n;i.push(c)
|
||||
}}return i},a.invert=J,a.invoke=function(n,t){var e=M(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=wt(typeof a=="number"?a:0);return at(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},a.keys=ye,a.map=ot,a.max=it,a.memoize=function(n,t){var e={};return function(){var r=(t?t.apply(this,arguments):arguments[0])+"";return Mt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=Z,a.min=function(n,t,e){var r=1/0,u=r;if(!t&&he(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];i<u&&(u=i)}}else t=!t&&Y(n)?F:a.createCallback(t,e),se(n,function(n,e,a){e=t(n,e,a),e<r&&(r=e,u=n)
|
||||
});return u},a.omit=function(n,t,e){var r=typeof t=="function",u={};if(r)t=a.createCallback(t,e);else var o=Dt.apply($t,arguments);return ve(n,function(n,e,a){(r?!t(n,e,a):0>vt(o,e,1))&&(u[e]=n)}),u},a.once=function(n){var t,e;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},a.pairs=function(n){for(var t=-1,e=ye(n),r=e.length,u=wt(r);++t<r;){var a=e[t];u[t]=[a,n[a]]}return u},a.partial=function(n){return B(n,M(arguments,1))},a.partialRight=function(n){return B(n,M(arguments,1),null,i)
|
||||
},a.pick=function(n,t,e){var r={};if(typeof t!="function")for(var u=0,o=Dt.apply($t,arguments),i=W(n)?o.length:0;++u<i;){var f=o[u];f in n&&(r[f]=n[f])}else t=a.createCallback(t,e),ve(n,function(n,e,u){t(n,e,u)&&(r[e]=n)});return r},a.pluck=ot,a.range=function(n,t,e){n=+n||0,e=+e||1,null==t&&(t=n,n=0);var r=-1;t=Yt(0,Rt((t-n)/e));for(var u=wt(t);++r<t;)u[r]=n,n+=e;return u},a.reject=function(n,t,e){return t=a.createCallback(t,e),rt(n,function(n,e,r){return!t(n,e,r)})},a.rest=gt,a.shuffle=function(n){var t=-1,e=n?n.length:0,r=wt(typeof e=="number"?e:0);
|
||||
return at(n,function(n){var e=zt(te()*(++t+1));r[t]=r[e],r[e]=n}),r},a.sortBy=function(n,t,e){var r=-1,u=n?n.length:0,o=wt(typeof u=="number"?u:0);for(t=a.createCallback(t,e),at(n,function(n,e,u){o[++r]={a:t(n,e,u),b:r,c:n}}),u=o.length,o.sort(q);u--;)o[u]=o[u].c;return o},a.tap=function(n,t){return t(n),n},a.throttle=function(n,t){function e(){i=new xt,o=null,u=n.apply(a,r)}var r,u,a,o,i=0;return function(){var f=new xt,c=t-(f-i);return r=arguments,a=this,0<c?o||(o=Vt(e,c)):(Tt(o),o=null,i=f,u=n.apply(a,r)),u
|
||||
}},a.times=function(n,t,e){n=+n||0;for(var r=-1,u=wt(n);++r<n;)u[r]=t.call(e,r);return u},a.toArray=function(n){return n&&typeof n.length=="number"?M(n):nt(n)},a.union=function(){return yt(Dt.apply($t,arguments))},a.uniq=yt,a.values=nt,a.where=rt,a.without=function(n){for(var t=-1,e=n?n.length:0,r=$(arguments,1),u=[];++t<e;){var a=n[t];r(a)||u.push(a)}return u},a.wrap=function(n,t){return function(){var e=[n];return Kt.apply(e,arguments),t.apply(this,e)}},a.zip=function(n){for(var t=-1,e=n?it(ot(arguments,"length")):0,r=wt(e);++t<e;)r[t]=ot(arguments,t);
|
||||
return r},a.zipObject=mt,a.collect=ot,a.drop=gt,a.each=at,a.extend=be,a.methods=H,a.object=mt,a.select=rt,a.tail=gt,a.unique=yt,kt(a),a.clone=G,a.cloneDeep=function(n,t,e){return G(n,!0,t,e)},a.contains=tt,a.escape=function(n){return null==n?"":(n+"").replace(m,z)},a.every=et,a.find=ut,a.has=function(n,t){return n?Mt.call(n,t):!1},a.identity=_t,a.indexOf=vt,a.isArguments=U,a.isArray=he,a.isBoolean=function(n){return!0===n||!1===n||Gt.call(n)==j},a.isDate=function(n){return n instanceof xt||Gt.call(n)==w
|
||||
return r},a.zipObject=mt,a.collect=ot,a.drop=gt,a.each=at,a.extend=de,a.methods=H,a.object=mt,a.select=rt,a.tail=gt,a.unique=yt,kt(a),a.clone=G,a.cloneDeep=function(n,t,e){return G(n,!0,t,e)},a.contains=tt,a.escape=function(n){return null==n?"":(n+"").replace(m,z)},a.every=et,a.find=ut,a.has=function(n,t){return n?Mt.call(n,t):!1},a.identity=_t,a.indexOf=vt,a.isArguments=U,a.isArray=he,a.isBoolean=function(n){return!0===n||!1===n||Gt.call(n)==j},a.isDate=function(n){return n instanceof xt||Gt.call(n)==w
|
||||
},a.isElement=function(n){return n?1===n.nodeType:!1},a.isEmpty=function(n){var t=!0;if(!n)return t;var e=Gt.call(n),r=n.length;return e==k||e==N||e==_||e==x&&typeof r=="number"&&Q(n.splice)?!r:(ge(n,function(){return t=!1}),t)},a.isEqual=L,a.isFinite=function(n){return Qt(n)&&!Wt(parseFloat(n))},a.isFunction=Q,a.isNaN=function(n){return X(n)&&n!=+n},a.isNull=function(n){return null===n},a.isNumber=X,a.isObject=W,a.isPlainObject=ke,a.isRegExp=function(n){return n instanceof Et||Gt.call(n)==O},a.isString=Y,a.isUndefined=function(n){return typeof n=="undefined"
|
||||
},a.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?Yt(0,r+e):Zt(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=kt,a.noConflict=function(){return r._=qt,this},a.parseInt=je,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+zt(te()*((+t||0)-n+1))},a.reduce=ft,a.reduceRight=ct,a.result=function(n,t){var r=n?n[t]:e;return Q(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ye(n).length
|
||||
},a.some=lt,a.sortedIndex=ht,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=_e({},r,u);var o,i=_e({},r.imports,u.imports),u=ye(i),i=nt(i),f=0,c=r.interpolate||y,v="__p+='",c=Et((r.escape||y).source+"|"+c.source+"|"+(c===h?g:y).source+"|"+(r.evaluate||y).source+"|$","g");n.replace(c,function(t,e,r,u,a,i){return r||(r=u),v+=n.slice(f,i).replace(d,D),e&&(v+="'+__e("+e+")+'"),a&&(o=!0,v+="';"+a+";__p+='"),r&&(v+="'+((__t=("+r+"))==null?'':__t)+'"),f=i+t.length,t}),v+="';\n",c=r=r.variable,c||(r="obj",v="with("+r+"){"+v+"}"),v=(o?v.replace(l,""):v).replace(p,"$1").replace(s,"$1;"),v="function("+r+"){"+(c?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+v+"return __p}";
|
||||
try{var m=Ot(u,"return "+v).apply(e,i)}catch(b){throw b.source=v,b}return t?m(t):(m.source=v,m)},a.unescape=function(n){return null==n?"":(n+"").replace(c,K)},a.uniqueId=function(n){var t=++o;return(null==n?"":n+"")+t},a.all=et,a.any=lt,a.detect=ut,a.foldl=ft,a.foldr=ct,a.include=tt,a.inject=ft,ge(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Kt.apply(t,arguments),n.apply(a,t)})}),a.first=pt,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;
|
||||
},a.some=lt,a.sortedIndex=ht,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=_e({},r,u);var o,i=_e({},r.imports,u.imports),u=ye(i),i=nt(i),f=0,c=r.interpolate||y,v="__p+='",c=Et((r.escape||y).source+"|"+c.source+"|"+(c===h?g:y).source+"|"+(r.evaluate||y).source+"|$","g");n.replace(c,function(t,e,r,u,a,i){return r||(r=u),v+=n.slice(f,i).replace(b,D),e&&(v+="'+__e("+e+")+'"),a&&(o=!0,v+="';"+a+";__p+='"),r&&(v+="'+((__t=("+r+"))==null?'':__t)+'"),f=i+t.length,t}),v+="';\n",c=r=r.variable,c||(r="obj",v="with("+r+"){"+v+"}"),v=(o?v.replace(l,""):v).replace(p,"$1").replace(s,"$1;"),v="function("+r+"){"+(c?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+v+"return __p}";
|
||||
try{var m=Ot(u,"return "+v).apply(e,i)}catch(d){throw d.source=v,d}return t?m(t):(m.source=v,m)},a.unescape=function(n){return null==n?"":(n+"").replace(c,K)},a.uniqueId=function(n){var t=++o;return(null==n?"":n+"")+t},a.all=et,a.any=lt,a.detect=ut,a.foldl=ft,a.foldr=ct,a.include=tt,a.inject=ft,ge(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Kt.apply(t,arguments),n.apply(a,t)})}),a.first=pt,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;
|
||||
for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[u-1];return M(n,Yt(0,u-r))}},a.take=pt,a.head=pt,ge(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return null==t||e&&typeof t!="function"?r:T(r)})}),a.VERSION="1.0.1",a.prototype.toString=function(){return this.__wrapped__+""},a.prototype.value=jt,a.prototype.valueOf=jt,se(["join","pop","shift"],function(n){var t=$t[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)
|
||||
}}),se(["push","reverse","sort","unshift"],function(n){var t=$t[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),se(["concat","slice","splice"],function(n){var t=$t[n];a.prototype[n]=function(){return T(t.apply(this.__wrapped__,arguments))}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;a.global===a&&(n=a);var o=0,i={},f=30,c=/&(?:amp|lt|gt|quot|#39);/g,l=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,v=/\w*$/,g=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/<%=([\s\S]+?)%>/g,y=/($^)/,m=/[&<>"']/g,d=/['\n\r\t\u2028\u2029\\]/g,b="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),_="[object Arguments]",k="[object Array]",j="[object Boolean]",w="[object Date]",C="[object Number]",x="[object Object]",O="[object RegExp]",N="[object String]",S={"[object Function]":!1};
|
||||
}}),se(["push","reverse","sort","unshift"],function(n){var t=$t[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),se(["concat","slice","splice"],function(n){var t=$t[n];a.prototype[n]=function(){return T(t.apply(this.__wrapped__,arguments))}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;a.global===a&&(n=a);var o=0,i={},f=30,c=/&(?:amp|lt|gt|quot|#39);/g,l=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,v=/\w*$/,g=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/<%=([\s\S]+?)%>/g,y=/($^)/,m=/[&<>"']/g,b=/['\n\r\t\u2028\u2029\\]/g,d="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),_="[object Arguments]",k="[object Array]",j="[object Boolean]",w="[object Date]",C="[object Number]",x="[object Object]",O="[object RegExp]",N="[object String]",S={"[object Function]":!1};
|
||||
S[_]=S[k]=S[j]=S[w]=S[C]=S[x]=S[O]=S[N]=!0;var A={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},E={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},I=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=I,define(function(){return I})):r&&!r.nodeType?u?(u.exports=I)._=I:r._=I:n._=I})(this);
|
||||
39
dist/lodash.underscore.js
vendored
39
dist/lodash.underscore.js
vendored
@@ -2478,7 +2478,7 @@
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
return result
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2560,14 +2560,28 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens a nested array (the nesting can be to any depth). If `shallow` is
|
||||
* truthy, `array` will only be flattened a single level.
|
||||
* Flattens a nested array (the nesting can be to any depth). If `isShallow`
|
||||
* is truthy, `array` will only be flattened a single level. If `callback`
|
||||
* is passed, each element of `array` is passed through a callback` before
|
||||
* flattening. The `callback` is bound to `thisArg` and invoked with three
|
||||
* arguments; (value, index, array).
|
||||
*
|
||||
* If a property name is passed for `callback`, the created "_.pluck" style
|
||||
* callback will return the property value of the given element.
|
||||
*
|
||||
* If an object is passed 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 Arrays
|
||||
* @param {Array} array The array to compact.
|
||||
* @param {Boolean} shallow A flag to indicate only flattening a single level.
|
||||
* @param {Boolean} [isShallow=false] A flag to indicate only flattening a single level.
|
||||
* @param {Function|Object|String} [callback=identity] The function called per
|
||||
* iteration. If a property name or object is passed, it will be used to create
|
||||
* a "_.pluck" or "_.where" style callback, respectively.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a new flattened array.
|
||||
* @example
|
||||
*
|
||||
@@ -2576,18 +2590,25 @@
|
||||
*
|
||||
* _.flatten([1, [2], [3, [[4]]]], true);
|
||||
* // => [1, 2, 3, [[4]]];
|
||||
*
|
||||
* var stooges = [
|
||||
* { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
|
||||
* { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] }
|
||||
* ];
|
||||
*
|
||||
* // using "_.pluck" callback shorthand
|
||||
* _.flatten(stooges, 'quotes');
|
||||
* // => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!']
|
||||
*/
|
||||
function flatten(array, shallow) {
|
||||
function flatten(array, isShallow) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0,
|
||||
result = [];
|
||||
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
|
||||
// recursively flatten arrays (susceptible to call stack limits)
|
||||
if (isArray(value)) {
|
||||
push.apply(result, shallow ? value : flatten(value));
|
||||
push.apply(result, isShallow ? value : flatten(value));
|
||||
} else {
|
||||
result.push(value);
|
||||
}
|
||||
|
||||
109
doc/README.md
109
doc/README.md
@@ -10,7 +10,7 @@
|
||||
* [`_.difference`](#_differencearray--array1-array2-)
|
||||
* [`_.drop`](#_restarray--callbackn1-thisarg)
|
||||
* [`_.first`](#_firstarray--callbackn-thisarg)
|
||||
* [`_.flatten`](#_flattenarray-shallow)
|
||||
* [`_.flatten`](#_flattenarray--isshallowfalse-callbackidentity-thisarg)
|
||||
* [`_.head`](#_firstarray--callbackn-thisarg)
|
||||
* [`_.indexOf`](#_indexofarray-value--fromindex0)
|
||||
* [`_.initial`](#_initialarray--callbackn1-thisarg)
|
||||
@@ -309,14 +309,20 @@ _.first(food, { 'type': 'fruit' });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_flattenarray-shallow"></a>`_.flatten(array, shallow)`
|
||||
<a href="#_flattenarray-shallow">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3347 "View in source") [Ⓣ][1]
|
||||
### <a id="_flattenarray--isshallowfalse-callbackidentity-thisarg"></a>`_.flatten(array [, isShallow=false, callback=identity, thisArg])`
|
||||
<a href="#_flattenarray--isshallowfalse-callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3370 "View in source") [Ⓣ][1]
|
||||
|
||||
Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level.
|
||||
Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truthy, `array` will only be flattened a single level. If `callback` is passed, each element of `array` is passed through a callback` before flattening. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
|
||||
|
||||
If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element.
|
||||
|
||||
If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`.
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to compact.
|
||||
2. `shallow` *(Boolean)*: A flag to indicate only flattening a single level.
|
||||
2. `[isShallow=false]` *(Boolean)*: A flag to indicate only flattening a single level.
|
||||
3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively.
|
||||
4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`.
|
||||
|
||||
#### Returns
|
||||
*(Array)*: Returns a new flattened array.
|
||||
@@ -328,6 +334,15 @@ _.flatten([1, [2], [3, [[4]]]]);
|
||||
|
||||
_.flatten([1, [2], [3, [[4]]]], true);
|
||||
// => [1, 2, 3, [[4]]];
|
||||
|
||||
var stooges = [
|
||||
{ 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
|
||||
{ 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] }
|
||||
];
|
||||
|
||||
// using "_.pluck" callback shorthand
|
||||
_.flatten(stooges, 'quotes');
|
||||
// => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!']
|
||||
```
|
||||
|
||||
* * *
|
||||
@@ -338,7 +353,7 @@ _.flatten([1, [2], [3, [[4]]]], true);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_indexofarray-value--fromindex0"></a>`_.indexOf(array, value [, fromIndex=0])`
|
||||
<a href="#_indexofarray-value--fromindex0">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3389 "View in source") [Ⓣ][1]
|
||||
<a href="#_indexofarray-value--fromindex0">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3423 "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, passing `true` for `fromIndex` will run a faster binary search.
|
||||
|
||||
@@ -370,7 +385,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_initialarray--callbackn1-thisarg"></a>`_.initial(array [, callback|n=1, thisArg])`
|
||||
<a href="#_initialarray--callbackn1-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3463 "View in source") [Ⓣ][1]
|
||||
<a href="#_initialarray--callbackn1-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3497 "View in source") [Ⓣ][1]
|
||||
|
||||
Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, elements at the end of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
|
||||
|
||||
@@ -427,7 +442,7 @@ _.initial(food, { 'type': 'vegetable' });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_intersectionarray1-array2-"></a>`_.intersection([array1, array2, ...])`
|
||||
<a href="#_intersectionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3497 "View in source") [Ⓣ][1]
|
||||
<a href="#_intersectionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3531 "View in source") [Ⓣ][1]
|
||||
|
||||
Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`.
|
||||
|
||||
@@ -451,7 +466,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_lastarray--callbackn-thisarg"></a>`_.last(array [, callback|n, thisArg])`
|
||||
<a href="#_lastarray--callbackn-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3589 "View in source") [Ⓣ][1]
|
||||
<a href="#_lastarray--callbackn-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3623 "View in source") [Ⓣ][1]
|
||||
|
||||
Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, elements at the end of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments;(value, index, array).
|
||||
|
||||
@@ -508,7 +523,7 @@ _.last(food, { 'type': 'vegetable' });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_lastindexofarray-value--fromindexarraylength-1"></a>`_.lastIndexOf(array, value [, fromIndex=array.length-1])`
|
||||
<a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3630 "View in source") [Ⓣ][1]
|
||||
<a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "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.
|
||||
|
||||
@@ -537,7 +552,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_rangestart0-end--step1"></a>`_.range([start=0], end [, step=1])`
|
||||
<a href="#_rangestart0-end--step1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [Ⓣ][1]
|
||||
<a href="#_rangestart0-end--step1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3705 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`.
|
||||
|
||||
@@ -575,7 +590,7 @@ _.range(0);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_restarray--callbackn1-thisarg"></a>`_.rest(array [, callback|n=1, thisArg])`
|
||||
<a href="#_restarray--callbackn1-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3750 "View in source") [Ⓣ][1]
|
||||
<a href="#_restarray--callbackn1-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3784 "View in source") [Ⓣ][1]
|
||||
|
||||
The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, elements at the beginning of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
|
||||
|
||||
@@ -635,7 +650,7 @@ _.rest(food, { 'type': 'fruit' });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_sortedindexarray-value--callbackidentity-thisarg"></a>`_.sortedIndex(array, value [, callback=identity, thisArg])`
|
||||
<a href="#_sortedindexarray-value--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3814 "View in source") [Ⓣ][1]
|
||||
<a href="#_sortedindexarray-value--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3848 "View in source") [Ⓣ][1]
|
||||
|
||||
Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*.
|
||||
|
||||
@@ -684,7 +699,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_unionarray1-array2-"></a>`_.union([array1, array2, ...])`
|
||||
<a href="#_unionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3846 "View in source") [Ⓣ][1]
|
||||
<a href="#_unionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3880 "View in source") [Ⓣ][1]
|
||||
|
||||
Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`.
|
||||
|
||||
@@ -708,7 +723,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_uniqarray--issortedfalse-callbackidentity-thisarg"></a>`_.uniq(array [, isSorted=false, callback=identity, thisArg])`
|
||||
<a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3893 "View in source") [Ⓣ][1]
|
||||
<a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3927 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
|
||||
|
||||
@@ -755,7 +770,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_withoutarray--value1-value2-"></a>`_.without(array [, value1, value2, ...])`
|
||||
<a href="#_withoutarray--value1-value2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3952 "View in source") [Ⓣ][1]
|
||||
<a href="#_withoutarray--value1-value2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3986 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`.
|
||||
|
||||
@@ -780,7 +795,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_ziparray1-array2-"></a>`_.zip([array1, array2, ...])`
|
||||
<a href="#_ziparray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3983 "View in source") [Ⓣ][1]
|
||||
<a href="#_ziparray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4017 "View in source") [Ⓣ][1]
|
||||
|
||||
Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion.
|
||||
|
||||
@@ -804,7 +819,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_zipobjectkeys--values"></a>`_.zipObject(keys [, values=[]])`
|
||||
<a href="#_zipobjectkeys--values">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4012 "View in source") [Ⓣ][1]
|
||||
<a href="#_zipobjectkeys--values">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4046 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`.
|
||||
|
||||
@@ -870,7 +885,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_tapvalue-interceptor"></a>`_.tap(value, interceptor)`
|
||||
<a href="#_tapvalue-interceptor">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4980 "View in source") [Ⓣ][1]
|
||||
<a href="#_tapvalue-interceptor">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5014 "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.
|
||||
|
||||
@@ -900,7 +915,7 @@ _([1, 2, 3, 4])
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_prototypetostring"></a>`_.prototype.toString()`
|
||||
<a href="#_prototypetostring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4997 "View in source") [Ⓣ][1]
|
||||
<a href="#_prototypetostring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5031 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces the `toString` result of the wrapped value.
|
||||
|
||||
@@ -921,7 +936,7 @@ _([1, 2, 3]).toString();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_prototypevalueof"></a>`_.prototype.valueOf()`
|
||||
<a href="#_prototypevalueof">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5014 "View in source") [Ⓣ][1]
|
||||
<a href="#_prototypevalueof">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5048 "View in source") [Ⓣ][1]
|
||||
|
||||
Extracts the wrapped value.
|
||||
|
||||
@@ -1761,7 +1776,7 @@ _.where(stooges, { 'age': 40 });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_aftern-func"></a>`_.after(n, func)`
|
||||
<a href="#_aftern-func">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4050 "View in source") [Ⓣ][1]
|
||||
<a href="#_aftern-func">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4084 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function.
|
||||
|
||||
@@ -1789,7 +1804,7 @@ _.forEach(notes, function(note) {
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_bindfunc--thisarg-arg1-arg2-"></a>`_.bind(func [, thisArg, arg1, arg2, ...])`
|
||||
<a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4083 "View in source") [Ⓣ][1]
|
||||
<a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4117 "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 passed to the bound function.
|
||||
|
||||
@@ -1820,7 +1835,7 @@ func();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_bindallobject--methodname1-methodname2-"></a>`_.bindAll(object [, methodName1, methodName2, ...])`
|
||||
<a href="#_bindallobject--methodname1-methodname2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4114 "View in source") [Ⓣ][1]
|
||||
<a href="#_bindallobject--methodname1-methodname2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4148 "View in source") [Ⓣ][1]
|
||||
|
||||
Binds methods on `object` to `object`, 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.
|
||||
|
||||
@@ -1851,7 +1866,7 @@ jQuery('#docs').on('click', view.onClick);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_bindkeyobject-key--arg1-arg2-"></a>`_.bindKey(object, key [, arg1, arg2, ...])`
|
||||
<a href="#_bindkeyobject-key--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4160 "View in source") [Ⓣ][1]
|
||||
<a href="#_bindkeyobject-key--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4194 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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.
|
||||
|
||||
@@ -1892,7 +1907,7 @@ func();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_composefunc1-func2-"></a>`_.compose([func1, func2, ...])`
|
||||
<a href="#_composefunc1-func2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4183 "View in source") [Ⓣ][1]
|
||||
<a href="#_composefunc1-func2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a function that is the composition of the passed 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.
|
||||
|
||||
@@ -1919,7 +1934,7 @@ welcome('moe');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_createcallbackfuncidentity-thisarg-argcount3"></a>`_.createCallback([func=identity, thisArg, argCount=3])`
|
||||
<a href="#_createcallbackfuncidentity-thisarg-argcount3">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4210 "View in source") [Ⓣ][1]
|
||||
<a href="#_createcallbackfuncidentity-thisarg-argcount3">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4244 "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`.
|
||||
|
||||
@@ -1939,7 +1954,7 @@ Produces a callback bound to an optional `thisArg`. If `func` is a property name
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_debouncefunc-wait-immediate"></a>`_.debounce(func, wait, immediate)`
|
||||
<a href="#_debouncefunc-wait-immediate">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4276 "View in source") [Ⓣ][1]
|
||||
<a href="#_debouncefunc-wait-immediate">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4310 "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. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call.
|
||||
|
||||
@@ -1965,7 +1980,7 @@ jQuery(window).on('resize', lazyLayout);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_deferfunc--arg1-arg2-"></a>`_.defer(func [, arg1, arg2, ...])`
|
||||
<a href="#_deferfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4340 "View in source") [Ⓣ][1]
|
||||
<a href="#_deferfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4374 "View in source") [Ⓣ][1]
|
||||
|
||||
Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked.
|
||||
|
||||
@@ -1990,7 +2005,7 @@ _.defer(function() { alert('deferred'); });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_delayfunc-wait--arg1-arg2-"></a>`_.delay(func, wait [, arg1, arg2, ...])`
|
||||
<a href="#_delayfunc-wait--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4320 "View in source") [Ⓣ][1]
|
||||
<a href="#_delayfunc-wait--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4354 "View in source") [Ⓣ][1]
|
||||
|
||||
Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked.
|
||||
|
||||
@@ -2017,7 +2032,7 @@ _.delay(log, 1000, 'logged later');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_memoizefunc--resolver"></a>`_.memoize(func [, resolver])`
|
||||
<a href="#_memoizefunc--resolver">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4368 "View in source") [Ⓣ][1]
|
||||
<a href="#_memoizefunc--resolver">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4402 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function.
|
||||
|
||||
@@ -2043,7 +2058,7 @@ var fibonacci = _.memoize(function(n) {
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_oncefunc"></a>`_.once(func)`
|
||||
<a href="#_oncefunc">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4395 "View in source") [Ⓣ][1]
|
||||
<a href="#_oncefunc">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4429 "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.
|
||||
|
||||
@@ -2069,7 +2084,7 @@ initialize();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_partialfunc--arg1-arg2-"></a>`_.partial(func [, arg1, arg2, ...])`
|
||||
<a href="#_partialfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4430 "View in source") [Ⓣ][1]
|
||||
<a href="#_partialfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4464 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding.
|
||||
|
||||
@@ -2096,7 +2111,7 @@ hi('moe');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_partialrightfunc--arg1-arg2-"></a>`_.partialRight(func [, arg1, arg2, ...])`
|
||||
<a href="#_partialrightfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4461 "View in source") [Ⓣ][1]
|
||||
<a href="#_partialrightfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4495 "View in source") [Ⓣ][1]
|
||||
|
||||
This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function.
|
||||
|
||||
@@ -2133,7 +2148,7 @@ options.imports
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_throttlefunc-wait"></a>`_.throttle(func, wait)`
|
||||
<a href="#_throttlefunc-wait">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4483 "View in source") [Ⓣ][1]
|
||||
<a href="#_throttlefunc-wait">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4517 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call.
|
||||
|
||||
@@ -2158,7 +2173,7 @@ jQuery(window).on('scroll', throttled);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_wrapvalue-wrapper"></a>`_.wrap(value, wrapper)`
|
||||
<a href="#_wrapvalue-wrapper">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4536 "View in source") [Ⓣ][1]
|
||||
<a href="#_wrapvalue-wrapper">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4570 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function.
|
||||
|
||||
@@ -3200,7 +3215,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_escapestring"></a>`_.escape(string)`
|
||||
<a href="#_escapestring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4560 "View in source") [Ⓣ][1]
|
||||
<a href="#_escapestring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4594 "View in source") [Ⓣ][1]
|
||||
|
||||
Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities.
|
||||
|
||||
@@ -3224,7 +3239,7 @@ _.escape('Moe, Larry & Curly');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_identityvalue"></a>`_.identity(value)`
|
||||
<a href="#_identityvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4578 "View in source") [Ⓣ][1]
|
||||
<a href="#_identityvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4612 "View in source") [Ⓣ][1]
|
||||
|
||||
This function returns the first argument passed to it.
|
||||
|
||||
@@ -3249,7 +3264,7 @@ moe === _.identity(moe);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_mixinobject"></a>`_.mixin(object)`
|
||||
<a href="#_mixinobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4604 "View in source") [Ⓣ][1]
|
||||
<a href="#_mixinobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4638 "View in source") [Ⓣ][1]
|
||||
|
||||
Adds functions properties of `object` to the `lodash` function and chainable wrapper.
|
||||
|
||||
@@ -3279,7 +3294,7 @@ _('moe').capitalize();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_noconflict"></a>`_.noConflict()`
|
||||
<a href="#_noconflict">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4633 "View in source") [Ⓣ][1]
|
||||
<a href="#_noconflict">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4667 "View in source") [Ⓣ][1]
|
||||
|
||||
Reverts the '_' variable to its previous value and returns a reference to the `lodash` function.
|
||||
|
||||
@@ -3299,7 +3314,7 @@ var lodash = _.noConflict();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_randommin0-max1"></a>`_.random([min=0, max=1])`
|
||||
<a href="#_randommin0-max1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4656 "View in source") [Ⓣ][1]
|
||||
<a href="#_randommin0-max1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4690 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned.
|
||||
|
||||
@@ -3327,7 +3342,7 @@ _.random(5);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_resultobject-property"></a>`_.result(object, property)`
|
||||
<a href="#_resultobject-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4694 "View in source") [Ⓣ][1]
|
||||
<a href="#_resultobject-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4728 "View in source") [Ⓣ][1]
|
||||
|
||||
Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned.
|
||||
|
||||
@@ -3380,7 +3395,7 @@ Create a new `lodash` function using the given `context` object.
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_templatetext-data-options"></a>`_.template(text, data, options)`
|
||||
<a href="#_templatetext-data-options">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4781 "View in source") [Ⓣ][1]
|
||||
<a href="#_templatetext-data-options">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4815 "View in source") [Ⓣ][1]
|
||||
|
||||
A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.
|
||||
|
||||
@@ -3464,7 +3479,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_timesn-callback--thisarg"></a>`_.times(n, callback [, thisArg])`
|
||||
<a href="#_timesn-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4906 "View in source") [Ⓣ][1]
|
||||
<a href="#_timesn-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4940 "View in source") [Ⓣ][1]
|
||||
|
||||
Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*.
|
||||
|
||||
@@ -3496,7 +3511,7 @@ _.times(3, function(n) { this.cast(n); }, mage);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_unescapestring"></a>`_.unescape(string)`
|
||||
<a href="#_unescapestring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4932 "View in source") [Ⓣ][1]
|
||||
<a href="#_unescapestring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4966 "View in source") [Ⓣ][1]
|
||||
|
||||
The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters.
|
||||
|
||||
@@ -3520,7 +3535,7 @@ _.unescape('Moe, Larry & Curly');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_uniqueidprefix"></a>`_.uniqueId([prefix])`
|
||||
<a href="#_uniqueidprefix">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4952 "View in source") [Ⓣ][1]
|
||||
<a href="#_uniqueidprefix">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4986 "View in source") [Ⓣ][1]
|
||||
|
||||
Generates a unique ID. If `prefix` is passed, the ID will be appended to it.
|
||||
|
||||
@@ -3573,7 +3588,7 @@ A reference to the `lodash` function.
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_version"></a>`_.VERSION`
|
||||
<a href="#_version">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5186 "View in source") [Ⓣ][1]
|
||||
<a href="#_version">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5220 "View in source") [Ⓣ][1]
|
||||
|
||||
*(String)*: The semantic version number.
|
||||
|
||||
|
||||
46
lodash.js
46
lodash.js
@@ -3327,14 +3327,28 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens a nested array (the nesting can be to any depth). If `shallow` is
|
||||
* truthy, `array` will only be flattened a single level.
|
||||
* Flattens a nested array (the nesting can be to any depth). If `isShallow`
|
||||
* is truthy, `array` will only be flattened a single level. If `callback`
|
||||
* is passed, each element of `array` is passed through a callback` before
|
||||
* flattening. The `callback` is bound to `thisArg` and invoked with three
|
||||
* arguments; (value, index, array).
|
||||
*
|
||||
* If a property name is passed for `callback`, the created "_.pluck" style
|
||||
* callback will return the property value of the given element.
|
||||
*
|
||||
* If an object is passed 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 Arrays
|
||||
* @param {Array} array The array to compact.
|
||||
* @param {Boolean} shallow A flag to indicate only flattening a single level.
|
||||
* @param {Boolean} [isShallow=false] A flag to indicate only flattening a single level.
|
||||
* @param {Function|Object|String} [callback=identity] The function called per
|
||||
* iteration. If a property name or object is passed, it will be used to create
|
||||
* a "_.pluck" or "_.where" style callback, respectively.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a new flattened array.
|
||||
* @example
|
||||
*
|
||||
@@ -3343,18 +3357,38 @@
|
||||
*
|
||||
* _.flatten([1, [2], [3, [[4]]]], true);
|
||||
* // => [1, 2, 3, [[4]]];
|
||||
*
|
||||
* var stooges = [
|
||||
* { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
|
||||
* { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] }
|
||||
* ];
|
||||
*
|
||||
* // using "_.pluck" callback shorthand
|
||||
* _.flatten(stooges, 'quotes');
|
||||
* // => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!']
|
||||
*/
|
||||
function flatten(array, shallow) {
|
||||
function flatten(array, isShallow, callback, thisArg) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0,
|
||||
result = [];
|
||||
|
||||
// juggle arguments
|
||||
if (typeof isShallow != 'boolean' && isShallow != null) {
|
||||
thisArg = callback;
|
||||
callback = isShallow;
|
||||
isShallow = false;
|
||||
}
|
||||
if (callback != null) {
|
||||
callback = lodash.createCallback(callback, thisArg);
|
||||
}
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
|
||||
if (callback) {
|
||||
value = callback(value, index, array);
|
||||
}
|
||||
// recursively flatten arrays (susceptible to call stack limits)
|
||||
if (isArray(value)) {
|
||||
push.apply(result, shallow ? value : flatten(value));
|
||||
push.apply(result, isShallow ? value : flatten(value));
|
||||
} else {
|
||||
result.push(value);
|
||||
}
|
||||
|
||||
@@ -821,8 +821,7 @@
|
||||
var start = _.after(2, _.once(QUnit.start));
|
||||
|
||||
build(['-s', 'underscore'], function(data) {
|
||||
var last,
|
||||
array = [{ 'a': 1, 'b': 2 }, { 'a': 2, 'b': 2 }],
|
||||
var array = [{ 'a': 1, 'b': 2 }, { 'a': 2, 'b': 2 }],
|
||||
basename = path.basename(data.outputPath, '.js'),
|
||||
context = createContext();
|
||||
|
||||
@@ -869,6 +868,7 @@
|
||||
|
||||
equal(actual, _.first(array), '_.find: ' + basename);
|
||||
|
||||
var last;
|
||||
actual = lodash.forEach(array, function(value) {
|
||||
last = value;
|
||||
return false;
|
||||
@@ -877,6 +877,15 @@
|
||||
equal(last, _.last(array), '_.forEach should not exit early: ' + basename);
|
||||
equal(actual, undefined, '_.forEach should return `undefined`: ' + basename);
|
||||
|
||||
array = [{ 'a': [1, 2] }, { 'a': [3] }];
|
||||
|
||||
actual = lodash.flatten(array, function(value, index) {
|
||||
return this[index].a;
|
||||
}, array);
|
||||
|
||||
deepEqual(actual, array, '_.flatten should should ignore `callback` and `thisArg`: ' + basename);
|
||||
deepEqual(lodash.flatten(array, 'a'), array, '_.flatten should should ignore string `callback` values: ' + basename);
|
||||
|
||||
object = { 'length': 0, 'splice': Array.prototype.splice };
|
||||
equal(lodash.isEmpty(object), false, '_.isEmpty should return `false` for jQuery/MooTools DOM query collections: ' + basename);
|
||||
|
||||
|
||||
40
test/test.js
40
test/test.js
@@ -789,6 +789,46 @@
|
||||
QUnit.module('lodash.flatten');
|
||||
|
||||
(function() {
|
||||
var array = [{ 'a': [1, [2]] }, { 'a': [3] }];
|
||||
|
||||
test('should work with a `callback`', function() {
|
||||
var actual = _.flatten(array, function(value) {
|
||||
return value.a;
|
||||
});
|
||||
|
||||
deepEqual(actual, [1, 2, 3]);
|
||||
});
|
||||
|
||||
test('should work with `isShallow` and `callback`', function() {
|
||||
var actual = _.flatten(array, true, function(value) {
|
||||
return value.a;
|
||||
});
|
||||
|
||||
deepEqual(actual, [1, [2], 3]);
|
||||
});
|
||||
|
||||
test('should pass the correct `callback` arguments', function() {
|
||||
var args;
|
||||
|
||||
_.flatten(array, function() {
|
||||
args || (args = slice.call(arguments));
|
||||
});
|
||||
|
||||
deepEqual(args, [{ 'a': [1, [2]] }, 0, array]);
|
||||
});
|
||||
|
||||
test('supports the `thisArg` argument', function() {
|
||||
var actual = _.flatten(array, function(value, index) {
|
||||
return this[index].a;
|
||||
}, array);
|
||||
|
||||
deepEqual(actual, [1, 2, 3]);
|
||||
});
|
||||
|
||||
test('should work with a string for `callback`', function() {
|
||||
deepEqual(_.flatten(array, 'a'), [1, 2, 3]);
|
||||
});
|
||||
|
||||
test('should treat sparse arrays as dense', function() {
|
||||
var array = [[1, 2, 3], Array(3)],
|
||||
expected = [1, 2, 3],
|
||||
|
||||
Reference in New Issue
Block a user