lodash-rails 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/lodash/rails/version.rb +1 -1
- data/vendor/assets/javascripts/lodash.compat.js +783 -552
- data/vendor/assets/javascripts/lodash.compat.min.js +54 -52
- data/vendor/assets/javascripts/lodash.js +776 -545
- data/vendor/assets/javascripts/lodash.min.js +51 -50
- data/vendor/assets/javascripts/lodash.underscore.js +553 -439
- data/vendor/assets/javascripts/lodash.underscore.min.js +35 -34
- metadata +2 -2
@@ -1,54 +1,55 @@
|
|
1
1
|
/**
|
2
2
|
* @license
|
3
|
-
* Lo-Dash 2.
|
3
|
+
* Lo-Dash 2.3.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE
|
4
4
|
* Build: `lodash modern -o ./dist/lodash.js`
|
5
5
|
*/
|
6
|
-
;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++e<r;)if(n[e]===t)return e;return-1}function t(t,e){var r=typeof e;if(t=t.l,"boolean"==r||null==e)return t[e]?0:-1;"number"!=r&&"string"!=r&&(r="object");var u="number"==r?e:
|
7
|
-
}}function r(n){return n.charCodeAt(0)}function u(n,t){var e=n.m,r=t.m;if(e!==r){if(e>r||typeof e=="undefined")return 1;if(e<r||typeof r=="undefined")return-1}return n.n-t.n}function o(n){var t=-1,r=n.length,u=n[0],o=n[
|
8
|
-
}function l(
|
9
|
-
for(var r=-1,u=
|
10
|
-
if(!u)return o;var
|
11
|
-
}function tt(n,t,e,r,u){if(e){var o=e(n);if(typeof o!="undefined")return o}if(!
|
12
|
-
}),
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}function
|
21
|
-
|
22
|
-
|
23
|
-
return
|
24
|
-
var
|
25
|
-
}function
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}function
|
29
|
-
|
30
|
-
}
|
31
|
-
var
|
32
|
-
}:
|
33
|
-
return function(){return 1>--n?t.apply(this,arguments):void 0}},
|
34
|
-
},
|
35
|
-
}:function(n){return n=n[o],
|
36
|
-
|
37
|
-
}n:for(;++
|
38
|
-
}if(!
|
39
|
-
|
40
|
-
},
|
41
|
-
|
42
|
-
|
43
|
-
}
|
44
|
-
},
|
45
|
-
|
46
|
-
},
|
47
|
-
},
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
var
|
6
|
+
;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++e<r;)if(n[e]===t)return e;return-1}function t(t,e){var r=typeof e;if(t=t.l,"boolean"==r||null==e)return t[e]?0:-1;"number"!=r&&"string"!=r&&(r="object");var u="number"==r?e:m+e;return t=(t=t[r])&&t[u],"object"==r?t&&-1<n(t,e)?0:-1:t?0:-1}function e(n){var t=this.l,e=typeof n;if("boolean"==e||null==n)t[n]=true;else{"number"!=e&&"string"!=e&&(e="object");var r="number"==e?n:m+n,t=t[e]||(t[e]={});"object"==e?(t[r]||(t[r]=[])).push(n):t[r]=true
|
7
|
+
}}function r(n){return n.charCodeAt(0)}function u(n,t){var e=n.m,r=t.m;if(e!==r){if(e>r||typeof e=="undefined")return 1;if(e<r||typeof r=="undefined")return-1}return n.n-t.n}function o(n){var t=-1,r=n.length,u=n[0],o=n[r/2|0],i=n[r-1];if(u&&typeof u=="object"&&o&&typeof o=="object"&&i&&typeof i=="object")return false;for(u=f(),u["false"]=u["null"]=u["true"]=u.undefined=false,o=f(),o.k=n,o.l=u,o.push=e;++t<r;)o.push(n[t]);return o}function i(n){return"\\"+V[n]}function a(){return h.pop()||[]}function f(){return g.pop()||{k:null,l:null,m:null,"false":false,n:0,"null":false,number:null,object:null,push:null,string:null,"true":false,undefined:false,o:null}
|
8
|
+
}function l(n){n.length=0,h.length<b&&h.push(n)}function c(n){var t=n.l;t&&c(t),n.k=n.l=n.m=n.object=n.number=n.string=n.o=null,g.length<b&&g.push(n)}function p(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1;e=e-t||0;for(var u=Array(0>e?0:e);++r<e;)u[r]=n[t+r];return u}function s(e){function h(n){if(!n||ve.call(n)!=q)return false;var t=n.valueOf,e=typeof t=="function"&&(e=be(t))&&be(e);return e?n==e||be(n)==e:yt(n)}function g(n,t,e){if(!n||!U[typeof n])return n;t=t&&typeof e=="undefined"?t:ut(t,e,3);
|
9
|
+
for(var r=-1,u=U[typeof n]&&ze(n),o=u?u.length:0;++r<o&&(e=u[r],false!==t(n[e],e,n)););return n}function b(n,t,e){var r;if(!n||!U[typeof n])return n;t=t&&typeof e=="undefined"?t:ut(t,e,3);for(r in n)if(false===t(n[r],r,n))break;return n}function V(n,t,e){var r,u=n,o=u;if(!u)return o;for(var i=arguments,a=0,f=typeof e=="number"?2:i.length;++a<f;)if((u=i[a])&&U[typeof u])for(var l=-1,c=U[typeof u]&&ze(u),p=c?c.length:0;++l<p;)r=c[l],"undefined"==typeof o[r]&&(o[r]=u[r]);return o}function H(n,t,e){var r,u=n,o=u;
|
10
|
+
if(!u)return o;var i=arguments,a=0,f=typeof e=="number"?2:i.length;if(3<f&&"function"==typeof i[f-2])var l=ut(i[--f-1],i[f--],2);else 2<f&&"function"==typeof i[f-1]&&(l=i[--f]);for(;++a<f;)if((u=i[a])&&U[typeof u])for(var c=-1,p=U[typeof u]&&ze(u),s=p?p.length:0;++c<s;)r=p[c],o[r]=l?l(o[r],u[r]):u[r];return o}function J(n){var t,e=[];if(!n||!U[typeof n])return e;for(t in n)de.call(n,t)&&e.push(t);return e}function Z(n){return n&&typeof n=="object"&&!qe(n)&&de.call(n,"__wrapped__")?n:new nt(n)}function nt(n,t){this.__chain__=!!t,this.__wrapped__=n
|
11
|
+
}function tt(n){function t(){if(r){var n=r.slice();je.apply(n,arguments)}if(this instanceof t){var o=rt(e.prototype),n=e.apply(o,n||arguments);return kt(n)?n:o}return e.apply(u,n||arguments)}var e=n[0],r=n[2],u=n[4];return We(t,n),t}function et(n,t,e,r,u){if(e){var o=e(n);if(typeof o!="undefined")return o}if(!kt(n))return n;var i=ve.call(n);if(!K[i])return n;var f=Te[i];switch(i){case F:case T:return new f(+n);case W:case P:return new f(n);case z:return o=f(n.source,C.exec(n)),o.lastIndex=n.lastIndex,o
|
12
|
+
}if(i=qe(n),t){var c=!r;r||(r=a()),u||(u=a());for(var s=r.length;s--;)if(r[s]==n)return u[s];o=i?f(n.length):{}}else o=i?p(n):H({},n);return i&&(de.call(n,"index")&&(o.index=n.index),de.call(n,"input")&&(o.input=n.input)),t?(r.push(n),u.push(o),(i?Rt:g)(n,function(n,i){o[i]=et(n,t,e,r,u)}),c&&(l(r),l(u)),o):o}function rt(n){return kt(n)?Ie(n):{}}function ut(n,t,e){if(typeof n!="function")return Qt;if(typeof t=="undefined"||!("prototype"in n))return n;var r=n.__bindData__;if(typeof r=="undefined"&&(Be.funcNames&&(r=!n.name),r=r||!Be.funcDecomp,!r)){var u=_e.call(n);
|
13
|
+
Be.funcNames||(r=!O.test(u)),r||(r=E.test(u),We(n,r))}if(false===r||true!==r&&1&r[1])return n;switch(e){case 1:return function(e){return n.call(t,e)};case 2:return function(e,r){return n.call(t,e,r)};case 3:return function(e,r,u){return n.call(t,e,r,u)};case 4:return function(e,r,u,o){return n.call(t,e,r,u,o)}}return Gt(n,t)}function ot(n){function t(){var n=f?i:this;if(u){var h=u.slice();je.apply(h,arguments)}return(o||c)&&(h||(h=p(arguments)),o&&je.apply(h,o),c&&h.length<a)?(r|=16,ot([e,s?r:-4&r,h,null,i,a])):(h||(h=arguments),l&&(e=n[v]),this instanceof t?(n=rt(e.prototype),h=e.apply(n,h),kt(h)?h:n):e.apply(n,h))
|
14
|
+
}var e=n[0],r=n[1],u=n[2],o=n[3],i=n[4],a=n[5],f=1&r,l=2&r,c=4&r,s=8&r,v=e;return We(t,n),t}function it(e,r){var u=-1,i=gt(),a=e?e.length:0,f=a>=_&&i===n,l=[];if(f){var p=o(r);p?(i=t,r=p):f=false}for(;++u<a;)p=e[u],0>i(r,p)&&l.push(p);return f&&c(r),l}function at(n,t,e,r){r=(r||0)-1;for(var u=n?n.length:0,o=[];++r<u;){var i=n[r];if(i&&typeof i=="object"&&typeof i.length=="number"&&(qe(i)||_t(i))){t||(i=at(i,t,e));var a=-1,f=i.length,l=o.length;for(o.length+=f;++a<f;)o[l++]=i[a]}else e||o.push(i)}return o
|
15
|
+
}function ft(n,t,e,r,u,o){if(e){var i=e(n,t);if(typeof i!="undefined")return!!i}if(n===t)return 0!==n||1/n==1/t;if(n===n&&!(n&&U[typeof n]||t&&U[typeof t]))return false;if(null==n||null==t)return n===t;var f=ve.call(n),c=ve.call(t);if(f==D&&(f=q),c==D&&(c=q),f!=c)return false;switch(f){case F:case T:return+n==+t;case W:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case z:case P:return n==fe(t)}if(c=f==$,!c){var p=de.call(n,"__wrapped__"),s=de.call(t,"__wrapped__");if(p||s)return ft(p?n.__wrapped__:n,s?t.__wrapped__:t,e,r,u,o);
|
16
|
+
if(f!=q)return false;if(f=n.constructor,p=t.constructor,f!=p&&!(jt(f)&&f instanceof f&&jt(p)&&p instanceof p)&&"constructor"in n&&"constructor"in t)return false}for(p=!u,u||(u=a()),o||(o=a()),f=u.length;f--;)if(u[f]==n)return o[f]==t;var v=0,i=true;if(u.push(n),o.push(t),c){if(f=n.length,v=t.length,i=v==n.length,!i&&!r)return i;for(;v--;)if(c=f,p=t[v],r)for(;c--&&!(i=ft(n[c],p,e,r,u,o)););else if(!(i=ft(n[v],p,e,r,u,o)))break;return i}return b(t,function(t,a,f){return de.call(f,a)?(v++,i=de.call(n,a)&&ft(n[a],t,e,r,u,o)):void 0
|
17
|
+
}),i&&!r&&b(n,function(n,t,e){return de.call(e,t)?i=-1<--v:void 0}),p&&(l(u),l(o)),i}function lt(n,t,e,r,u){(qe(t)?Rt:g)(t,function(t,o){var i,a,f=t,l=n[o];if(t&&((a=qe(t))||h(t))){for(f=r.length;f--;)if(i=r[f]==t){l=u[f];break}if(!i){var c;e&&(f=e(l,t),c=typeof f!="undefined")&&(l=f),c||(l=a?qe(l)?l:[]:h(l)?l:{}),r.push(t),u.push(l),c||lt(l,t,e,r,u)}}else e&&(f=e(l,t),typeof f=="undefined"&&(f=t)),typeof f!="undefined"&&(l=f);n[o]=l})}function ct(n,t){return n+me(Fe()*(t-n+1))}function pt(e,r,u){var i=-1,f=gt(),p=e?e.length:0,s=[],v=!r&&p>=_&&f===n,h=u||v?a():s;
|
18
|
+
if(v){var g=o(h);g?(f=t,h=g):(v=false,h=u?h:(l(h),s))}for(;++i<p;){var g=e[i],y=u?u(g,i,e):g;(r?!i||h[h.length-1]!==y:0>f(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(l(h.k),c(h)):u&&l(h),s}function st(n){return function(t,e,r){var u={};e=Z.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++r<o;){var i=t[r];n(u,i,e(i,r,t),t)}else g(t,function(t,r,o){n(u,t,e(t,r,o),o)});return u}}function vt(n,t,e,r,u,o){var i=1&t,a=4&t,f=16&t,l=32&t;if(!(2&t||jt(n)))throw new le;f&&!e.length&&(t&=-17,f=e=false),l&&!r.length&&(t&=-33,l=r=false);
|
19
|
+
var c=n&&n.__bindData__;return c&&true!==c?(c=c.slice(),!i||1&c[1]||(c[4]=u),!i&&1&c[1]&&(t|=8),!a||4&c[1]||(c[5]=o),f&&je.apply(c[2]||(c[2]=[]),e),l&&je.apply(c[3]||(c[3]=[]),r),c[1]|=t,vt.apply(null,c)):(1==t||17===t?tt:ot)([n,t,e,r,u,o])}function ht(n){return Pe[n]}function gt(){var t=(t=Z.indexOf)===Pt?n:t;return t}function yt(n){var t,e;return n&&ve.call(n)==q&&(t=n.constructor,!jt(t)||t instanceof t)?(b(n,function(n,t){e=t}),typeof e=="undefined"||de.call(n,e)):false}function mt(n){return Ke[n]}function _t(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ve.call(n)==D||false
|
20
|
+
}function bt(n,t,e){var r=ze(n),u=r.length;for(t=ut(t,e,3);u--&&(e=r[u],false!==t(n[e],e,n)););return n}function dt(n){var t=[];return b(n,function(n,e){jt(n)&&t.push(e)}),t.sort()}function wt(n){for(var t=-1,e=ze(n),r=e.length,u={};++t<r;){var o=e[t];u[n[o]]=o}return u}function jt(n){return typeof n=="function"}function kt(n){return!(!n||!U[typeof n])}function xt(n){return typeof n=="number"||n&&typeof n=="object"&&ve.call(n)==W||false}function Ct(n){return typeof n=="string"||n&&typeof n=="object"&&ve.call(n)==P||false
|
21
|
+
}function Ot(n){for(var t=-1,e=ze(n),r=e.length,u=ne(r);++t<r;)u[t]=n[e[t]];return u}function It(n,t,e){var r=-1,u=gt(),o=n?n.length:0,i=false;return e=(0>e?Ae(0,o+e):e)||0,qe(n)?i=-1<u(n,t,e):typeof o=="number"?i=-1<(Ct(n)?n.indexOf(t,e):u(n,t,e)):g(n,function(n){return++r<e?void 0:!(i=n===t)}),i}function Nt(n,t,e){var r=true;t=Z.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u&&(r=!!t(n[e],e,n)););else g(n,function(n,e,u){return r=!!t(n,e,u)});return r}function St(n,t,e){var r=[];
|
22
|
+
t=Z.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u;){var o=n[e];t(o,e,n)&&r.push(o)}else g(n,function(n,e,u){t(n,e,u)&&r.push(n)});return r}function Et(n,t,e){t=Z.createCallback(t,e,3),e=-1;var r=n?n.length:0;if(typeof r!="number"){var u;return g(n,function(n,e,r){return t(n,e,r)?(u=n,false):void 0}),u}for(;++e<r;){var o=n[e];if(t(o,e,n))return o}}function Rt(n,t,e){var r=-1,u=n?n.length:0;if(t=t&&typeof e=="undefined"?t:ut(t,e,3),typeof u=="number")for(;++r<u&&false!==t(n[r],r,n););else g(n,t);
|
23
|
+
return n}function At(n,t,e){var r=n?n.length:0;if(t=t&&typeof e=="undefined"?t:ut(t,e,3),typeof r=="number")for(;r--&&false!==t(n[r],r,n););else{var u=ze(n),r=u.length;g(n,function(n,e,o){return e=u?u[--r]:--r,t(o[e],e,o)})}return n}function Dt(n,t,e){var r=-1,u=n?n.length:0;if(t=Z.createCallback(t,e,3),typeof u=="number")for(var o=ne(u);++r<u;)o[r]=t(n[r],r,n);else o=[],g(n,function(n,e,u){o[++r]=t(n,e,u)});return o}function $t(n,t,e){var u=-1/0,o=u;if(typeof t!="function"&&e&&e[t]===n&&(t=null),null==t&&qe(n)){e=-1;
|
24
|
+
for(var i=n.length;++e<i;){var a=n[e];a>o&&(o=a)}}else t=null==t&&Ct(n)?r:Z.createCallback(t,e,3),Rt(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Ft(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=ne(r);++e<r;)u[e]=n[e][t];return u||Dt(n,t)}function Tt(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=Z.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++o<i;)e=t(e,n[o],o,n);else g(n,function(n,r,o){e=u?(u=false,n):t(e,n,r,o)});return e
|
25
|
+
}function Bt(n,t,e,r){var u=3>arguments.length;return t=Z.createCallback(t,r,4),At(n,function(n,r,o){e=u?(u=false,n):t(e,n,r,o)}),e}function Wt(n){var t=-1,e=n?n.length:0,r=ne(typeof e=="number"?e:0);return Rt(n,function(n){var e=ct(0,++t);r[t]=r[e],r[e]=n}),r}function qt(n,t,e){var r;t=Z.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u&&!(r=t(n[e],e,n)););else g(n,function(n,e,u){return!(r=t(n,e,u))});return!!r}function zt(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;
|
26
|
+
for(t=Z.createCallback(t,e,3);++o<u&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[0]:v;return p(n,0,De(Ae(0,r),u))}function Pt(t,e,r){if(typeof r=="number"){var u=t?t.length:0;r=0>r?Ae(0,u+r):r||0}else if(r)return r=Lt(t,e),t[r]===e?r:-1;return n(t,e,r)}function Kt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=Z.createCallback(t,e,3);++u<o&&t(n[u],u,n);)r++}else r=null==t||e?1:Ae(0,t);return p(n,r)}function Lt(n,t,e,r){var u=0,o=n?n.length:u;for(e=e?Z.createCallback(e,r,1):Qt,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;
|
27
|
+
return u}function Mt(n,t,e,r){return typeof t!="boolean"&&null!=t&&(r=e,e=typeof t!="function"&&r&&r[t]===n?null:t,t=false),null!=e&&(e=Z.createCallback(e,r,3)),pt(n,t,e)}function Ut(){for(var n=1<arguments.length?arguments:arguments[0],t=-1,e=n?$t(Ft(n,"length")):0,r=ne(0>e?0:e);++t<e;)r[t]=Ft(n,t);return r}function Vt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var o=n[e];t?u[o]=t[e]:o&&(u[o[0]]=o[1])}return u}function Gt(n,t){return 2<arguments.length?vt(n,17,p(arguments,2),null,t):vt(n,1,null,null,t)
|
28
|
+
}function Ht(n,t,e){function r(){c&&ye(c),i=c=p=v,(g||h!==t)&&(s=we(),a=n.apply(l,o),c||i||(o=l=null))}function u(){var e=t-(we()-f);0<e?c=ke(u,e):(i&&ye(i),e=p,i=c=p=v,e&&(s=we(),a=n.apply(l,o),c||i||(o=l=null)))}var o,i,a,f,l,c,p,s=0,h=false,g=true;if(!jt(n))throw new le;if(t=Ae(0,t)||0,true===e)var y=true,g=false;else kt(e)&&(y=e.leading,h="maxWait"in e&&(Ae(t,e.maxWait)||0),g="trailing"in e?e.trailing:g);return function(){if(o=arguments,f=we(),l=this,p=g&&(c||!y),false===h)var e=y&&!c;else{i||y||(s=f);var v=h-(f-s),m=0>=v;
|
29
|
+
m?(i&&(i=ye(i)),s=f,a=n.apply(l,o)):i||(i=ke(r,v))}return m&&c?c=ye(c):c||t===h||(c=ke(u,t)),e&&(m=true,a=n.apply(l,o)),!m||c||i||(o=l=null),a}}function Jt(n){if(!jt(n))throw new le;var t=p(arguments,1);return ke(function(){n.apply(v,t)},1)}function Qt(n){return n}function Xt(n,t){var e=n,r=!t||jt(e);t||(e=nt,t=n,n=Z),Rt(dt(t),function(u){var o=n[u]=t[u];r&&(e.prototype[u]=function(){var t=this.__wrapped__,r=[t];return je.apply(r,arguments),r=o.apply(n,r),t&&typeof t=="object"&&t===r?this:(r=new e(r),r.__chain__=this.__chain__,r)
|
30
|
+
})})}function Yt(){}function Zt(){return this.__wrapped__}e=e?Y.defaults(G.Object(),e,Y.pick(G,A)):G;var ne=e.Array,te=e.Boolean,ee=e.Date,re=e.Function,ue=e.Math,oe=e.Number,ie=e.Object,ae=e.RegExp,fe=e.String,le=e.TypeError,ce=[],pe=ie.prototype,se=e._,ve=pe.toString,he=ae("^"+fe(ve).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),ge=ue.ceil,ye=e.clearTimeout,me=ue.floor,_e=re.prototype.toString,be=he.test(be=ie.getPrototypeOf)&&be,de=pe.hasOwnProperty,we=he.test(we=ee.now)&&we||function(){return+new ee
|
31
|
+
},je=ce.push,ke=e.setTimeout,xe=ce.splice,Ce=typeof(Ce=X&&Q&&X.setImmediate)=="function"&&!he.test(Ce)&&Ce,Oe=function(){try{var n={},t=he.test(t=ie.defineProperty)&&t,e=t(n,n,n)&&t}catch(r){}return e}(),Ie=he.test(Ie=ie.create)&&Ie,Ne=he.test(Ne=ne.isArray)&&Ne,Se=e.isFinite,Ee=e.isNaN,Re=he.test(Re=ie.keys)&&Re,Ae=ue.max,De=ue.min,$e=e.parseInt,Fe=ue.random,Te={};Te[$]=ne,Te[F]=te,Te[T]=ee,Te[B]=re,Te[q]=ie,Te[W]=oe,Te[z]=ae,Te[P]=fe,nt.prototype=Z.prototype;var Be=Z.support={};Be.funcDecomp=!he.test(e.a)&&E.test(s),Be.funcNames=typeof re.name=="string",Z.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:I,variable:"",imports:{_:Z}},Ie||(rt=function(){function n(){}return function(t){if(kt(t)){n.prototype=t;
|
32
|
+
var r=new n;n.prototype=null}return r||e.Object()}}());var We=Oe?function(n,t){M.value=t,Oe(n,"__bindData__",M)}:Yt,qe=Ne||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ve.call(n)==$||false},ze=Re?function(n){return kt(n)?Re(n):[]}:J,Pe={"&":"&","<":"<",">":">",'"':""","'":"'"},Ke=wt(Pe),Le=ae("("+ze(Ke).join("|")+")","g"),Me=ae("["+ze(Pe).join("")+"]","g"),Ue=st(function(n,t,e){de.call(n,e)?n[e]++:n[e]=1}),Ve=st(function(n,t,e){(de.call(n,e)?n[e]:n[e]=[]).push(t)
|
33
|
+
}),Ge=st(function(n,t,e){n[e]=t});Ce&&(Jt=function(n){if(!jt(n))throw new le;return Ce.apply(e,arguments)});var He=8==$e(d+"08")?$e:function(n,t){return $e(Ct(n)?n.replace(N,""):n,t||0)};return Z.after=function(n,t){if(!jt(t))throw new le;return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=H,Z.at=function(n){for(var t=arguments,e=-1,r=at(t,true,false,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=ne(t);++e<t;)u[e]=n[r[e]];return u},Z.bind=Gt,Z.bindAll=function(n){for(var t=1<arguments.length?at(arguments,true,false,1):dt(n),e=-1,r=t.length;++e<r;){var u=t[e];
|
34
|
+
n[u]=vt(n[u],1,null,null,n)}return n},Z.bindKey=function(n,t){return 2<arguments.length?vt(t,19,p(arguments,2),null,n):vt(t,3,null,null,n)},Z.chain=function(n){return n=new nt(n),n.__chain__=true,n},Z.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},Z.compose=function(){for(var n=arguments,t=n.length;t--;)if(!jt(n[t]))throw new le;return function(){for(var t=arguments,e=n.length;e--;)t=[n[e].apply(this,t)];return t[0]}},Z.countBy=Ue,Z.create=function(n,t){var e=rt(n);
|
35
|
+
return t?H(e,t):e},Z.createCallback=function(n,t,e){var r=typeof n;if(null==n||"function"==r)return ut(n,t,e);if("object"!=r)return function(t){return t[n]};var u=ze(n),o=u[0],i=n[o];return 1!=u.length||i!==i||kt(i)?function(t){for(var e=u.length,r=false;e--&&(r=ft(t[u[e]],n[u[e]],null,true)););return r}:function(n){return n=n[o],i===n&&(0!==i||1/i==1/n)}},Z.curry=function(n,t){return t=typeof t=="number"?t:+t||n.length,vt(n,4,null,null,null,t)},Z.debounce=Ht,Z.defaults=V,Z.defer=Jt,Z.delay=function(n,t){if(!jt(n))throw new le;
|
36
|
+
var e=p(arguments,2);return ke(function(){n.apply(v,e)},t)},Z.difference=function(n){return it(n,at(arguments,true,true,1))},Z.filter=St,Z.flatten=function(n,t,e,r){return typeof t!="boolean"&&null!=t&&(r=e,e=typeof t!="function"&&r&&r[t]===n?null:t,t=false),null!=e&&(n=Dt(n,e,r)),at(n,t)},Z.forEach=Rt,Z.forEachRight=At,Z.forIn=b,Z.forInRight=function(n,t,e){var r=[];b(n,function(n,t){r.push(t,n)});var u=r.length;for(t=ut(t,e,3);u--&&false!==t(r[u--],r[u],n););return n},Z.forOwn=g,Z.forOwnRight=bt,Z.functions=dt,Z.groupBy=Ve,Z.indexBy=Ge,Z.initial=function(n,t,e){var r=0,u=n?n.length:0;
|
37
|
+
if(typeof t!="number"&&null!=t){var o=u;for(t=Z.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else r=null==t||e?1:t||r;return p(n,0,De(Ae(0,u-r),u))},Z.intersection=function(e){for(var r=arguments,u=r.length,i=-1,f=a(),p=-1,s=gt(),v=e?e.length:0,h=[],g=a();++i<u;){var y=r[i];f[i]=s===n&&(y?y.length:0)>=_&&o(i?r[i]:g)}n:for(;++p<v;){var m=f[0],y=e[p];if(0>(m?t(m,y):s(g,y))){for(i=u,(m||g).push(y);--i;)if(m=f[i],0>(m?t(m,y):s(r[i],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&c(m);return l(f),l(g),h},Z.invert=wt,Z.invoke=function(n,t){var e=p(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,i=ne(typeof o=="number"?o:0);
|
38
|
+
return Rt(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},Z.keys=ze,Z.map=Dt,Z.max=$t,Z.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):m+arguments[0];return de.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!jt(n))throw new le;return e.cache={},e},Z.merge=function(n){var t=arguments,e=2;if(!kt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3<e&&"function"==typeof t[e-2])var r=ut(t[--e-1],t[e--],2);else 2<e&&"function"==typeof t[e-1]&&(r=t[--e]);for(var t=p(arguments,1,e),u=-1,o=a(),i=a();++u<e;)lt(n,t[u],r,o,i);
|
39
|
+
return l(o),l(i),n},Z.min=function(n,t,e){var u=1/0,o=u;if(typeof t!="function"&&e&&e[t]===n&&(t=null),null==t&&qe(n)){e=-1;for(var i=n.length;++e<i;){var a=n[e];a<o&&(o=a)}}else t=null==t&&Ct(n)?r:Z.createCallback(t,e,3),Rt(n,function(n,e,r){e=t(n,e,r),e<u&&(u=e,o=n)});return o},Z.omit=function(n,t,e){var r={};if(typeof t!="function"){var u=[];b(n,function(n,t){u.push(t)});for(var u=it(u,at(arguments,true,false,1)),o=-1,i=u.length;++o<i;){var a=u[o];r[a]=n[a]}}else t=Z.createCallback(t,e,3),b(n,function(n,e,u){t(n,e,u)||(r[e]=n)
|
40
|
+
});return r},Z.once=function(n){var t,e;if(!jt(n))throw new le;return function(){return t?e:(t=true,e=n.apply(this,arguments),n=null,e)}},Z.pairs=function(n){for(var t=-1,e=ze(n),r=e.length,u=ne(r);++t<r;){var o=e[t];u[t]=[o,n[o]]}return u},Z.partial=function(n){return vt(n,16,p(arguments,1))},Z.partialRight=function(n){return vt(n,32,null,p(arguments,1))},Z.pick=function(n,t,e){var r={};if(typeof t!="function")for(var u=-1,o=at(arguments,true,false,1),i=kt(n)?o.length:0;++u<i;){var a=o[u];a in n&&(r[a]=n[a])
|
41
|
+
}else t=Z.createCallback(t,e,3),b(n,function(n,e,u){t(n,e,u)&&(r[e]=n)});return r},Z.pluck=Ft,Z.pull=function(n){for(var t=arguments,e=0,r=t.length,u=n?n.length:0;++e<r;)for(var o=-1,i=t[e];++o<u;)n[o]===i&&(xe.call(n,o--,1),u--);return n},Z.range=function(n,t,e){n=+n||0,e=typeof e=="number"?e:+e||1,null==t&&(t=n,n=0);var r=-1;t=Ae(0,ge((t-n)/(e||1)));for(var u=ne(t);++r<t;)u[r]=n,n+=e;return u},Z.reject=function(n,t,e){return t=Z.createCallback(t,e,3),St(n,function(n,e,r){return!t(n,e,r)})},Z.remove=function(n,t,e){var r=-1,u=n?n.length:0,o=[];
|
42
|
+
for(t=Z.createCallback(t,e,3);++r<u;)e=n[r],t(e,r,n)&&(o.push(e),xe.call(n,r--,1),u--);return o},Z.rest=Kt,Z.shuffle=Wt,Z.sortBy=function(n,t,e){var r=-1,o=n?n.length:0,i=ne(typeof o=="number"?o:0);for(t=Z.createCallback(t,e,3),Rt(n,function(n,e,u){var o=i[++r]=f();o.m=t(n,e,u),o.n=r,o.o=n}),o=i.length,i.sort(u);o--;)n=i[o],i[o]=n.o,c(n);return i},Z.tap=function(n,t){return t(n),n},Z.throttle=function(n,t,e){var r=true,u=true;if(!jt(n))throw new le;return false===e?r=false:kt(e)&&(r="leading"in e?e.leading:r,u="trailing"in e?e.trailing:u),L.leading=r,L.maxWait=t,L.trailing=u,Ht(n,t,L)
|
43
|
+
},Z.times=function(n,t,e){n=-1<(n=+n)?n:0;var r=-1,u=ne(n);for(t=ut(t,e,1);++r<n;)u[r]=t(r);return u},Z.toArray=function(n){return n&&typeof n.length=="number"?p(n):Ot(n)},Z.transform=function(n,t,e,r){var u=qe(n);if(null==e)if(u)e=[];else{var o=n&&n.constructor;e=rt(o&&o.prototype)}return t&&(t=Z.createCallback(t,r,4),(u?Rt:g)(n,function(n,r,u){return t(e,n,r,u)})),e},Z.union=function(){return pt(at(arguments,true,true))},Z.uniq=Mt,Z.values=Ot,Z.where=St,Z.without=function(n){return it(n,p(arguments,1))
|
44
|
+
},Z.wrap=function(n,t){return vt(t,16,[n])},Z.zip=Ut,Z.zipObject=Vt,Z.collect=Dt,Z.drop=Kt,Z.each=Rt,Z.eachRight=At,Z.extend=H,Z.methods=dt,Z.object=Vt,Z.select=St,Z.tail=Kt,Z.unique=Mt,Z.unzip=Ut,Xt(Z),Z.clone=function(n,t,e,r){return typeof t!="boolean"&&null!=t&&(r=e,e=t,t=false),et(n,t,typeof e=="function"&&ut(e,r,1))},Z.cloneDeep=function(n,t,e){return et(n,true,typeof t=="function"&&ut(t,e,1))},Z.contains=It,Z.escape=function(n){return null==n?"":fe(n).replace(Me,ht)},Z.every=Nt,Z.find=Et,Z.findIndex=function(n,t,e){var r=-1,u=n?n.length:0;
|
45
|
+
for(t=Z.createCallback(t,e,3);++r<u;)if(t(n[r],r,n))return r;return-1},Z.findKey=function(n,t,e){var r;return t=Z.createCallback(t,e,3),g(n,function(n,e,u){return t(n,e,u)?(r=e,false):void 0}),r},Z.findLast=function(n,t,e){var r;return t=Z.createCallback(t,e,3),At(n,function(n,e,u){return t(n,e,u)?(r=n,false):void 0}),r},Z.findLastIndex=function(n,t,e){var r=n?n.length:0;for(t=Z.createCallback(t,e,3);r--;)if(t(n[r],r,n))return r;return-1},Z.findLastKey=function(n,t,e){var r;return t=Z.createCallback(t,e,3),bt(n,function(n,e,u){return t(n,e,u)?(r=e,false):void 0
|
46
|
+
}),r},Z.has=function(n,t){return n?de.call(n,t):false},Z.identity=Qt,Z.indexOf=Pt,Z.isArguments=_t,Z.isArray=qe,Z.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&ve.call(n)==F||false},Z.isDate=function(n){return n&&typeof n=="object"&&ve.call(n)==T||false},Z.isElement=function(n){return n&&1===n.nodeType||false},Z.isEmpty=function(n){var t=true;if(!n)return t;var e=ve.call(n),r=n.length;return e==$||e==P||e==D||e==q&&typeof r=="number"&&jt(n.splice)?!r:(g(n,function(){return t=false}),t)},Z.isEqual=function(n,t,e,r){return ft(n,t,typeof e=="function"&&ut(e,r,2))
|
47
|
+
},Z.isFinite=function(n){return Se(n)&&!Ee(parseFloat(n))},Z.isFunction=jt,Z.isNaN=function(n){return xt(n)&&n!=+n},Z.isNull=function(n){return null===n},Z.isNumber=xt,Z.isObject=kt,Z.isPlainObject=h,Z.isRegExp=function(n){return n&&typeof n=="object"&&ve.call(n)==z||false},Z.isString=Ct,Z.isUndefined=function(n){return typeof n=="undefined"},Z.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?Ae(0,r+e):De(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Z.mixin=Xt,Z.noConflict=function(){return e._=se,this
|
48
|
+
},Z.noop=Yt,Z.parseInt=He,Z.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=Fe(),De(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):ct(n,t)},Z.reduce=Tt,Z.reduceRight=Bt,Z.result=function(n,t){if(n){var e=n[t];return jt(e)?n[t]():e}},Z.runInContext=s,Z.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ze(n).length},Z.some=qt,Z.sortedIndex=Lt,Z.template=function(n,t,e){var r=Z.templateSettings;
|
49
|
+
n=fe(n||""),e=V({},e,r);var u,o=V({},e.imports,r.imports),r=ze(o),o=Ot(o),a=0,f=e.interpolate||S,l="__p+='",f=ae((e.escape||S).source+"|"+f.source+"|"+(f===I?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}";
|
50
|
+
try{var c=re(r,"return "+l).apply(v,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},Z.unescape=function(n){return null==n?"":fe(n).replace(Le,mt)},Z.uniqueId=function(n){var t=++y;return fe(null==n?"":n)+t},Z.all=Nt,Z.any=qt,Z.detect=Et,Z.findWhere=Et,Z.foldl=Tt,Z.foldr=Bt,Z.include=It,Z.inject=Tt,g(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return je.apply(t,arguments),t=n.apply(Z,t),e?new nt(t,e):t})}),Z.first=zt,Z.last=function(n,t,e){var r=0,u=n?n.length:0;
|
51
|
+
if(typeof t!="number"&&null!=t){var o=u;for(t=Z.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,Ae(0,u-r))},Z.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=Ot(n)),null==t||e?n?n[ct(0,n.length-1)]:v:(n=Wt(n),n.length=De(Ae(0,t),n.length),n)},Z.take=zt,Z.head=zt,g(Z,function(n,t){var e="sample"!==t;Z.prototype[t]||(Z.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 nt(o,u):o
|
52
|
+
})}),Z.VERSION="2.3.0",Z.prototype.chain=function(){return this.__chain__=true,this},Z.prototype.toString=function(){return fe(this.__wrapped__)},Z.prototype.value=Zt,Z.prototype.valueOf=Zt,Rt(["join","pop","shift"],function(n){var t=ce[n];Z.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new nt(e,n):e}}),Rt(["push","reverse","sort","unshift"],function(n){var t=ce[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Rt(["concat","slice","splice"],function(n){var t=ce[n];
|
53
|
+
Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Z}var v,h=[],g=[],y=0,m=+new Date+"",_=75,b=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/,I=/<%=([\s\S]+?)%>/g,N=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 setImmediate setTimeout".split(" "),D="[object Arguments]",$="[object Array]",F="[object Boolean]",T="[object Date]",B="[object Function]",W="[object Number]",q="[object Object]",z="[object RegExp]",P="[object String]",K={};
|
54
|
+
K[B]=false,K[D]=K[$]=K[F]=K[T]=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},U={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},V={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},G=U[typeof window]&&window||this,H=U[typeof exports]&&exports&&!exports.nodeType&&exports,J=U[typeof module]&&module&&!module.nodeType&&module,Q=J&&J.exports===H&&H,X=U[typeof global]&&global;!X||X.global!==X&&X.window!==X||(G=X);
|
55
|
+
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);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* @license
|
3
|
-
* Lo-Dash 2.
|
3
|
+
* Lo-Dash 2.3.0 (Custom Build) <http://lodash.com/>
|
4
4
|
* Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js`
|
5
5
|
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
|
6
6
|
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
|
@@ -147,12 +147,31 @@
|
|
147
147
|
}
|
148
148
|
|
149
149
|
/**
|
150
|
-
*
|
150
|
+
* Slices the `collection` from the `start` index up to, but not including,
|
151
|
+
* the `end` index.
|
152
|
+
*
|
153
|
+
* Note: This function is used instead of `Array#slice` to support node lists
|
154
|
+
* in IE < 9 and to ensure dense arrays are returned.
|
151
155
|
*
|
152
156
|
* @private
|
157
|
+
* @param {Array|Object|string} collection The collection to slice.
|
158
|
+
* @param {number} start The start index.
|
159
|
+
* @param {number} end The end index.
|
160
|
+
* @returns {Array} Returns the new array.
|
153
161
|
*/
|
154
|
-
function
|
155
|
-
|
162
|
+
function slice(array, start, end) {
|
163
|
+
start || (start = 0);
|
164
|
+
if (typeof end == 'undefined') {
|
165
|
+
end = array ? array.length : 0;
|
166
|
+
}
|
167
|
+
var index = -1,
|
168
|
+
length = end - start || 0,
|
169
|
+
result = Array(length < 0 ? 0 : length);
|
170
|
+
|
171
|
+
while (++index < length) {
|
172
|
+
result[index] = array[start + index];
|
173
|
+
}
|
174
|
+
return result;
|
156
175
|
}
|
157
176
|
|
158
177
|
/*--------------------------------------------------------------------------*/
|
@@ -171,11 +190,14 @@
|
|
171
190
|
/** Used to restore the original `_` reference in `noConflict` */
|
172
191
|
var oldDash = root._;
|
173
192
|
|
193
|
+
/** Used to resolve the internal [[Class]] of values */
|
194
|
+
var toString = objectProto.toString;
|
195
|
+
|
174
196
|
/** Used to detect if a method is native */
|
175
197
|
var reNative = RegExp('^' +
|
176
|
-
String(
|
198
|
+
String(toString)
|
177
199
|
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
178
|
-
.replace(/
|
200
|
+
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
179
201
|
);
|
180
202
|
|
181
203
|
/** Native method shortcuts */
|
@@ -184,24 +206,17 @@
|
|
184
206
|
hasOwnProperty = objectProto.hasOwnProperty,
|
185
207
|
now = reNative.test(now = Date.now) && now || function() { return +new Date; },
|
186
208
|
push = arrayRef.push,
|
187
|
-
|
188
|
-
unshift = arrayRef.unshift;
|
209
|
+
propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
189
210
|
|
190
211
|
/* Native method shortcuts for methods with the same name as other `lodash` methods */
|
191
|
-
var
|
192
|
-
nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate,
|
212
|
+
var nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate,
|
193
213
|
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
|
194
214
|
nativeIsFinite = root.isFinite,
|
195
215
|
nativeIsNaN = root.isNaN,
|
196
216
|
nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys,
|
197
217
|
nativeMax = Math.max,
|
198
218
|
nativeMin = Math.min,
|
199
|
-
nativeRandom = Math.random
|
200
|
-
nativeSlice = arrayRef.slice;
|
201
|
-
|
202
|
-
/** Detect various environments */
|
203
|
-
var isIeOpera = reNative.test(root.attachEvent),
|
204
|
-
isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
|
219
|
+
nativeRandom = Math.random;
|
205
220
|
|
206
221
|
/*--------------------------------------------------------------------------*/
|
207
222
|
|
@@ -218,15 +233,16 @@
|
|
218
233
|
*
|
219
234
|
* The chainable wrapper functions are:
|
220
235
|
* `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
|
221
|
-
* `compose`, `concat`, `countBy`, `
|
222
|
-
* `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`,
|
223
|
-
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
|
224
|
-
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
|
225
|
-
* `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
|
226
|
-
* `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`,
|
227
|
-
* `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
|
228
|
-
* `
|
229
|
-
* `unzip`, `values`, `where`, `without`, `wrap`,
|
236
|
+
* `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`,
|
237
|
+
* `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`,
|
238
|
+
* `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
|
239
|
+
* `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
|
240
|
+
* `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
|
241
|
+
* `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`,
|
242
|
+
* `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
|
243
|
+
* `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`,
|
244
|
+
* `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`,
|
245
|
+
* and `zip`
|
230
246
|
*
|
231
247
|
* The non-chainable wrapper functions are:
|
232
248
|
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`,
|
@@ -302,14 +318,6 @@
|
|
302
318
|
(function() {
|
303
319
|
var object = { '0': 1, 'length': 1 };
|
304
320
|
|
305
|
-
/**
|
306
|
-
* Detect if `Function#bind` exists and is inferred to be fast (all but V8).
|
307
|
-
*
|
308
|
-
* @memberOf _.support
|
309
|
-
* @type boolean
|
310
|
-
*/
|
311
|
-
support.fastBind = nativeBind && !isV8;
|
312
|
-
|
313
321
|
/**
|
314
322
|
* Detect if `Array#shift` and `Array#splice` augment array-like objects correctly.
|
315
323
|
*
|
@@ -371,6 +379,65 @@
|
|
371
379
|
|
372
380
|
/*--------------------------------------------------------------------------*/
|
373
381
|
|
382
|
+
/**
|
383
|
+
* The base implementation of `_.bind` that creates the bound function and
|
384
|
+
* sets its meta data.
|
385
|
+
*
|
386
|
+
* @private
|
387
|
+
* @param {Array} bindData The bind data array.
|
388
|
+
* @returns {Function} Returns the new bound function.
|
389
|
+
*/
|
390
|
+
function baseBind(bindData) {
|
391
|
+
var func = bindData[0],
|
392
|
+
partialArgs = bindData[2],
|
393
|
+
thisArg = bindData[4];
|
394
|
+
|
395
|
+
function bound() {
|
396
|
+
// `Function#bind` spec
|
397
|
+
// http://es5.github.io/#x15.3.4.5
|
398
|
+
if (partialArgs) {
|
399
|
+
var args = partialArgs.slice();
|
400
|
+
push.apply(args, arguments);
|
401
|
+
}
|
402
|
+
// mimic the constructor's `return` behavior
|
403
|
+
// http://es5.github.io/#x13.2.2
|
404
|
+
if (this instanceof bound) {
|
405
|
+
// ensure `new bound` is an instance of `func`
|
406
|
+
var thisBinding = baseCreate(func.prototype),
|
407
|
+
result = func.apply(thisBinding, args || arguments);
|
408
|
+
return isObject(result) ? result : thisBinding;
|
409
|
+
}
|
410
|
+
return func.apply(thisArg, args || arguments);
|
411
|
+
}
|
412
|
+
return bound;
|
413
|
+
}
|
414
|
+
|
415
|
+
/**
|
416
|
+
* The base implementation of `_.create` without support for assigning
|
417
|
+
* properties to the created object.
|
418
|
+
*
|
419
|
+
* @private
|
420
|
+
* @param {Object} prototype The object to inherit from.
|
421
|
+
* @returns {Object} Returns the new object.
|
422
|
+
*/
|
423
|
+
function baseCreate(prototype, properties) {
|
424
|
+
return isObject(prototype) ? nativeCreate(prototype) : {};
|
425
|
+
}
|
426
|
+
// fallback for browsers without `Object.create`
|
427
|
+
if (!nativeCreate) {
|
428
|
+
baseCreate = (function() {
|
429
|
+
function Object() {}
|
430
|
+
return function(prototype) {
|
431
|
+
if (isObject(prototype)) {
|
432
|
+
Object.prototype = prototype;
|
433
|
+
var result = new Object;
|
434
|
+
Object.prototype = null;
|
435
|
+
}
|
436
|
+
return result || root.Object();
|
437
|
+
};
|
438
|
+
}());
|
439
|
+
}
|
440
|
+
|
374
441
|
/**
|
375
442
|
* The base implementation of `_.createCallback` without support for creating
|
376
443
|
* "_.pluck" or "_.where" style callbacks.
|
@@ -385,8 +452,8 @@
|
|
385
452
|
if (typeof func != 'function') {
|
386
453
|
return identity;
|
387
454
|
}
|
388
|
-
// exit early
|
389
|
-
if (typeof thisArg == 'undefined') {
|
455
|
+
// exit early for no `thisArg` or already bound by `Function#bind`
|
456
|
+
if (typeof thisArg == 'undefined' || !('prototype' in func)) {
|
390
457
|
return func;
|
391
458
|
}
|
392
459
|
switch (argCount) {
|
@@ -406,6 +473,82 @@
|
|
406
473
|
return bind(func, thisArg);
|
407
474
|
}
|
408
475
|
|
476
|
+
/**
|
477
|
+
* The base implementation of `createWrapper` that creates the wrapper and
|
478
|
+
* sets its meta data.
|
479
|
+
*
|
480
|
+
* @private
|
481
|
+
* @param {Array} bindData The bind data array.
|
482
|
+
* @returns {Function} Returns the new function.
|
483
|
+
*/
|
484
|
+
function baseCreateWrapper(bindData) {
|
485
|
+
var func = bindData[0],
|
486
|
+
bitmask = bindData[1],
|
487
|
+
partialArgs = bindData[2],
|
488
|
+
partialRightArgs = bindData[3],
|
489
|
+
thisArg = bindData[4],
|
490
|
+
arity = bindData[5];
|
491
|
+
|
492
|
+
var isBind = bitmask & 1,
|
493
|
+
isBindKey = bitmask & 2,
|
494
|
+
isCurry = bitmask & 4,
|
495
|
+
isCurryBound = bitmask & 8,
|
496
|
+
key = func;
|
497
|
+
|
498
|
+
function bound() {
|
499
|
+
var thisBinding = isBind ? thisArg : this;
|
500
|
+
if (partialArgs) {
|
501
|
+
var args = partialArgs.slice();
|
502
|
+
push.apply(args, arguments);
|
503
|
+
}
|
504
|
+
if (partialRightArgs || isCurry) {
|
505
|
+
args || (args = slice(arguments));
|
506
|
+
if (partialRightArgs) {
|
507
|
+
push.apply(args, partialRightArgs);
|
508
|
+
}
|
509
|
+
if (isCurry && args.length < arity) {
|
510
|
+
bitmask |= 16 & ~32;
|
511
|
+
return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]);
|
512
|
+
}
|
513
|
+
}
|
514
|
+
args || (args = arguments);
|
515
|
+
if (isBindKey) {
|
516
|
+
func = thisBinding[key];
|
517
|
+
}
|
518
|
+
if (this instanceof bound) {
|
519
|
+
thisBinding = baseCreate(func.prototype);
|
520
|
+
var result = func.apply(thisBinding, args);
|
521
|
+
return isObject(result) ? result : thisBinding;
|
522
|
+
}
|
523
|
+
return func.apply(thisBinding, args);
|
524
|
+
}
|
525
|
+
return bound;
|
526
|
+
}
|
527
|
+
|
528
|
+
/**
|
529
|
+
* The base implementation of `_.difference` that accepts a single array
|
530
|
+
* of values to exclude.
|
531
|
+
*
|
532
|
+
* @private
|
533
|
+
* @param {Array} array The array to process.
|
534
|
+
* @param {Array} [values] The array of values to exclude.
|
535
|
+
* @returns {Array} Returns a new array of filtered values.
|
536
|
+
*/
|
537
|
+
function baseDifference(array, values) {
|
538
|
+
var index = -1,
|
539
|
+
indexOf = getIndexOf(),
|
540
|
+
length = array ? array.length : 0,
|
541
|
+
result = [];
|
542
|
+
|
543
|
+
while (++index < length) {
|
544
|
+
var value = array[index];
|
545
|
+
if (indexOf(values, value) < 0) {
|
546
|
+
result.push(value);
|
547
|
+
}
|
548
|
+
}
|
549
|
+
return result;
|
550
|
+
}
|
551
|
+
|
409
552
|
/**
|
410
553
|
* The base implementation of `_.flatten` without support for callback
|
411
554
|
* shorthands or `thisArg` binding.
|
@@ -413,11 +556,11 @@
|
|
413
556
|
* @private
|
414
557
|
* @param {Array} array The array to flatten.
|
415
558
|
* @param {boolean} [isShallow=false] A flag to restrict flattening to a single level.
|
416
|
-
* @param {boolean} [
|
559
|
+
* @param {boolean} [isStrict=false] A flag to restrict flattening to arrays and `arguments` objects.
|
417
560
|
* @param {number} [fromIndex=0] The index to start from.
|
418
561
|
* @returns {Array} Returns a new flattened array.
|
419
562
|
*/
|
420
|
-
function baseFlatten(array, isShallow,
|
563
|
+
function baseFlatten(array, isShallow, isStrict, fromIndex) {
|
421
564
|
var index = (fromIndex || 0) - 1,
|
422
565
|
length = array ? array.length : 0,
|
423
566
|
result = [];
|
@@ -429,7 +572,7 @@
|
|
429
572
|
&& (isArray(value) || isArguments(value))) {
|
430
573
|
// recursively flatten arrays (susceptible to call stack limits)
|
431
574
|
if (!isShallow) {
|
432
|
-
value = baseFlatten(value, isShallow,
|
575
|
+
value = baseFlatten(value, isShallow, isStrict);
|
433
576
|
}
|
434
577
|
var valIndex = -1,
|
435
578
|
valLength = value.length,
|
@@ -439,7 +582,7 @@
|
|
439
582
|
while (++valIndex < valLength) {
|
440
583
|
result[resIndex++] = value[valIndex];
|
441
584
|
}
|
442
|
-
} else if (!
|
585
|
+
} else if (!isStrict) {
|
443
586
|
result.push(value);
|
444
587
|
}
|
445
588
|
}
|
@@ -496,8 +639,11 @@
|
|
496
639
|
}
|
497
640
|
var isArr = className == arrayClass;
|
498
641
|
if (!isArr) {
|
499
|
-
|
500
|
-
|
642
|
+
var aWrapped = a instanceof lodash,
|
643
|
+
bWrapped = b instanceof lodash;
|
644
|
+
|
645
|
+
if (aWrapped || bWrapped) {
|
646
|
+
return baseIsEqual(aWrapped ? a.__wrapped__ : a, bWrapped ? b.__wrapped__ : b, stackA, stackB);
|
501
647
|
}
|
502
648
|
if (className != objectClass) {
|
503
649
|
return false;
|
@@ -505,10 +651,10 @@
|
|
505
651
|
var ctorA = a.constructor,
|
506
652
|
ctorB = b.constructor;
|
507
653
|
|
508
|
-
if (ctorA != ctorB &&
|
509
|
-
isFunction(ctorA) && ctorA instanceof ctorA &&
|
510
|
-
|
511
|
-
)
|
654
|
+
if (ctorA != ctorB &&
|
655
|
+
!(isFunction(ctorA) && ctorA instanceof ctorA && isFunction(ctorB) && ctorB instanceof ctorB) &&
|
656
|
+
('constructor' in a && 'constructor' in b)
|
657
|
+
) {
|
512
658
|
return false;
|
513
659
|
}
|
514
660
|
}
|
@@ -557,6 +703,19 @@
|
|
557
703
|
return result;
|
558
704
|
}
|
559
705
|
|
706
|
+
/**
|
707
|
+
* The base implementation of `_.random` without argument juggling or support
|
708
|
+
* for returning floating-point numbers.
|
709
|
+
*
|
710
|
+
* @private
|
711
|
+
* @param {number} min The minimum possible value.
|
712
|
+
* @param {number} max The maximum possible value.
|
713
|
+
* @returns {number} Returns a random number.
|
714
|
+
*/
|
715
|
+
function baseRandom(min, max) {
|
716
|
+
return min + floor(nativeRandom() * (max - min + 1));
|
717
|
+
}
|
718
|
+
|
560
719
|
/**
|
561
720
|
* The base implementation of `_.uniq` without support for callback shorthands
|
562
721
|
* or `thisArg` binding.
|
@@ -643,16 +802,15 @@
|
|
643
802
|
* provided to the new function.
|
644
803
|
* @param {*} [thisArg] The `this` binding of `func`.
|
645
804
|
* @param {number} [arity] The arity of `func`.
|
646
|
-
* @returns {Function} Returns the new
|
805
|
+
* @returns {Function} Returns the new function.
|
647
806
|
*/
|
648
|
-
function
|
807
|
+
function createWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) {
|
649
808
|
var isBind = bitmask & 1,
|
650
809
|
isBindKey = bitmask & 2,
|
651
810
|
isCurry = bitmask & 4,
|
652
811
|
isCurryBound = bitmask & 8,
|
653
812
|
isPartial = bitmask & 16,
|
654
|
-
isPartialRight = bitmask & 32
|
655
|
-
key = func;
|
813
|
+
isPartialRight = bitmask & 32;
|
656
814
|
|
657
815
|
if (!isBindKey && !isFunction(func)) {
|
658
816
|
throw new TypeError;
|
@@ -665,76 +823,9 @@
|
|
665
823
|
bitmask &= ~32;
|
666
824
|
isPartialRight = partialRightArgs = false;
|
667
825
|
}
|
668
|
-
//
|
669
|
-
|
670
|
-
|
671
|
-
(support.fastBind || (nativeBind && isPartial))) {
|
672
|
-
if (isPartial) {
|
673
|
-
var args = [thisArg];
|
674
|
-
push.apply(args, partialArgs);
|
675
|
-
}
|
676
|
-
var bound = isPartial
|
677
|
-
? nativeBind.apply(func, args)
|
678
|
-
: nativeBind.call(func, thisArg);
|
679
|
-
}
|
680
|
-
else {
|
681
|
-
bound = function() {
|
682
|
-
// `Function#bind` spec
|
683
|
-
// http://es5.github.io/#x15.3.4.5
|
684
|
-
var args = arguments,
|
685
|
-
thisBinding = isBind ? thisArg : this;
|
686
|
-
|
687
|
-
if (isCurry || isPartial || isPartialRight) {
|
688
|
-
args = nativeSlice.call(args);
|
689
|
-
if (isPartial) {
|
690
|
-
unshift.apply(args, partialArgs);
|
691
|
-
}
|
692
|
-
if (isPartialRight) {
|
693
|
-
push.apply(args, partialRightArgs);
|
694
|
-
}
|
695
|
-
if (isCurry && args.length < arity) {
|
696
|
-
bitmask |= 16 & ~32;
|
697
|
-
return createBound(func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity);
|
698
|
-
}
|
699
|
-
}
|
700
|
-
if (isBindKey) {
|
701
|
-
func = thisBinding[key];
|
702
|
-
}
|
703
|
-
if (this instanceof bound) {
|
704
|
-
// ensure `new bound` is an instance of `func`
|
705
|
-
thisBinding = createObject(func.prototype);
|
706
|
-
|
707
|
-
// mimic the constructor's `return` behavior
|
708
|
-
// http://es5.github.io/#x13.2.2
|
709
|
-
var result = func.apply(thisBinding, args);
|
710
|
-
return isObject(result) ? result : thisBinding;
|
711
|
-
}
|
712
|
-
return func.apply(thisBinding, args);
|
713
|
-
};
|
714
|
-
}
|
715
|
-
return bound;
|
716
|
-
}
|
717
|
-
|
718
|
-
/**
|
719
|
-
* Creates a new object with the specified `prototype`.
|
720
|
-
*
|
721
|
-
* @private
|
722
|
-
* @param {Object} prototype The prototype object.
|
723
|
-
* @returns {Object} Returns the new object.
|
724
|
-
*/
|
725
|
-
function createObject(prototype) {
|
726
|
-
return isObject(prototype) ? nativeCreate(prototype) : {};
|
727
|
-
}
|
728
|
-
// fallback for browsers without `Object.create`
|
729
|
-
if (!nativeCreate) {
|
730
|
-
createObject = function(prototype) {
|
731
|
-
if (isObject(prototype)) {
|
732
|
-
noop.prototype = prototype;
|
733
|
-
var result = new noop;
|
734
|
-
noop.prototype = null;
|
735
|
-
}
|
736
|
-
return result || {};
|
737
|
-
};
|
826
|
+
// fast path for `_.bind`
|
827
|
+
var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper;
|
828
|
+
return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]);
|
738
829
|
}
|
739
830
|
|
740
831
|
/**
|
@@ -798,7 +889,7 @@
|
|
798
889
|
if (!isArguments(arguments)) {
|
799
890
|
isArguments = function(value) {
|
800
891
|
return value && typeof value == 'object' && typeof value.length == 'number' &&
|
801
|
-
hasOwnProperty.call(value, 'callee') || false;
|
892
|
+
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee') || false;
|
802
893
|
};
|
803
894
|
}
|
804
895
|
|
@@ -909,16 +1000,16 @@
|
|
909
1000
|
* @returns {Object} Returns the destination object.
|
910
1001
|
* @example
|
911
1002
|
*
|
912
|
-
* _.assign({ 'name': '
|
913
|
-
* // => { 'name': '
|
1003
|
+
* _.assign({ 'name': 'fred' }, { 'employer': 'slate' });
|
1004
|
+
* // => { 'name': 'fred', 'employer': 'slate' }
|
914
1005
|
*
|
915
1006
|
* var defaults = _.partialRight(_.assign, function(a, b) {
|
916
1007
|
* return typeof a == 'undefined' ? b : a;
|
917
1008
|
* });
|
918
1009
|
*
|
919
|
-
* var
|
920
|
-
* defaults(
|
921
|
-
* // => { 'name': '
|
1010
|
+
* var object = { 'name': 'barney' };
|
1011
|
+
* defaults(object, { 'name': 'fred', 'employer': 'slate' });
|
1012
|
+
* // => { 'name': 'barney', 'employer': 'slate' }
|
922
1013
|
*/
|
923
1014
|
function assign(object) {
|
924
1015
|
if (!object) {
|
@@ -936,7 +1027,7 @@
|
|
936
1027
|
}
|
937
1028
|
|
938
1029
|
/**
|
939
|
-
* Creates a clone of `value`. If `
|
1030
|
+
* Creates a clone of `value`. If `isDeep` is `true` nested objects will also
|
940
1031
|
* be cloned, otherwise they will be assigned by reference. If a callback
|
941
1032
|
* is provided it will be executed to produce the cloned values. If the
|
942
1033
|
* callback returns `undefined` cloning will be handled by the method instead.
|
@@ -946,23 +1037,23 @@
|
|
946
1037
|
* @memberOf _
|
947
1038
|
* @category Objects
|
948
1039
|
* @param {*} value The value to clone.
|
949
|
-
* @param {boolean} [
|
1040
|
+
* @param {boolean} [isDeep=false] Specify a deep clone.
|
950
1041
|
* @param {Function} [callback] The function to customize cloning values.
|
951
1042
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
952
1043
|
* @returns {*} Returns the cloned value.
|
953
1044
|
* @example
|
954
1045
|
*
|
955
|
-
* var
|
956
|
-
* { 'name': '
|
957
|
-
* { 'name': '
|
1046
|
+
* var characters = [
|
1047
|
+
* { 'name': 'barney', 'age': 36 },
|
1048
|
+
* { 'name': 'fred', 'age': 40 }
|
958
1049
|
* ];
|
959
1050
|
*
|
960
|
-
* var shallow = _.clone(
|
961
|
-
* shallow[0] ===
|
1051
|
+
* var shallow = _.clone(characters);
|
1052
|
+
* shallow[0] === characters[0];
|
962
1053
|
* // => true
|
963
1054
|
*
|
964
|
-
* var deep = _.clone(
|
965
|
-
* deep[0] ===
|
1055
|
+
* var deep = _.clone(characters, true);
|
1056
|
+
* deep[0] === characters[0];
|
966
1057
|
* // => false
|
967
1058
|
*
|
968
1059
|
* _.mixin({
|
@@ -977,7 +1068,7 @@
|
|
977
1068
|
*/
|
978
1069
|
function clone(value) {
|
979
1070
|
return isObject(value)
|
980
|
-
? (isArray(value) ?
|
1071
|
+
? (isArray(value) ? slice(value) : assign({}, value))
|
981
1072
|
: value;
|
982
1073
|
}
|
983
1074
|
|
@@ -997,9 +1088,9 @@
|
|
997
1088
|
* @returns {Object} Returns the destination object.
|
998
1089
|
* @example
|
999
1090
|
*
|
1000
|
-
* var
|
1001
|
-
* _.defaults(
|
1002
|
-
* // => { 'name': '
|
1091
|
+
* var object = { 'name': 'barney' };
|
1092
|
+
* _.defaults(object, { 'name': 'fred', 'employer': 'slate' });
|
1093
|
+
* // => { 'name': 'barney', 'employer': 'slate' }
|
1003
1094
|
*/
|
1004
1095
|
function defaults(object) {
|
1005
1096
|
if (!object) {
|
@@ -1034,18 +1125,20 @@
|
|
1034
1125
|
* @returns {Object} Returns `object`.
|
1035
1126
|
* @example
|
1036
1127
|
*
|
1037
|
-
* function
|
1038
|
-
* this.
|
1128
|
+
* function Shape() {
|
1129
|
+
* this.x = 0;
|
1130
|
+
* this.y = 0;
|
1039
1131
|
* }
|
1040
1132
|
*
|
1041
|
-
*
|
1042
|
-
*
|
1133
|
+
* Shape.prototype.move = function(x, y) {
|
1134
|
+
* this.x += x;
|
1135
|
+
* this.y += y;
|
1043
1136
|
* };
|
1044
1137
|
*
|
1045
|
-
* _.forIn(new
|
1138
|
+
* _.forIn(new Shape, function(value, key) {
|
1046
1139
|
* console.log(key);
|
1047
1140
|
* });
|
1048
|
-
* // => logs '
|
1141
|
+
* // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments)
|
1049
1142
|
*/
|
1050
1143
|
var forIn = function(collection, callback) {
|
1051
1144
|
var index, iterable = collection, result = iterable;
|
@@ -1144,8 +1237,8 @@
|
|
1144
1237
|
* @returns {Object} Returns the created inverted object.
|
1145
1238
|
* @example
|
1146
1239
|
*
|
1147
|
-
* _.invert({ 'first': '
|
1148
|
-
* // => { '
|
1240
|
+
* _.invert({ 'first': 'fred', 'second': 'barney' });
|
1241
|
+
* // => { 'fred': 'first', 'barney': 'second' }
|
1149
1242
|
*/
|
1150
1243
|
function invert(object) {
|
1151
1244
|
var index = -1,
|
@@ -1174,7 +1267,8 @@
|
|
1174
1267
|
* // => false
|
1175
1268
|
*/
|
1176
1269
|
function isBoolean(value) {
|
1177
|
-
return value === true || value === false ||
|
1270
|
+
return value === true || value === false ||
|
1271
|
+
value && typeof value == 'object' && toString.call(value) == boolClass || false;
|
1178
1272
|
}
|
1179
1273
|
|
1180
1274
|
/**
|
@@ -1191,7 +1285,7 @@
|
|
1191
1285
|
* // => true
|
1192
1286
|
*/
|
1193
1287
|
function isDate(value) {
|
1194
|
-
return value
|
1288
|
+
return value && typeof value == 'object' && toString.call(value) == dateClass || false;
|
1195
1289
|
}
|
1196
1290
|
|
1197
1291
|
/**
|
@@ -1208,7 +1302,7 @@
|
|
1208
1302
|
* // => true
|
1209
1303
|
*/
|
1210
1304
|
function isElement(value) {
|
1211
|
-
return value
|
1305
|
+
return value && value.nodeType === 1 || false;
|
1212
1306
|
}
|
1213
1307
|
|
1214
1308
|
/**
|
@@ -1264,13 +1358,13 @@
|
|
1264
1358
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
1265
1359
|
* @example
|
1266
1360
|
*
|
1267
|
-
* var
|
1268
|
-
* var copy = { 'name': '
|
1361
|
+
* var object = { 'name': 'fred' };
|
1362
|
+
* var copy = { 'name': 'fred' };
|
1269
1363
|
*
|
1270
|
-
*
|
1364
|
+
* object == copy;
|
1271
1365
|
* // => false
|
1272
1366
|
*
|
1273
|
-
* _.isEqual(
|
1367
|
+
* _.isEqual(object, copy);
|
1274
1368
|
* // => true
|
1275
1369
|
*
|
1276
1370
|
* var words = ['hello', 'goodbye'];
|
@@ -1439,7 +1533,8 @@
|
|
1439
1533
|
* // => true
|
1440
1534
|
*/
|
1441
1535
|
function isNumber(value) {
|
1442
|
-
return typeof value == 'number' ||
|
1536
|
+
return typeof value == 'number' ||
|
1537
|
+
value && typeof value == 'object' && toString.call(value) == numberClass || false;
|
1443
1538
|
}
|
1444
1539
|
|
1445
1540
|
/**
|
@@ -1452,11 +1547,11 @@
|
|
1452
1547
|
* @returns {boolean} Returns `true` if the `value` is a regular expression, else `false`.
|
1453
1548
|
* @example
|
1454
1549
|
*
|
1455
|
-
* _.isRegExp(/
|
1550
|
+
* _.isRegExp(/fred/);
|
1456
1551
|
* // => true
|
1457
1552
|
*/
|
1458
1553
|
function isRegExp(value) {
|
1459
|
-
return
|
1554
|
+
return value && objectTypes[typeof value] && toString.call(value) == regexpClass || false;
|
1460
1555
|
}
|
1461
1556
|
|
1462
1557
|
/**
|
@@ -1469,11 +1564,12 @@
|
|
1469
1564
|
* @returns {boolean} Returns `true` if the `value` is a string, else `false`.
|
1470
1565
|
* @example
|
1471
1566
|
*
|
1472
|
-
* _.isString('
|
1567
|
+
* _.isString('fred');
|
1473
1568
|
* // => true
|
1474
1569
|
*/
|
1475
1570
|
function isString(value) {
|
1476
|
-
return typeof value == 'string' ||
|
1571
|
+
return typeof value == 'string' ||
|
1572
|
+
value && typeof value == 'object' && toString.call(value) == stringClass || false;
|
1477
1573
|
}
|
1478
1574
|
|
1479
1575
|
/**
|
@@ -1511,24 +1607,29 @@
|
|
1511
1607
|
* @returns {Object} Returns an object without the omitted properties.
|
1512
1608
|
* @example
|
1513
1609
|
*
|
1514
|
-
* _.omit({ 'name': '
|
1515
|
-
* // => { 'name': '
|
1610
|
+
* _.omit({ 'name': 'fred', 'age': 40 }, 'age');
|
1611
|
+
* // => { 'name': 'fred' }
|
1516
1612
|
*
|
1517
|
-
* _.omit({ 'name': '
|
1613
|
+
* _.omit({ 'name': 'fred', 'age': 40 }, function(value) {
|
1518
1614
|
* return typeof value == 'number';
|
1519
1615
|
* });
|
1520
|
-
* // => { 'name': '
|
1616
|
+
* // => { 'name': 'fred' }
|
1521
1617
|
*/
|
1522
1618
|
function omit(object) {
|
1523
|
-
var
|
1524
|
-
props = baseFlatten(arguments, true, false, 1),
|
1525
|
-
result = {};
|
1526
|
-
|
1619
|
+
var props = [];
|
1527
1620
|
forIn(object, function(value, key) {
|
1528
|
-
|
1529
|
-
result[key] = value;
|
1530
|
-
}
|
1621
|
+
props.push(key);
|
1531
1622
|
});
|
1623
|
+
props = baseDifference(props, baseFlatten(arguments, true, false, 1));
|
1624
|
+
|
1625
|
+
var index = -1,
|
1626
|
+
length = props.length,
|
1627
|
+
result = {};
|
1628
|
+
|
1629
|
+
while (++index < length) {
|
1630
|
+
var key = props[index];
|
1631
|
+
result[key] = object[key];
|
1632
|
+
}
|
1532
1633
|
return result;
|
1533
1634
|
}
|
1534
1635
|
|
@@ -1543,8 +1644,8 @@
|
|
1543
1644
|
* @returns {Array} Returns new array of key-value pairs.
|
1544
1645
|
* @example
|
1545
1646
|
*
|
1546
|
-
* _.pairs({ '
|
1547
|
-
* // => [['
|
1647
|
+
* _.pairs({ 'barney': 36, 'fred': 40 });
|
1648
|
+
* // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments)
|
1548
1649
|
*/
|
1549
1650
|
function pairs(object) {
|
1550
1651
|
var index = -1,
|
@@ -1578,13 +1679,13 @@
|
|
1578
1679
|
* @returns {Object} Returns an object composed of the picked properties.
|
1579
1680
|
* @example
|
1580
1681
|
*
|
1581
|
-
* _.pick({ 'name': '
|
1582
|
-
* // => { 'name': '
|
1682
|
+
* _.pick({ 'name': 'fred', '_userid': 'fred1' }, 'name');
|
1683
|
+
* // => { 'name': 'fred' }
|
1583
1684
|
*
|
1584
|
-
* _.pick({ 'name': '
|
1685
|
+
* _.pick({ 'name': 'fred', '_userid': 'fred1' }, function(value, key) {
|
1585
1686
|
* return key.charAt(0) != '_';
|
1586
1687
|
* });
|
1587
|
-
* // => { 'name': '
|
1688
|
+
* // => { 'name': 'fred' }
|
1588
1689
|
*/
|
1589
1690
|
function pick(object) {
|
1590
1691
|
var index = -1,
|
@@ -1593,9 +1694,9 @@
|
|
1593
1694
|
result = {};
|
1594
1695
|
|
1595
1696
|
while (++index < length) {
|
1596
|
-
var
|
1597
|
-
if (
|
1598
|
-
result[
|
1697
|
+
var key = props[index];
|
1698
|
+
if (key in object) {
|
1699
|
+
result[key] = object[key];
|
1599
1700
|
}
|
1600
1701
|
}
|
1601
1702
|
return result;
|
@@ -1649,10 +1750,10 @@
|
|
1649
1750
|
* _.contains([1, 2, 3], 1, 2);
|
1650
1751
|
* // => false
|
1651
1752
|
*
|
1652
|
-
* _.contains({ 'name': '
|
1753
|
+
* _.contains({ 'name': 'fred', 'age': 40 }, 'fred');
|
1653
1754
|
* // => true
|
1654
1755
|
*
|
1655
|
-
* _.contains('
|
1756
|
+
* _.contains('pebbles', 'eb');
|
1656
1757
|
* // => true
|
1657
1758
|
*/
|
1658
1759
|
function contains(collection, target) {
|
@@ -1732,20 +1833,20 @@
|
|
1732
1833
|
* else `false`.
|
1733
1834
|
* @example
|
1734
1835
|
*
|
1735
|
-
* _.every([true, 1, null, 'yes']
|
1836
|
+
* _.every([true, 1, null, 'yes']);
|
1736
1837
|
* // => false
|
1737
1838
|
*
|
1738
|
-
* var
|
1739
|
-
* { 'name': '
|
1740
|
-
* { 'name': '
|
1839
|
+
* var characters = [
|
1840
|
+
* { 'name': 'barney', 'age': 36 },
|
1841
|
+
* { 'name': 'fred', 'age': 40 }
|
1741
1842
|
* ];
|
1742
1843
|
*
|
1743
1844
|
* // using "_.pluck" callback shorthand
|
1744
|
-
* _.every(
|
1845
|
+
* _.every(characters, 'age');
|
1745
1846
|
* // => true
|
1746
1847
|
*
|
1747
1848
|
* // using "_.where" callback shorthand
|
1748
|
-
* _.every(
|
1849
|
+
* _.every(characters, { 'age': 36 });
|
1749
1850
|
* // => false
|
1750
1851
|
*/
|
1751
1852
|
function every(collection, callback, thisArg) {
|
@@ -1796,18 +1897,18 @@
|
|
1796
1897
|
* var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
1797
1898
|
* // => [2, 4, 6]
|
1798
1899
|
*
|
1799
|
-
* var
|
1800
|
-
* { 'name': '
|
1801
|
-
* { 'name': '
|
1900
|
+
* var characters = [
|
1901
|
+
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
1902
|
+
* { 'name': 'fred', 'age': 40, 'blocked': true }
|
1802
1903
|
* ];
|
1803
1904
|
*
|
1804
1905
|
* // using "_.pluck" callback shorthand
|
1805
|
-
* _.filter(
|
1806
|
-
* // => [{ 'name': '
|
1906
|
+
* _.filter(characters, 'blocked');
|
1907
|
+
* // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
|
1807
1908
|
*
|
1808
1909
|
* // using "_.where" callback shorthand
|
1809
|
-
* _.filter(
|
1810
|
-
* // => [{ 'name': '
|
1910
|
+
* _.filter(characters, { 'age': 36 });
|
1911
|
+
* // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
|
1811
1912
|
*/
|
1812
1913
|
function filter(collection, callback, thisArg) {
|
1813
1914
|
var result = [];
|
@@ -1857,24 +1958,24 @@
|
|
1857
1958
|
* @returns {*} Returns the found element, else `undefined`.
|
1858
1959
|
* @example
|
1859
1960
|
*
|
1860
|
-
*
|
1861
|
-
*
|
1862
|
-
* }
|
1863
|
-
*
|
1864
|
-
*
|
1865
|
-
* var food = [
|
1866
|
-
* { 'name': 'apple', 'organic': false, 'type': 'fruit' },
|
1867
|
-
* { 'name': 'banana', 'organic': true, 'type': 'fruit' },
|
1868
|
-
* { 'name': 'beet', 'organic': false, 'type': 'vegetable' }
|
1961
|
+
* var characters = [
|
1962
|
+
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
1963
|
+
* { 'name': 'fred', 'age': 40, 'blocked': true },
|
1964
|
+
* { 'name': 'pebbles', 'age': 1, 'blocked': false }
|
1869
1965
|
* ];
|
1870
1966
|
*
|
1967
|
+
* _.find(characters, function(chr) {
|
1968
|
+
* return chr.age < 40;
|
1969
|
+
* });
|
1970
|
+
* // => { 'name': 'barney', 'age': 36, 'blocked': false }
|
1971
|
+
*
|
1871
1972
|
* // using "_.where" callback shorthand
|
1872
|
-
* _.find(
|
1873
|
-
* // =>
|
1973
|
+
* _.find(characters, { 'age': 1 });
|
1974
|
+
* // => { 'name': 'pebbles', 'age': 1, 'blocked': false }
|
1874
1975
|
*
|
1875
1976
|
* // using "_.pluck" callback shorthand
|
1876
|
-
* _.find(
|
1877
|
-
* // => { 'name': '
|
1977
|
+
* _.find(characters, 'blocked');
|
1978
|
+
* // => { 'name': 'fred', 'age': 40, 'blocked': true }
|
1878
1979
|
*/
|
1879
1980
|
function find(collection, callback, thisArg) {
|
1880
1981
|
callback = createCallback(callback, thisArg, 3);
|
@@ -1934,6 +2035,10 @@
|
|
1934
2035
|
* (value, index|key, collection). Callbacks may exit iteration early by
|
1935
2036
|
* explicitly returning `false`.
|
1936
2037
|
*
|
2038
|
+
* Note: As with other "Collections" methods, objects with a `length` property
|
2039
|
+
* are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
|
2040
|
+
* may be used for object iteration.
|
2041
|
+
*
|
1937
2042
|
* @static
|
1938
2043
|
* @memberOf _
|
1939
2044
|
* @alias each
|
@@ -2076,7 +2181,7 @@
|
|
2076
2181
|
* _.indexBy(keys, function(key) { return String.fromCharCode(key.code); });
|
2077
2182
|
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
|
2078
2183
|
*
|
2079
|
-
* _.indexBy(
|
2184
|
+
* _.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String);
|
2080
2185
|
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
|
2081
2186
|
*/
|
2082
2187
|
var indexBy = createAggregator(function(result, value, key) {
|
@@ -2106,7 +2211,7 @@
|
|
2106
2211
|
* // => [['1', '2', '3'], ['4', '5', '6']]
|
2107
2212
|
*/
|
2108
2213
|
function invoke(collection, methodName) {
|
2109
|
-
var args =
|
2214
|
+
var args = slice(arguments, 2),
|
2110
2215
|
index = -1,
|
2111
2216
|
isFunc = typeof methodName == 'function',
|
2112
2217
|
length = collection ? collection.length : 0,
|
@@ -2148,14 +2253,14 @@
|
|
2148
2253
|
* _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
|
2149
2254
|
* // => [3, 6, 9] (property order is not guaranteed across environments)
|
2150
2255
|
*
|
2151
|
-
* var
|
2152
|
-
* { 'name': '
|
2153
|
-
* { 'name': '
|
2256
|
+
* var characters = [
|
2257
|
+
* { 'name': 'barney', 'age': 36 },
|
2258
|
+
* { 'name': 'fred', 'age': 40 }
|
2154
2259
|
* ];
|
2155
2260
|
*
|
2156
2261
|
* // using "_.pluck" callback shorthand
|
2157
|
-
* _.map(
|
2158
|
-
* // => ['
|
2262
|
+
* _.map(characters, 'name');
|
2263
|
+
* // => ['barney', 'fred']
|
2159
2264
|
*/
|
2160
2265
|
function map(collection, callback, thisArg) {
|
2161
2266
|
var index = -1,
|
@@ -2204,26 +2309,31 @@
|
|
2204
2309
|
* _.max([4, 2, 8, 6]);
|
2205
2310
|
* // => 8
|
2206
2311
|
*
|
2207
|
-
* var
|
2208
|
-
* { 'name': '
|
2209
|
-
* { 'name': '
|
2312
|
+
* var characters = [
|
2313
|
+
* { 'name': 'barney', 'age': 36 },
|
2314
|
+
* { 'name': 'fred', 'age': 40 }
|
2210
2315
|
* ];
|
2211
2316
|
*
|
2212
|
-
* _.max(
|
2213
|
-
* // => { 'name': '
|
2317
|
+
* _.max(characters, function(chr) { return chr.age; });
|
2318
|
+
* // => { 'name': 'fred', 'age': 40 };
|
2214
2319
|
*
|
2215
2320
|
* // using "_.pluck" callback shorthand
|
2216
|
-
* _.max(
|
2217
|
-
* // => { 'name': '
|
2321
|
+
* _.max(characters, 'age');
|
2322
|
+
* // => { 'name': 'fred', 'age': 40 };
|
2218
2323
|
*/
|
2219
2324
|
function max(collection, callback, thisArg) {
|
2220
2325
|
var computed = -Infinity,
|
2221
2326
|
result = computed;
|
2222
2327
|
|
2328
|
+
// allows working with functions like `_.map` without using
|
2329
|
+
// their `index` argument as a callback
|
2330
|
+
if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) {
|
2331
|
+
callback = null;
|
2332
|
+
}
|
2223
2333
|
var index = -1,
|
2224
2334
|
length = collection ? collection.length : 0;
|
2225
2335
|
|
2226
|
-
if (
|
2336
|
+
if (callback == null && typeof length == 'number') {
|
2227
2337
|
while (++index < length) {
|
2228
2338
|
var value = collection[index];
|
2229
2339
|
if (value > result) {
|
@@ -2272,26 +2382,31 @@
|
|
2272
2382
|
* _.min([4, 2, 8, 6]);
|
2273
2383
|
* // => 2
|
2274
2384
|
*
|
2275
|
-
* var
|
2276
|
-
* { 'name': '
|
2277
|
-
* { 'name': '
|
2385
|
+
* var characters = [
|
2386
|
+
* { 'name': 'barney', 'age': 36 },
|
2387
|
+
* { 'name': 'fred', 'age': 40 }
|
2278
2388
|
* ];
|
2279
2389
|
*
|
2280
|
-
* _.min(
|
2281
|
-
* // => { 'name': '
|
2390
|
+
* _.min(characters, function(chr) { return chr.age; });
|
2391
|
+
* // => { 'name': 'barney', 'age': 36 };
|
2282
2392
|
*
|
2283
2393
|
* // using "_.pluck" callback shorthand
|
2284
|
-
* _.min(
|
2285
|
-
* // => { 'name': '
|
2394
|
+
* _.min(characters, 'age');
|
2395
|
+
* // => { 'name': 'barney', 'age': 36 };
|
2286
2396
|
*/
|
2287
2397
|
function min(collection, callback, thisArg) {
|
2288
2398
|
var computed = Infinity,
|
2289
2399
|
result = computed;
|
2290
2400
|
|
2401
|
+
// allows working with functions like `_.map` without using
|
2402
|
+
// their `index` argument as a callback
|
2403
|
+
if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) {
|
2404
|
+
callback = null;
|
2405
|
+
}
|
2291
2406
|
var index = -1,
|
2292
2407
|
length = collection ? collection.length : 0;
|
2293
2408
|
|
2294
|
-
if (
|
2409
|
+
if (callback == null && typeof length == 'number') {
|
2295
2410
|
while (++index < length) {
|
2296
2411
|
var value = collection[index];
|
2297
2412
|
if (value < result) {
|
@@ -2313,7 +2428,7 @@
|
|
2313
2428
|
}
|
2314
2429
|
|
2315
2430
|
/**
|
2316
|
-
* Retrieves the value of a specified property from all elements in the
|
2431
|
+
* Retrieves the value of a specified property from all elements in the collection.
|
2317
2432
|
*
|
2318
2433
|
* @static
|
2319
2434
|
* @memberOf _
|
@@ -2324,13 +2439,13 @@
|
|
2324
2439
|
* @returns {Array} Returns a new array of property values.
|
2325
2440
|
* @example
|
2326
2441
|
*
|
2327
|
-
* var
|
2328
|
-
* { 'name': '
|
2329
|
-
* { 'name': '
|
2442
|
+
* var characters = [
|
2443
|
+
* { 'name': 'barney', 'age': 36 },
|
2444
|
+
* { 'name': 'fred', 'age': 40 }
|
2330
2445
|
* ];
|
2331
2446
|
*
|
2332
|
-
* _.pluck(
|
2333
|
-
* // => ['
|
2447
|
+
* _.pluck(characters, 'name');
|
2448
|
+
* // => ['barney', 'fred']
|
2334
2449
|
*/
|
2335
2450
|
function pluck(collection, property) {
|
2336
2451
|
var index = -1,
|
@@ -2378,7 +2493,7 @@
|
|
2378
2493
|
function reduce(collection, callback, accumulator, thisArg) {
|
2379
2494
|
if (!collection) return accumulator;
|
2380
2495
|
var noaccum = arguments.length < 3;
|
2381
|
-
callback =
|
2496
|
+
callback = createCallback(callback, thisArg, 4);
|
2382
2497
|
|
2383
2498
|
var index = -1,
|
2384
2499
|
length = collection.length;
|
@@ -2421,7 +2536,7 @@
|
|
2421
2536
|
*/
|
2422
2537
|
function reduceRight(collection, callback, accumulator, thisArg) {
|
2423
2538
|
var noaccum = arguments.length < 3;
|
2424
|
-
callback =
|
2539
|
+
callback = createCallback(callback, thisArg, 4);
|
2425
2540
|
forEachRight(collection, function(value, index, collection) {
|
2426
2541
|
accumulator = noaccum
|
2427
2542
|
? (noaccum = false, value)
|
@@ -2455,18 +2570,18 @@
|
|
2455
2570
|
* var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
2456
2571
|
* // => [1, 3, 5]
|
2457
2572
|
*
|
2458
|
-
* var
|
2459
|
-
* { 'name': '
|
2460
|
-
* { 'name': '
|
2573
|
+
* var characters = [
|
2574
|
+
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
2575
|
+
* { 'name': 'fred', 'age': 40, 'blocked': true }
|
2461
2576
|
* ];
|
2462
2577
|
*
|
2463
2578
|
* // using "_.pluck" callback shorthand
|
2464
|
-
* _.reject(
|
2465
|
-
* // => [{ 'name': '
|
2579
|
+
* _.reject(characters, 'blocked');
|
2580
|
+
* // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
|
2466
2581
|
*
|
2467
2582
|
* // using "_.where" callback shorthand
|
2468
|
-
* _.reject(
|
2469
|
-
* // => [{ 'name': '
|
2583
|
+
* _.reject(characters, { 'age': 36 });
|
2584
|
+
* // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
|
2470
2585
|
*/
|
2471
2586
|
function reject(collection, callback, thisArg) {
|
2472
2587
|
callback = createCallback(callback, thisArg, 3);
|
@@ -2483,8 +2598,8 @@
|
|
2483
2598
|
* @category Collections
|
2484
2599
|
* @param {Array|Object|string} collection The collection to sample.
|
2485
2600
|
* @param {number} [n] The number of elements to sample.
|
2486
|
-
* @param- {Object} [guard] Allows working with functions
|
2487
|
-
* without using their `
|
2601
|
+
* @param- {Object} [guard] Allows working with functions like `_.map`
|
2602
|
+
* without using their `index` arguments as `n`.
|
2488
2603
|
* @returns {Array} Returns the random sample(s) of `collection`.
|
2489
2604
|
* @example
|
2490
2605
|
*
|
@@ -2495,12 +2610,11 @@
|
|
2495
2610
|
* // => [3, 1]
|
2496
2611
|
*/
|
2497
2612
|
function sample(collection, n, guard) {
|
2498
|
-
|
2499
|
-
if (typeof length != 'number') {
|
2613
|
+
if (collection && typeof collection.length != 'number') {
|
2500
2614
|
collection = values(collection);
|
2501
2615
|
}
|
2502
2616
|
if (n == null || guard) {
|
2503
|
-
return collection ? collection[
|
2617
|
+
return collection ? collection[baseRandom(0, collection.length - 1)] : undefined;
|
2504
2618
|
}
|
2505
2619
|
var result = shuffle(collection);
|
2506
2620
|
result.length = nativeMin(nativeMax(0, n), result.length);
|
@@ -2527,7 +2641,7 @@
|
|
2527
2641
|
result = Array(typeof length == 'number' ? length : 0);
|
2528
2642
|
|
2529
2643
|
forEach(collection, function(value) {
|
2530
|
-
var rand =
|
2644
|
+
var rand = baseRandom(0, ++index);
|
2531
2645
|
result[index] = result[rand];
|
2532
2646
|
result[rand] = value;
|
2533
2647
|
});
|
@@ -2551,7 +2665,7 @@
|
|
2551
2665
|
* _.size({ 'one': 1, 'two': 2, 'three': 3 });
|
2552
2666
|
* // => 3
|
2553
2667
|
*
|
2554
|
-
* _.size('
|
2668
|
+
* _.size('pebbles');
|
2555
2669
|
* // => 5
|
2556
2670
|
*/
|
2557
2671
|
function size(collection) {
|
@@ -2588,17 +2702,17 @@
|
|
2588
2702
|
* _.some([null, 0, 'yes', false], Boolean);
|
2589
2703
|
* // => true
|
2590
2704
|
*
|
2591
|
-
* var
|
2592
|
-
* { 'name': '
|
2593
|
-
* { 'name': '
|
2705
|
+
* var characters = [
|
2706
|
+
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
2707
|
+
* { 'name': 'fred', 'age': 40, 'blocked': true }
|
2594
2708
|
* ];
|
2595
2709
|
*
|
2596
2710
|
* // using "_.pluck" callback shorthand
|
2597
|
-
* _.some(
|
2711
|
+
* _.some(characters, 'blocked');
|
2598
2712
|
* // => true
|
2599
2713
|
*
|
2600
2714
|
* // using "_.where" callback shorthand
|
2601
|
-
* _.some(
|
2715
|
+
* _.some(characters, { 'age': 1 });
|
2602
2716
|
* // => false
|
2603
2717
|
*/
|
2604
2718
|
function some(collection, callback, thisArg) {
|
@@ -2694,7 +2808,7 @@
|
|
2694
2808
|
*/
|
2695
2809
|
function toArray(collection) {
|
2696
2810
|
if (isArray(collection)) {
|
2697
|
-
return
|
2811
|
+
return slice(collection);
|
2698
2812
|
}
|
2699
2813
|
if (collection && typeof collection.length == 'number') {
|
2700
2814
|
return map(collection);
|
@@ -2716,16 +2830,16 @@
|
|
2716
2830
|
* @returns {Array} Returns a new array of elements that have the given properties.
|
2717
2831
|
* @example
|
2718
2832
|
*
|
2719
|
-
* var
|
2720
|
-
* { 'name': '
|
2721
|
-
* { 'name': '
|
2833
|
+
* var characters = [
|
2834
|
+
* { 'name': 'barney', 'age': 36, 'pets': ['hoppy'] },
|
2835
|
+
* { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }
|
2722
2836
|
* ];
|
2723
2837
|
*
|
2724
|
-
* _.where(
|
2725
|
-
* // => [{ 'name': '
|
2838
|
+
* _.where(characters, { 'age': 36 });
|
2839
|
+
* // => [{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }]
|
2726
2840
|
*
|
2727
|
-
* _.where(
|
2728
|
-
* // => [{ 'name': '
|
2841
|
+
* _.where(characters, { 'pets': ['dino'] });
|
2842
|
+
* // => [{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }]
|
2729
2843
|
*/
|
2730
2844
|
function where(collection, properties, first) {
|
2731
2845
|
return (first && isEmpty(properties))
|
@@ -2771,7 +2885,7 @@
|
|
2771
2885
|
* @memberOf _
|
2772
2886
|
* @category Arrays
|
2773
2887
|
* @param {Array} array The array to process.
|
2774
|
-
* @param {...Array} [
|
2888
|
+
* @param {...Array} [values] The arrays of values to exclude.
|
2775
2889
|
* @returns {Array} Returns a new array of filtered values.
|
2776
2890
|
* @example
|
2777
2891
|
*
|
@@ -2779,19 +2893,7 @@
|
|
2779
2893
|
* // => [1, 3, 4]
|
2780
2894
|
*/
|
2781
2895
|
function difference(array) {
|
2782
|
-
|
2783
|
-
indexOf = getIndexOf(),
|
2784
|
-
length = array.length,
|
2785
|
-
flattened = baseFlatten(arguments, true, true, 1),
|
2786
|
-
result = [];
|
2787
|
-
|
2788
|
-
while (++index < length) {
|
2789
|
-
var value = array[index];
|
2790
|
-
if (indexOf(flattened, value) < 0) {
|
2791
|
-
result.push(value);
|
2792
|
-
}
|
2793
|
-
}
|
2794
|
-
return result;
|
2896
|
+
return baseDifference(array, baseFlatten(arguments, true, true, 1));
|
2795
2897
|
}
|
2796
2898
|
|
2797
2899
|
/**
|
@@ -2831,24 +2933,19 @@
|
|
2831
2933
|
* });
|
2832
2934
|
* // => [1, 2]
|
2833
2935
|
*
|
2834
|
-
* var
|
2835
|
-
* { 'name': '
|
2836
|
-
* { 'name': '
|
2936
|
+
* var characters = [
|
2937
|
+
* { 'name': 'barney', 'blocked': true, 'employer': 'slate' },
|
2938
|
+
* { 'name': 'fred', 'blocked': false, 'employer': 'slate' },
|
2939
|
+
* { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
|
2837
2940
|
* ];
|
2838
2941
|
*
|
2839
2942
|
* // using "_.pluck" callback shorthand
|
2840
|
-
* _.first(
|
2841
|
-
* // => [{ 'name': '
|
2842
|
-
*
|
2843
|
-
* var food = [
|
2844
|
-
* { 'name': 'apple', 'type': 'fruit' },
|
2845
|
-
* { 'name': 'banana', 'type': 'fruit' },
|
2846
|
-
* { 'name': 'beet', 'type': 'vegetable' }
|
2847
|
-
* ];
|
2943
|
+
* _.first(characters, 'blocked');
|
2944
|
+
* // => [{ 'name': 'barney', 'blocked': true, 'employer': 'slate' }]
|
2848
2945
|
*
|
2849
2946
|
* // using "_.where" callback shorthand
|
2850
|
-
* _.first(
|
2851
|
-
* // => [
|
2947
|
+
* _.pluck(_.first(characters, { 'employer': 'slate' }), 'name');
|
2948
|
+
* // => ['barney', 'fred']
|
2852
2949
|
*/
|
2853
2950
|
function first(array, callback, thisArg) {
|
2854
2951
|
var n = 0,
|
@@ -2866,7 +2963,7 @@
|
|
2866
2963
|
return array ? array[0] : undefined;
|
2867
2964
|
}
|
2868
2965
|
}
|
2869
|
-
return
|
2966
|
+
return slice(array, 0, nativeMin(nativeMax(0, n), length));
|
2870
2967
|
}
|
2871
2968
|
|
2872
2969
|
/**
|
@@ -2901,14 +2998,14 @@
|
|
2901
2998
|
* _.flatten([1, [2], [3, [[4]]]], true);
|
2902
2999
|
* // => [1, 2, 3, [[4]]];
|
2903
3000
|
*
|
2904
|
-
* var
|
2905
|
-
* { 'name': '
|
2906
|
-
* { 'name': '
|
3001
|
+
* var characters = [
|
3002
|
+
* { 'name': 'barney', 'age': 30, 'pets': ['hoppy'] },
|
3003
|
+
* { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }
|
2907
3004
|
* ];
|
2908
3005
|
*
|
2909
3006
|
* // using "_.pluck" callback shorthand
|
2910
|
-
* _.flatten(
|
2911
|
-
* // => ['
|
3007
|
+
* _.flatten(characters, 'pets');
|
3008
|
+
* // => ['hoppy', 'baby puss', 'dino']
|
2912
3009
|
*/
|
2913
3010
|
function flatten(array, isShallow) {
|
2914
3011
|
return baseFlatten(array, isShallow);
|
@@ -2985,24 +3082,19 @@
|
|
2985
3082
|
* });
|
2986
3083
|
* // => [1]
|
2987
3084
|
*
|
2988
|
-
* var
|
2989
|
-
* { 'name': '
|
2990
|
-
* { 'name': '
|
3085
|
+
* var characters = [
|
3086
|
+
* { 'name': 'barney', 'blocked': false, 'employer': 'slate' },
|
3087
|
+
* { 'name': 'fred', 'blocked': true, 'employer': 'slate' },
|
3088
|
+
* { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
|
2991
3089
|
* ];
|
2992
3090
|
*
|
2993
3091
|
* // using "_.pluck" callback shorthand
|
2994
|
-
* _.initial(
|
2995
|
-
* // => [{ 'name': '
|
2996
|
-
*
|
2997
|
-
* var food = [
|
2998
|
-
* { 'name': 'banana', 'type': 'fruit' },
|
2999
|
-
* { 'name': 'beet', 'type': 'vegetable' },
|
3000
|
-
* { 'name': 'carrot', 'type': 'vegetable' }
|
3001
|
-
* ];
|
3092
|
+
* _.initial(characters, 'blocked');
|
3093
|
+
* // => [{ 'name': 'barney', 'blocked': false, 'employer': 'slate' }]
|
3002
3094
|
*
|
3003
3095
|
* // using "_.where" callback shorthand
|
3004
|
-
* _.initial(
|
3005
|
-
* // => [
|
3096
|
+
* _.pluck(_.initial(characters, { 'employer': 'na' }), 'name');
|
3097
|
+
* // => ['barney', 'fred']
|
3006
3098
|
*/
|
3007
3099
|
function initial(array, callback, thisArg) {
|
3008
3100
|
var n = 0,
|
@@ -3017,7 +3109,7 @@
|
|
3017
3109
|
} else {
|
3018
3110
|
n = (callback == null || thisArg) ? 1 : callback || n;
|
3019
3111
|
}
|
3020
|
-
return
|
3112
|
+
return slice(array, 0, nativeMin(nativeMax(0, length - n), length));
|
3021
3113
|
}
|
3022
3114
|
|
3023
3115
|
/**
|
@@ -3094,24 +3186,19 @@
|
|
3094
3186
|
* });
|
3095
3187
|
* // => [2, 3]
|
3096
3188
|
*
|
3097
|
-
* var
|
3098
|
-
* { 'name': '
|
3099
|
-
* { 'name': '
|
3189
|
+
* var characters = [
|
3190
|
+
* { 'name': 'barney', 'blocked': false, 'employer': 'slate' },
|
3191
|
+
* { 'name': 'fred', 'blocked': true, 'employer': 'slate' },
|
3192
|
+
* { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
|
3100
3193
|
* ];
|
3101
3194
|
*
|
3102
3195
|
* // using "_.pluck" callback shorthand
|
3103
|
-
* _.last(
|
3104
|
-
* // => [
|
3105
|
-
*
|
3106
|
-
* var food = [
|
3107
|
-
* { 'name': 'banana', 'type': 'fruit' },
|
3108
|
-
* { 'name': 'beet', 'type': 'vegetable' },
|
3109
|
-
* { 'name': 'carrot', 'type': 'vegetable' }
|
3110
|
-
* ];
|
3196
|
+
* _.pluck(_.last(characters, 'blocked'), 'name');
|
3197
|
+
* // => ['fred', 'pebbles']
|
3111
3198
|
*
|
3112
3199
|
* // using "_.where" callback shorthand
|
3113
|
-
* _.last(
|
3114
|
-
* // => [{ 'name': '
|
3200
|
+
* _.last(characters, { 'employer': 'na' });
|
3201
|
+
* // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
|
3115
3202
|
*/
|
3116
3203
|
function last(array, callback, thisArg) {
|
3117
3204
|
var n = 0,
|
@@ -3129,7 +3216,7 @@
|
|
3129
3216
|
return array ? array[length - 1] : undefined;
|
3130
3217
|
}
|
3131
3218
|
}
|
3132
|
-
return
|
3219
|
+
return slice(array, nativeMax(0, length - n));
|
3133
3220
|
}
|
3134
3221
|
|
3135
3222
|
/**
|
@@ -3137,6 +3224,13 @@
|
|
3137
3224
|
* equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
|
3138
3225
|
* as the offset from the end of the collection.
|
3139
3226
|
*
|
3227
|
+
* If a property name is provided for `callback` the created "_.pluck" style
|
3228
|
+
* callback will return the property value of the given element.
|
3229
|
+
*
|
3230
|
+
* If an object is provided for `callback` the created "_.where" style callback
|
3231
|
+
* will return `true` for elements that have the properties of the given object,
|
3232
|
+
* else `false`.
|
3233
|
+
*
|
3140
3234
|
* @static
|
3141
3235
|
* @memberOf _
|
3142
3236
|
* @category Arrays
|
@@ -3179,17 +3273,17 @@
|
|
3179
3273
|
* @returns {Array} Returns a new range array.
|
3180
3274
|
* @example
|
3181
3275
|
*
|
3182
|
-
* _.range(
|
3183
|
-
* // => [0, 1, 2, 3
|
3276
|
+
* _.range(4);
|
3277
|
+
* // => [0, 1, 2, 3]
|
3184
3278
|
*
|
3185
|
-
* _.range(1,
|
3186
|
-
* // => [1, 2, 3, 4
|
3279
|
+
* _.range(1, 5);
|
3280
|
+
* // => [1, 2, 3, 4]
|
3187
3281
|
*
|
3188
|
-
* _.range(0,
|
3189
|
-
* // => [0, 5, 10, 15
|
3282
|
+
* _.range(0, 20, 5);
|
3283
|
+
* // => [0, 5, 10, 15]
|
3190
3284
|
*
|
3191
|
-
* _.range(0, -
|
3192
|
-
* // => [0, -1, -2, -3
|
3285
|
+
* _.range(0, -4, -1);
|
3286
|
+
* // => [0, -1, -2, -3]
|
3193
3287
|
*
|
3194
3288
|
* _.range(1, 4, 0);
|
3195
3289
|
* // => [1, 1, 1]
|
@@ -3205,7 +3299,7 @@
|
|
3205
3299
|
end = start;
|
3206
3300
|
start = 0;
|
3207
3301
|
}
|
3208
|
-
// use `Array(length)` so engines
|
3302
|
+
// use `Array(length)` so engines like Chakra and V8 avoid slower modes
|
3209
3303
|
// http://youtu.be/XAqIpGU8ZZk#t=17m25s
|
3210
3304
|
var index = -1,
|
3211
3305
|
length = nativeMax(0, ceil((end - start) / step)),
|
@@ -3256,24 +3350,19 @@
|
|
3256
3350
|
* });
|
3257
3351
|
* // => [3]
|
3258
3352
|
*
|
3259
|
-
* var
|
3260
|
-
* { 'name': '
|
3261
|
-
* { 'name': '
|
3353
|
+
* var characters = [
|
3354
|
+
* { 'name': 'barney', 'blocked': true, 'employer': 'slate' },
|
3355
|
+
* { 'name': 'fred', 'blocked': false, 'employer': 'slate' },
|
3356
|
+
* { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
|
3262
3357
|
* ];
|
3263
3358
|
*
|
3264
3359
|
* // using "_.pluck" callback shorthand
|
3265
|
-
* _.rest(
|
3266
|
-
* // => [
|
3267
|
-
*
|
3268
|
-
* var food = [
|
3269
|
-
* { 'name': 'apple', 'type': 'fruit' },
|
3270
|
-
* { 'name': 'banana', 'type': 'fruit' },
|
3271
|
-
* { 'name': 'beet', 'type': 'vegetable' }
|
3272
|
-
* ];
|
3360
|
+
* _.pluck(_.rest(characters, 'blocked'), 'name');
|
3361
|
+
* // => ['fred', 'pebbles']
|
3273
3362
|
*
|
3274
3363
|
* // using "_.where" callback shorthand
|
3275
|
-
* _.rest(
|
3276
|
-
* // => [{ 'name': '
|
3364
|
+
* _.rest(characters, { 'employer': 'slate' });
|
3365
|
+
* // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
|
3277
3366
|
*/
|
3278
3367
|
function rest(array, callback, thisArg) {
|
3279
3368
|
if (typeof callback != 'number' && callback != null) {
|
@@ -3288,7 +3377,7 @@
|
|
3288
3377
|
} else {
|
3289
3378
|
n = (callback == null || thisArg) ? 1 : nativeMax(0, callback);
|
3290
3379
|
}
|
3291
|
-
return
|
3380
|
+
return slice(array, n);
|
3292
3381
|
}
|
3293
3382
|
|
3294
3383
|
/**
|
@@ -3422,7 +3511,7 @@
|
|
3422
3511
|
// juggle arguments
|
3423
3512
|
if (typeof isSorted != 'boolean' && isSorted != null) {
|
3424
3513
|
thisArg = callback;
|
3425
|
-
callback =
|
3514
|
+
callback = (typeof isSorted != 'function' && thisArg && thisArg[isSorted] === array) ? null : isSorted;
|
3426
3515
|
isSorted = false;
|
3427
3516
|
}
|
3428
3517
|
if (callback != null) {
|
@@ -3447,7 +3536,7 @@
|
|
3447
3536
|
* // => [2, 3, 4]
|
3448
3537
|
*/
|
3449
3538
|
function without(array) {
|
3450
|
-
return
|
3539
|
+
return baseDifference(array, slice(arguments, 1));
|
3451
3540
|
}
|
3452
3541
|
|
3453
3542
|
/**
|
@@ -3463,8 +3552,8 @@
|
|
3463
3552
|
* @returns {Array} Returns a new array of grouped elements.
|
3464
3553
|
* @example
|
3465
3554
|
*
|
3466
|
-
* _.zip(['
|
3467
|
-
* // => [['
|
3555
|
+
* _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
3556
|
+
* // => [['fred', 30, true], ['barney', 40, false]]
|
3468
3557
|
*/
|
3469
3558
|
function zip() {
|
3470
3559
|
var index = -1,
|
@@ -3492,8 +3581,8 @@
|
|
3492
3581
|
* corresponding values.
|
3493
3582
|
* @example
|
3494
3583
|
*
|
3495
|
-
* _.zipObject(['
|
3496
|
-
* // => { '
|
3584
|
+
* _.zipObject(['fred', 'barney'], [30, 40]);
|
3585
|
+
* // => { 'fred': 30, 'barney': 40 }
|
3497
3586
|
*/
|
3498
3587
|
function zipObject(keys, values) {
|
3499
3588
|
var index = -1,
|
@@ -3566,14 +3655,14 @@
|
|
3566
3655
|
* return greeting + ' ' + this.name;
|
3567
3656
|
* };
|
3568
3657
|
*
|
3569
|
-
* func = _.bind(func, { 'name': '
|
3658
|
+
* func = _.bind(func, { 'name': 'fred' }, 'hi');
|
3570
3659
|
* func();
|
3571
|
-
* // => 'hi
|
3660
|
+
* // => 'hi fred'
|
3572
3661
|
*/
|
3573
3662
|
function bind(func, thisArg) {
|
3574
3663
|
return arguments.length > 2
|
3575
|
-
?
|
3576
|
-
:
|
3664
|
+
? createWrapper(func, 17, slice(arguments, 2), null, thisArg)
|
3665
|
+
: createWrapper(func, 1, null, null, thisArg);
|
3577
3666
|
}
|
3578
3667
|
|
3579
3668
|
/**
|
@@ -3607,7 +3696,7 @@
|
|
3607
3696
|
|
3608
3697
|
while (++index < length) {
|
3609
3698
|
var key = funcs[index];
|
3610
|
-
object[key] =
|
3699
|
+
object[key] = createWrapper(object[key], 1, null, null, object);
|
3611
3700
|
}
|
3612
3701
|
return object;
|
3613
3702
|
}
|
@@ -3626,7 +3715,7 @@
|
|
3626
3715
|
* @example
|
3627
3716
|
*
|
3628
3717
|
* var realNameMap = {
|
3629
|
-
* '
|
3718
|
+
* 'pebbles': 'penelope'
|
3630
3719
|
* };
|
3631
3720
|
*
|
3632
3721
|
* var format = function(name) {
|
@@ -3639,8 +3728,8 @@
|
|
3639
3728
|
* };
|
3640
3729
|
*
|
3641
3730
|
* var welcome = _.compose(greet, format);
|
3642
|
-
* welcome('
|
3643
|
-
* // => 'Hiya
|
3731
|
+
* welcome('pebbles');
|
3732
|
+
* // => 'Hiya Penelope!'
|
3644
3733
|
*/
|
3645
3734
|
function compose() {
|
3646
3735
|
var funcs = arguments,
|
@@ -3677,9 +3766,9 @@
|
|
3677
3766
|
* @returns {Function} Returns a callback function.
|
3678
3767
|
* @example
|
3679
3768
|
*
|
3680
|
-
* var
|
3681
|
-
* { 'name': '
|
3682
|
-
* { 'name': '
|
3769
|
+
* var characters = [
|
3770
|
+
* { 'name': 'barney', 'age': 36 },
|
3771
|
+
* { 'name': 'fred', 'age': 40 }
|
3683
3772
|
* ];
|
3684
3773
|
*
|
3685
3774
|
* // wrap to create custom callback shorthands
|
@@ -3690,8 +3779,8 @@
|
|
3690
3779
|
* };
|
3691
3780
|
* });
|
3692
3781
|
*
|
3693
|
-
* _.filter(
|
3694
|
-
* // => [{ 'name': '
|
3782
|
+
* _.filter(characters, 'age__gt38');
|
3783
|
+
* // => [{ 'name': 'fred', 'age': 40 }]
|
3695
3784
|
*/
|
3696
3785
|
function createCallback(func, thisArg, argCount) {
|
3697
3786
|
var type = typeof func;
|
@@ -3792,6 +3881,9 @@
|
|
3792
3881
|
if (isCalled) {
|
3793
3882
|
lastCalled = now();
|
3794
3883
|
result = func.apply(thisArg, args);
|
3884
|
+
if (!timeoutId && !maxTimeoutId) {
|
3885
|
+
args = thisArg = null;
|
3886
|
+
}
|
3795
3887
|
}
|
3796
3888
|
} else {
|
3797
3889
|
timeoutId = setTimeout(delayed, remaining);
|
@@ -3806,6 +3898,9 @@
|
|
3806
3898
|
if (trailing || (maxWait !== wait)) {
|
3807
3899
|
lastCalled = now();
|
3808
3900
|
result = func.apply(thisArg, args);
|
3901
|
+
if (!timeoutId && !maxTimeoutId) {
|
3902
|
+
args = thisArg = null;
|
3903
|
+
}
|
3809
3904
|
}
|
3810
3905
|
};
|
3811
3906
|
|
@@ -3821,8 +3916,10 @@
|
|
3821
3916
|
if (!maxTimeoutId && !leading) {
|
3822
3917
|
lastCalled = stamp;
|
3823
3918
|
}
|
3824
|
-
var remaining = maxWait - (stamp - lastCalled)
|
3825
|
-
|
3919
|
+
var remaining = maxWait - (stamp - lastCalled),
|
3920
|
+
isCalled = remaining <= 0;
|
3921
|
+
|
3922
|
+
if (isCalled) {
|
3826
3923
|
if (maxTimeoutId) {
|
3827
3924
|
maxTimeoutId = clearTimeout(maxTimeoutId);
|
3828
3925
|
}
|
@@ -3833,12 +3930,19 @@
|
|
3833
3930
|
maxTimeoutId = setTimeout(maxDelayed, remaining);
|
3834
3931
|
}
|
3835
3932
|
}
|
3836
|
-
if (
|
3933
|
+
if (isCalled && timeoutId) {
|
3934
|
+
timeoutId = clearTimeout(timeoutId);
|
3935
|
+
}
|
3936
|
+
else if (!timeoutId && wait !== maxWait) {
|
3837
3937
|
timeoutId = setTimeout(delayed, wait);
|
3838
3938
|
}
|
3839
3939
|
if (leadingCall) {
|
3940
|
+
isCalled = true;
|
3840
3941
|
result = func.apply(thisArg, args);
|
3841
3942
|
}
|
3943
|
+
if (isCalled && !timeoutId && !maxTimeoutId) {
|
3944
|
+
args = thisArg = null;
|
3945
|
+
}
|
3842
3946
|
return result;
|
3843
3947
|
};
|
3844
3948
|
}
|
@@ -3862,7 +3966,7 @@
|
|
3862
3966
|
if (!isFunction(func)) {
|
3863
3967
|
throw new TypeError;
|
3864
3968
|
}
|
3865
|
-
var args =
|
3969
|
+
var args = slice(arguments, 1);
|
3866
3970
|
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
3867
3971
|
}
|
3868
3972
|
|
@@ -3887,7 +3991,7 @@
|
|
3887
3991
|
if (!isFunction(func)) {
|
3888
3992
|
throw new TypeError;
|
3889
3993
|
}
|
3890
|
-
var args =
|
3994
|
+
var args = slice(arguments, 2);
|
3891
3995
|
return setTimeout(function() { func.apply(undefined, args); }, wait);
|
3892
3996
|
}
|
3893
3997
|
|
@@ -3911,19 +4015,22 @@
|
|
3911
4015
|
* return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
3912
4016
|
* });
|
3913
4017
|
*
|
4018
|
+
* fibonacci(9)
|
4019
|
+
* // => 34
|
4020
|
+
*
|
3914
4021
|
* var data = {
|
3915
|
-
* '
|
3916
|
-
* '
|
4022
|
+
* 'fred': { 'name': 'fred', 'age': 40 },
|
4023
|
+
* 'pebbles': { 'name': 'pebbles', 'age': 1 }
|
3917
4024
|
* };
|
3918
4025
|
*
|
3919
4026
|
* // modifying the result cache
|
3920
|
-
* var
|
3921
|
-
*
|
3922
|
-
* // => { 'name': '
|
4027
|
+
* var get = _.memoize(function(name) { return data[name]; }, _.identity);
|
4028
|
+
* get('pebbles');
|
4029
|
+
* // => { 'name': 'pebbles', 'age': 1 }
|
3923
4030
|
*
|
3924
|
-
*
|
3925
|
-
*
|
3926
|
-
* // => { 'name': '
|
4031
|
+
* get.cache.pebbles.name = 'penelope';
|
4032
|
+
* get('pebbles');
|
4033
|
+
* // => { 'name': 'penelope', 'age': 1 }
|
3927
4034
|
*/
|
3928
4035
|
function memoize(func, resolver) {
|
3929
4036
|
var cache = {};
|
@@ -3987,11 +4094,11 @@
|
|
3987
4094
|
*
|
3988
4095
|
* var greet = function(greeting, name) { return greeting + ' ' + name; };
|
3989
4096
|
* var hi = _.partial(greet, 'hi');
|
3990
|
-
* hi('
|
3991
|
-
* // => 'hi
|
4097
|
+
* hi('fred');
|
4098
|
+
* // => 'hi fred'
|
3992
4099
|
*/
|
3993
4100
|
function partial(func) {
|
3994
|
-
return
|
4101
|
+
return createWrapper(func, 16, slice(arguments, 1));
|
3995
4102
|
}
|
3996
4103
|
|
3997
4104
|
/**
|
@@ -4060,22 +4167,15 @@
|
|
4060
4167
|
* @returns {Function} Returns the new function.
|
4061
4168
|
* @example
|
4062
4169
|
*
|
4063
|
-
* var
|
4064
|
-
*
|
4065
|
-
* return 'before, ' + func('moe') + ', after';
|
4170
|
+
* var p = _.wrap(_.escape, function(func, text) {
|
4171
|
+
* return '<p>' + func(text) + '</p>';
|
4066
4172
|
* });
|
4067
|
-
*
|
4068
|
-
*
|
4173
|
+
*
|
4174
|
+
* p('Fred, Wilma, & Pebbles');
|
4175
|
+
* // => '<p>Fred, Wilma, & Pebbles</p>'
|
4069
4176
|
*/
|
4070
4177
|
function wrap(value, wrapper) {
|
4071
|
-
|
4072
|
-
throw new TypeError;
|
4073
|
-
}
|
4074
|
-
return function() {
|
4075
|
-
var args = [value];
|
4076
|
-
push.apply(args, arguments);
|
4077
|
-
return wrapper.apply(this, args);
|
4078
|
-
};
|
4178
|
+
return createWrapper(wrapper, 16, [value]);
|
4079
4179
|
}
|
4080
4180
|
|
4081
4181
|
/*--------------------------------------------------------------------------*/
|
@@ -4091,8 +4191,8 @@
|
|
4091
4191
|
* @returns {string} Returns the escaped string.
|
4092
4192
|
* @example
|
4093
4193
|
*
|
4094
|
-
* _.escape('
|
4095
|
-
* // => '
|
4194
|
+
* _.escape('Fred, Wilma, & Pebbles');
|
4195
|
+
* // => 'Fred, Wilma, & Pebbles'
|
4096
4196
|
*/
|
4097
4197
|
function escape(string) {
|
4098
4198
|
return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar);
|
@@ -4108,8 +4208,8 @@
|
|
4108
4208
|
* @returns {*} Returns `value`.
|
4109
4209
|
* @example
|
4110
4210
|
*
|
4111
|
-
* var
|
4112
|
-
*
|
4211
|
+
* var object = { 'name': 'fred' };
|
4212
|
+
* _.identity(object) === object;
|
4113
4213
|
* // => true
|
4114
4214
|
*/
|
4115
4215
|
function identity(value) {
|
@@ -4133,11 +4233,11 @@
|
|
4133
4233
|
* }
|
4134
4234
|
* });
|
4135
4235
|
*
|
4136
|
-
* _.capitalize('
|
4137
|
-
* // => '
|
4236
|
+
* _.capitalize('fred');
|
4237
|
+
* // => 'Fred'
|
4138
4238
|
*
|
4139
|
-
* _('
|
4140
|
-
* // => '
|
4239
|
+
* _('fred').capitalize();
|
4240
|
+
* // => 'Fred'
|
4141
4241
|
*/
|
4142
4242
|
function mixin(object) {
|
4143
4243
|
forEach(functions(object), function(methodName) {
|
@@ -4172,6 +4272,22 @@
|
|
4172
4272
|
return this;
|
4173
4273
|
}
|
4174
4274
|
|
4275
|
+
/**
|
4276
|
+
* A no-operation function.
|
4277
|
+
*
|
4278
|
+
* @static
|
4279
|
+
* @memberOf _
|
4280
|
+
* @category Utilities
|
4281
|
+
* @example
|
4282
|
+
*
|
4283
|
+
* var object = { 'name': 'fred' };
|
4284
|
+
* _.noop(object) === undefined;
|
4285
|
+
* // => true
|
4286
|
+
*/
|
4287
|
+
function noop() {
|
4288
|
+
// no operation performed
|
4289
|
+
}
|
4290
|
+
|
4175
4291
|
/**
|
4176
4292
|
* Produces a random number between `min` and `max` (inclusive). If only one
|
4177
4293
|
* argument is provided a number between `0` and the given number will be
|
@@ -4255,7 +4371,7 @@
|
|
4255
4371
|
* debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
|
4256
4372
|
*
|
4257
4373
|
* For more information on precompiling templates see:
|
4258
|
-
* http://lodash.com
|
4374
|
+
* http://lodash.com/custom-builds
|
4259
4375
|
*
|
4260
4376
|
* For more information on Chrome extension sandboxes see:
|
4261
4377
|
* http://developer.chrome.com/stable/extensions/sandboxingEval.html
|
@@ -4278,8 +4394,8 @@
|
|
4278
4394
|
*
|
4279
4395
|
* // using the "interpolate" delimiter to create a compiled template
|
4280
4396
|
* var compiled = _.template('hello <%= name %>');
|
4281
|
-
* compiled({ 'name': '
|
4282
|
-
* // => 'hello
|
4397
|
+
* compiled({ 'name': 'fred' });
|
4398
|
+
* // => 'hello fred'
|
4283
4399
|
*
|
4284
4400
|
* // using the "escape" delimiter to escape HTML in data property values
|
4285
4401
|
* _.template('<b><%- value %></b>', { 'value': '<script>' });
|
@@ -4287,16 +4403,16 @@
|
|
4287
4403
|
*
|
4288
4404
|
* // using the "evaluate" delimiter to generate HTML
|
4289
4405
|
* var list = '<% _.forEach(people, function(name) { %><li><%- name %></li><% }); %>';
|
4290
|
-
* _.template(list, { 'people': ['
|
4291
|
-
* // => '<li>
|
4406
|
+
* _.template(list, { 'people': ['fred', 'barney'] });
|
4407
|
+
* // => '<li>fred</li><li>barney</li>'
|
4292
4408
|
*
|
4293
4409
|
* // using the ES6 delimiter as an alternative to the default "interpolate" delimiter
|
4294
|
-
* _.template('hello ${ name }', { 'name': '
|
4295
|
-
* // => 'hello
|
4410
|
+
* _.template('hello ${ name }', { 'name': 'pebbles' });
|
4411
|
+
* // => 'hello pebbles'
|
4296
4412
|
*
|
4297
4413
|
* // using the internal `print` function in "evaluate" delimiters
|
4298
|
-
* _.template('<% print("hello " + name); %>!', { 'name': '
|
4299
|
-
* // => 'hello
|
4414
|
+
* _.template('<% print("hello " + name); %>!', { 'name': 'barney' });
|
4415
|
+
* // => 'hello barney!'
|
4300
4416
|
*
|
4301
4417
|
* // using a custom template delimiters
|
4302
4418
|
* _.templateSettings = {
|
@@ -4308,8 +4424,8 @@
|
|
4308
4424
|
*
|
4309
4425
|
* // using the `imports` option to import jQuery
|
4310
4426
|
* var list = '<% $.each(people, function(name) { %><li><%- name %></li><% }); %>';
|
4311
|
-
* _.template(list, { 'people': ['
|
4312
|
-
* // => '<li>
|
4427
|
+
* _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } });
|
4428
|
+
* // => '<li>fred</li><li>barney</li>'
|
4313
4429
|
*
|
4314
4430
|
* // using the `sourceURL` option to specify a custom sourceURL for the template
|
4315
4431
|
* var compiled = _.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
|
@@ -4337,7 +4453,7 @@
|
|
4337
4453
|
var _ = lodash,
|
4338
4454
|
settings = _.templateSettings;
|
4339
4455
|
|
4340
|
-
text
|
4456
|
+
text = String(text || '');
|
4341
4457
|
options = defaults({}, options, settings);
|
4342
4458
|
|
4343
4459
|
var index = 0,
|
@@ -4436,8 +4552,8 @@
|
|
4436
4552
|
* @returns {string} Returns the unescaped string.
|
4437
4553
|
* @example
|
4438
4554
|
*
|
4439
|
-
* _.unescape('
|
4440
|
-
* // => '
|
4555
|
+
* _.unescape('Fred, Barney & Pebbles');
|
4556
|
+
* // => 'Fred, Barney & Pebbles'
|
4441
4557
|
*/
|
4442
4558
|
function unescape(string) {
|
4443
4559
|
return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar);
|
@@ -4477,18 +4593,18 @@
|
|
4477
4593
|
* @returns {Object} Returns the wrapper object.
|
4478
4594
|
* @example
|
4479
4595
|
*
|
4480
|
-
* var
|
4481
|
-
* { 'name': '
|
4482
|
-
* { 'name': '
|
4483
|
-
* { 'name': '
|
4596
|
+
* var characters = [
|
4597
|
+
* { 'name': 'barney', 'age': 36 },
|
4598
|
+
* { 'name': 'fred', 'age': 40 },
|
4599
|
+
* { 'name': 'pebbles', 'age': 1 }
|
4484
4600
|
* ];
|
4485
4601
|
*
|
4486
|
-
* var youngest = _.chain(
|
4602
|
+
* var youngest = _.chain(characters)
|
4487
4603
|
* .sortBy('age')
|
4488
|
-
* .map(function(
|
4604
|
+
* .map(function(chr) { return chr.name + ' is ' + chr.age; })
|
4489
4605
|
* .first()
|
4490
4606
|
* .value();
|
4491
|
-
* // => '
|
4607
|
+
* // => 'pebbles is 1'
|
4492
4608
|
*/
|
4493
4609
|
function chain(value) {
|
4494
4610
|
value = new lodashWrapper(value);
|
@@ -4511,12 +4627,10 @@
|
|
4511
4627
|
* @example
|
4512
4628
|
*
|
4513
4629
|
* _([1, 2, 3, 4])
|
4514
|
-
* .
|
4515
|
-
* .
|
4516
|
-
* .map(function(num) { return num * num; })
|
4630
|
+
* .tap(function(array) { array.pop(); })
|
4631
|
+
* .reverse()
|
4517
4632
|
* .value();
|
4518
|
-
* // =>
|
4519
|
-
* // => [4, 16]
|
4633
|
+
* // => [3, 2, 1]
|
4520
4634
|
*/
|
4521
4635
|
function tap(value, interceptor) {
|
4522
4636
|
interceptor(value);
|
@@ -4532,21 +4646,21 @@
|
|
4532
4646
|
* @returns {*} Returns the wrapper object.
|
4533
4647
|
* @example
|
4534
4648
|
*
|
4535
|
-
* var
|
4536
|
-
* { 'name': '
|
4537
|
-
* { 'name': '
|
4649
|
+
* var characters = [
|
4650
|
+
* { 'name': 'barney', 'age': 36 },
|
4651
|
+
* { 'name': 'fred', 'age': 40 }
|
4538
4652
|
* ];
|
4539
4653
|
*
|
4540
4654
|
* // without explicit chaining
|
4541
|
-
* _(
|
4542
|
-
* // => { 'name': '
|
4655
|
+
* _(characters).first();
|
4656
|
+
* // => { 'name': 'barney', 'age': 36 }
|
4543
4657
|
*
|
4544
4658
|
* // with explicit chaining
|
4545
|
-
* _(
|
4659
|
+
* _(characters).chain()
|
4546
4660
|
* .first()
|
4547
4661
|
* .pick('age')
|
4548
4662
|
* .value()
|
4549
|
-
* // => { 'age':
|
4663
|
+
* // => { 'age': 36 }
|
4550
4664
|
*/
|
4551
4665
|
function wrapperChain() {
|
4552
4666
|
this.__chain__ = true;
|
@@ -4708,7 +4822,7 @@
|
|
4708
4822
|
* @memberOf _
|
4709
4823
|
* @type string
|
4710
4824
|
*/
|
4711
|
-
lodash.VERSION = '2.
|
4825
|
+
lodash.VERSION = '2.3.0';
|
4712
4826
|
|
4713
4827
|
// add "Chaining" functions to the wrapper
|
4714
4828
|
lodash.prototype.chain = wrapperChain;
|
@@ -4747,7 +4861,7 @@
|
|
4747
4861
|
|
4748
4862
|
/*--------------------------------------------------------------------------*/
|
4749
4863
|
|
4750
|
-
// some AMD build optimizers
|
4864
|
+
// some AMD build optimizers like r.js check for condition patterns like the following:
|
4751
4865
|
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
4752
4866
|
// Expose Lo-Dash to the global object even when an AMD loader is present in
|
4753
4867
|
// case Lo-Dash was injected by a third-party script and not intended to be
|