343. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/7/2018 11:36:20 AM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

343.1 Files compared

# Location File Last Modified
1 C:\SCRUB\MHED\MHED\VATS 2.3.0\var-utility-web-2.3.0@19406cb7810\app\libs\lodash\js lodash.js Thu Sep 13 18:55:48 2018 UTC
2 C:\MHED-scrubbed\MHED\MHED\VATS 2.3.0\var-utility-web-2.3.0@19406cb7810\app\libs\lodash\js lodash.js Fri Dec 7 13:49:22 2018 UTC

343.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 14356
Changed 2 6
Inserted 0 0
Removed 0 0

343.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

343.4 Active regular expressions

No regular expressions were active.

343.5 Comparison detail

  1   /**
  2    * @licens e
  3    * Lo-Dash  2.4.2 <ht tps://loda sh.com/>
  4    * Build:  `lodash mo dern -o ./ dist/lodas h.js`
  5    * Copyrig ht 2012-20 13 The Doj o Foundati on <http:/ /dojofound ation.org/ >
  6    * Based o n Undersco re.js 1.5. 2 <http:// underscore js.org/LIC ENSE>
  7    * Copyrig ht 2009-20 13 Jeremy  Ashkenas,  DocumentCl oud and In vestigativ e Reporter s & Editor s
  8    * Availab le under M IT license  <https:// lodash.com /license>
  9    */
  10   ;(function () {
  11  
  12     /** Used  as a safe  reference  for `unde fined` in  pre ES5 en vironments  */
  13     var unde fined;
  14  
  15     /** Used  to pool a rrays and  objects us ed interna lly */
  16     var arra yPool = [] ,
  17         obje ctPool = [ ];
  18  
  19     /** Used  to genera te unique  IDs */
  20     var idCo unter = 0;
  21  
  22     /** Used  internall y to indic ate variou s things * /
  23     var indi catorObjec t = {};
  24  
  25     /** Used  to prefix  keys to a void issue s with `__ proto__` a nd propert ies on `Ob ject.proto type` */
  26     var keyP refix = +n ew Date +  '';
  27  
  28     /** Used  as the si ze when op timization s are enab led for la rge arrays  */
  29     var larg eArraySize  = 75;
  30  
  31     /** Used  as the ma x size of  the `array Pool` and  `objectPoo l` */
  32     var maxP oolSize =  40;
  33  
  34     /** Used  to detect  and test  whitespace  */
  35     var whit espace = (
  36       // whi tespace
  37       ' \t\x 0B\f\xA0\u feff' +
  38  
  39       // lin e terminat ors
  40       '\n\r\ u2028\u202 9' +
  41  
  42       // uni code categ ory "Zs" s pace separ ators
  43       '\u168 0\u180e\u2 000\u2001\ u2002\u200 3\u2004\u2 005\u2006\ u2007\u200 8\u2009\u2 00a\u202f\ u205f\u300 0'
  44     );
  45  
  46     /** Used  to match  empty stri ng literal s in compi led templa te source  */
  47     var reEm ptyStringL eading = / \b__p \+=  '';/g,
  48         reEm ptyStringM iddle = /\ b(__p \+=)  '' \+/g,
  49         reEm ptyStringT railing =  /(__e\(.*? \)|\b__t\) ) \+\n'';/ g;
  50  
  51     /**
  52      * Used  to match E S6 templat e delimite rs
  53      * http: //people.m ozilla.org /~jorendor ff/es6-dra ft.html#se c-literals -string-li terals
  54      */
  55     var reEs Template =  /\$\{([^\ \}]*(?:\\. [^\\}]*)*) \}/g;
  56  
  57     /** Used  to match  regexp fla gs from th eir coerce d string v alues */
  58     var reFl ags = /\w* $/;
  59  
  60     /** Used  to detect ed named f unctions * /
  61     var reFu ncName = / ^\s*functi on[ \n\r\t ]+\w/;
  62  
  63     /** Used  to match  "interpola te" templa te delimit ers */
  64     var reIn terpolate  = /<%=([\s \S]+?)%>/g ;
  65  
  66     /** Used  to match  leading wh itespace a nd zeros t o be remov ed */
  67     var reLe adingSpace sAndZeros  = RegExp(' ^[' + whit espace + ' ]*0+(?=.$) ');
  68  
  69     /** Used  to ensure  capturing  order of  template d elimiters  */
  70     var reNo Match = /( $^)/;
  71  
  72     /** Used  to detect  functions  containin g a `this`  reference  */
  73     var reTh is = /\bth is\b/;
  74  
  75     /** Used  to match  unescaped  characters  in compil ed string  literals * /
  76     var reUn escapedStr ing = /['\ n\r\t\u202 8\u2029\\] /g;
  77  
  78     /** Used  to assign  default ` context` o bject prop erties */
  79     var cont extProps =  [
  80       'Array ', 'Boolea n', 'Date' , 'Error',  'Function ', 'Math',  'Number',  'Object',
  81       'RegEx p', 'Strin g', '_', ' attachEven t', 'clear Timeout',  'isFinite' , 'isNaN',
  82       'parse Int', 'set Timeout'
  83     ];
  84  
  85     /** Used  to fix th e JScript  [[DontEnum ]] bug */
  86     var shad owedProps  = [
  87       'const ructor', ' hasOwnProp erty', 'is PrototypeO f', 'prope rtyIsEnume rable',
  88       'toLoc aleString' , 'toStrin g', 'value Of'
  89     ];
  90  
  91     /** Used  to make t emplate so urceURLs e asier to i dentify */
  92     var temp lateCounte r = 0;
  93  
  94     /** `Obj ect#toStri ng` result  shortcuts  */
  95     var args Class = '[ object Arg uments]',
  96         arra yClass = ' [object Ar ray]',
  97         bool Class = '[ object Boo lean]',
  98         date Class = '[ object Dat e]',
  99         erro rClass = ' [object Er ror]',
  100         func Class = '[ object Fun ction]',
  101         numb erClass =  '[object N umber]',
  102         obje ctClass =  '[object O bject]',
  103         rege xpClass =  '[object R egExp]',
  104         stri ngClass =  '[object S tring]';
  105  
  106     /** Used  to identi fy object  classifica tions that  `_.clone`  supports  */
  107     var clon eableClass es = {};
  108     cloneabl eClasses[f uncClass]  = false;
  109     cloneabl eClasses[a rgsClass]  = cloneabl eClasses[a rrayClass]  =
  110     cloneabl eClasses[b oolClass]  = cloneabl eClasses[d ateClass]  =
  111     cloneabl eClasses[n umberClass ] = clonea bleClasses [objectCla ss] =
  112     cloneabl eClasses[r egexpClass ] = clonea bleClasses [stringCla ss] = true ;
  113  
  114     /** Used  as an int ernal `_.d ebounce` o ptions obj ect */
  115     var debo unceOption s = {
  116       'leadi ng': false ,
  117       'maxWa it': 0,
  118       'trail ing': fals e
  119     };
  120  
  121     /** Used  as the pr operty des criptor fo r `__bindD ata__` */
  122     var desc riptor = {
  123       'confi gurable':  false,
  124       'enume rable': fa lse,
  125       'value ': null,
  126       'writa ble': fals e
  127     };
  128  
  129     /** Used  as the da ta object  for `itera torTemplat e` */
  130     var iter atorData =  {
  131       'args' : '',
  132       'array ': null,
  133       'botto m': '',
  134       'first Arg': '',
  135       'init' : '',
  136       'keys' : null,
  137       'loop' : '',
  138       'shado wedProps':  null,
  139       'suppo rt': null,
  140       'top':  '',
  141       'useHa s': false
  142     };
  143  
  144     /** Used  to determ ine if val ues are of  the langu age type O bject */
  145     var obje ctTypes =  {
  146       'boole an': false ,
  147       'funct ion': true ,
  148       'objec t': true,
  149       'numbe r': false,
  150       'strin g': false,
  151       'undef ined': fal se
  152     };
  153  
  154     /** Used  to escape  character s for incl usion in c ompiled st ring liter als */
  155     var stri ngEscapes  = {
  156       '\\':  '\\',
  157       "'": " '",
  158       '\n':  'n',
  159       '\r':  'r',
  160       '\t':  't',
  161       '\u202 8': 'u2028 ',
  162       '\u202 9': 'u2029 '
  163     };
  164  
  165     /** Used  as a refe rence to t he global  object */
  166     var root  = (object Types[type of window]  && window ) || this;
  167  
  168     /** Dete ct free va riable `ex ports` */
  169     var free Exports =  objectType s[typeof e xports] &&  exports & & !exports .nodeType  && exports ;
  170  
  171     /** Dete ct free va riable `mo dule` */
  172     var free Module = o bjectTypes [typeof mo dule] && m odule && ! module.nod eType && m odule;
  173  
  174     /** Dete ct the pop ular Commo nJS extens ion `modul e.exports`  */
  175     var modu leExports  = freeModu le && free Module.exp orts === f reeExports  && freeEx ports;
  176  
  177     /** Dete ct free va riable `gl obal` from  Node.js o r Browseri fied code  and use it  as `root`  */
  178     var free Global = o bjectTypes [typeof gl obal] && g lobal;
  179     if (free Global &&  (freeGloba l.global = == freeGlo bal || fre eGlobal.wi ndow === f reeGlobal) ) {
  180       root =  freeGloba l;
  181     }
  182  
  183     /*------ ---------- ---------- ---------- ---------- ---------- ---------- --------*/
  184  
  185     /**
  186      * The b ase implem entation o f `_.index Of` withou t support  for binary  searches
  187      * or `f romIndex`  constraint s.
  188      *
  189      * @priv ate
  190      * @para m {Array}  array The  array to s earch.
  191      * @para m {*} valu e The valu e to searc h for.
  192      * @para m {number}  [fromInde x=0] The i ndex to se arch from.
  193      * @retu rns {numbe r} Returns  the index  of the ma tched valu e or `-1`.
  194      */
  195     function  baseIndex Of(array,  value, fro mIndex) {
  196       var in dex = (fro mIndex ||  0) - 1,
  197           le ngth = arr ay ? array .length :  0;
  198  
  199       while  (++index <  length) {
  200         if ( array[inde x] === val ue) {
  201           re turn index ;
  202         }
  203       }
  204       return  -1;
  205     }
  206  
  207     /**
  208      * An im plementati on of `_.c ontains` f or cache o bjects tha t mimics t he return
  209      * signa ture of `_ .indexOf`  by returni ng `0` if  the value  is found,  else `-1`.
  210      *
  211      * @priv ate
  212      * @para m {Object}  cache The  cache obj ect to ins pect.
  213      * @para m {*} valu e The valu e to searc h for.
  214      * @retu rns {numbe r} Returns  `0` if `v alue` is f ound, else  `-1`.
  215      */
  216     function  cacheInde xOf(cache,  value) {
  217       var ty pe = typeo f value;
  218       cache  = cache.ca che;
  219  
  220       if (ty pe == 'boo lean' || v alue == nu ll) {
  221         retu rn cache[v alue] ? 0  : -1;
  222       }
  223       if (ty pe != 'num ber' && ty pe != 'str ing') {
  224         type  = 'object ';
  225       }
  226       var ke y = type = = 'number'  ? value :  keyPrefix  + value;
  227       cache  = (cache =  cache[typ e]) && cac he[key];
  228  
  229       return  type == ' object'
  230         ? (c ache && ba seIndexOf( cache, val ue) > -1 ?  0 : -1)
  231         : (c ache ? 0 :  -1);
  232     }
  233  
  234     /**
  235      * Adds  a given va lue to the  correspon ding cache  object.
  236      *
  237      * @priv ate
  238      * @para m {*} valu e The valu e to add t o the cach e.
  239      */
  240     function  cachePush (value) {
  241       var ca che = this .cache,
  242           ty pe = typeo f value;
  243  
  244       if (ty pe == 'boo lean' || v alue == nu ll) {
  245         cach e[value] =  true;
  246       } else  {
  247         if ( type != 'n umber' &&  type != 's tring') {
  248           ty pe = 'obje ct';
  249         }
  250         var  key = type  == 'numbe r' ? value  : keyPref ix + value ,
  251              typeCache  = cache[ty pe] || (ca che[type]  = {});
  252  
  253         if ( type == 'o bject') {
  254           (t ypeCache[k ey] || (ty peCache[ke y] = [])). push(value );
  255         } el se {
  256           ty peCache[ke y] = true;
  257         }
  258       }
  259     }
  260  
  261     /**
  262      * Used  by `_.max`  and `_.mi n` as the  default ca llback whe n a given
  263      * colle ction is a  string va lue.
  264      *
  265      * @priv ate
  266      * @para m {string}  value The  character  to inspec t.
  267      * @retu rns {numbe r} Returns  the code  unit of gi ven charac ter.
  268      */
  269     function  charAtCal lback(valu e) {
  270       return  value.cha rCodeAt(0) ;
  271     }
  272  
  273     /**
  274      * Used  by `sortBy ` to compa re transfo rmed `coll ection` el ements, st able sorti ng
  275      * them  in ascendi ng order.
  276      *
  277      * @priv ate
  278      * @para m {Object}  a The obj ect to com pare to `b `.
  279      * @para m {Object}  b The obj ect to com pare to `a `.
  280      * @retu rns {numbe r} Returns  the sort  order indi cator of ` 1` or `-1` .
  281      */
  282     function  compareAs cending(a,  b) {
  283       var ac  = a.crite ria,
  284           bc  = b.crite ria,
  285           in dex = -1,
  286           le ngth = ac. length;
  287  
  288       while  (++index <  length) {
  289         var  value = ac [index],
  290              other = bc [index];
  291  
  292         if ( value !==  other) {
  293           if  (value >  other || t ypeof valu e == 'unde fined') {
  294              return 1;
  295           }
  296           if  (value <  other || t ypeof othe r == 'unde fined') {
  297              return -1;
  298           }
  299         }
  300       }
  301       // Fix es an `Arr ay#sort` b ug in the  JS engine  embedded i n Adobe ap plications
  302       // tha t causes i t, under c ertain cir cumstances , to retur n the same  value for
  303       // `a`  and `b`.  See https: //github.c om/jashken as/undersc ore/pull/1 247
  304       //
  305       // Thi s also ens ures a sta ble sort i n V8 and o ther engin es.
  306       // See  http://co de.google. com/p/v8/i ssues/deta il?id=90
  307       return  a.index -  b.index;
  308     }
  309  
  310     /**
  311      * Creat es a cache  object to  optimize  linear sea rches of l arge array s.
  312      *
  313      * @priv ate
  314      * @para m {Array}  [array=[]]  The array  to search .
  315      * @retu rns {null| Object} Re turns the  cache obje ct or `nul l` if cach ing should  not be us ed.
  316      */
  317     function  createCac he(array)  {
  318       var in dex = -1,
  319           le ngth = arr ay.length,
  320           fi rst = arra y[0],
  321           mi d = array[ (length /  2) | 0],
  322           la st = array [length -  1];
  323  
  324       if (fi rst && typ eof first  == 'object ' &&
  325           mi d && typeo f mid == ' object' &&  last && t ypeof last  == 'objec t') {
  326         retu rn false;
  327       }
  328       var ca che = getO bject();
  329       cache[ 'false'] =  cache['nu ll'] = cac he['true']  = cache[' undefined' ] = false;
  330  
  331       var re sult = get Object();
  332       result .array = a rray;
  333       result .cache = c ache;
  334       result .push = ca chePush;
  335  
  336       while  (++index <  length) {
  337         resu lt.push(ar ray[index] );
  338       }
  339       return  result;
  340     }
  341  
  342     /**
  343      * Used  by `templa te` to esc ape charac ters for i nclusion i n compiled
  344      * strin g literals .
  345      *
  346      * @priv ate
  347      * @para m {string}  match The  matched c haracter t o escape.
  348      * @retu rns {strin g} Returns  the escap ed charact er.
  349      */
  350     function  escapeStr ingChar(ma tch) {
  351       return  '\\' + st ringEscape s[match];
  352     }
  353  
  354     /**
  355      * Gets  an array f rom the ar ray pool o r creates  a new one  if the poo l is empty .
  356      *
  357      * @priv ate
  358      * @retu rns {Array } The arra y from the  pool.
  359      */
  360     function  getArray( ) {
  361       return  arrayPool .pop() ||  [];
  362     }
  363  
  364     /**
  365      * Gets  an object  from the o bject pool  or create s a new on e if the p ool is emp ty.
  366      *
  367      * @priv ate
  368      * @retu rns {Objec t} The obj ect from t he pool.
  369      */
  370     function  getObject () {
  371       return  objectPoo l.pop() ||  {
  372         'arr ay': null,
  373         'cac he': null,
  374         'cri teria': nu ll,
  375         'fal se': false ,
  376         'ind ex': 0,
  377         'nul l': false,
  378         'num ber': null ,
  379         'obj ect': null ,
  380         'pus h': null,
  381         'str ing': null ,
  382         'tru e': false,
  383         'und efined': f alse,
  384         'val ue': null
  385       };
  386     }
  387  
  388     /**
  389      * Check s if `valu e` is a DO M node in  IE < 9.
  390      *
  391      * @priv ate
  392      * @para m {*} valu e The valu e to check .
  393      * @retu rns {boole an} Return s `true` i f the `val ue` is a D OM node, e lse `false `.
  394      */
  395     function  isNode(va lue) {
  396       // IE  < 9 presen ts DOM nod es as `Obj ect` objec ts except  they have  `toString`
  397       // met hods that  are `typeo f` "string " and stil l can coer ce nodes t o strings
  398       return  typeof va lue.toStri ng != 'fun ction' &&  typeof (va lue + '')  == 'string ';
  399     }
  400  
  401     /**
  402      * Relea ses the gi ven array  back to th e array po ol.
  403      *
  404      * @priv ate
  405      * @para m {Array}  [array] Th e array to  release.
  406      */
  407     function  releaseAr ray(array)  {
  408       array. length = 0 ;
  409       if (ar rayPool.le ngth < max PoolSize)  {
  410         arra yPool.push (array);
  411       }
  412     }
  413  
  414     /**
  415      * Relea ses the gi ven object  back to t he object  pool.
  416      *
  417      * @priv ate
  418      * @para m {Object}  [object]  The object  to releas e.
  419      */
  420     function  releaseOb ject(objec t) {
  421       var ca che = obje ct.cache;
  422       if (ca che) {
  423         rele aseObject( cache);
  424       }
  425       object .array = o bject.cach e = object .criteria  = object.o bject = ob ject.numbe r = object .string =  object.val ue = null;
  426       if (ob jectPool.l ength < ma xPoolSize)  {
  427         obje ctPool.pus h(object);
  428       }
  429     }
  430  
  431     /**
  432      * Slice s the `col lection` f rom the `s tart` inde x up to, b ut not inc luding,
  433      * the ` end` index .
  434      *
  435      * Note:  This func tion is us ed instead  of `Array #slice` to  support n ode lists
  436      * in IE  < 9 and t o ensure d ense array s are retu rned.
  437      *
  438      * @priv ate
  439      * @para m {Array|O bject|stri ng} collec tion The c ollection  to slice.
  440      * @para m {number}  start The  start ind ex.
  441      * @para m {number}  end The e nd index.
  442      * @retu rns {Array } Returns  the new ar ray.
  443      */
  444     function  slice(arr ay, start,  end) {
  445       start  || (start  = 0);
  446       if (ty peof end = = 'undefin ed') {
  447         end  = array ?  array.leng th : 0;
  448       }
  449       var in dex = -1,
  450           le ngth = end  - start | | 0,
  451           re sult = Arr ay(length  < 0 ? 0 :  length);
  452  
  453       while  (++index <  length) {
  454         resu lt[index]  = array[st art + inde x];
  455       }
  456       return  result;
  457     }
  458  
  459     /*------ ---------- ---------- ---------- ---------- ---------- ---------- --------*/
  460  
  461     /**
  462      * Creat e a new `l odash` fun ction usin g the give n context  object.
  463      *
  464      * @stat ic
  465      * @memb erOf _
  466      * @cate gory Utili ties
  467      * @para m {Object}  [context= root] The  context ob ject.
  468      * @retu rns {Funct ion} Retur ns the `lo dash` func tion.
  469      */
  470     function  runInCont ext(contex t) {
  471       // Avo id issues  with some  ES3 enviro nments tha t attempt  to use val ues, named
  472       // aft er built-i n construc tors like  `Object`,  for the cr eation of  literals.
  473       // ES5  clears th is up by s tating tha t literals  must use  built-in c onstructor s.
  474       // See  http://es 5.github.i o/#x11.1.5 .
  475       contex t = contex t ? _.defa ults(root. Object(),  context, _ .pick(root , contextP rops)) : r oot;
  476  
  477       /** Na tive const ructor ref erences */
  478       var Ar ray = cont ext.Array,
  479           Bo olean = co ntext.Bool ean,
  480           Da te = conte xt.Date,
  481           Er ror = cont ext.Error,
  482           Fu nction = c ontext.Fun ction,
  483           Ma th = conte xt.Math,
  484           Nu mber = con text.Numbe r,
  485           Ob ject = con text.Objec t,
  486           Re gExp = con text.RegEx p,
  487           St ring = con text.Strin g,
  488           Ty peError =  context.Ty peError;
  489  
  490       /**
  491        * Use d for `Arr ay` method  reference s.
  492        *
  493        * Nor mally `Arr ay.prototy pe` would  suffice, h owever, us ing an arr ay literal
  494        * avo ids issues  in Narwha l.
  495        */
  496       var ar rayRef = [ ];
  497  
  498       /** Us ed for nat ive method  reference s */
  499       var er rorProto =  Error.pro totype,
  500           ob jectProto  = Object.p rototype,
  501           st ringProto  = String.p rototype;
  502  
  503       /** Us ed to rest ore the or iginal `_`  reference  in `noCon flict` */
  504       var ol dDash = co ntext._;
  505  
  506       /** Us ed to reso lve the in ternal [[C lass]] of  values */
  507       var to String = o bjectProto .toString;
  508  
  509       /** Us ed to dete ct if a me thod is na tive */
  510       var re Native = R egExp('^'  +
  511         Stri ng(toStrin g)
  512           .r eplace(/[. *+?^${}()| [\]\\]/g,  '\\$&')
  513           .r eplace(/to String| fo r [^\]]+/g , '.*?') +  '$'
  514       );
  515  
  516       /** Na tive metho d shortcut s */
  517       var ce il = Math. ceil,
  518           cl earTimeout  = context .clearTime out,
  519           fl oor = Math .floor,
  520           fn ToString =  Function. prototype. toString,
  521           ge tPrototype Of = isNat ive(getPro totypeOf =  Object.ge tPrototype Of) && get PrototypeO f,
  522           ha sOwnProper ty = objec tProto.has OwnPropert y,
  523           pu sh = array Ref.push,
  524           pr opertyIsEn umerable =  objectPro to.propert yIsEnumera ble,
  525           se tTimeout =  context.s etTimeout,
  526           sp lice = arr ayRef.spli ce,
  527           un shift = ar rayRef.uns hift;
  528  
  529       /** Us ed to set  meta data  on functio ns */
  530       var de fineProper ty = (func tion() {
  531         // I E 8 only a ccepts DOM  elements
  532         try  {
  533           va r o = {},
  534                func = i sNative(fu nc = Objec t.definePr operty) &&  func,
  535                result =  func(o, o , o) && fu nc;
  536         } ca tch(e) { }
  537         retu rn result;
  538       }());
  539  
  540       /* Nat ive method  shortcuts  for metho ds with th e same nam e as other  `lodash`  methods */
  541       var na tiveCreate  = isNativ e(nativeCr eate = Obj ect.create ) && nativ eCreate,
  542           na tiveIsArra y = isNati ve(nativeI sArray = A rray.isArr ay) && nat iveIsArray ,
  543           na tiveIsFini te = conte xt.isFinit e,
  544           na tiveIsNaN  = context. isNaN,
  545           na tiveKeys =  isNative( nativeKeys  = Object. keys) && n ativeKeys,
  546           na tiveMax =  Math.max,
  547           na tiveMin =  Math.min,
  548           na tiveParseI nt = conte xt.parseIn t,
  549           na tiveRandom  = Math.ra ndom;
  550  
  551       /** Us ed to look up a built -in constr uctor by [ [Class]] * /
  552       var ct orByClass  = {};
  553       ctorBy Class[arra yClass] =  Array;
  554       ctorBy Class[bool Class] = B oolean;
  555       ctorBy Class[date Class] = D ate;
  556       ctorBy Class[func Class] = F unction;
  557       ctorBy Class[obje ctClass] =  Object;
  558       ctorBy Class[numb erClass] =  Number;
  559       ctorBy Class[rege xpClass] =  RegExp;
  560       ctorBy Class[stri ngClass] =  String;
  561  
  562       /** Us ed to avoi d iteratin g non-enum erable pro perties in  IE < 9 */
  563       var no nEnumProps  = {};
  564       nonEnu mProps[arr ayClass] =  nonEnumPr ops[dateCl ass] = non EnumProps[ numberClas s] = { 'co nstructor' : true, 't oLocaleStr ing': true , 'toStrin g': true,  'valueOf':  true };
  565       nonEnu mProps[boo lClass] =  nonEnumPro ps[stringC lass] = {  'construct or': true,  'toString ': true, ' valueOf':  true };
  566       nonEnu mProps[err orClass] =  nonEnumPr ops[funcCl ass] = non EnumProps[ regexpClas s] = { 'co nstructor' : true, 't oString':  true };
  567       nonEnu mProps[obj ectClass]  = { 'const ructor': t rue };
  568  
  569       (funct ion() {
  570         var  length = s hadowedPro ps.length;
  571         whil e (length- -) {
  572           va r key = sh adowedProp s[length];
  573           fo r (var cla ssName in  nonEnumPro ps) {
  574              if (hasOwn Property.c all(nonEnu mProps, cl assName) & & !hasOwnP roperty.ca ll(nonEnum Props[clas sName], ke y)) {
  575                nonEnumP rops[class Name][key]  = false;
  576              }
  577           }
  578         }
  579       }());
  580  
  581       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  582  
  583       /**
  584        * Cre ates a `lo dash` obje ct which w raps the g iven value  to enable  intuitive
  585        * met hod chaini ng.
  586        *
  587        * In  addition t o Lo-Dash  methods, w rappers al so have th e followin g `Array`  methods:
  588        * `co ncat`, `jo in`, `pop` , `push`,  `reverse`,  `shift`,  `slice`, ` sort`, `sp lice`,
  589        * and  `unshift`
  590        *
  591        * Cha ining is s upported i n custom b uilds as l ong as the  `value` m ethod is
  592        * imp licitly or  explicitl y included  in the bu ild.
  593        *
  594        * The  chainable  wrapper f unctions a re:
  595        * `af ter`, `ass ign`, `bin d`, `bindA ll`, `bind Key`, `cha in`, `comp act`,
  596        * `co mpose`, `c oncat`, `c ountBy`, ` create`, ` createCall back`, `cu rry`,
  597        * `de bounce`, ` defaults`,  `defer`,  `delay`, ` difference `, `filter `, `flatte n`,
  598        * `fo rEach`, `f orEachRigh t`, `forIn `, `forInR ight`, `fo rOwn`, `fo rOwnRight` ,
  599        * `fu nctions`,  `groupBy`,  `indexBy` , `initial `, `inters ection`, ` invert`,
  600        * `in voke`, `ke ys`, `map` , `max`, ` memoize`,  `merge`, ` min`, `obj ect`, `omi t`,
  601        * `on ce`, `pair s`, `parti al`, `part ialRight`,  `pick`, ` pluck`, `p ull`, `pus h`,
  602        * `ra nge`, `rej ect`, `rem ove`, `res t`, `rever se`, `shuf fle`, `sli ce`, `sort `,
  603        * `so rtBy`, `sp lice`, `ta p`, `throt tle`, `tim es`, `toAr ray`, `tra nsform`,
  604        * `un ion`, `uni q`, `unshi ft`, `unzi p`, `value s`, `where `, `withou t`, `wrap` ,
  605        * and  `zip`
  606        *
  607        * The  non-chain able wrapp er functio ns are:
  608        * `cl one`, `clo neDeep`, ` contains`,  `escape`,  `every`,  `find`, `f indIndex`,
  609        * `fi ndKey`, `f indLast`,  `findLastI ndex`, `fi ndLastKey` , `has`, ` identity`,
  610        * `in dexOf`, `i sArguments `, `isArra y`, `isBoo lean`, `is Date`, `is Element`,
  611        * `is Empty`, `i sEqual`, ` isFinite`,  `isFuncti on`, `isNa N`, `isNul l`, `isNum ber`,
  612        * `is Object`, ` isPlainObj ect`, `isR egExp`, `i sString`,  `isUndefin ed`, `join `,
  613        * `la stIndexOf` , `mixin`,  `noConfli ct`, `pars eInt`, `po p`, `rando m`, `reduc e`,
  614        * `re duceRight` , `result` , `shift`,  `size`, ` some`, `so rtedIndex` , `runInCo ntext`,
  615        * `te mplate`, ` unescape`,  `uniqueId `, and `va lue`
  616        *
  617        * The  wrapper f unctions ` first` and  `last` re turn wrapp ed values  when `n` i s
  618        * pro vided, oth erwise the y return u nwrapped v alues.
  619        *
  620        * Exp licit chai ning can b e enabled  by using t he `_.chai n` method.
  621        *
  622        * @na me _
  623        * @co nstructor
  624        * @ca tegory Cha ining
  625        * @pa ram {*} va lue The va lue to wra p in a `lo dash` inst ance.
  626        * @re turns {Obj ect} Retur ns a `loda sh` instan ce.
  627        * @ex ample
  628        *
  629        * var  wrapped =  _([1, 2,  3]);
  630        *
  631        * //  returns an  unwrapped  value
  632        * wra pped.reduc e(function (sum, num)  {
  633        *   r eturn sum  + num;
  634        * });
  635        * //  => 6
  636        *
  637        * //  returns a  wrapped va lue
  638        * var  squares =  wrapped.m ap(functio n(num) {
  639        *   r eturn num  * num;
  640        * });
  641        *
  642        * _.i sArray(squ ares);
  643        * //  => false
  644        *
  645        * _.i sArray(squ ares.value ());
  646        * //  => true
  647        */
  648       functi on lodash( value) {
  649         // d on't wrap  if already  wrapped,  even if wr apped by a  different  `lodash`  constructo r
  650         retu rn (value  && typeof  value == ' object' &&  !isArray( value) &&  hasOwnProp erty.call( value, '__ wrapped__' ))
  651          ? v alue
  652          : n ew lodashW rapper(val ue);
  653       }
  654  
  655       /**
  656        * A f ast path f or creatin g `lodash`  wrapper o bjects.
  657        *
  658        * @pr ivate
  659        * @pa ram {*} va lue The va lue to wra p in a `lo dash` inst ance.
  660        * @pa ram {boole an} chainA ll A flag  to enable  chaining f or all met hods
  661        * @re turns {Obj ect} Retur ns a `loda sh` instan ce.
  662        */
  663       functi on lodashW rapper(val ue, chainA ll) {
  664         this .__chain__  = !!chain All;
  665         this .__wrapped __ = value ;
  666       }
  667       // ens ure `new l odashWrapp er` is an  instance o f `lodash`
  668       lodash Wrapper.pr ototype =  lodash.pro totype;
  669  
  670       /**
  671        * An  object use d to flag  environmen ts feature s.
  672        *
  673        * @st atic
  674        * @me mberOf _
  675        * @ty pe Object
  676        */
  677       var su pport = lo dash.suppo rt = {};
  678  
  679       (funct ion() {
  680         var  ctor = fun ction() {  this.x = 1 ; },
  681              object = {  '0': 1, ' length': 1  },
  682              props = [] ;
  683  
  684         ctor .prototype  = { 'valu eOf': 1, ' y': 1 };
  685         for  (var key i n new ctor ) { props. push(key);  }
  686         for  (key in ar guments) {  }
  687  
  688         /**
  689          * D etect if a n `argumen ts` object 's [[Class ]] is reso lvable (al l but Fire fox < 4, I E < 9).
  690          *
  691          * @ memberOf _ .support
  692          * @ type boole an
  693          */
  694         supp ort.argsCl ass = toSt ring.call( arguments)  == argsCl ass;
  695  
  696         /**
  697          * D etect if ` arguments`  objects a re `Object ` objects  (all but N arwhal and  Opera < 1 0.5).
  698          *
  699          * @ memberOf _ .support
  700          * @ type boole an
  701          */
  702         supp ort.argsOb ject = arg uments.con structor = = Object & & !(argume nts instan ceof Array );
  703  
  704         /**
  705          * D etect if ` name` or ` message` p roperties  of `Error. prototype`  are
  706          * e numerable  by default . (IE < 9,  Safari <  5.1)
  707          *
  708          * @ memberOf _ .support
  709          * @ type boole an
  710          */
  711         supp ort.enumEr rorProps =  propertyI sEnumerabl e.call(err orProto, ' message')  || propert yIsEnumera ble.call(e rrorProto,  'name');
  712  
  713         /**
  714          * D etect if ` prototype`  propertie s are enum erable by  default.
  715          *
  716          * F irefox < 3 .6, Opera  > 9.50 - O pera < 11. 60, and Sa fari < 5.1
  717          * ( if the pro totype or  a property  on the pr ototype ha s been set )
  718          * i ncorrectly  sets a fu nction's ` prototype`  property  [[Enumerab le]]
  719          * v alue to `t rue`.
  720          *
  721          * @ memberOf _ .support
  722          * @ type boole an
  723          */
  724         supp ort.enumPr ototypes =  propertyI sEnumerabl e.call(cto r, 'protot ype');
  725  
  726         /**
  727          * D etect if f unctions c an be deco mpiled by  `Function# toString`
  728          * ( all but PS 3 and olde r Opera mo bile brows ers & avoi ded in Win dows 8 app s).
  729          *
  730          * @ memberOf _ .support
  731          * @ type boole an
  732          */
  733         supp ort.funcDe comp = !is Native(con text.WinRT Error) &&  reThis.tes t(runInCon text);
  734  
  735         /**
  736          * D etect if ` Function#n ame` is su pported (a ll but IE) .
  737          *
  738          * @ memberOf _ .support
  739          * @ type boole an
  740          */
  741         supp ort.funcNa mes = type of Functio n.name ==  'string';
  742  
  743         /**
  744          * D etect if ` arguments`  object in dexes are  non-enumer able
  745          * ( Firefox <  4, IE < 9,  PhantomJS , Safari <  5.1).
  746          *
  747          * @ memberOf _ .support
  748          * @ type boole an
  749          */
  750         supp ort.nonEnu mArgs = ke y != 0;
  751  
  752         /**
  753          * D etect if p roperties  shadowing  those on ` Object.pro totype` ar e non-enum erable.
  754          *
  755          * I n IE < 9 a n objects  own proper ties, shad owing non- enumerable  ones, are
  756          * m ade non-en umerable a s well (a. k.a the JS cript [[Do ntEnum]] b ug).
  757          *
  758          * @ memberOf _ .support
  759          * @ type boole an
  760          */
  761         supp ort.nonEnu mShadows =  !/valueOf /.test(pro ps);
  762  
  763         /**
  764          * D etect if o wn propert ies are it erated aft er inherit ed propert ies (all b ut IE < 9) .
  765          *
  766          * @ memberOf _ .support
  767          * @ type boole an
  768          */
  769         supp ort.ownLas t = props[ 0] != 'x';
  770  
  771         /**
  772          * D etect if ` Array#shif t` and `Ar ray#splice ` augment  array-like  objects c orrectly.
  773          *
  774          * F irefox < 1 0, IE comp atibility  mode, and  IE < 9 hav e buggy Ar ray `shift ()`
  775          * a nd `splice ()` functi ons that f ail to rem ove the la st element , `value[0 ]`,
  776          * o f array-li ke objects  even thou gh the `le ngth` prop erty is se t to `0`.
  777          * T he `shift( )` method  is buggy i n IE 8 com patibility  mode, whi le `splice ()`
  778          * i s buggy re gardless o f mode in  IE < 9 and  buggy in  compatibil ity mode i n IE 9.
  779          *
  780          * @ memberOf _ .support
  781          * @ type boole an
  782          */
  783         supp ort.splice Objects =  (arrayRef. splice.cal l(object,  0, 1), !ob ject[0]);
  784  
  785         /**
  786          * D etect lack  of suppor t for acce ssing stri ng charact ers by ind ex.
  787          *
  788          * I E < 8 can' t access c haracters  by index a nd IE 8 ca n only acc ess
  789          * c haracters  by index o n string l iterals.
  790          *
  791          * @ memberOf _ .support
  792          * @ type boole an
  793          */
  794         supp ort.uninde xedChars =  ('x'[0] +  Object('x ')[0]) !=  'xx';
  795  
  796         /**
  797          * D etect if a  DOM node' s [[Class] ] is resol vable (all  but IE <  9)
  798          * a nd that th e JS engin e errors w hen attemp ting to co erce an ob ject to
  799          * a  string wi thout a `t oString` f unction.
  800          *
  801          * @ memberOf _ .support
  802          * @ type boole an
  803          */
  804         try  {
  805           su pport.node Class = !( toString.c all(docume nt) == obj ectClass & & !({ 'toS tring': 0  } + ''));
  806         } ca tch(e) {
  807           su pport.node Class = tr ue;
  808         }
  809       }(1));
  810  
  811       /**
  812        * By  default, t he templat e delimite rs used by  Lo-Dash a re similar  to those  in
  813        * emb edded Ruby  (ERB). Ch ange the f ollowing t emplate se ttings to  use altern ative
  814        * del imiters.
  815        *
  816        * @st atic
  817        * @me mberOf _
  818        * @ty pe Object
  819        */
  820       lodash .templateS ettings =  {
  821  
  822         /**
  823          * U sed to det ect `data`  property  values to  be HTML-es caped.
  824          *
  825          * @ memberOf _ .templateS ettings
  826          * @ type RegEx p
  827          */
  828         'esc ape': /<%- ([\s\S]+?) %>/g,
  829  
  830         /**
  831          * U sed to det ect code t o be evalu ated.
  832          *
  833          * @ memberOf _ .templateS ettings
  834          * @ type RegEx p
  835          */
  836         'eva luate': /< %([\s\S]+? )%>/g,
  837  
  838         /**
  839          * U sed to det ect `data`  property  values to  inject.
  840          *
  841          * @ memberOf _ .templateS ettings
  842          * @ type RegEx p
  843          */
  844         'int erpolate':  reInterpo late,
  845  
  846         /**
  847          * U sed to ref erence the  data obje ct in the  template t ext.
  848          *
  849          * @ memberOf _ .templateS ettings
  850          * @ type strin g
  851          */
  852         'var iable': '' ,
  853  
  854         /**
  855          * U sed to imp ort variab les into t he compile d template .
  856          *
  857          * @ memberOf _ .templateS ettings
  858          * @ type Objec t
  859          */
  860         'imp orts': {
  861  
  862           /* *
  863            *  A referen ce to the  `lodash` f unction.
  864            *
  865            *  @memberOf  _.templat eSettings. imports
  866            *  @type Fun ction
  867            * /
  868           '_ ': lodash
  869         }
  870       };
  871  
  872       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  873  
  874       /**
  875        * The  template  used to cr eate itera tor functi ons.
  876        *
  877        * @pr ivate
  878        * @pa ram {Objec t} data Th e data obj ect used t o populate  the text.
  879        * @re turns {str ing} Retur ns the int erpolated  text.
  880        */
  881       var it eratorTemp late = tem plate(
  882         // t he `iterab le` may be  reassigne d by the ` top` snipp et
  883         'var  index, it erable = < %= firstAr g %>, ' +
  884         // a ssign the  `result` v ariable an  initial v alue
  885         'res ult = <%=  init %>;\n ' +
  886         // e xit early  if the fir st argumen t is false y
  887         'if  (!iterable ) return r esult;\n'  +
  888         // a dd code be fore the i teration b ranches
  889         '<%=  top %>;'  +
  890  
  891         // a rray-like  iteration:
  892         '<%  if (array)  { %>\n' +
  893         'var  length =  iterable.l ength; ind ex = -1;\n ' +
  894         'if  (<%= array  %>) {' +
  895  
  896         // a dd support  for acces sing strin g characte rs by inde x if neede d
  897         '  < % if (supp ort.uninde xedChars)  { %>\n' +
  898         '  i f (isStrin g(iterable )) {\n' +
  899         "     iterable  = iterable .split('') \n" +
  900         '  } ' +
  901         '  < % } %>\n'  +
  902  
  903         // i terate ove r the arra y-like val ue
  904         '  w hile (++in dex < leng th) {\n' +
  905         '     <%= loop  %>;\n' +
  906         '  } \n' +
  907         '}\n ' +
  908         'els e {' +
  909  
  910         // o bject iter ation:
  911         // a dd support  for itera ting over  `arguments ` objects  if needed
  912         '  < % } else i f (support .nonEnumAr gs) { %>\n ' +
  913         '  v ar length  = iterable .length; i ndex = -1; \n' +
  914         '  i f (length  && isArgum ents(itera ble)) {\n'  +
  915         '     while (++ index < le ngth) {\n'  +
  916         "       index + = '';\n" +
  917         '       <%= loo p %>;\n' +
  918         '     }\n' +
  919         '  }  else {' +
  920         '  < % } %>' +
  921  
  922         // a void itera ting over  `prototype ` properti es in olde r Firefox,  Opera, an d Safari
  923         '  < % if (supp ort.enumPr ototypes)  { %>\n' +
  924         "  v ar skipPro to = typeo f iterable  == 'funct ion';\n" +
  925         '  < % } %>' +
  926  
  927         // a void itera ting over  `Error.pro totype` pr operties i n older IE  and Safar i
  928         '  < % if (supp ort.enumEr rorProps)  { %>\n' +
  929         '  v ar skipErr orProps =  iterable = == errorPr oto || ite rable inst anceof Err or;\n' +
  930         '  < % } %>' +
  931  
  932         // d efine cond itions use d in the l oop
  933         '  < %' +
  934         '     var condi tions = [] ;' +
  935         '     if (suppo rt.enumPro totypes) {  condition s.push(\'! (skipProto  && index  == "protot ype")\');  }' +
  936         '     if (suppo rt.enumErr orProps)   { conditio ns.push(\' !(skipErro rProps &&  (index ==  "message"  || index = = "name")) \'); }' +
  937         '  % >' +
  938  
  939         // i terate own  propertie s using `O bject.keys `
  940         '  < % if (useH as && keys ) { %>\n'  +
  941         '  v ar ownInde x = -1,\n'  +
  942         '       ownProp s = object Types[type of iterabl e] && keys (iterable) ,\n' +
  943         '       length  = ownProps  ? ownProp s.length :  0;\n\n' +
  944         '  w hile (++ow nIndex < l ength) {\n ' +
  945         '     index = o wnProps[ow nIndex];\n <%' +
  946         "     if (condi tions.leng th) { %>     if (<%=  conditions .join(' &&  ') %>) {\ n  <% } %> " +
  947         '     <%= loop  %>;' +
  948         '     <% if (co nditions.l ength) { % >\n    }<%  } %>\n' +
  949         '  } ' +
  950  
  951         // e lse using  a for-in l oop
  952         '  < % } else {  %>\n' +
  953         '  f or (index  in iterabl e) {\n<%'  +
  954         '     if (useHa s) { condi tions.push ("hasOwnPr operty.cal l(iterable , index)") ; }' +
  955         "     if (condi tions.leng th) { %>     if (<%=  conditions .join(' &&  ') %>) {\ n  <% } %> " +
  956         '     <%= loop  %>;' +
  957         '     <% if (co nditions.l ength) { % >\n    }<%  } %>\n' +
  958         '  } ' +
  959  
  960         // B ecause IE  < 9 can't  set the `[ [Enumerabl e]]` attri bute of an
  961         // e xisting pr operty and  the `cons tructor` p roperty of  a prototy pe
  962         // d efaults to  non-enume rable, Lo- Dash skips  the `cons tructor`
  963         // p roperty wh en it infe rs it's it erating ov er a `prot otype` obj ect.
  964         '     <% if (su pport.nonE numShadows ) { %>\n\n ' +
  965         '  i f (iterabl e !== obje ctProto) { \n' +
  966         "     var ctor  = iterable .construct or,\n" +
  967         '         isPro to = itera ble === (c tor && cto r.prototyp e),\n' +
  968         '         class Name = ite rable ===  stringProt o ? string Class : it erable ===  errorProt o ? errorC lass : toS tring.call (iterable) ,\n' +
  969         '         nonEn um = nonEn umProps[cl assName];\ n' +
  970         '       <% for  (k = 0; k  < 7; k++)  { %>\n' +
  971         "     index = ' <%= shadow edProps[k]  %>';\n" +
  972         '     if ((!(is Proto && n onEnum[ind ex]) && ha sOwnProper ty.call(it erable, in dex))<%' +
  973         '         if (! useHas) {  %> || (!no nEnum[inde x] && iter able[index ] !== obje ctProto[in dex])<% }'  +
  974         '       %>) {\n ' +
  975         '       <%= loo p %>;\n' +
  976         '     }' +
  977         '       <% } %> \n' +
  978         '  } ' +
  979         '     <% } %>'  +
  980         '  < % } %>' +
  981         '  < % if (arra y || suppo rt.nonEnum Args) { %> \n}<% } %> \n' +
  982  
  983         // a dd code to  the botto m of the i teration f unction
  984         '<%=  bottom %> ;\n' +
  985         // f inally, re turn the ` result`
  986         'ret urn result '
  987       );
  988  
  989       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  990  
  991       /**
  992        * The  base impl ementation  of `_.bin d` that cr eates the  bound func tion and
  993        * set s its meta  data.
  994        *
  995        * @pr ivate
  996        * @pa ram {Array } bindData  The bind  data array .
  997        * @re turns {Fun ction} Ret urns the n ew bound f unction.
  998        */
  999       functi on baseBin d(bindData ) {
  1000         var  func = bin dData[0],
  1001              partialArg s = bindDa ta[2],
  1002              thisArg =  bindData[4 ];
  1003  
  1004         func tion bound () {
  1005           //  `Function #bind` spe c
  1006           //  http://es 5.github.i o/#x15.3.4 .5
  1007           if  (partialA rgs) {
  1008              // avoid ` arguments`  object de optimizati ons by usi ng `slice`  instead
  1009              // of `Arr ay.prototy pe.slice.c all` and n ot assigni ng `argume nts` to a
  1010              // variabl e as a ter nary expre ssion
  1011              var args =  slice(par tialArgs);
  1012              push.apply (args, arg uments);
  1013           }
  1014           //  mimic the  construct or's `retu rn` behavi or
  1015           //  http://es 5.github.i o/#x13.2.2
  1016           if  (this ins tanceof bo und) {
  1017              // ensure  `new bound ` is an in stance of  `func`
  1018              var thisBi nding = ba seCreate(f unc.protot ype),
  1019                  result  = func.ap ply(thisBi nding, arg s || argum ents);
  1020              return isO bject(resu lt) ? resu lt : thisB inding;
  1021           }
  1022           re turn func. apply(this Arg, args  || argumen ts);
  1023         }
  1024         setB indData(bo und, bindD ata);
  1025         retu rn bound;
  1026       }
  1027  
  1028       /**
  1029        * The  base impl ementation  of `_.clo ne` withou t argument  juggling  or support
  1030        * for  `thisArg`  binding.
  1031        *
  1032        * @pr ivate
  1033        * @pa ram {*} va lue The va lue to clo ne.
  1034        * @pa ram {boole an} [isDee p=false] S pecify a d eep clone.
  1035        * @pa ram {Funct ion} [call back] The  function t o customiz e cloning  values.
  1036        * @pa ram {Array } [stackA= []] Tracks  traversed  source ob jects.
  1037        * @pa ram {Array } [stackB= []] Associ ates clone s with sou rce counte rparts.
  1038        * @re turns {*}  Returns th e cloned v alue.
  1039        */
  1040       functi on baseClo ne(value,  isDeep, ca llback, st ackA, stac kB) {
  1041         if ( callback)  {
  1042           va r result =  callback( value);
  1043           if  (typeof r esult != ' undefined' ) {
  1044              return res ult;
  1045           }
  1046         }
  1047         // i nspect [[C lass]]
  1048         var  isObj = is Object(val ue);
  1049         if ( isObj) {
  1050           va r classNam e = toStri ng.call(va lue);
  1051           if  (!cloneab leClasses[ className]  || (!supp ort.nodeCl ass && isN ode(value) )) {
  1052              return val ue;
  1053           }
  1054           va r ctor = c torByClass [className ];
  1055           sw itch (clas sName) {
  1056              case boolC lass:
  1057              case dateC lass:
  1058                return n ew ctor(+v alue);
  1059  
  1060              case numbe rClass:
  1061              case strin gClass:
  1062                return n ew ctor(va lue);
  1063  
  1064              case regex pClass:
  1065                result =  ctor(valu e.source,  reFlags.ex ec(value)) ;
  1066                result.l astIndex =  value.las tIndex;
  1067                return r esult;
  1068           }
  1069         } el se {
  1070           re turn value ;
  1071         }
  1072         var  isArr = is Array(valu e);
  1073         if ( isDeep) {
  1074           //  check for  circular  references  and retur n correspo nding clon e
  1075           va r initedSt ack = !sta ckA;
  1076           st ackA || (s tackA = ge tArray());
  1077           st ackB || (s tackB = ge tArray());
  1078  
  1079           va r length =  stackA.le ngth;
  1080           wh ile (lengt h--) {
  1081              if (stackA [length] = = value) {
  1082                return s tackB[leng th];
  1083              }
  1084           }
  1085           re sult = isA rr ? ctor( value.leng th) : {};
  1086         }
  1087         else  {
  1088           re sult = isA rr ? slice (value) :  assign({},  value);
  1089         }
  1090         // a dd array p roperties  assigned b y `RegExp# exec`
  1091         if ( isArr) {
  1092           if  (hasOwnPr operty.cal l(value, ' index')) {
  1093              result.ind ex = value .index;
  1094           }
  1095           if  (hasOwnPr operty.cal l(value, ' input')) {
  1096              result.inp ut = value .input;
  1097           }
  1098         }
  1099         // e xit for sh allow clon e
  1100         if ( !isDeep) {
  1101           re turn resul t;
  1102         }
  1103         // a dd the sou rce value  to the sta ck of trav ersed obje cts
  1104         // a nd associa te it with  its clone
  1105         stac kA.push(va lue);
  1106         stac kB.push(re sult);
  1107  
  1108         // r ecursively  populate  clone (sus ceptible t o call sta ck limits)
  1109         (isA rr ? baseE ach : forO wn)(value,  function( objValue,  key) {
  1110           re sult[key]  = baseClon e(objValue , isDeep,  callback,  stackA, st ackB);
  1111         });
  1112  
  1113         if ( initedStac k) {
  1114           re leaseArray (stackA);
  1115           re leaseArray (stackB);
  1116         }
  1117         retu rn result;
  1118       }
  1119  
  1120       /**
  1121        * The  base impl ementation  of `_.cre ate` witho ut support  for assig ning
  1122        * pro perties to  the creat ed object.
  1123        *
  1124        * @pr ivate
  1125        * @pa ram {Objec t} prototy pe The obj ect to inh erit from.
  1126        * @re turns {Obj ect} Retur ns the new  object.
  1127        */
  1128       functi on baseCre ate(protot ype, prope rties) {
  1129         retu rn isObjec t(prototyp e) ? nativ eCreate(pr ototype) :  {};
  1130       }
  1131       // fal lback for  browsers w ithout `Ob ject.creat e`
  1132       if (!n ativeCreat e) {
  1133         base Create = ( function()  {
  1134           fu nction Obj ect() {}
  1135           re turn funct ion(protot ype) {
  1136              if (isObje ct(prototy pe)) {
  1137                Object.p rototype =  prototype ;
  1138                var resu lt = new O bject;
  1139                Object.p rototype =  null;
  1140              }
  1141              return res ult || con text.Objec t();
  1142           };
  1143         }()) ;
  1144       }
  1145  
  1146       /**
  1147        * The  base impl ementation  of `_.cre ateCallbac k` without  support f or creatin g
  1148        * "_. pluck" or  "_.where"  style call backs.
  1149        *
  1150        * @pr ivate
  1151        * @pa ram {*} [f unc=identi ty] The va lue to con vert to a  callback.
  1152        * @pa ram {*} [t hisArg] Th e `this` b inding of  the create d callback .
  1153        * @pa ram {numbe r} [argCou nt] The nu mber of ar guments th e callback  accepts.
  1154        * @re turns {Fun ction} Ret urns a cal lback func tion.
  1155        */
  1156       functi on baseCre ateCallbac k(func, th isArg, arg Count) {
  1157         if ( typeof fun c != 'func tion') {
  1158           re turn ident ity;
  1159         }
  1160         // e xit early  for no `th isArg` or  already bo und by `Fu nction#bin d`
  1161         if ( typeof thi sArg == 'u ndefined'  || !('prot otype' in  func)) {
  1162           re turn func;
  1163         }
  1164         var  bindData =  func.__bi ndData__;
  1165         if ( typeof bin dData == ' undefined' ) {
  1166           if  (support. funcNames)  {
  1167              bindData =  !func.nam e;
  1168           }
  1169           bi ndData = b indData ||  !support. funcDecomp ;
  1170           if  (!bindDat a) {
  1171              var source  = fnToStr ing.call(f unc);
  1172              if (!suppo rt.funcNam es) {
  1173                bindData  = !reFunc Name.test( source);
  1174              }
  1175              if (!bindD ata) {
  1176                // check s if `func ` referenc es the `th is` keywor d and stor es the res ult
  1177                bindData  = reThis. test(sourc e);
  1178                setBindD ata(func,  bindData);
  1179              }
  1180           }
  1181         }
  1182         // e xit early  if there a re no `thi s` referen ces or `fu nc` is bou nd
  1183         if ( bindData = == false | | (bindDat a !== true  && bindDa ta[1] & 1) ) {
  1184           re turn func;
  1185         }
  1186         swit ch (argCou nt) {
  1187           ca se 1: retu rn functio n(value) {
  1188              return fun c.call(thi sArg, valu e);
  1189           };
  1190           ca se 2: retu rn functio n(a, b) {
  1191              return fun c.call(thi sArg, a, b );
  1192           };
  1193           ca se 3: retu rn functio n(value, i ndex, coll ection) {
  1194              return fun c.call(thi sArg, valu e, index,  collection );
  1195           };
  1196           ca se 4: retu rn functio n(accumula tor, value , index, c ollection)  {
  1197              return fun c.call(thi sArg, accu mulator, v alue, inde x, collect ion);
  1198           };
  1199         }
  1200         retu rn bind(fu nc, thisAr g);
  1201       }
  1202  
  1203       /**
  1204        * The  base impl ementation  of `creat eWrapper`  that creat es the wra pper and
  1205        * set s its meta  data.
  1206        *
  1207        * @pr ivate
  1208        * @pa ram {Array } bindData  The bind  data array .
  1209        * @re turns {Fun ction} Ret urns the n ew functio n.
  1210        */
  1211       functi on baseCre ateWrapper (bindData)  {
  1212         var  func = bin dData[0],
  1213              bitmask =  bindData[1 ],
  1214              partialArg s = bindDa ta[2],
  1215              partialRig htArgs = b indData[3] ,
  1216              thisArg =  bindData[4 ],
  1217              arity = bi ndData[5];
  1218  
  1219         var  isBind = b itmask & 1 ,
  1220              isBindKey  = bitmask  & 2,
  1221              isCurry =  bitmask &  4,
  1222              isCurryBou nd = bitma sk & 8,
  1223              key = func ;
  1224  
  1225         func tion bound () {
  1226           va r thisBind ing = isBi nd ? thisA rg : this;
  1227           if  (partialA rgs) {
  1228              var args =  slice(par tialArgs);
  1229              push.apply (args, arg uments);
  1230           }
  1231           if  (partialR ightArgs | | isCurry)  {
  1232              args || (a rgs = slic e(argument s));
  1233              if (partia lRightArgs ) {
  1234                push.app ly(args, p artialRigh tArgs);
  1235              }
  1236              if (isCurr y && args. length < a rity) {
  1237                bitmask  |= 16 & ~3 2;
  1238                return b aseCreateW rapper([fu nc, (isCur ryBound ?  bitmask :  bitmask &  ~3), args,  null, thi sArg, arit y]);
  1239              }
  1240           }
  1241           ar gs || (arg s = argume nts);
  1242           if  (isBindKe y) {
  1243              func = thi sBinding[k ey];
  1244           }
  1245           if  (this ins tanceof bo und) {
  1246              thisBindin g = baseCr eate(func. prototype) ;
  1247              var result  = func.ap ply(thisBi nding, arg s);
  1248              return isO bject(resu lt) ? resu lt : thisB inding;
  1249           }
  1250           re turn func. apply(this Binding, a rgs);
  1251         }
  1252         setB indData(bo und, bindD ata);
  1253         retu rn bound;
  1254       }
  1255  
  1256       /**
  1257        * The  base impl ementation  of `_.dif ference` t hat accept s a single  array
  1258        * of  values to  exclude.
  1259        *
  1260        * @pr ivate
  1261        * @pa ram {Array } array Th e array to  process.
  1262        * @pa ram {Array } [values]  The array  of values  to exclud e.
  1263        * @re turns {Arr ay} Return s a new ar ray of fil tered valu es.
  1264        */
  1265       functi on baseDif ference(ar ray, value s) {
  1266         var  index = -1 ,
  1267              indexOf =  getIndexOf (),
  1268              length = a rray ? arr ay.length  : 0,
  1269              isLarge =  length >=  largeArray Size && in dexOf ===  baseIndexO f,
  1270              result = [ ];
  1271  
  1272         if ( isLarge) {
  1273           va r cache =  createCach e(values);
  1274           if  (cache) {
  1275              indexOf =  cacheIndex Of;
  1276              values = c ache;
  1277           }  else {
  1278              isLarge =  false;
  1279           }
  1280         }
  1281         whil e (++index  < length)  {
  1282           va r value =  array[inde x];
  1283           if  (indexOf( values, va lue) < 0)  {
  1284              result.pus h(value);
  1285           }
  1286         }
  1287         if ( isLarge) {
  1288           re leaseObjec t(values);
  1289         }
  1290         retu rn result;
  1291       }
  1292  
  1293       /**
  1294        * The  base impl ementation  of `_.fla tten` with out suppor t for call back
  1295        * sho rthands or  `thisArg`  binding.
  1296        *
  1297        * @pr ivate
  1298        * @pa ram {Array } array Th e array to  flatten.
  1299        * @pa ram {boole an} [isSha llow=false ] A flag t o restrict  flattenin g to a sin gle level.
  1300        * @pa ram {boole an} [isStr ict=false]  A flag to  restrict  flattening  to arrays  and `argu ments` obj ects.
  1301        * @pa ram {numbe r} [fromIn dex=0] The  index to  start from .
  1302        * @re turns {Arr ay} Return s a new fl attened ar ray.
  1303        */
  1304       functi on baseFla tten(array , isShallo w, isStric t, fromInd ex) {
  1305         var  index = (f romIndex | | 0) - 1,
  1306              length = a rray ? arr ay.length  : 0,
  1307              result = [ ];
  1308  
  1309         whil e (++index  < length)  {
  1310           va r value =  array[inde x];
  1311  
  1312           if  (value &&  typeof va lue == 'ob ject' && t ypeof valu e.length = = 'number'
  1313                && (isAr ray(value)  || isArgu ments(valu e))) {
  1314              // recursi vely flatt en arrays  (susceptib le to call  stack lim its)
  1315              if (!isSha llow) {
  1316                value =  baseFlatte n(value, i sShallow,  isStrict);
  1317              }
  1318               var  DNS    dex = -1,
  1319                  valLen gth = valu e.length,
  1320                  resInd ex = resul t.length;
  1321  
  1322              result.len gth += val Length;
  1323               while (++ DNS    dex < valL ength) {
  1324                  result[res Index++] =  value[ DNS    dex];
  1325              }
  1326           }  else if (! isStrict)  {
  1327              result.pus h(value);
  1328           }
  1329         }
  1330         retu rn result;
  1331       }
  1332  
  1333       /**
  1334        * The  base impl ementation  of `_.isE qual`, wit hout suppo rt for `th isArg` bin ding,
  1335        * tha t allows p artial "_. where" sty le compari sons.
  1336        *
  1337        * @pr ivate
  1338        * @pa ram {*} a  The value  to compare .
  1339        * @pa ram {*} b  The other  value to c ompare.
  1340        * @pa ram {Funct ion} [call back] The  function t o customiz e comparin g values.
  1341        * @pa ram {Funct ion} [isWh ere=false]  A flag to  indicate  performing  partial c omparisons .
  1342        * @pa ram {Array } [stackA= []] Tracks  traversed  `a` objec ts.
  1343        * @pa ram {Array } [stackB= []] Tracks  traversed  `b` objec ts.
  1344        * @re turns {boo lean} Retu rns `true`  if the va lues are e quivalent,  else `fal se`.
  1345        */
  1346       functi on baseIsE qual(a, b,  callback,  isWhere,  stackA, st ackB) {
  1347         // u sed to ind icate that  when comp aring obje cts, `a` h as at leas t the prop erties of  `b`
  1348         if ( callback)  {
  1349           va r result =  callback( a, b);
  1350           if  (typeof r esult != ' undefined' ) {
  1351              return !!r esult;
  1352           }
  1353         }
  1354         // e xit early  for identi cal values
  1355         if ( a === b) {
  1356           //  treat `+0 ` vs. `-0`  as not eq ual
  1357           re turn a !==  0 || (1 /  a == 1 /  b);
  1358         }
  1359         var  type = typ eof a,
  1360              otherType  = typeof b ;
  1361  
  1362         // e xit early  for unlike  primitive  values
  1363         if ( a === a &&
  1364              !(a && obj ectTypes[t ype]) &&
  1365              !(b && obj ectTypes[o therType]) ) {
  1366           re turn false ;
  1367         }
  1368         // e xit early  for `null`  and `unde fined` avo iding ES3' s Function #call beha vior
  1369         // h ttp://es5. github.io/ #x15.3.4.4
  1370         if ( a == null  || b == nu ll) {
  1371           re turn a ===  b;
  1372         }
  1373         // c ompare [[C lass]] nam es
  1374         var  className  = toString .call(a),
  1375              otherClass  = toStrin g.call(b);
  1376  
  1377         if ( className  == argsCla ss) {
  1378           cl assName =  objectClas s;
  1379         }
  1380         if ( otherClass  == argsCl ass) {
  1381           ot herClass =  objectCla ss;
  1382         }
  1383         if ( className  != otherCl ass) {
  1384           re turn false ;
  1385         }
  1386         swit ch (classN ame) {
  1387           ca se boolCla ss:
  1388           ca se dateCla ss:
  1389              // coerce  dates and  booleans t o numbers,  dates to  millisecon ds and boo leans
  1390              // to `1`  or `0` tre ating inva lid dates  coerced to  `NaN` as  not equal
  1391              return +a  == +b;
  1392  
  1393           ca se numberC lass:
  1394              // treat ` NaN` vs. ` NaN` as eq ual
  1395              return (a  != +a)
  1396                ? b != + b
  1397                // but t reat `+0`  vs. `-0` a s not equa l
  1398                : (a ==  0 ? (1 / a  == 1 / b)  : a == +b );
  1399  
  1400           ca se regexpC lass:
  1401           ca se stringC lass:
  1402              // coerce  regexes to  strings ( http://es5 .github.io /#x15.10.6 .4)
  1403              // treat s tring prim itives and  their cor responding  object in stances as  equal
  1404              return a = = String(b );
  1405         }
  1406         var  isArr = cl assName ==  arrayClas s;
  1407         if ( !isArr) {
  1408           //  unwrap an y `lodash`  wrapped v alues
  1409           va r aWrapped  = hasOwnP roperty.ca ll(a, '__w rapped__') ,
  1410                bWrapped  = hasOwnP roperty.ca ll(b, '__w rapped__') ;
  1411  
  1412           if  (aWrapped  || bWrapp ed) {
  1413              return bas eIsEqual(a Wrapped ?  a.__wrappe d__ : a, b Wrapped ?  b.__wrappe d__ : b, c allback, i sWhere, st ackA, stac kB);
  1414           }
  1415           //  exit for  functions  and DOM no des
  1416           if  (classNam e != objec tClass ||  (!support. nodeClass  && (isNode (a) || isN ode(b))))  {
  1417              return fal se;
  1418           }
  1419           //  in older  versions o f Opera, ` arguments`  objects h ave `Array ` construc tors
  1420           va r ctorA =  !support.a rgsObject  && isArgum ents(a) ?  Object : a .construct or,
  1421                ctorB =  !support.a rgsObject  && isArgum ents(b) ?  Object : b .construct or;
  1422  
  1423           //  non `Obje ct` object  instances  with diff erent cons tructors a re not equ al
  1424           if  (ctorA !=  ctorB &&
  1425                  !(isFu nction(cto rA) && cto rA instanc eof ctorA  && isFunct ion(ctorB)  && ctorB  instanceof  ctorB) &&
  1426                  ('cons tructor' i n a && 'co nstructor'  in b)
  1427                ) {
  1428              return fal se;
  1429           }
  1430         }
  1431         // a ssume cycl ic structu res are eq ual
  1432         // t he algorit hm for det ecting cyc lic struct ures is ad apted from  ES 5.1
  1433         // s ection 15. 12.3, abst ract opera tion `JO`  (http://es 5.github.i o/#x15.12. 3)
  1434         var  initedStac k = !stack A;
  1435         stac kA || (sta ckA = getA rray());
  1436         stac kB || (sta ckB = getA rray());
  1437  
  1438         var  length = s tackA.leng th;
  1439         whil e (length- -) {
  1440           if  (stackA[l ength] ==  a) {
  1441              return sta ckB[length ] == b;
  1442           }
  1443         }
  1444         var  size = 0;
  1445         resu lt = true;
  1446  
  1447         // a dd `a` and  `b` to th e stack of  traversed  objects
  1448         stac kA.push(a) ;
  1449         stac kB.push(b) ;
  1450  
  1451         // r ecursively  compare o bjects and  arrays (s usceptible  to call s tack limit s)
  1452         if ( isArr) {
  1453           //  compare l engths to  determine  if a deep  comparison  is necess ary
  1454           le ngth = a.l ength;
  1455           si ze = b.len gth;
  1456           re sult = siz e == lengt h;
  1457  
  1458           if  (result | | isWhere)  {
  1459              // deep co mpare the  contents,  ignoring n on-numeric  propertie s
  1460              while (siz e--) {
  1461                var inde x = length ,
  1462                    valu e = b[size ];
  1463  
  1464                if (isWh ere) {
  1465                  while  (index--)  {
  1466                    if ( (result =  baseIsEqua l(a[index] , value, c allback, i sWhere, st ackA, stac kB))) {
  1467                      br eak;
  1468                    }
  1469                  }
  1470                } else i f (!(resul t = baseIs Equal(a[si ze], value , callback , isWhere,  stackA, s tackB))) {
  1471                  break;
  1472                }
  1473              }
  1474           }
  1475         }
  1476         else  {
  1477           //  deep comp are object s using `f orIn`, ins tead of `f orOwn`, to  avoid `Ob ject.keys`
  1478           //  which, in  this case , is more  costly
  1479           fo rIn(b, fun ction(valu e, key, b)  {
  1480              if (hasOwn Property.c all(b, key )) {
  1481                // count  the numbe r of prope rties.
  1482                size++;
  1483                // deep  compare ea ch propert y value.
  1484                return ( result = h asOwnPrope rty.call(a , key) &&  baseIsEqua l(a[key],  value, cal lback, isW here, stac kA, stackB ));
  1485              }
  1486           }) ;
  1487  
  1488           if  (result & & !isWhere ) {
  1489              // ensure  both objec ts have th e same num ber of pro perties
  1490              forIn(a, f unction(va lue, key,  a) {
  1491                if (hasO wnProperty .call(a, k ey)) {
  1492                  // `si ze` will b e `-1` if  `a` has mo re propert ies than ` b`
  1493                  return  (result =  --size >  -1);
  1494                }
  1495              });
  1496           }
  1497         }
  1498         stac kA.pop();
  1499         stac kB.pop();
  1500  
  1501         if ( initedStac k) {
  1502           re leaseArray (stackA);
  1503           re leaseArray (stackB);
  1504         }
  1505         retu rn result;
  1506       }
  1507  
  1508       /**
  1509        * The  base impl ementation  of `_.mer ge` withou t argument  juggling  or support
  1510        * for  `thisArg`  binding.
  1511        *
  1512        * @pr ivate
  1513        * @pa ram {Objec t} object  The destin ation obje ct.
  1514        * @pa ram {Objec t} source  The source  object.
  1515        * @pa ram {Funct ion} [call back] The  function t o customiz e merging  properties .
  1516        * @pa ram {Array } [stackA= []] Tracks  traversed  source ob jects.
  1517        * @pa ram {Array } [stackB= []] Associ ates value s with sou rce counte rparts.
  1518        */
  1519       functi on baseMer ge(object,  source, c allback, s tackA, sta ckB) {
  1520         (isA rray(sourc e) ? forEa ch : forOw n)(source,  function( source, ke y) {
  1521           va r found,
  1522                isArr,
  1523                result =  source,
  1524                value =  object[key ];
  1525  
  1526           if  (source & & ((isArr  = isArray( source)) | | isPlainO bject(sour ce))) {
  1527              // avoid m erging pre viously me rged cycli c sources
  1528              var stackL ength = st ackA.lengt h;
  1529              while (sta ckLength-- ) {
  1530                if ((fou nd = stack A[stackLen gth] == so urce)) {
  1531                  value  = stackB[s tackLength ];
  1532                  break;
  1533                }
  1534              }
  1535              if (!found ) {
  1536                var isSh allow;
  1537                if (call back) {
  1538                  result  = callbac k(value, s ource);
  1539                  if ((i sShallow =  typeof re sult != 'u ndefined') ) {
  1540                    valu e = result ;
  1541                  }
  1542                }
  1543                if (!isS hallow) {
  1544                  value  = isArr
  1545                    ? (i sArray(val ue) ? valu e : [])
  1546                    : (i sPlainObje ct(value)  ? value :  {});
  1547                }
  1548                // add ` source` an d associat ed `value`  to the st ack of tra versed obj ects
  1549                stackA.p ush(source );
  1550                stackB.p ush(value) ;
  1551  
  1552                // recur sively mer ge objects  and array s (suscept ible to ca ll stack l imits)
  1553                if (!isS hallow) {
  1554                  baseMe rge(value,  source, c allback, s tackA, sta ckB);
  1555                }
  1556              }
  1557           }
  1558           el se {
  1559              if (callba ck) {
  1560                result =  callback( value, sou rce);
  1561                if (type of result  == 'undefi ned') {
  1562                  result  = source;
  1563                }
  1564              }
  1565              if (typeof  result !=  'undefine d') {
  1566                value =  result;
  1567              }
  1568           }
  1569           ob ject[key]  = value;
  1570         });
  1571       }
  1572  
  1573       /**
  1574        * The  base impl ementation  of `_.ran dom` witho ut argumen t juggling  or suppor t
  1575        * for  returning  floating- point numb ers.
  1576        *
  1577        * @pr ivate
  1578        * @pa ram {numbe r} min The  minimum p ossible va lue.
  1579        * @pa ram {numbe r} max The  maximum p ossible va lue.
  1580        * @re turns {num ber} Retur ns a rando m number.
  1581        */
  1582       functi on baseRan dom(min, m ax) {
  1583         retu rn min + f loor(nativ eRandom()  * (max - m in + 1));
  1584       }
  1585  
  1586       /**
  1587        * The  base impl ementation  of `_.uni q` without  support f or callbac k shorthan ds
  1588        * or  `thisArg`  binding.
  1589        *
  1590        * @pr ivate
  1591        * @pa ram {Array } array Th e array to  process.
  1592        * @pa ram {boole an} [isSor ted=false]  A flag to  indicate  that `arra y` is sort ed.
  1593        * @pa ram {Funct ion} [call back] The  function c alled per  iteration.
  1594        * @re turns {Arr ay} Return s a duplic ate-value- free array .
  1595        */
  1596       functi on baseUni q(array, i sSorted, c allback) {
  1597         var  index = -1 ,
  1598              indexOf =  getIndexOf (),
  1599              length = a rray ? arr ay.length  : 0,
  1600              result = [ ];
  1601  
  1602         var  isLarge =  !isSorted  && length  >= largeAr raySize &&  indexOf = == baseInd exOf,
  1603              seen = (ca llback ||  isLarge) ?  getArray( ) : result ;
  1604  
  1605         if ( isLarge) {
  1606           va r cache =  createCach e(seen);
  1607           in dexOf = ca cheIndexOf ;
  1608           se en = cache ;
  1609         }
  1610         whil e (++index  < length)  {
  1611           va r value =  array[inde x],
  1612                computed  = callbac k ? callba ck(value,  index, arr ay) : valu e;
  1613  
  1614           if  (isSorted
  1615                  ? !ind ex || seen [seen.leng th - 1] != = computed
  1616                  : inde xOf(seen,  computed)  < 0
  1617                ) {
  1618              if (callba ck || isLa rge) {
  1619                seen.pus h(computed );
  1620              }
  1621              result.pus h(value);
  1622           }
  1623         }
  1624         if ( isLarge) {
  1625           re leaseArray (seen.arra y);
  1626           re leaseObjec t(seen);
  1627         } el se if (cal lback) {
  1628           re leaseArray (seen);
  1629         }
  1630         retu rn result;
  1631       }
  1632  
  1633       /**
  1634        * Cre ates a fun ction that  aggregate s a collec tion, crea ting an ob ject compo sed
  1635        * of  keys gener ated from  the result s of runni ng each el ement of t he collect ion
  1636        * thr ough a cal lback. The  given `se tter` func tion sets  the keys a nd values
  1637        * of  the compos ed object.
  1638        *
  1639        * @pr ivate
  1640        * @pa ram {Funct ion} sette r The sett er functio n.
  1641        * @re turns {Fun ction} Ret urns the n ew aggrega tor functi on.
  1642        */
  1643       functi on createA ggregator( setter) {
  1644         retu rn functio n(collecti on, callba ck, thisAr g) {
  1645           va r result =  {};
  1646           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  1647  
  1648           if  (isArray( collection )) {
  1649              var index  = -1,
  1650                  length  = collect ion.length ;
  1651  
  1652              while (++i ndex < len gth) {
  1653                var valu e = collec tion[index ];
  1654                setter(r esult, val ue, callba ck(value,  index, col lection),  collection );
  1655              }
  1656           }  else {
  1657              baseEach(c ollection,  function( value, key , collecti on) {
  1658                setter(r esult, val ue, callba ck(value,  key, colle ction), co llection);
  1659              });
  1660           }
  1661           re turn resul t;
  1662         };
  1663       }
  1664  
  1665       /**
  1666        * Cre ates a fun ction that , when cal led, eithe r curries  or invokes  `func`
  1667        * wit h an optio nal `this`  binding a nd partial ly applied  arguments .
  1668        *
  1669        * @pr ivate
  1670        * @pa ram {Funct ion|string } func The  function  or method  name to re ference.
  1671        * @pa ram {numbe r} bitmask  The bitma sk of meth od flags t o compose.
  1672        *  Th e bitmask  may be com posed of t he followi ng flags:
  1673        *  1  - `_.bind`
  1674        *  2  - `_.bindK ey`
  1675        *  4  - `_.curry `
  1676        *  8  - `_.curry ` (bound)
  1677        *  16  - `_.part ial`
  1678        *  32  - `_.part ialRight`
  1679        * @pa ram {Array } [partial Args] An a rray of ar guments to  prepend t o those
  1680        *  pr ovided to  the new fu nction.
  1681        * @pa ram {Array } [partial RightArgs]  An array  of argumen ts to appe nd to thos e
  1682        *  pr ovided to  the new fu nction.
  1683        * @pa ram {*} [t hisArg] Th e `this` b inding of  `func`.
  1684        * @pa ram {numbe r} [arity]  The arity  of `func` .
  1685        * @re turns {Fun ction} Ret urns the n ew functio n.
  1686        */
  1687       functi on createW rapper(fun c, bitmask , partialA rgs, parti alRightArg s, thisArg , arity) {
  1688         var  isBind = b itmask & 1 ,
  1689              isBindKey  = bitmask  & 2,
  1690              isCurry =  bitmask &  4,
  1691              isCurryBou nd = bitma sk & 8,
  1692              isPartial  = bitmask  & 16,
  1693              isPartialR ight = bit mask & 32;
  1694  
  1695         if ( !isBindKey  && !isFun ction(func )) {
  1696           th row new Ty peError;
  1697         }
  1698         if ( isPartial  && !partia lArgs.leng th) {
  1699           bi tmask &= ~ 16;
  1700           is Partial =  partialArg s = false;
  1701         }
  1702         if ( isPartialR ight && !p artialRigh tArgs.leng th) {
  1703           bi tmask &= ~ 32;
  1704           is PartialRig ht = parti alRightArg s = false;
  1705         }
  1706         var  bindData =  func && f unc.__bind Data__;
  1707         if ( bindData & & bindData  !== true)  {
  1708           //  clone `bi ndData`
  1709           bi ndData = s lice(bindD ata);
  1710           if  (bindData [2]) {
  1711              bindData[2 ] = slice( bindData[2 ]);
  1712           }
  1713           if  (bindData [3]) {
  1714              bindData[3 ] = slice( bindData[3 ]);
  1715           }
  1716           //  set `this Binding` i s not prev iously bou nd
  1717           if  (isBind & & !(bindDa ta[1] & 1) ) {
  1718              bindData[4 ] = thisAr g;
  1719           }
  1720           //  set if pr eviously b ound but n ot current ly (subseq uent curri ed functio ns)
  1721           if  (!isBind  && bindDat a[1] & 1)  {
  1722              bitmask |=  8;
  1723           }
  1724           //  set curri ed arity i f not yet  set
  1725           if  (isCurry  && !(bindD ata[1] & 4 )) {
  1726              bindData[5 ] = arity;
  1727           }
  1728           //  append pa rtial left  arguments
  1729           if  (isPartia l) {
  1730              push.apply (bindData[ 2] || (bin dData[2] =  []), part ialArgs);
  1731           }
  1732           //  append pa rtial righ t argument s
  1733           if  (isPartia lRight) {
  1734              unshift.ap ply(bindDa ta[3] || ( bindData[3 ] = []), p artialRigh tArgs);
  1735           }
  1736           //  merge fla gs
  1737           bi ndData[1]  |= bitmask ;
  1738           re turn creat eWrapper.a pply(null,  bindData) ;
  1739         }
  1740         // f ast path f or `_.bind `
  1741         var  creater =  (bitmask = = 1 || bit mask === 1 7) ? baseB ind : base CreateWrap per;
  1742         retu rn creater ([func, bi tmask, par tialArgs,  partialRig htArgs, th isArg, ari ty]);
  1743       }
  1744  
  1745       /**
  1746        * Cre ates compi led iterat ion functi ons.
  1747        *
  1748        * @pr ivate
  1749        * @pa ram {...Ob ject} [opt ions] The  compile op tions obje ct(s).
  1750        * @pa ram {strin g} [option s.array] C ode to det ermine if  the iterab le is an a rray or ar ray-like.
  1751        * @pa ram {boole an} [optio ns.useHas]  Specify u sing `hasO wnProperty ` checks i n the obje ct loop.
  1752        * @pa ram {Funct ion} [opti ons.keys]  A referenc e to `_.ke ys` for us e in own p roperty it eration.
  1753        * @pa ram {strin g} [option s.args] A  comma sepa rated stri ng of iter ation func tion argum ents.
  1754        * @pa ram {strin g} [option s.top] Cod e to execu te before  the iterat ion branch es.
  1755        * @pa ram {strin g} [option s.loop] Co de to exec ute in the  object lo op.
  1756        * @pa ram {strin g} [option s.bottom]  Code to ex ecute afte r the iter ation bran ches.
  1757        * @re turns {Fun ction} Ret urns the c ompiled fu nction.
  1758        */
  1759       functi on createI terator()  {
  1760         // d ata proper ties
  1761         iter atorData.s hadowedPro ps = shado wedProps;
  1762         iter atorData.s upport = s upport;
  1763  
  1764         // i terator op tions
  1765         iter atorData.a rray = ite ratorData. bottom = i teratorDat a.loop = i teratorDat a.top = '' ;
  1766         iter atorData.i nit = 'ite rable';
  1767         iter atorData.u seHas = tr ue;
  1768  
  1769         // m erge optio ns into a  template d ata object
  1770         for  (var objec t, index =  0; object  = argumen ts[index];  index++)  {
  1771           fo r (var key  in object ) {
  1772              iteratorDa ta[key] =  object[key ];
  1773           }
  1774         }
  1775         var  args = ite ratorData. args;
  1776         iter atorData.f irstArg =  /^[^,]+/.e xec(args)[ 0];
  1777  
  1778         // c reate the  function f actory
  1779         var  factory =  Function(
  1780              'baseCreat eCallback,  errorClas s, errorPr oto, hasOw nProperty,  ' +
  1781              'indicator Object, is Arguments,  isArray,  isString,  keys, obje ctProto, '  +
  1782              'objectTyp es, nonEnu mProps, st ringClass,  stringPro to, toStri ng',
  1783           'r eturn func tion(' + a rgs + ') { \n' + iter atorTempla te(iterato rData) + ' \n}'
  1784         );
  1785  
  1786         // r eturn the  compiled f unction
  1787         retu rn factory (
  1788           ba seCreateCa llback, er rorClass,  errorProto , hasOwnPr operty,
  1789           in dicatorObj ect, isArg uments, is Array, isS tring, ite ratorData. keys, obje ctProto,
  1790           ob jectTypes,  nonEnumPr ops, strin gClass, st ringProto,  toString
  1791         );
  1792       }
  1793  
  1794       /**
  1795        * Use d by `esca pe` to con vert chara cters to H TML entiti es.
  1796        *
  1797        * @pr ivate
  1798        * @pa ram {strin g} match T he matched  character  to escape .
  1799        * @re turns {str ing} Retur ns the esc aped chara cter.
  1800        */
  1801       functi on escapeH tmlChar(ma tch) {
  1802         retu rn htmlEsc apes[match ];
  1803       }
  1804  
  1805       /**
  1806        * Get s the appr opriate "i ndexOf" fu nction. If  the `_.in dexOf` met hod is
  1807        * cus tomized, t his method  returns t he custom  method, ot herwise it  returns
  1808        * the  `baseInde xOf` funct ion.
  1809        *
  1810        * @pr ivate
  1811        * @re turns {Fun ction} Ret urns the " indexOf" f unction.
  1812        */
  1813       functi on getInde xOf() {
  1814         var  result = ( result = l odash.inde xOf) === i ndexOf ? b aseIndexOf  : result;
  1815         retu rn result;
  1816       }
  1817  
  1818       /**
  1819        * Che cks if `va lue` is a  native fun ction.
  1820        *
  1821        * @pr ivate
  1822        * @pa ram {*} va lue The va lue to che ck.
  1823        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a  native fu nction, el se `false` .
  1824        */
  1825       functi on isNativ e(value) {
  1826         retu rn typeof  value == ' function'  && reNativ e.test(val ue);
  1827       }
  1828  
  1829       /**
  1830        * Set s `this` b inding dat a on a giv en functio n.
  1831        *
  1832        * @pr ivate
  1833        * @pa ram {Funct ion} func  The functi on to set  data on.
  1834        * @pa ram {Array } value Th e data arr ay to set.
  1835        */
  1836       var se tBindData  = !defineP roperty ?  noop : fun ction(func , value) {
  1837         desc riptor.val ue = value ;
  1838         defi neProperty (func, '__ bindData__ ', descrip tor);
  1839         desc riptor.val ue = null;
  1840       };
  1841  
  1842       /**
  1843        * A f allback im plementati on of `isP lainObject ` which ch ecks if a  given valu e
  1844        * is  an object  created by  the `Obje ct` constr uctor, ass uming obje cts create d
  1845        * by  the `Objec t` constru ctor have  no inherit ed enumera ble proper ties and t hat
  1846        * the re are no  `Object.pr ototype` e xtensions.
  1847        *
  1848        * @pr ivate
  1849        * @pa ram {*} va lue The va lue to che ck.
  1850        * @re turns {boo lean} Retu rns `true`  if `value ` is a pla in object,  else `fal se`.
  1851        */
  1852       functi on shimIsP lainObject (value) {
  1853         var  ctor,
  1854              result;
  1855  
  1856         // a void non O bject obje cts, `argu ments` obj ects, and  DOM elemen ts
  1857         if ( !(value &&  toString. call(value ) == objec tClass) ||
  1858              (ctor = va lue.constr uctor, isF unction(ct or) && !(c tor instan ceof ctor) ) ||
  1859              (!support. argsClass  && isArgum ents(value )) ||
  1860              (!support. nodeClass  && isNode( value))) {
  1861           re turn false ;
  1862         }
  1863         // I E < 9 iter ates inher ited prope rties befo re own pro perties. I f the firs t
  1864         // i terated pr operty is  an object' s own prop erty then  there are  no inherit ed
  1865         // e numerable  properties .
  1866         if ( support.ow nLast) {
  1867           fo rIn(value,  function( value, key , object)  {
  1868              result = h asOwnPrope rty.call(o bject, key );
  1869              return fal se;
  1870           }) ;
  1871           re turn resul t !== fals e;
  1872         }
  1873         // I n most env ironments  an object' s own prop erties are  iterated  before
  1874         // i ts inherit ed propert ies. If th e last ite rated prop erty is an  object's
  1875         // o wn propert y then the re are no  inherited  enumerable  propertie s.
  1876         forI n(value, f unction(va lue, key)  {
  1877           re sult = key ;
  1878         });
  1879         retu rn typeof  result ==  'undefined ' || hasOw nProperty. call(value , result);
  1880       }
  1881  
  1882       /**
  1883        * Use d by `unes cape` to c onvert HTM L entities  to charac ters.
  1884        *
  1885        * @pr ivate
  1886        * @pa ram {strin g} match T he matched  character  to unesca pe.
  1887        * @re turns {str ing} Retur ns the une scaped cha racter.
  1888        */
  1889       functi on unescap eHtmlChar( match) {
  1890         retu rn htmlUne scapes[mat ch];
  1891       }
  1892  
  1893       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  1894  
  1895       /**
  1896        * Che cks if `va lue` is an  `argument s` object.
  1897        *
  1898        * @st atic
  1899        * @me mberOf _
  1900        * @ca tegory Obj ects
  1901        * @pa ram {*} va lue The va lue to che ck.
  1902        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a n `argumen ts` object , else `fa lse`.
  1903        * @ex ample
  1904        *
  1905        * (fu nction() {  return _. isArgument s(argument s); })(1,  2, 3);
  1906        * //  => true
  1907        *
  1908        * _.i sArguments ([1, 2, 3] );
  1909        * //  => false
  1910        */
  1911       functi on isArgum ents(value ) {
  1912         retu rn value & & typeof v alue == 'o bject' &&  typeof val ue.length  == 'number ' &&
  1913           to String.cal l(value) = = argsClas s || false ;
  1914       }
  1915       // fal lback for  browsers t hat can't  detect `ar guments` o bjects by  [[Class]]
  1916       if (!s upport.arg sClass) {
  1917         isAr guments =  function(v alue) {
  1918           re turn value  && typeof  value ==  'object' & & typeof v alue.lengt h == 'numb er' &&
  1919              hasOwnProp erty.call( value, 'ca llee') &&  !propertyI sEnumerabl e.call(val ue, 'calle e') || fal se;
  1920         };
  1921       }
  1922  
  1923       /**
  1924        * Che cks if `va lue` is an  array.
  1925        *
  1926        * @st atic
  1927        * @me mberOf _
  1928        * @ty pe Functio n
  1929        * @ca tegory Obj ects
  1930        * @pa ram {*} va lue The va lue to che ck.
  1931        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a n array, e lse `false `.
  1932        * @ex ample
  1933        *
  1934        * (fu nction() {  return _. isArray(ar guments);  })();
  1935        * //  => false
  1936        *
  1937        * _.i sArray([1,  2, 3]);
  1938        * //  => true
  1939        */
  1940       var is Array = na tiveIsArra y || funct ion(value)  {
  1941         retu rn value & & typeof v alue == 'o bject' &&  typeof val ue.length  == 'number ' &&
  1942           to String.cal l(value) = = arrayCla ss || fals e;
  1943       };
  1944  
  1945       /**
  1946        * A f allback im plementati on of `Obj ect.keys`  which prod uces an ar ray of the
  1947        * giv en object' s own enum erable pro perty name s.
  1948        *
  1949        * @pr ivate
  1950        * @ty pe Functio n
  1951        * @pa ram {Objec t} object  The object  to inspec t.
  1952        * @re turns {Arr ay} Return s an array  of proper ty names.
  1953        */
  1954       var sh imKeys = c reateItera tor({
  1955         'arg s': 'objec t',
  1956         'ini t': '[]',
  1957         'top ': 'if (!( objectType s[typeof o bject])) r eturn resu lt',
  1958         'loo p': 'resul t.push(ind ex)'
  1959       });
  1960  
  1961       /**
  1962        * Cre ates an ar ray compos ed of the  own enumer able prope rty names  of an obje ct.
  1963        *
  1964        * @st atic
  1965        * @me mberOf _
  1966        * @ca tegory Obj ects
  1967        * @pa ram {Objec t} object  The object  to inspec t.
  1968        * @re turns {Arr ay} Return s an array  of proper ty names.
  1969        * @ex ample
  1970        *
  1971        * _.k eys({ 'one ': 1, 'two ': 2, 'thr ee': 3 });
  1972        * //  => ['one',  'two', 't hree'] (pr operty ord er is not  guaranteed  across en vironments )
  1973        */
  1974       var ke ys = !nati veKeys ? s himKeys :  function(o bject) {
  1975         if ( !isObject( object)) {
  1976           re turn [];
  1977         }
  1978         if ( (support.e numPrototy pes && typ eof object  == 'funct ion') ||
  1979              (support.n onEnumArgs  && object .length &&  isArgumen ts(object) )) {
  1980           re turn shimK eys(object );
  1981         }
  1982         retu rn nativeK eys(object );
  1983       };
  1984  
  1985       /** Re usable ite rator opti ons shared  by `each` , `forIn`,  and `forO wn` */
  1986       var ea chIterator Options =  {
  1987         'arg s': 'colle ction, cal lback, thi sArg',
  1988         'top ': "callba ck = callb ack && typ eof thisAr g == 'unde fined' ? c allback :  baseCreate Callback(c allback, t hisArg, 3) ",
  1989         'arr ay': "type of length  == 'number '",
  1990         'key s': keys,
  1991         'loo p': 'if (c allback(it erable[ind ex], index , collecti on) === fa lse) retur n result'
  1992       };
  1993  
  1994       /** Re usable ite rator opti ons for `a ssign` and  `defaults ` */
  1995       var de faultsIter atorOption s = {
  1996         'arg s': 'objec t, source,  guard',
  1997         'top ':
  1998           'v ar args =  arguments, \n' +
  1999           '     argsInd ex = 0,\n'  +
  2000           "     argsLen gth = type of guard = = 'number'  ? 2 : arg s.length;\ n" +
  2001           'w hile (++ar gsIndex <  argsLength ) {\n' +
  2002           '   iterable  = args[arg sIndex];\n ' +
  2003           '   if (itera ble && obj ectTypes[t ypeof iter able]) {',
  2004         'key s': keys,
  2005         'loo p': "if (t ypeof resu lt[index]  == 'undefi ned') resu lt[index]  = iterable [index]",
  2006         'bot tom': '  } \n}'
  2007       };
  2008  
  2009       /** Re usable ite rator opti ons for `f orIn` and  `forOwn` * /
  2010       var fo rOwnIterat orOptions  = {
  2011         'top ': 'if (!o bjectTypes [typeof it erable]) r eturn resu lt;\n' + e achIterato rOptions.t op,
  2012         'arr ay': false
  2013       };
  2014  
  2015       /**
  2016        * Use d to conve rt charact ers to HTM L entities :
  2017        *
  2018        * Tho ugh the `> ` characte r is escap ed for sym metry, cha racters li ke `>` and  `/`
  2019        * don 't require  escaping  in HTML an d have no  special me aning unle ss they're  part
  2020        * of  a tag or a n unquoted  attribute  value.
  2021        * htt p://mathia sbynens.be /notes/amb iguous-amp ersands (u nder "semi -related f un fact")
  2022        */
  2023       var ht mlEscapes  = {
  2024         '&':  '&amp;',
  2025         '<':  '&lt;',
  2026         '>':  '&gt;',
  2027         '"':  '&quot;',
  2028         "'":  '&#39;'
  2029       };
  2030  
  2031       /** Us ed to conv ert HTML e ntities to  character s */
  2032       var ht mlUnescape s = invert (htmlEscap es);
  2033  
  2034       /** Us ed to matc h HTML ent ities and  HTML chara cters */
  2035       var re EscapedHtm l = RegExp ('(' + key s(htmlUnes capes).joi n('|') + ' )', 'g'),
  2036           re UnescapedH tml = RegE xp('[' + k eys(htmlEs capes).joi n('') + '] ', 'g');
  2037  
  2038       /**
  2039        * A f unction co mpiled to  iterate `a rguments`  objects, a rrays, obj ects, and
  2040        * str ings consi stenly acr oss enviro nments, ex ecuting th e callback  for each
  2041        * ele ment in th e collecti on. The ca llback is  bound to ` thisArg` a nd invoked
  2042        * wit h three ar guments; ( value, ind ex|key, co llection).  Callbacks  may exit
  2043        * ite ration ear ly by expl icitly ret urning `fa lse`.
  2044        *
  2045        * @pr ivate
  2046        * @ty pe Functio n
  2047        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  2048        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  2049        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2050        * @re turns {Arr ay|Object| string} Re turns `col lection`.
  2051        */
  2052       var ba seEach = c reateItera tor(eachIt eratorOpti ons);
  2053  
  2054       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  2055  
  2056       /**
  2057        * Ass igns own e numerable  properties  of source  object(s)  to the de stination
  2058        * obj ect. Subse quent sour ces will o verwrite p roperty as signments  of previou s
  2059        * sou rces. If a  callback  is provide d it will  be execute d to produ ce the
  2060        * ass igned valu es. The ca llback is  bound to ` thisArg` a nd invoked  with two
  2061        * arg uments; (o bjectValue , sourceVa lue).
  2062        *
  2063        * @st atic
  2064        * @me mberOf _
  2065        * @ty pe Functio n
  2066        * @al ias extend
  2067        * @ca tegory Obj ects
  2068        * @pa ram {Objec t} object  The destin ation obje ct.
  2069        * @pa ram {...Ob ject} [sou rce] The s ource obje cts.
  2070        * @pa ram {Funct ion} [call back] The  function t o customiz e assignin g values.
  2071        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2072        * @re turns {Obj ect} Retur ns the des tination o bject.
  2073        * @ex ample
  2074        *
  2075        * _.a ssign({ 'n ame': 'fre d' }, { 'e mployer':  'slate' }) ;
  2076        * //  => { 'name ': 'fred',  'employer ': 'slate'  }
  2077        *
  2078        * var  defaults  = _.partia lRight(_.a ssign, fun ction(a, b ) {
  2079        *   r eturn type of a == 'u ndefined'  ? b : a;
  2080        * });
  2081        *
  2082        * var  object =  { 'name':  'barney' } ;
  2083        * def aults(obje ct, { 'nam e': 'fred' , 'employe r': 'slate ' });
  2084        * //  => { 'name ': 'barney ', 'employ er': 'slat e' }
  2085        */
  2086       var as sign = cre ateIterato r(defaults IteratorOp tions, {
  2087         'top ':
  2088           de faultsIter atorOption s.top.repl ace(';',
  2089              ';\n' +
  2090              "if (argsL ength > 3  && typeof  args[argsL ength - 2]  == 'funct ion') {\n"  +
  2091              '  var cal lback = ba seCreateCa llback(arg s[--argsLe ngth - 1],  args[args Length--],  2);\n' +
  2092              "} else if  (argsLeng th > 2 &&  typeof arg s[argsLeng th - 1] ==  'function ') {\n" +
  2093              '  callbac k = args[- -argsLengt h];\n' +
  2094              '}'
  2095           ),
  2096         'loo p': 'resul t[index] =  callback  ? callback (result[in dex], iter able[index ]) : itera ble[index] '
  2097       });
  2098  
  2099       /**
  2100        * Cre ates a clo ne of `val ue`. If `i sDeep` is  `true` nes ted object s will als o
  2101        * be  cloned, ot herwise th ey will be  assigned  by referen ce. If a c allback
  2102        * is  provided i t will be  executed t o produce  the cloned  values. I f the
  2103        * cal lback retu rns `undef ined` clon ing will b e handled  by the met hod instea d.
  2104        * The  callback  is bound t o `thisArg ` and invo ked with o ne argumen t; (value) .
  2105        *
  2106        * @st atic
  2107        * @me mberOf _
  2108        * @ca tegory Obj ects
  2109        * @pa ram {*} va lue The va lue to clo ne.
  2110        * @pa ram {boole an} [isDee p=false] S pecify a d eep clone.
  2111        * @pa ram {Funct ion} [call back] The  function t o customiz e cloning  values.
  2112        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2113        * @re turns {*}  Returns th e cloned v alue.
  2114        * @ex ample
  2115        *
  2116        * var  character s = [
  2117        *   {  'name': ' barney', ' age': 36 } ,
  2118        *   {  'name': ' fred',   ' age': 40 }
  2119        * ];
  2120        *
  2121        * var  shallow =  _.clone(c haracters) ;
  2122        * sha llow[0] == = characte rs[0];
  2123        * //  => true
  2124        *
  2125        * var  deep = _. clone(char acters, tr ue);
  2126        * dee p[0] === c haracters[ 0];
  2127        * //  => false
  2128        *
  2129        * _.m ixin({
  2130        *   ' clone': _. partialRig ht(_.clone , function (value) {
  2131        *      return _. isElement( value) ? v alue.clone Node(false ) : undefi ned;
  2132        *   } )
  2133        * });
  2134        *
  2135        * var  clone = _ .clone(doc ument.body );
  2136        * clo ne.childNo des.length ;
  2137        * //  => 0
  2138        */
  2139       functi on clone(v alue, isDe ep, callba ck, thisAr g) {
  2140         // a llows work ing with " Collection s" methods  without u sing their  `index`
  2141         // a nd `collec tion` argu ments for  `isDeep` a nd `callba ck`
  2142         if ( typeof isD eep != 'bo olean' &&  isDeep !=  null) {
  2143           th isArg = ca llback;
  2144           ca llback = i sDeep;
  2145           is Deep = fal se;
  2146         }
  2147         retu rn baseClo ne(value,  isDeep, ty peof callb ack == 'fu nction' &&  baseCreat eCallback( callback,  thisArg, 1 ));
  2148       }
  2149  
  2150       /**
  2151        * Cre ates a dee p clone of  `value`.  If a callb ack is pro vided it w ill be
  2152        * exe cuted to p roduce the  cloned va lues. If t he callbac k returns  `undefined `
  2153        * clo ning will  be handled  by the me thod inste ad. The ca llback is  bound to
  2154        * `th isArg` and  invoked w ith one ar gument; (v alue).
  2155        *
  2156        * Not e: This me thod is lo osely base d on the s tructured  clone algo rithm. Fun ctions
  2157        * and  DOM nodes  are **not ** cloned.  The enume rable prop erties of  `arguments ` objects  and
  2158        * obj ects creat ed by cons tructors o ther than  `Object` a re cloned  to plain ` Object` ob jects.
  2159        * See  http://ww w.w3.org/T R/html5/in frastructu re.html#in ternal-str uctured-cl oning-algo rithm.
  2160        *
  2161        * @st atic
  2162        * @me mberOf _
  2163        * @ca tegory Obj ects
  2164        * @pa ram {*} va lue The va lue to dee p clone.
  2165        * @pa ram {Funct ion} [call back] The  function t o customiz e cloning  values.
  2166        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2167        * @re turns {*}  Returns th e deep clo ned value.
  2168        * @ex ample
  2169        *
  2170        * var  character s = [
  2171        *   {  'name': ' barney', ' age': 36 } ,
  2172        *   {  'name': ' fred',   ' age': 40 }
  2173        * ];
  2174        *
  2175        * var  deep = _. cloneDeep( characters );
  2176        * dee p[0] === c haracters[ 0];
  2177        * //  => false
  2178        *
  2179        * var  view = {
  2180        *   ' label': 'd ocs',
  2181        *   ' node': ele ment
  2182        * };
  2183        *
  2184        * var  clone = _ .cloneDeep (view, fun ction(valu e) {
  2185        *   r eturn _.is Element(va lue) ? val ue.cloneNo de(true) :  undefined ;
  2186        * });
  2187        *
  2188        * clo ne.node ==  view.node ;
  2189        * //  => false
  2190        */
  2191       functi on cloneDe ep(value,  callback,  thisArg) {
  2192         retu rn baseClo ne(value,  true, type of callbac k == 'func tion' && b aseCreateC allback(ca llback, th isArg, 1)) ;
  2193       }
  2194  
  2195       /**
  2196        * Cre ates an ob ject that  inherits f rom the gi ven `proto type` obje ct. If a
  2197        * `pr operties`  object is  provided i ts own enu merable pr operties a re assigne d
  2198        * to  the create d object.
  2199        *
  2200        * @st atic
  2201        * @me mberOf _
  2202        * @ca tegory Obj ects
  2203        * @pa ram {Objec t} prototy pe The obj ect to inh erit from.
  2204        * @pa ram {Objec t} [proper ties] The  properties  to assign  to the ob ject.
  2205        * @re turns {Obj ect} Retur ns the new  object.
  2206        * @ex ample
  2207        *
  2208        * fun ction Shap e() {
  2209        *   t his.x = 0;
  2210        *   t his.y = 0;
  2211        * }
  2212        *
  2213        * fun ction Circ le() {
  2214        *   S hape.call( this);
  2215        * }
  2216        *
  2217        * Cir cle.protot ype = _.cr eate(Shape .prototype , { 'const ructor': C ircle });
  2218        *
  2219        * var  circle =  new Circle ;
  2220        * cir cle instan ceof Circl e;
  2221        * //  => true
  2222        *
  2223        * cir cle instan ceof Shape ;
  2224        * //  => true
  2225        */
  2226       functi on create( prototype,  propertie s) {
  2227         var  result = b aseCreate( prototype) ;
  2228         retu rn propert ies ? assi gn(result,  propertie s) : resul t;
  2229       }
  2230  
  2231       /**
  2232        * Ass igns own e numerable  properties  of source  object(s)  to the de stination
  2233        * obj ect for al l destinat ion proper ties that  resolve to  `undefine d`. Once a
  2234        * pro perty is s et, additi onal defau lts of the  same prop erty will  be ignored .
  2235        *
  2236        * @st atic
  2237        * @me mberOf _
  2238        * @ty pe Functio n
  2239        * @ca tegory Obj ects
  2240        * @pa ram {Objec t} object  The destin ation obje ct.
  2241        * @pa ram {...Ob ject} [sou rce] The s ource obje cts.
  2242        * @pa ram- {Obje ct} [guard ] Allows w orking wit h `_.reduc e` without  using its
  2243        *  `k ey` and `o bject` arg uments as  sources.
  2244        * @re turns {Obj ect} Retur ns the des tination o bject.
  2245        * @ex ample
  2246        *
  2247        * var  object =  { 'name':  'barney' } ;
  2248        * _.d efaults(ob ject, { 'n ame': 'fre d', 'emplo yer': 'sla te' });
  2249        * //  => { 'name ': 'barney ', 'employ er': 'slat e' }
  2250        */
  2251       var de faults = c reateItera tor(defaul tsIterator Options);
  2252  
  2253       /**
  2254        * Thi s method i s like `_. findIndex`  except th at it retu rns the ke y of the
  2255        * fir st element  that pass es the cal lback chec k, instead  of the el ement itse lf.
  2256        *
  2257        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  2258        * cal lback will  return th e property  value of  the given  element.
  2259        *
  2260        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  2261        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  2262        * els e `false`.
  2263        *
  2264        * @st atic
  2265        * @me mberOf _
  2266        * @ca tegory Obj ects
  2267        * @pa ram {Objec t} object  The object  to search .
  2268        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called p er
  2269        *  it eration. I f a proper ty name or  object is  provided  it will be  used to
  2270        *  cr eate a "_. pluck" or  "_.where"  style call back, resp ectively.
  2271        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2272        * @re turns {str ing|undefi ned} Retur ns the key  of the fo und elemen t, else `u ndefined`.
  2273        * @ex ample
  2274        *
  2275        * var  character s = {
  2276        *   ' barney': {   'age': 3 6, 'blocke d': false  },
  2277        *   ' fred': {     'age': 4 0, 'blocke d': true } ,
  2278        *   ' pebbles':  { 'age': 1 ,  'blocke d': false  }
  2279        * };
  2280        *
  2281        * _.f indKey(cha racters, f unction(ch r) {
  2282        *   r eturn chr. age < 40;
  2283        * });
  2284        * //  => 'barney ' (propert y order is  not guara nteed acro ss environ ments)
  2285        *
  2286        * //  using "_.w here" call back short hand
  2287        * _.f indKey(cha racters, {  'age': 1  });
  2288        * //  => 'pebble s'
  2289        *
  2290        * //  using "_.p luck" call back short hand
  2291        * _.f indKey(cha racters, ' blocked');
  2292        * //  => 'fred'
  2293        */
  2294       functi on findKey (object, c allback, t hisArg) {
  2295         var  result;
  2296         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  2297         forO wn(object,  function( value, key , object)  {
  2298           if  (callback (value, ke y, object) ) {
  2299              result = k ey;
  2300              return fal se;
  2301           }
  2302         });
  2303         retu rn result;
  2304       }
  2305  
  2306       /**
  2307        * Thi s method i s like `_. findKey` e xcept that  it iterat es over el ements
  2308        * of  a `collect ion` in th e opposite  order.
  2309        *
  2310        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  2311        * cal lback will  return th e property  value of  the given  element.
  2312        *
  2313        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  2314        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  2315        * els e `false`.
  2316        *
  2317        * @st atic
  2318        * @me mberOf _
  2319        * @ca tegory Obj ects
  2320        * @pa ram {Objec t} object  The object  to search .
  2321        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called p er
  2322        *  it eration. I f a proper ty name or  object is  provided  it will be  used to
  2323        *  cr eate a "_. pluck" or  "_.where"  style call back, resp ectively.
  2324        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2325        * @re turns {str ing|undefi ned} Retur ns the key  of the fo und elemen t, else `u ndefined`.
  2326        * @ex ample
  2327        *
  2328        * var  character s = {
  2329        *   ' barney': {   'age': 3 6, 'blocke d': true } ,
  2330        *   ' fred': {     'age': 4 0, 'blocke d': false  },
  2331        *   ' pebbles':  { 'age': 1 ,  'blocke d': true }
  2332        * };
  2333        *
  2334        * _.f indLastKey (character s, functio n(chr) {
  2335        *   r eturn chr. age < 40;
  2336        * });
  2337        * //  => returns  `pebbles` , assuming  `_.findKe y` returns  `barney`
  2338        *
  2339        * //  using "_.w here" call back short hand
  2340        * _.f indLastKey (character s, { 'age' : 40 });
  2341        * //  => 'fred'
  2342        *
  2343        * //  using "_.p luck" call back short hand
  2344        * _.f indLastKey (character s, 'blocke d');
  2345        * //  => 'pebble s'
  2346        */
  2347       functi on findLas tKey(objec t, callbac k, thisArg ) {
  2348         var  result;
  2349         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  2350         forO wnRight(ob ject, func tion(value , key, obj ect) {
  2351           if  (callback (value, ke y, object) ) {
  2352              result = k ey;
  2353              return fal se;
  2354           }
  2355         });
  2356         retu rn result;
  2357       }
  2358  
  2359       /**
  2360        * Ite rates over  own and i nherited e numerable  properties  of an obj ect,
  2361        * exe cuting the  callback  for each p roperty. T he callbac k is bound  to `thisA rg`
  2362        * and  invoked w ith three  arguments;  (value, k ey, object ). Callbac ks may exi t
  2363        * ite ration ear ly by expl icitly ret urning `fa lse`.
  2364        *
  2365        * @st atic
  2366        * @me mberOf _
  2367        * @ty pe Functio n
  2368        * @ca tegory Obj ects
  2369        * @pa ram {Objec t} object  The object  to iterat e over.
  2370        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  2371        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2372        * @re turns {Obj ect} Retur ns `object `.
  2373        * @ex ample
  2374        *
  2375        * fun ction Shap e() {
  2376        *   t his.x = 0;
  2377        *   t his.y = 0;
  2378        * }
  2379        *
  2380        * Sha pe.prototy pe.move =  function(x , y) {
  2381        *   t his.x += x ;
  2382        *   t his.y += y ;
  2383        * };
  2384        *
  2385        * _.f orIn(new S hape, func tion(value , key) {
  2386        *   c onsole.log (key);
  2387        * });
  2388        * //  => logs 'x ', 'y', an d 'move' ( property o rder is no t guarante ed across  environmen ts)
  2389        */
  2390       var fo rIn = crea teIterator (eachItera torOptions , forOwnIt eratorOpti ons, {
  2391         'use Has': fals e
  2392       });
  2393  
  2394       /**
  2395        * Thi s method i s like `_. forIn` exc ept that i t iterates  over elem ents
  2396        * of  a `collect ion` in th e opposite  order.
  2397        *
  2398        * @st atic
  2399        * @me mberOf _
  2400        * @ca tegory Obj ects
  2401        * @pa ram {Objec t} object  The object  to iterat e over.
  2402        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  2403        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2404        * @re turns {Obj ect} Retur ns `object `.
  2405        * @ex ample
  2406        *
  2407        * fun ction Shap e() {
  2408        *   t his.x = 0;
  2409        *   t his.y = 0;
  2410        * }
  2411        *
  2412        * Sha pe.prototy pe.move =  function(x , y) {
  2413        *   t his.x += x ;
  2414        *   t his.y += y ;
  2415        * };
  2416        *
  2417        * _.f orInRight( new Shape,  function( value, key ) {
  2418        *   c onsole.log (key);
  2419        * });
  2420        * //  => logs 'm ove', 'y',  and 'x' a ssuming `_ .forIn ` l ogs 'x', ' y', and 'm ove'
  2421        */
  2422       functi on forInRi ght(object , callback , thisArg)  {
  2423         var  pairs = [] ;
  2424  
  2425         forI n(object,  function(v alue, key)  {
  2426           pa irs.push(k ey, value) ;
  2427         });
  2428  
  2429         var  length = p airs.lengt h;
  2430         call back = bas eCreateCal lback(call back, this Arg, 3);
  2431         whil e (length- -) {
  2432           if  (callback (pairs[len gth--], pa irs[length ], object)  === false ) {
  2433              break;
  2434           }
  2435         }
  2436         retu rn object;
  2437       }
  2438  
  2439       /**
  2440        * Ite rates over  own enume rable prop erties of  an object,  executing  the callb ack
  2441        * for  each prop erty. The  callback i s bound to  `thisArg`  and invok ed with th ree
  2442        * arg uments; (v alue, key,  object).  Callbacks  may exit i teration e arly by
  2443        * exp licitly re turning `f alse`.
  2444        *
  2445        * @st atic
  2446        * @me mberOf _
  2447        * @ty pe Functio n
  2448        * @ca tegory Obj ects
  2449        * @pa ram {Objec t} object  The object  to iterat e over.
  2450        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  2451        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2452        * @re turns {Obj ect} Retur ns `object `.
  2453        * @ex ample
  2454        *
  2455        * _.f orOwn({ '0 ': 'zero',  '1': 'one ', 'length ': 2 }, fu nction(num , key) {
  2456        *   c onsole.log (key);
  2457        * });
  2458        * //  => logs '0 ', '1', an d 'length'  (property  order is  not guaran teed acros s environm ents)
  2459        */
  2460       var fo rOwn = cre ateIterato r(eachIter atorOption s, forOwnI teratorOpt ions);
  2461  
  2462       /**
  2463        * Thi s method i s like `_. forOwn` ex cept that  it iterate s over ele ments
  2464        * of  a `collect ion` in th e opposite  order.
  2465        *
  2466        * @st atic
  2467        * @me mberOf _
  2468        * @ca tegory Obj ects
  2469        * @pa ram {Objec t} object  The object  to iterat e over.
  2470        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  2471        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2472        * @re turns {Obj ect} Retur ns `object `.
  2473        * @ex ample
  2474        *
  2475        * _.f orOwnRight ({ '0': 'z ero', '1':  'one', 'l ength': 2  }, functio n(num, key ) {
  2476        *   c onsole.log (key);
  2477        * });
  2478        * //  => logs 'l ength', '1 ', and '0'  assuming  `_.forOwn`  logs '0',  '1', and  'length'
  2479        */
  2480       functi on forOwnR ight(objec t, callbac k, thisArg ) {
  2481         var  props = ke ys(object) ,
  2482              length = p rops.lengt h;
  2483  
  2484         call back = bas eCreateCal lback(call back, this Arg, 3);
  2485         whil e (length- -) {
  2486           va r key = pr ops[length ];
  2487           if  (callback (object[ke y], key, o bject) ===  false) {
  2488              break;
  2489           }
  2490         }
  2491         retu rn object;
  2492       }
  2493  
  2494       /**
  2495        * Cre ates a sor ted array  of propert y names of  all enume rable prop erties,
  2496        * own  and inher ited, of ` object` th at have fu nction val ues.
  2497        *
  2498        * @st atic
  2499        * @me mberOf _
  2500        * @al ias method s
  2501        * @ca tegory Obj ects
  2502        * @pa ram {Objec t} object  The object  to inspec t.
  2503        * @re turns {Arr ay} Return s an array  of proper ty names t hat have f unction va lues.
  2504        * @ex ample
  2505        *
  2506        * _.f unctions(_ );
  2507        * //  => ['all',  'any', 'b ind', 'bin dAll', 'cl one', 'com pact', 'co mpose', .. .]
  2508        */
  2509       functi on functio ns(object)  {
  2510         var  result = [ ];
  2511         forI n(object,  function(v alue, key)  {
  2512           if  (isFuncti on(value))  {
  2513              result.pus h(key);
  2514           }
  2515         });
  2516         retu rn result. sort();
  2517       }
  2518  
  2519       /**
  2520        * Che cks if the  specified  property  name exist s as a dir ect proper ty of `obj ect`,
  2521        * ins tead of an  inherited  property.
  2522        *
  2523        * @st atic
  2524        * @me mberOf _
  2525        * @ca tegory Obj ects
  2526        * @pa ram {Objec t} object  The object  to inspec t.
  2527        * @pa ram {strin g} key The  name of t he propert y to check .
  2528        * @re turns {boo lean} Retu rns `true`  if key is  a direct  property,  else `fals e`.
  2529        * @ex ample
  2530        *
  2531        * _.h as({ 'a':  1, 'b': 2,  'c': 3 },  'b');
  2532        * //  => true
  2533        */
  2534       functi on has(obj ect, key)  {
  2535         retu rn object  ? hasOwnPr operty.cal l(object,  key) : fal se;
  2536       }
  2537  
  2538       /**
  2539        * Cre ates an ob ject compo sed of the  inverted  keys and v alues of t he given o bject.
  2540        *
  2541        * @st atic
  2542        * @me mberOf _
  2543        * @ca tegory Obj ects
  2544        * @pa ram {Objec t} object  The object  to invert .
  2545        * @re turns {Obj ect} Retur ns the cre ated inver ted object .
  2546        * @ex ample
  2547        *
  2548        * _.i nvert({ 'f irst': 'fr ed', 'seco nd': 'barn ey' });
  2549        * //  => { 'fred ': 'first' , 'barney' : 'second'  }
  2550        */
  2551       functi on invert( object) {
  2552         var  index = -1 ,
  2553              props = ke ys(object) ,
  2554              length = p rops.lengt h,
  2555              result = { };
  2556  
  2557         whil e (++index  < length)  {
  2558           va r key = pr ops[index] ;
  2559           re sult[objec t[key]] =  key;
  2560         }
  2561         retu rn result;
  2562       }
  2563  
  2564       /**
  2565        * Che cks if `va lue` is a  boolean va lue.
  2566        *
  2567        * @st atic
  2568        * @me mberOf _
  2569        * @ca tegory Obj ects
  2570        * @pa ram {*} va lue The va lue to che ck.
  2571        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a  boolean v alue, else  `false`.
  2572        * @ex ample
  2573        *
  2574        * _.i sBoolean(n ull);
  2575        * //  => false
  2576        */
  2577       functi on isBoole an(value)  {
  2578         retu rn value = == true ||  value ===  false ||
  2579           va lue && typ eof value  == 'object ' && toStr ing.call(v alue) == b oolClass | | false;
  2580       }
  2581  
  2582       /**
  2583        * Che cks if `va lue` is a  date.
  2584        *
  2585        * @st atic
  2586        * @me mberOf _
  2587        * @ca tegory Obj ects
  2588        * @pa ram {*} va lue The va lue to che ck.
  2589        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a  date, els e `false`.
  2590        * @ex ample
  2591        *
  2592        * _.i sDate(new  Date);
  2593        * //  => true
  2594        */
  2595       functi on isDate( value) {
  2596         retu rn value & & typeof v alue == 'o bject' &&  toString.c all(value)  == dateCl ass || fal se;
  2597       }
  2598  
  2599       /**
  2600        * Che cks if `va lue` is a  DOM elemen t.
  2601        *
  2602        * @st atic
  2603        * @me mberOf _
  2604        * @ca tegory Obj ects
  2605        * @pa ram {*} va lue The va lue to che ck.
  2606        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a  DOM eleme nt, else ` false`.
  2607        * @ex ample
  2608        *
  2609        * _.i sElement(d ocument.bo dy);
  2610        * //  => true
  2611        */
  2612       functi on isEleme nt(value)  {
  2613         retu rn value & & value.no deType ===  1 || fals e;
  2614       }
  2615  
  2616       /**
  2617        * Che cks if `va lue` is em pty. Array s, strings , or `argu ments` obj ects with  a
  2618        * len gth of `0`  and objec ts with no  own enume rable prop erties are  considere d
  2619        * "em pty".
  2620        *
  2621        * @st atic
  2622        * @me mberOf _
  2623        * @ca tegory Obj ects
  2624        * @pa ram {Array |Object|st ring} valu e The valu e to inspe ct.
  2625        * @re turns {boo lean} Retu rns `true`  if the `v alue` is e mpty, else  `false`.
  2626        * @ex ample
  2627        *
  2628        * _.i sEmpty([1,  2, 3]);
  2629        * //  => false
  2630        *
  2631        * _.i sEmpty({}) ;
  2632        * //  => true
  2633        *
  2634        * _.i sEmpty('') ;
  2635        * //  => true
  2636        */
  2637       functi on isEmpty (value) {
  2638         var  result = t rue;
  2639         if ( !value) {
  2640           re turn resul t;
  2641         }
  2642         var  className  = toString .call(valu e),
  2643              length = v alue.lengt h;
  2644  
  2645         if ( (className  == arrayC lass || cl assName ==  stringCla ss ||
  2646              (support.a rgsClass ?  className  == argsCl ass : isAr guments(va lue))) ||
  2647              (className  == object Class && t ypeof leng th == 'num ber' && is Function(v alue.splic e))) {
  2648           re turn !leng th;
  2649         }
  2650         forO wn(value,  function()  {
  2651           re turn (resu lt = false );
  2652         });
  2653         retu rn result;
  2654       }
  2655  
  2656       /**
  2657        * Per forms a de ep compari son betwee n two valu es to dete rmine if t hey are
  2658        * equ ivalent to  each othe r. If a ca llback is  provided i t will be  executed
  2659        * to  compare va lues. If t he callbac k returns  `undefined ` comparis ons will
  2660        * be  handled by  the metho d instead.  The callb ack is bou nd to `thi sArg` and
  2661        * inv oked with  two argume nts; (a, b ).
  2662        *
  2663        * @st atic
  2664        * @me mberOf _
  2665        * @ca tegory Obj ects
  2666        * @pa ram {*} a  The value  to compare .
  2667        * @pa ram {*} b  The other  value to c ompare.
  2668        * @pa ram {Funct ion} [call back] The  function t o customiz e comparin g values.
  2669        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2670        * @re turns {boo lean} Retu rns `true`  if the va lues are e quivalent,  else `fal se`.
  2671        * @ex ample
  2672        *
  2673        * var  object =  { 'name':  'fred' };
  2674        * var  copy = {  'name': 'f red' };
  2675        *
  2676        * obj ect == cop y;
  2677        * //  => false
  2678        *
  2679        * _.i sEqual(obj ect, copy) ;
  2680        * //  => true
  2681        *
  2682        * var  words = [ 'hello', ' goodbye'];
  2683        * var  otherWord s = ['hi',  'goodbye' ];
  2684        *
  2685        * _.i sEqual(wor ds, otherW ords, func tion(a, b)  {
  2686        *   v ar reGreet  = /^(?:he llo|hi)$/i ,
  2687        *        aGreet  = _.isStri ng(a) && r eGreet.tes t(a),
  2688        *        bGreet  = _.isStri ng(b) && r eGreet.tes t(b);
  2689        *
  2690        *   r eturn (aGr eet || bGr eet) ? (aG reet == bG reet) : un defined;
  2691        * });
  2692        * //  => true
  2693        */
  2694       functi on isEqual (a, b, cal lback, thi sArg) {
  2695         retu rn baseIsE qual(a, b,  typeof ca llback ==  'function'  && baseCr eateCallba ck(callbac k, thisArg , 2));
  2696       }
  2697  
  2698       /**
  2699        * Che cks if `va lue` is, o r can be c oerced to,  a finite  number.
  2700        *
  2701        * Not e: This is  not the s ame as nat ive `isFin ite` which  will retu rn true fo r
  2702        * boo leans and  empty stri ngs. See h ttp://es5. github.io/ #x15.1.2.5 .
  2703        *
  2704        * @st atic
  2705        * @me mberOf _
  2706        * @ca tegory Obj ects
  2707        * @pa ram {*} va lue The va lue to che ck.
  2708        * @re turns {boo lean} Retu rns `true`  if the `v alue` is f inite, els e `false`.
  2709        * @ex ample
  2710        *
  2711        * _.i sFinite(-1 01);
  2712        * //  => true
  2713        *
  2714        * _.i sFinite('1 0');
  2715        * //  => true
  2716        *
  2717        * _.i sFinite(tr ue);
  2718        * //  => false
  2719        *
  2720        * _.i sFinite('' );
  2721        * //  => false
  2722        *
  2723        * _.i sFinite(In finity);
  2724        * //  => false
  2725        */
  2726       functi on isFinit e(value) {
  2727         retu rn nativeI sFinite(va lue) && !n ativeIsNaN (parseFloa t(value));
  2728       }
  2729  
  2730       /**
  2731        * Che cks if `va lue` is a  function.
  2732        *
  2733        * @st atic
  2734        * @me mberOf _
  2735        * @ca tegory Obj ects
  2736        * @pa ram {*} va lue The va lue to che ck.
  2737        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a  function,  else `fal se`.
  2738        * @ex ample
  2739        *
  2740        * _.i sFunction( _);
  2741        * //  => true
  2742        */
  2743       functi on isFunct ion(value)  {
  2744         retu rn typeof  value == ' function';
  2745       }
  2746       // fal lback for  older vers ions of Ch rome and S afari
  2747       if (is Function(/ x/)) {
  2748         isFu nction = f unction(va lue) {
  2749           re turn typeo f value ==  'function ' && toStr ing.call(v alue) == f uncClass;
  2750         };
  2751       }
  2752  
  2753       /**
  2754        * Che cks if `va lue` is th e language  type of O bject.
  2755        * (e. g. arrays,  functions , objects,  regexes,  `new Numbe r(0)`, and  `new Stri ng('')`)
  2756        *
  2757        * @st atic
  2758        * @me mberOf _
  2759        * @ca tegory Obj ects
  2760        * @pa ram {*} va lue The va lue to che ck.
  2761        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a n object,  else `fals e`.
  2762        * @ex ample
  2763        *
  2764        * _.i sObject({} );
  2765        * //  => true
  2766        *
  2767        * _.i sObject([1 , 2, 3]);
  2768        * //  => true
  2769        *
  2770        * _.i sObject(1) ;
  2771        * //  => false
  2772        */
  2773       functi on isObjec t(value) {
  2774         // c heck if th e value is  the ECMAS cript lang uage type  of Object
  2775         // h ttp://es5. github.io/ #x8
  2776         // a nd avoid a  V8 bug
  2777         // h ttp://code .google.co m/p/v8/iss ues/detail ?id=2291
  2778         retu rn !!(valu e && objec tTypes[typ eof value] );
  2779       }
  2780  
  2781       /**
  2782        * Che cks if `va lue` is `N aN`.
  2783        *
  2784        * Not e: This is  not the s ame as nat ive `isNaN ` which wi ll return  `true` for
  2785        * `un defined` a nd other n on-numeric  values. S ee http:// es5.github .io/#x15.1 .2.4.
  2786        *
  2787        * @st atic
  2788        * @me mberOf _
  2789        * @ca tegory Obj ects
  2790        * @pa ram {*} va lue The va lue to che ck.
  2791        * @re turns {boo lean} Retu rns `true`  if the `v alue` is ` NaN`, else  `false`.
  2792        * @ex ample
  2793        *
  2794        * _.i sNaN(NaN);
  2795        * //  => true
  2796        *
  2797        * _.i sNaN(new N umber(NaN) );
  2798        * //  => true
  2799        *
  2800        * isN aN(undefin ed);
  2801        * //  => true
  2802        *
  2803        * _.i sNaN(undef ined);
  2804        * //  => false
  2805        */
  2806       functi on isNaN(v alue) {
  2807         // ` NaN` as a  primitive  is the onl y value th at is not  equal to i tself
  2808         // ( perform th e [[Class] ] check fi rst to avo id errors  with some  host objec ts in IE)
  2809         retu rn isNumbe r(value) & & value !=  +value;
  2810       }
  2811  
  2812       /**
  2813        * Che cks if `va lue` is `n ull`.
  2814        *
  2815        * @st atic
  2816        * @me mberOf _
  2817        * @ca tegory Obj ects
  2818        * @pa ram {*} va lue The va lue to che ck.
  2819        * @re turns {boo lean} Retu rns `true`  if the `v alue` is ` null`, els e `false`.
  2820        * @ex ample
  2821        *
  2822        * _.i sNull(null );
  2823        * //  => true
  2824        *
  2825        * _.i sNull(unde fined);
  2826        * //  => false
  2827        */
  2828       functi on isNull( value) {
  2829         retu rn value = == null;
  2830       }
  2831  
  2832       /**
  2833        * Che cks if `va lue` is a  number.
  2834        *
  2835        * Not e: `NaN` i s consider ed a numbe r. See htt p://es5.gi thub.io/#x 8.5.
  2836        *
  2837        * @st atic
  2838        * @me mberOf _
  2839        * @ca tegory Obj ects
  2840        * @pa ram {*} va lue The va lue to che ck.
  2841        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a  number, e lse `false `.
  2842        * @ex ample
  2843        *
  2844        * _.i sNumber(8. 4 * 5);
  2845        * //  => true
  2846        */
  2847       functi on isNumbe r(value) {
  2848         retu rn typeof  value == ' number' ||
  2849           va lue && typ eof value  == 'object ' && toStr ing.call(v alue) == n umberClass  || false;
  2850       }
  2851  
  2852       /**
  2853        * Che cks if `va lue` is an  object cr eated by t he `Object ` construc tor.
  2854        *
  2855        * @st atic
  2856        * @me mberOf _
  2857        * @ca tegory Obj ects
  2858        * @pa ram {*} va lue The va lue to che ck.
  2859        * @re turns {boo lean} Retu rns `true`  if `value ` is a pla in object,  else `fal se`.
  2860        * @ex ample
  2861        *
  2862        * fun ction Shap e() {
  2863        *   t his.x = 0;
  2864        *   t his.y = 0;
  2865        * }
  2866        *
  2867        * _.i sPlainObje ct(new Sha pe);
  2868        * //  => false
  2869        *
  2870        * _.i sPlainObje ct([1, 2,  3]);
  2871        * //  => false
  2872        *
  2873        * _.i sPlainObje ct({ 'x':  0, 'y': 0  });
  2874        * //  => true
  2875        */
  2876       var is PlainObjec t = !getPr ototypeOf  ? shimIsPl ainObject  : function (value) {
  2877         if ( !(value &&  toString. call(value ) == objec tClass) ||  (!support .argsClass  && isArgu ments(valu e))) {
  2878           re turn false ;
  2879         }
  2880         var  valueOf =  value.valu eOf,
  2881              objProto =  isNative( valueOf) & & (objProt o = getPro totypeOf(v alueOf)) & & getProto typeOf(obj Proto);
  2882  
  2883         retu rn objProt o
  2884           ?  (value ==  objProto | | getProto typeOf(val ue) == obj Proto)
  2885           :  shimIsPlai nObject(va lue);
  2886       };
  2887  
  2888       /**
  2889        * Che cks if `va lue` is a  regular ex pression.
  2890        *
  2891        * @st atic
  2892        * @me mberOf _
  2893        * @ca tegory Obj ects
  2894        * @pa ram {*} va lue The va lue to che ck.
  2895        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a  regular e xpression,  else `fal se`.
  2896        * @ex ample
  2897        *
  2898        * _.i sRegExp(/f red/);
  2899        * //  => true
  2900        */
  2901       functi on isRegEx p(value) {
  2902         retu rn value & & objectTy pes[typeof  value] &&  toString. call(value ) == regex pClass ||  false;
  2903       }
  2904  
  2905       /**
  2906        * Che cks if `va lue` is a  string.
  2907        *
  2908        * @st atic
  2909        * @me mberOf _
  2910        * @ca tegory Obj ects
  2911        * @pa ram {*} va lue The va lue to che ck.
  2912        * @re turns {boo lean} Retu rns `true`  if the `v alue` is a  string, e lse `false `.
  2913        * @ex ample
  2914        *
  2915        * _.i sString('f red');
  2916        * //  => true
  2917        */
  2918       functi on isStrin g(value) {
  2919         retu rn typeof  value == ' string' ||
  2920           va lue && typ eof value  == 'object ' && toStr ing.call(v alue) == s tringClass  || false;
  2921       }
  2922  
  2923       /**
  2924        * Che cks if `va lue` is `u ndefined`.
  2925        *
  2926        * @st atic
  2927        * @me mberOf _
  2928        * @ca tegory Obj ects
  2929        * @pa ram {*} va lue The va lue to che ck.
  2930        * @re turns {boo lean} Retu rns `true`  if the `v alue` is ` undefined` , else `fa lse`.
  2931        * @ex ample
  2932        *
  2933        * _.i sUndefined (void 0);
  2934        * //  => true
  2935        */
  2936       functi on isUndef ined(value ) {
  2937         retu rn typeof  value == ' undefined' ;
  2938       }
  2939  
  2940       /**
  2941        * Cre ates an ob ject with  the same k eys as `ob ject` and  values gen erated by
  2942        * run ning each  own enumer able prope rty of `ob ject` thro ugh the ca llback.
  2943        * The  callback  is bound t o `thisArg ` and invo ked with t hree argum ents;
  2944        * (va lue, key,  object).
  2945        *
  2946        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  2947        * cal lback will  return th e property  value of  the given  element.
  2948        *
  2949        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  2950        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  2951        * els e `false`.
  2952        *
  2953        * @st atic
  2954        * @me mberOf _
  2955        * @ca tegory Obj ects
  2956        * @pa ram {Objec t} object  The object  to iterat e over.
  2957        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  2958        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  2959        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  2960        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  2961        * @re turns {Arr ay} Return s a new ob ject with  values of  the result s of each  `callback`  execution .
  2962        * @ex ample
  2963        *
  2964        * _.m apValues({  'a': 1, ' b': 2, 'c' : 3} , fun ction(num)  { return  num * 3; } );
  2965        * //  => { 'a':  3, 'b': 6,  'c': 9 }
  2966        *
  2967        * var  character s = {
  2968        *   ' fred': { ' name': 'fr ed', 'age' : 40 },
  2969        *   ' pebbles':  { 'name':  'pebbles',  'age': 1  }
  2970        * };
  2971        *
  2972        * //  using "_.p luck" call back short hand
  2973        * _.m apValues(c haracters,  'age');
  2974        * //  => { 'fred ': 40, 'pe bbles': 1  }
  2975        */
  2976       functi on mapValu es(object,  callback,  thisArg)  {
  2977         var  result = { };
  2978         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  2979  
  2980         forO wn(object,  function( value, key , object)  {
  2981           re sult[key]  = callback (value, ke y, object) ;
  2982         });
  2983         retu rn result;
  2984       }
  2985  
  2986       /**
  2987        * Rec ursively m erges own  enumerable  propertie s of the s ource obje ct(s), tha t
  2988        * don 't resolve  to `undef ined` into  the desti nation obj ect. Subse quent sour ces
  2989        * wil l overwrit e property  assignmen ts of prev ious sourc es. If a c allback is
  2990        * pro vided it w ill be exe cuted to p roduce the  merged va lues of th e destinat ion
  2991        * and  source pr operties.  If the cal lback retu rns `undef ined` merg ing will
  2992        * be  handled by  the metho d instead.  The callb ack is bou nd to `thi sArg` and
  2993        * inv oked with  two argume nts; (obje ctValue, s ourceValue ).
  2994        *
  2995        * @st atic
  2996        * @me mberOf _
  2997        * @ca tegory Obj ects
  2998        * @pa ram {Objec t} object  The destin ation obje ct.
  2999        * @pa ram {...Ob ject} [sou rce] The s ource obje cts.
  3000        * @pa ram {Funct ion} [call back] The  function t o customiz e merging  properties .
  3001        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3002        * @re turns {Obj ect} Retur ns the des tination o bject.
  3003        * @ex ample
  3004        *
  3005        * var  names = {
  3006        *   ' characters ': [
  3007        *      { 'name':  'barney'  },
  3008        *      { 'name':  'fred' }
  3009        *   ]
  3010        * };
  3011        *
  3012        * var  ages = {
  3013        *   ' characters ': [
  3014        *      { 'age':  36 },
  3015        *      { 'age':  40 }
  3016        *   ]
  3017        * };
  3018        *
  3019        * _.m erge(names , ages);
  3020        * //  => { 'char acters': [ { 'name':  'barney',  'age': 36  }, { 'name ': 'fred',  'age': 40  }] }
  3021        *
  3022        * var  food = {
  3023        *   ' fruits': [ 'apple'],
  3024        *   ' vegetables ': ['beet' ]
  3025        * };
  3026        *
  3027        * var  otherFood  = {
  3028        *   ' fruits': [ 'banana'],
  3029        *   ' vegetables ': ['carro t']
  3030        * };
  3031        *
  3032        * _.m erge(food,  otherFood , function (a, b) {
  3033        *   r eturn _.is Array(a) ?  a.concat( b) : undef ined;
  3034        * });
  3035        * //  => { 'frui ts': ['app le', 'bana na'], 'veg etables':  ['beet', ' carrot] }
  3036        */
  3037       functi on merge(o bject) {
  3038         var  args = arg uments,
  3039              length = 2 ;
  3040  
  3041         if ( !isObject( object)) {
  3042           re turn objec t;
  3043         }
  3044         // a llows work ing with ` _.reduce`  and `_.red uceRight`  without us ing
  3045         // t heir `inde x` and `co llection`  arguments
  3046         if ( typeof arg s[2] != 'n umber') {
  3047           le ngth = arg s.length;
  3048         }
  3049         if ( length > 3  && typeof  args[leng th - 2] ==  'function ') {
  3050           va r callback  = baseCre ateCallbac k(args[--l ength - 1] , args[len gth--], 2) ;
  3051         } el se if (len gth > 2 &&  typeof ar gs[length  - 1] == 'f unction')  {
  3052           ca llback = a rgs[--leng th];
  3053         }
  3054         var  sources =  slice(argu ments, 1,  length),
  3055              index = -1 ,
  3056              stackA = g etArray(),
  3057              stackB = g etArray();
  3058  
  3059         whil e (++index  < length)  {
  3060           ba seMerge(ob ject, sour ces[index] , callback , stackA,  stackB);
  3061         }
  3062         rele aseArray(s tackA);
  3063         rele aseArray(s tackB);
  3064         retu rn object;
  3065       }
  3066  
  3067       /**
  3068        * Cre ates a sha llow clone  of `objec t` excludi ng the spe cified pro perties.
  3069        * Pro perty name s may be s pecified a s individu al argumen ts or as a rrays of
  3070        * pro perty name s. If a ca llback is  provided i t will be  executed f or each
  3071        * pro perty of ` object` om itting the  propertie s the call back retur ns truey
  3072        * for . The call back is bo und to `th isArg` and  invoked w ith three  arguments;
  3073        * (va lue, key,  object).
  3074        *
  3075        * @st atic
  3076        * @me mberOf _
  3077        * @ca tegory Obj ects
  3078        * @pa ram {Objec t} object  The source  object.
  3079        * @pa ram {Funct ion|...str ing|string []} [callb ack] The p roperties  to omit or  the
  3080        *  fu nction cal led per it eration.
  3081        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3082        * @re turns {Obj ect} Retur ns an obje ct without  the omitt ed propert ies.
  3083        * @ex ample
  3084        *
  3085        * _.o mit({ 'nam e': 'fred' , 'age': 4 0 }, 'age' );
  3086        * //  => { 'name ': 'fred'  }
  3087        *
  3088        * _.o mit({ 'nam e': 'fred' , 'age': 4 0 }, funct ion(value)  {
  3089        *   r eturn type of value = = 'number' ;
  3090        * });
  3091        * //  => { 'name ': 'fred'  }
  3092        */
  3093       functi on omit(ob ject, call back, this Arg) {
  3094         var  result = { };
  3095         if ( typeof cal lback != ' function')  {
  3096           va r props =  [];
  3097           fo rIn(object , function (value, ke y) {
  3098              props.push (key);
  3099           }) ;
  3100           pr ops = base Difference (props, ba seFlatten( arguments,  true, fal se, 1));
  3101  
  3102           va r index =  -1,
  3103                length =  props.len gth;
  3104  
  3105           wh ile (++ind ex < lengt h) {
  3106              var key =  props[inde x];
  3107              result[key ] = object [key];
  3108           }
  3109         } el se {
  3110           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  3111           fo rIn(object , function (value, ke y, object)  {
  3112              if (!callb ack(value,  key, obje ct)) {
  3113                result[k ey] = valu e;
  3114              }
  3115           }) ;
  3116         }
  3117         retu rn result;
  3118       }
  3119  
  3120       /**
  3121        * Cre ates a two  dimension al array o f an objec t's key-va lue pairs,
  3122        * i.e . `[[key1,  value1],  [key2, val ue2]]`.
  3123        *
  3124        * @st atic
  3125        * @me mberOf _
  3126        * @ca tegory Obj ects
  3127        * @pa ram {Objec t} object  The object  to inspec t.
  3128        * @re turns {Arr ay} Return s new arra y of key-v alue pairs .
  3129        * @ex ample
  3130        *
  3131        * _.p airs({ 'ba rney': 36,  'fred': 4 0 });
  3132        * //  => [['barn ey', 36],  ['fred', 4 0]] (prope rty order  is not gua ranteed ac ross envir onments)
  3133        */
  3134       functi on pairs(o bject) {
  3135         var  index = -1 ,
  3136              props = ke ys(object) ,
  3137              length = p rops.lengt h,
  3138              result = A rray(lengt h);
  3139  
  3140         whil e (++index  < length)  {
  3141           va r key = pr ops[index] ;
  3142           re sult[index ] = [key,  object[key ]];
  3143         }
  3144         retu rn result;
  3145       }
  3146  
  3147       /**
  3148        * Cre ates a sha llow clone  of `objec t` compose d of the s pecified p roperties.
  3149        * Pro perty name s may be s pecified a s individu al argumen ts or as a rrays of
  3150        * pro perty name s. If a ca llback is  provided i t will be  executed f or each
  3151        * pro perty of ` object` pi cking the  properties  the callb ack return s truey
  3152        * for . The call back is bo und to `th isArg` and  invoked w ith three  arguments;
  3153        * (va lue, key,  object).
  3154        *
  3155        * @st atic
  3156        * @me mberOf _
  3157        * @ca tegory Obj ects
  3158        * @pa ram {Objec t} object  The source  object.
  3159        * @pa ram {Funct ion|...str ing|string []} [callb ack] The f unction ca lled per
  3160        *  it eration or  property  names to p ick, speci fied as in dividual p roperty
  3161        *  na mes or arr ays of pro perty name s.
  3162        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3163        * @re turns {Obj ect} Retur ns an obje ct compose d of the p icked prop erties.
  3164        * @ex ample
  3165        *
  3166        * _.p ick({ 'nam e': 'fred' , '_userid ': 'fred1'  }, 'name' );
  3167        * //  => { 'name ': 'fred'  }
  3168        *
  3169        * _.p ick({ 'nam e': 'fred' , '_userid ': 'fred1'  }, functi on(value,  key) {
  3170        *   r eturn key. charAt(0)  != '_';
  3171        * });
  3172        * //  => { 'name ': 'fred'  }
  3173        */
  3174       functi on pick(ob ject, call back, this Arg) {
  3175         var  result = { };
  3176         if ( typeof cal lback != ' function')  {
  3177           va r index =  -1,
  3178                props =  baseFlatte n(argument s, true, f alse, 1),
  3179                length =  isObject( object) ?  props.leng th : 0;
  3180  
  3181           wh ile (++ind ex < lengt h) {
  3182              var key =  props[inde x];
  3183              if (key in  object) {
  3184                result[k ey] = obje ct[key];
  3185              }
  3186           }
  3187         } el se {
  3188           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  3189           fo rIn(object , function (value, ke y, object)  {
  3190              if (callba ck(value,  key, objec t)) {
  3191                result[k ey] = valu e;
  3192              }
  3193           }) ;
  3194         }
  3195         retu rn result;
  3196       }
  3197  
  3198       /**
  3199        * An  alternativ e to `_.re duce` this  method tr ansforms ` object` to  a new
  3200        * `ac cumulator`  object wh ich is the  result of  running e ach of its  own
  3201        * enu merable pr operties t hrough a c allback, w ith each c allback ex ecution
  3202        * pot entially m utating th e `accumul ator` obje ct. The ca llback is  bound to
  3203        * `th isArg` and  invoked w ith four a rguments;  (accumulat or, value,  key, obje ct).
  3204        * Cal lbacks may  exit iter ation earl y by expli citly retu rning `fal se`.
  3205        *
  3206        * @st atic
  3207        * @me mberOf _
  3208        * @ca tegory Obj ects
  3209        * @pa ram {Array |Object} o bject The  object to  iterate ov er.
  3210        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  3211        * @pa ram {*} [a ccumulator ] The cust om accumul ator value .
  3212        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3213        * @re turns {*}  Returns th e accumula ted value.
  3214        * @ex ample
  3215        *
  3216        * var  squares =  _.transfo rm([1, 2,  3, 4, 5, 6 , 7, 8, 9,  10], func tion(resul t, num) {
  3217        *   n um *= num;
  3218        *   i f (num % 2 ) {
  3219        *      return re sult.push( num) < 3;
  3220        *   }
  3221        * });
  3222        * //  => [1, 9,  25]
  3223        *
  3224        * var  mapped =  _.transfor m({ 'a': 1 , 'b': 2,  'c': 3 },  function(r esult, num , key) {
  3225        *   r esult[key]  = num * 3 ;
  3226        * });
  3227        * //  => { 'a':  3, 'b': 6,  'c': 9 }
  3228        */
  3229       functi on transfo rm(object,  callback,  accumulat or, thisAr g) {
  3230         var  isArr = is Array(obje ct);
  3231         if ( accumulato r == null)  {
  3232           if  (isArr) {
  3233              accumulato r = [];
  3234           }  else {
  3235              var ctor =  object &&  object.co nstructor,
  3236                  proto  = ctor &&  ctor.proto type;
  3237  
  3238              accumulato r = baseCr eate(proto );
  3239           }
  3240         }
  3241         if ( callback)  {
  3242           ca llback = l odash.crea teCallback (callback,  thisArg,  4);
  3243           (i sArr ? bas eEach : fo rOwn)(obje ct, functi on(value,  index, obj ect) {
  3244              return cal lback(accu mulator, v alue, inde x, object) ;
  3245           }) ;
  3246         }
  3247         retu rn accumul ator;
  3248       }
  3249  
  3250       /**
  3251        * Cre ates an ar ray compos ed of the  own enumer able prope rty values  of `objec t`.
  3252        *
  3253        * @st atic
  3254        * @me mberOf _
  3255        * @ca tegory Obj ects
  3256        * @pa ram {Objec t} object  The object  to inspec t.
  3257        * @re turns {Arr ay} Return s an array  of proper ty values.
  3258        * @ex ample
  3259        *
  3260        * _.v alues({ 'o ne': 1, 't wo': 2, 't hree': 3 } );
  3261        * //  => [1, 2,  3] (proper ty order i s not guar anteed acr oss enviro nments)
  3262        */
  3263       functi on values( object) {
  3264         var  index = -1 ,
  3265              props = ke ys(object) ,
  3266              length = p rops.lengt h,
  3267              result = A rray(lengt h);
  3268  
  3269         whil e (++index  < length)  {
  3270           re sult[index ] = object [props[ind ex]];
  3271         }
  3272         retu rn result;
  3273       }
  3274  
  3275       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  3276  
  3277       /**
  3278        * Cre ates an ar ray of ele ments from  the speci fied index es, or key s, of the
  3279        * `co llection`.  Indexes m ay be spec ified as i ndividual  arguments  or as arra ys
  3280        * of  indexes.
  3281        *
  3282        * @st atic
  3283        * @me mberOf _
  3284        * @ca tegory Col lections
  3285        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3286        * @pa ram {...(n umber|numb er[]|strin g|string[] )} [index]  The index es of `col lection`
  3287        *   t o retrieve , specifie d as indiv idual inde xes or arr ays of ind exes.
  3288        * @re turns {Arr ay} Return s a new ar ray of ele ments corr esponding  to the
  3289        *  pr ovided ind exes.
  3290        * @ex ample
  3291        *
  3292        * _.a t(['a', 'b ', 'c', 'd ', 'e'], [ 0, 2, 4]);
  3293        * //  => ['a', ' c', 'e']
  3294        *
  3295        * _.a t(['fred',  'barney',  'pebbles' ], 0, 2);
  3296        * //  => ['fred' , 'pebbles ']
  3297        */
  3298       functi on at(coll ection) {
  3299         var  args = arg uments,
  3300              index = -1 ,
  3301              props = ba seFlatten( args, true , false, 1 ),
  3302              length = ( args[2] &&  args[2][a rgs[1]] == = collecti on) ? 1 :  props.leng th,
  3303              result = A rray(lengt h);
  3304  
  3305         if ( support.un indexedCha rs && isSt ring(colle ction)) {
  3306           co llection =  collectio n.split('' );
  3307         }
  3308         whil e(++index  < length)  {
  3309           re sult[index ] = collec tion[props [index]];
  3310         }
  3311         retu rn result;
  3312       }
  3313  
  3314       /**
  3315        * Che cks if a g iven value  is presen t in a col lection us ing strict  equality
  3316        * for  compariso ns, i.e. ` ===`. If ` fromIndex`  is negati ve, it is  used as th e
  3317        * off set from t he end of  the collec tion.
  3318        *
  3319        * @st atic
  3320        * @me mberOf _
  3321        * @al ias includ e
  3322        * @ca tegory Col lections
  3323        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3324        * @pa ram {*} ta rget The v alue to ch eck for.
  3325        * @pa ram {numbe r} [fromIn dex=0] The  index to  search fro m.
  3326        * @re turns {boo lean} Retu rns `true`  if the `t arget` ele ment is fo und, else  `false`.
  3327        * @ex ample
  3328        *
  3329        * _.c ontains([1 , 2, 3], 1 );
  3330        * //  => true
  3331        *
  3332        * _.c ontains([1 , 2, 3], 1 , 2);
  3333        * //  => false
  3334        *
  3335        * _.c ontains({  'name': 'f red', 'age ': 40 }, ' fred');
  3336        * //  => true
  3337        *
  3338        * _.c ontains('p ebbles', ' eb');
  3339        * //  => true
  3340        */
  3341       functi on contain s(collecti on, target , fromInde x) {
  3342         var  index = -1 ,
  3343              indexOf =  getIndexOf (),
  3344              length = c ollection  ? collecti on.length  : 0,
  3345              result = f alse;
  3346  
  3347         from Index = (f romIndex <  0 ? nativ eMax(0, le ngth + fro mIndex) :  fromIndex)  || 0;
  3348         if ( isArray(co llection))  {
  3349           re sult = ind exOf(colle ction, tar get, fromI ndex) > -1 ;
  3350         } el se if (typ eof length  == 'numbe r') {
  3351           re sult = (is String(col lection) ?  collectio n.indexOf( target, fr omIndex) :  indexOf(c ollection,  target, f romIndex))  > -1;
  3352         } el se {
  3353           ba seEach(col lection, f unction(va lue) {
  3354              if (++inde x >= fromI ndex) {
  3355                return ! (result =  value ===  target);
  3356              }
  3357           }) ;
  3358         }
  3359         retu rn result;
  3360       }
  3361  
  3362       /**
  3363        * Cre ates an ob ject compo sed of key s generate d from the  results o f running
  3364        * eac h element  of `collec tion` thro ugh the ca llback. Th e correspo nding valu e
  3365        * of  each key i s the numb er of time s the key  was return ed by the  callback.
  3366        * The  callback  is bound t o `thisArg ` and invo ked with t hree argum ents;
  3367        * (va lue, index |key, coll ection).
  3368        *
  3369        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3370        * cal lback will  return th e property  value of  the given  element.
  3371        *
  3372        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3373        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3374        * els e `false`.
  3375        *
  3376        * @st atic
  3377        * @me mberOf _
  3378        * @ca tegory Col lections
  3379        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3380        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3381        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3382        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3383        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3384        * @re turns {Obj ect} Retur ns the com posed aggr egate obje ct.
  3385        * @ex ample
  3386        *
  3387        * _.c ountBy([4. 3, 6.1, 6. 4], functi on(num) {  return Mat h.floor(nu m); });
  3388        * //  => { '4':  1, '6': 2  }
  3389        *
  3390        * _.c ountBy([4. 3, 6.1, 6. 4], functi on(num) {  return thi s.floor(nu m); }, Mat h);
  3391        * //  => { '4':  1, '6': 2  }
  3392        *
  3393        * _.c ountBy(['o ne', 'two' , 'three'] , 'length' );
  3394        * //  => { '3':  2, '5': 1  }
  3395        */
  3396       var co untBy = cr eateAggreg ator(funct ion(result , value, k ey) {
  3397         (has OwnPropert y.call(res ult, key)  ? result[k ey]++ : re sult[key]  = 1);
  3398       });
  3399  
  3400       /**
  3401        * Che cks if the  given cal lback retu rns truey  value for  **all** el ements of
  3402        * a c ollection.  The callb ack is bou nd to `thi sArg` and  invoked wi th three
  3403        * arg uments; (v alue, inde x|key, col lection).
  3404        *
  3405        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3406        * cal lback will  return th e property  value of  the given  element.
  3407        *
  3408        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3409        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3410        * els e `false`.
  3411        *
  3412        * @st atic
  3413        * @me mberOf _
  3414        * @al ias all
  3415        * @ca tegory Col lections
  3416        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3417        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3418        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3419        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3420        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3421        * @re turns {boo lean} Retu rns `true`  if all el ements pas sed the ca llback che ck,
  3422        *  el se `false` .
  3423        * @ex ample
  3424        *
  3425        * _.e very([true , 1, null,  'yes']);
  3426        * //  => false
  3427        *
  3428        * var  character s = [
  3429        *   {  'name': ' barney', ' age': 36 } ,
  3430        *   {  'name': ' fred',   ' age': 40 }
  3431        * ];
  3432        *
  3433        * //  using "_.p luck" call back short hand
  3434        * _.e very(chara cters, 'ag e');
  3435        * //  => true
  3436        *
  3437        * //  using "_.w here" call back short hand
  3438        * _.e very(chara cters, { ' age': 36 } );
  3439        * //  => false
  3440        */
  3441       functi on every(c ollection,  callback,  thisArg)  {
  3442         var  result = t rue;
  3443         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  3444  
  3445         if ( isArray(co llection))  {
  3446           va r index =  -1,
  3447                length =  collectio n.length;
  3448  
  3449           wh ile (++ind ex < lengt h) {
  3450              if (!(resu lt = !!cal lback(coll ection[ind ex], index , collecti on))) {
  3451                break;
  3452              }
  3453           }
  3454         } el se {
  3455           ba seEach(col lection, f unction(va lue, index , collecti on) {
  3456              return (re sult = !!c allback(va lue, index , collecti on));
  3457           }) ;
  3458         }
  3459         retu rn result;
  3460       }
  3461  
  3462       /**
  3463        * Ite rates over  elements  of a colle ction, ret urning an  array of a ll element s
  3464        * the  callback  returns tr uey for. T he callbac k is bound  to `thisA rg` and
  3465        * inv oked with  three argu ments; (va lue, index |key, coll ection).
  3466        *
  3467        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3468        * cal lback will  return th e property  value of  the given  element.
  3469        *
  3470        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3471        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3472        * els e `false`.
  3473        *
  3474        * @st atic
  3475        * @me mberOf _
  3476        * @al ias select
  3477        * @ca tegory Col lections
  3478        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3479        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3480        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3481        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3482        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3483        * @re turns {Arr ay} Return s a new ar ray of ele ments that  passed th e callback  check.
  3484        * @ex ample
  3485        *
  3486        * var  evens = _ .filter([1 , 2, 3, 4,  5, 6], fu nction(num ) { return  num % 2 = = 0; });
  3487        * //  => [2, 4,  6]
  3488        *
  3489        * var  character s = [
  3490        *   {  'name': ' barney', ' age': 36,  'blocked':  false },
  3491        *   {  'name': ' fred',   ' age': 40,  'blocked':  true }
  3492        * ];
  3493        *
  3494        * //  using "_.p luck" call back short hand
  3495        * _.f ilter(char acters, 'b locked');
  3496        * //  => [{ 'nam e': 'fred' , 'age': 4 0, 'blocke d': true } ]
  3497        *
  3498        * //  using "_.w here" call back short hand
  3499        * _.f ilter(char acters, {  'age': 36  });
  3500        * //  => [{ 'nam e': 'barne y', 'age':  36, 'bloc ked': fals e }]
  3501        */
  3502       functi on filter( collection , callback , thisArg)  {
  3503         var  result = [ ];
  3504         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  3505  
  3506         if ( isArray(co llection))  {
  3507           va r index =  -1,
  3508                length =  collectio n.length;
  3509  
  3510           wh ile (++ind ex < lengt h) {
  3511              var value  = collecti on[index];
  3512              if (callba ck(value,  index, col lection))  {
  3513                result.p ush(value) ;
  3514              }
  3515           }
  3516         } el se {
  3517           ba seEach(col lection, f unction(va lue, index , collecti on) {
  3518              if (callba ck(value,  index, col lection))  {
  3519                result.p ush(value) ;
  3520              }
  3521           }) ;
  3522         }
  3523         retu rn result;
  3524       }
  3525  
  3526       /**
  3527        * Ite rates over  elements  of a colle ction, ret urning the  first ele ment that
  3528        * the  callback  returns tr uey for. T he callbac k is bound  to `thisA rg` and
  3529        * inv oked with  three argu ments; (va lue, index |key, coll ection).
  3530        *
  3531        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3532        * cal lback will  return th e property  value of  the given  element.
  3533        *
  3534        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3535        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3536        * els e `false`.
  3537        *
  3538        * @st atic
  3539        * @me mberOf _
  3540        * @al ias detect , findWher e
  3541        * @ca tegory Col lections
  3542        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3543        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3544        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3545        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3546        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3547        * @re turns {*}  Returns th e found el ement, els e `undefin ed`.
  3548        * @ex ample
  3549        *
  3550        * var  character s = [
  3551        *   {  'name': ' barney',   'age': 36,  'blocked' : false },
  3552        *   {  'name': ' fred',     'age': 40,  'blocked' : true },
  3553        *   {  'name': ' pebbles',  'age': 1,   'blocked' : false }
  3554        * ];
  3555        *
  3556        * _.f ind(charac ters, func tion(chr)  {
  3557        *   r eturn chr. age < 40;
  3558        * });
  3559        * //  => { 'name ': 'barney ', 'age':  36, 'block ed': false  }
  3560        *
  3561        * //  using "_.w here" call back short hand
  3562        * _.f ind(charac ters, { 'a ge': 1 });
  3563        * //  =>  { 'nam e': 'pebbl es', 'age' : 1, 'bloc ked': fals e }
  3564        *
  3565        * //  using "_.p luck" call back short hand
  3566        * _.f ind(charac ters, 'blo cked');
  3567        * //  => { 'name ': 'fred',  'age': 40 , 'blocked ': true }
  3568        */
  3569       functi on find(co llection,  callback,  thisArg) {
  3570         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  3571  
  3572         if ( isArray(co llection))  {
  3573           va r index =  -1,
  3574                length =  collectio n.length;
  3575  
  3576           wh ile (++ind ex < lengt h) {
  3577              var value  = collecti on[index];
  3578              if (callba ck(value,  index, col lection))  {
  3579                return v alue;
  3580              }
  3581           }
  3582         } el se {
  3583           va r result;
  3584           ba seEach(col lection, f unction(va lue, index , collecti on) {
  3585              if (callba ck(value,  index, col lection))  {
  3586                result =  value;
  3587                return f alse;
  3588              }
  3589           }) ;
  3590           re turn resul t;
  3591         }
  3592       }
  3593  
  3594       /**
  3595        * Thi s method i s like `_. find` exce pt that it  iterates  over eleme nts
  3596        * of  a `collect ion` from  right to l eft.
  3597        *
  3598        * @st atic
  3599        * @me mberOf _
  3600        * @ca tegory Col lections
  3601        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3602        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3603        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3604        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3605        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3606        * @re turns {*}  Returns th e found el ement, els e `undefin ed`.
  3607        * @ex ample
  3608        *
  3609        * _.f indLast([1 , 2, 3, 4] , function (num) {
  3610        *   r eturn num  % 2 == 1;
  3611        * });
  3612        * //  => 3
  3613        */
  3614       functi on findLas t(collecti on, callba ck, thisAr g) {
  3615         var  result;
  3616         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  3617         forE achRight(c ollection,  function( value, ind ex, collec tion) {
  3618           if  (callback (value, in dex, colle ction)) {
  3619              result = v alue;
  3620              return fal se;
  3621           }
  3622         });
  3623         retu rn result;
  3624       }
  3625  
  3626       /**
  3627        * Ite rates over  elements  of a colle ction, exe cuting the  callback  for each
  3628        * ele ment. The  callback i s bound to  `thisArg`  and invok ed with th ree argume nts;
  3629        * (va lue, index |key, coll ection). C allbacks m ay exit it eration ea rly by
  3630        * exp licitly re turning `f alse`.
  3631        *
  3632        * Not e: As with  other "Co llections"  methods,  objects wi th a `leng th` proper ty
  3633        * are  iterated  like array s. To avoi d this beh avior `_.f orIn` or ` _.forOwn`
  3634        * may  be used f or object  iteration.
  3635        *
  3636        * @st atic
  3637        * @me mberOf _
  3638        * @al ias each
  3639        * @ca tegory Col lections
  3640        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3641        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  3642        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3643        * @re turns {Arr ay|Object| string} Re turns `col lection`.
  3644        * @ex ample
  3645        *
  3646        * _([ 1, 2, 3]). forEach(fu nction(num ) { consol e.log(num) ; }).join( ',');
  3647        * //  => logs ea ch number  and return s '1,2,3'
  3648        *
  3649        * _.f orEach({ ' one': 1, ' two': 2, ' three': 3  }, functio n(num) { c onsole.log (num); });
  3650        * //  => logs ea ch number  and return s the obje ct (proper ty order i s not guar anteed acr oss enviro nments)
  3651        */
  3652       functi on forEach (collectio n, callbac k, thisArg ) {
  3653         if ( callback & & typeof t hisArg ==  'undefined ' && isArr ay(collect ion)) {
  3654           va r index =  -1,
  3655                length =  collectio n.length;
  3656  
  3657           wh ile (++ind ex < lengt h) {
  3658              if (callba ck(collect ion[index] , index, c ollection)  === false ) {
  3659                break;
  3660              }
  3661           }
  3662         } el se {
  3663           ba seEach(col lection, c allback, t hisArg);
  3664         }
  3665         retu rn collect ion;
  3666       }
  3667  
  3668       /**
  3669        * Thi s method i s like `_. forEach` e xcept that  it iterat es over el ements
  3670        * of  a `collect ion` from  right to l eft.
  3671        *
  3672        * @st atic
  3673        * @me mberOf _
  3674        * @al ias eachRi ght
  3675        * @ca tegory Col lections
  3676        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3677        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  3678        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3679        * @re turns {Arr ay|Object| string} Re turns `col lection`.
  3680        * @ex ample
  3681        *
  3682        * _([ 1, 2, 3]). forEachRig ht(functio n(num) { c onsole.log (num); }). join(',');
  3683        * //  => logs ea ch number  from right  to left a nd returns  '3,2,1'
  3684        */
  3685       functi on forEach Right(coll ection, ca llback, th isArg) {
  3686         var  iterable =  collectio n,
  3687              length = c ollection  ? collecti on.length  : 0;
  3688  
  3689         call back = cal lback && t ypeof this Arg == 'un defined' ?  callback  : baseCrea teCallback (callback,  thisArg,  3);
  3690         if ( isArray(co llection))  {
  3691           wh ile (lengt h--) {
  3692              if (callba ck(collect ion[length ], length,  collectio n) === fal se) {
  3693                break;
  3694              }
  3695           }
  3696         } el se {
  3697           if  (typeof l ength != ' number') {
  3698              var props  = keys(col lection);
  3699              length = p rops.lengt h;
  3700           }  else if (s upport.uni ndexedChar s && isStr ing(collec tion)) {
  3701              iterable =  collectio n.split('' );
  3702           }
  3703           ba seEach(col lection, f unction(va lue, key,  collection ) {
  3704              key = prop s ? props[ --length]  : --length ;
  3705              return cal lback(iter able[key],  key, coll ection);
  3706           }) ;
  3707         }
  3708         retu rn collect ion;
  3709       }
  3710  
  3711       /**
  3712        * Cre ates an ob ject compo sed of key s generate d from the  results o f running
  3713        * eac h element  of a colle ction thro ugh the ca llback. Th e correspo nding valu e
  3714        * of  each key i s an array  of the el ements res ponsible f or generat ing the ke y.
  3715        * The  callback  is bound t o `thisArg ` and invo ked with t hree argum ents;
  3716        * (va lue, index |key, coll ection).
  3717        *
  3718        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3719        * cal lback will  return th e property  value of  the given  element.
  3720        *
  3721        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3722        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3723        * els e `false`
  3724        *
  3725        * @st atic
  3726        * @me mberOf _
  3727        * @ca tegory Col lections
  3728        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3729        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3730        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3731        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3732        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3733        * @re turns {Obj ect} Retur ns the com posed aggr egate obje ct.
  3734        * @ex ample
  3735        *
  3736        * _.g roupBy([4. 2, 6.1, 6. 4], functi on(num) {  return Mat h.floor(nu m); });
  3737        * //  => { '4':  [4.2], '6' : [6.1, 6. 4] }
  3738        *
  3739        * _.g roupBy([4. 2, 6.1, 6. 4], functi on(num) {  return thi s.floor(nu m); }, Mat h);
  3740        * //  => { '4':  [4.2], '6' : [6.1, 6. 4] }
  3741        *
  3742        * //  using "_.p luck" call back short hand
  3743        * _.g roupBy(['o ne', 'two' , 'three'] , 'length' );
  3744        * //  => { '3':  ['one', 't wo'], '5':  ['three']  }
  3745        */
  3746       var gr oupBy = cr eateAggreg ator(funct ion(result , value, k ey) {
  3747         (has OwnPropert y.call(res ult, key)  ? result[k ey] : resu lt[key] =  []).push(v alue);
  3748       });
  3749  
  3750       /**
  3751        * Cre ates an ob ject compo sed of key s generate d from the  results o f running
  3752        * eac h element  of the col lection th rough the  given call back. The  correspond ing
  3753        * val ue of each  key is th e last ele ment respo nsible for  generatin g the key.
  3754        * The  callback  is bound t o `thisArg ` and invo ked with t hree argum ents;
  3755        * (va lue, index |key, coll ection).
  3756        *
  3757        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3758        * cal lback will  return th e property  value of  the given  element.
  3759        *
  3760        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3761        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3762        * els e `false`.
  3763        *
  3764        * @st atic
  3765        * @me mberOf _
  3766        * @ca tegory Col lections
  3767        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3768        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3769        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3770        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3771        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3772        * @re turns {Obj ect} Retur ns the com posed aggr egate obje ct.
  3773        * @ex ample
  3774        *
  3775        * var  keys = [
  3776        *   {  'dir': 'l eft', 'cod e': 97 },
  3777        *   {  'dir': 'r ight', 'co de': 100 }
  3778        * ];
  3779        *
  3780        * _.i ndexBy(key s, 'dir');
  3781        * //  => { 'left ': { 'dir' : 'left',  'code': 97  }, 'right ': { 'dir' : 'right',  'code': 1 00 } }
  3782        *
  3783        * _.i ndexBy(key s, functio n(key) { r eturn Stri ng.fromCha rCode(key. code); });
  3784        * //  => { 'a':  { 'dir': ' left', 'co de': 97 },  'd': { 'd ir': 'righ t', 'code' : 100 } }
  3785        *
  3786        * _.i ndexBy(cha racters, f unction(ke y) { this. fromCharCo de(key.cod e); }, Str ing);
  3787        * //  => { 'a':  { 'dir': ' left', 'co de': 97 },  'd': { 'd ir': 'righ t', 'code' : 100 } }
  3788        */
  3789       var in dexBy = cr eateAggreg ator(funct ion(result , value, k ey) {
  3790         resu lt[key] =  value;
  3791       });
  3792  
  3793       /**
  3794        * Inv okes the m ethod name d by `meth odName` on  each elem ent in the  `collecti on`
  3795        * ret urning an  array of t he results  of each i nvoked met hod. Addit ional argu ments
  3796        * wil l be provi ded to eac h invoked  method. If  `methodNa me` is a f unction it
  3797        * wil l be invok ed for, an d `this` b ound to, e ach elemen t in the ` collection `.
  3798        *
  3799        * @st atic
  3800        * @me mberOf _
  3801        * @ca tegory Col lections
  3802        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3803        * @pa ram {Funct ion|string } methodNa me The nam e of the m ethod to i nvoke or
  3804        *  th e function  invoked p er iterati on.
  3805        * @pa ram {...*}  [arg] Arg uments to  invoke the  method wi th.
  3806        * @re turns {Arr ay} Return s a new ar ray of the  results o f each inv oked metho d.
  3807        * @ex ample
  3808        *
  3809        * _.i nvoke([[5,  1, 7], [3 , 2, 1]],  'sort');
  3810        * //  => [[1, 5,  7], [1, 2 , 3]]
  3811        *
  3812        * _.i nvoke([123 , 456], St ring.proto type.split , '');
  3813        * //  => [['1',  '2', '3'],  ['4', '5' , '6']]
  3814        */
  3815       functi on invoke( collection , methodNa me) {
  3816         var  args = sli ce(argumen ts, 2),
  3817              index = -1 ,
  3818              isFunc = t ypeof meth odName ==  'function' ,
  3819              length = c ollection  ? collecti on.length  : 0,
  3820              result = A rray(typeo f length = = 'number'  ? length  : 0);
  3821  
  3822         forE ach(collec tion, func tion(value ) {
  3823           re sult[++ind ex] = (isF unc ? meth odName : v alue[metho dName]).ap ply(value,  args);
  3824         });
  3825         retu rn result;
  3826       }
  3827  
  3828       /**
  3829        * Cre ates an ar ray of val ues by run ning each  element in  the colle ction
  3830        * thr ough the c allback. T he callbac k is bound  to `thisA rg` and in voked with
  3831        * thr ee argumen ts; (value , index|ke y, collect ion).
  3832        *
  3833        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3834        * cal lback will  return th e property  value of  the given  element.
  3835        *
  3836        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3837        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3838        * els e `false`.
  3839        *
  3840        * @st atic
  3841        * @me mberOf _
  3842        * @al ias collec t
  3843        * @ca tegory Col lections
  3844        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3845        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3846        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3847        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3848        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3849        * @re turns {Arr ay} Return s a new ar ray of the  results o f each `ca llback` ex ecution.
  3850        * @ex ample
  3851        *
  3852        * _.m ap([1, 2,  3], functi on(num) {  return num  * 3; });
  3853        * //  => [3, 6,  9]
  3854        *
  3855        * _.m ap({ 'one' : 1, 'two' : 2, 'thre e': 3 }, f unction(nu m) { retur n num * 3;  });
  3856        * //  => [3, 6,  9] (proper ty order i s not guar anteed acr oss enviro nments)
  3857        *
  3858        * var  character s = [
  3859        *   {  'name': ' barney', ' age': 36 } ,
  3860        *   {  'name': ' fred',   ' age': 40 }
  3861        * ];
  3862        *
  3863        * //  using "_.p luck" call back short hand
  3864        * _.m ap(charact ers, 'name ');
  3865        * //  => ['barne y', 'fred' ]
  3866        */
  3867       functi on map(col lection, c allback, t hisArg) {
  3868         var  index = -1 ,
  3869              length = c ollection  ? collecti on.length  : 0,
  3870              result = A rray(typeo f length = = 'number'  ? length  : 0);
  3871  
  3872         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  3873         if ( isArray(co llection))  {
  3874           wh ile (++ind ex < lengt h) {
  3875              result[ind ex] = call back(colle ction[inde x], index,  collectio n);
  3876           }
  3877         } el se {
  3878           ba seEach(col lection, f unction(va lue, key,  collection ) {
  3879              result[++i ndex] = ca llback(val ue, key, c ollection) ;
  3880           }) ;
  3881         }
  3882         retu rn result;
  3883       }
  3884  
  3885       /**
  3886        * Ret rieves the  maximum v alue of a  collection . If the c ollection  is empty o r
  3887        * fal sey `-Infi nity` is r eturned. I f a callba ck is prov ided it wi ll be exec uted
  3888        * for  each valu e in the c ollection  to generat e the crit erion by w hich the v alue
  3889        * is  ranked. Th e callback  is bound  to `thisAr g` and inv oked with  three
  3890        * arg uments; (v alue, inde x, collect ion).
  3891        *
  3892        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3893        * cal lback will  return th e property  value of  the given  element.
  3894        *
  3895        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3896        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3897        * els e `false`.
  3898        *
  3899        * @st atic
  3900        * @me mberOf _
  3901        * @ca tegory Col lections
  3902        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3903        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3904        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3905        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3906        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3907        * @re turns {*}  Returns th e maximum  value.
  3908        * @ex ample
  3909        *
  3910        * _.m ax([4, 2,  8, 6]);
  3911        * //  => 8
  3912        *
  3913        * var  character s = [
  3914        *   {  'name': ' barney', ' age': 36 } ,
  3915        *   {  'name': ' fred',   ' age': 40 }
  3916        * ];
  3917        *
  3918        * _.m ax(charact ers, funct ion(chr) {  return ch r.age; });
  3919        * //  => { 'name ': 'fred',  'age': 40  };
  3920        *
  3921        * //  using "_.p luck" call back short hand
  3922        * _.m ax(charact ers, 'age' );
  3923        * //  => { 'name ': 'fred',  'age': 40  };
  3924        */
  3925       functi on max(col lection, c allback, t hisArg) {
  3926         var  computed =  -Infinity ,
  3927              result = c omputed;
  3928  
  3929         // a llows work ing with f unctions l ike `_.map ` without  using
  3930         // t heir `inde x` argumen t as a cal lback
  3931         if ( typeof cal lback != ' function'  && thisArg  && thisAr g[callback ] === coll ection) {
  3932           ca llback = n ull;
  3933         }
  3934         if ( callback = = null &&  isArray(co llection))  {
  3935           va r index =  -1,
  3936                length =  collectio n.length;
  3937  
  3938           wh ile (++ind ex < lengt h) {
  3939              var value  = collecti on[index];
  3940              if (value  > result)  {
  3941                result =  value;
  3942              }
  3943           }
  3944         } el se {
  3945           ca llback = ( callback = = null &&  isString(c ollection) )
  3946              ? charAtCa llback
  3947              : lodash.c reateCallb ack(callba ck, thisAr g, 3);
  3948  
  3949           ba seEach(col lection, f unction(va lue, index , collecti on) {
  3950              var curren t = callba ck(value,  index, col lection);
  3951              if (curren t > comput ed) {
  3952                computed  = current ;
  3953                result =  value;
  3954              }
  3955           }) ;
  3956         }
  3957         retu rn result;
  3958       }
  3959  
  3960       /**
  3961        * Ret rieves the  minimum v alue of a  collection . If the c ollection  is empty o r
  3962        * fal sey `Infin ity` is re turned. If  a callbac k is provi ded it wil l be execu ted
  3963        * for  each valu e in the c ollection  to generat e the crit erion by w hich the v alue
  3964        * is  ranked. Th e callback  is bound  to `thisAr g` and inv oked with  three
  3965        * arg uments; (v alue, inde x, collect ion).
  3966        *
  3967        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  3968        * cal lback will  return th e property  value of  the given  element.
  3969        *
  3970        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  3971        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  3972        * els e `false`.
  3973        *
  3974        * @st atic
  3975        * @me mberOf _
  3976        * @ca tegory Col lections
  3977        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  3978        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  3979        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  3980        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  3981        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  3982        * @re turns {*}  Returns th e minimum  value.
  3983        * @ex ample
  3984        *
  3985        * _.m in([4, 2,  8, 6]);
  3986        * //  => 2
  3987        *
  3988        * var  character s = [
  3989        *   {  'name': ' barney', ' age': 36 } ,
  3990        *   {  'name': ' fred',   ' age': 40 }
  3991        * ];
  3992        *
  3993        * _.m in(charact ers, funct ion(chr) {  return ch r.age; });
  3994        * //  => { 'name ': 'barney ', 'age':  36 };
  3995        *
  3996        * //  using "_.p luck" call back short hand
  3997        * _.m in(charact ers, 'age' );
  3998        * //  => { 'name ': 'barney ', 'age':  36 };
  3999        */
  4000       functi on min(col lection, c allback, t hisArg) {
  4001         var  computed =  Infinity,
  4002              result = c omputed;
  4003  
  4004         // a llows work ing with f unctions l ike `_.map ` without  using
  4005         // t heir `inde x` argumen t as a cal lback
  4006         if ( typeof cal lback != ' function'  && thisArg  && thisAr g[callback ] === coll ection) {
  4007           ca llback = n ull;
  4008         }
  4009         if ( callback = = null &&  isArray(co llection))  {
  4010           va r index =  -1,
  4011                length =  collectio n.length;
  4012  
  4013           wh ile (++ind ex < lengt h) {
  4014              var value  = collecti on[index];
  4015              if (value  < result)  {
  4016                result =  value;
  4017              }
  4018           }
  4019         } el se {
  4020           ca llback = ( callback = = null &&  isString(c ollection) )
  4021              ? charAtCa llback
  4022              : lodash.c reateCallb ack(callba ck, thisAr g, 3);
  4023  
  4024           ba seEach(col lection, f unction(va lue, index , collecti on) {
  4025              var curren t = callba ck(value,  index, col lection);
  4026              if (curren t < comput ed) {
  4027                computed  = current ;
  4028                result =  value;
  4029              }
  4030           }) ;
  4031         }
  4032         retu rn result;
  4033       }
  4034  
  4035       /**
  4036        * Ret rieves the  value of  a specifie d property  from all  elements i n the coll ection.
  4037        *
  4038        * @st atic
  4039        * @me mberOf _
  4040        * @ty pe Functio n
  4041        * @ca tegory Col lections
  4042        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  4043        * @pa ram {strin g} propert y The name  of the pr operty to  pluck.
  4044        * @re turns {Arr ay} Return s a new ar ray of pro perty valu es.
  4045        * @ex ample
  4046        *
  4047        * var  character s = [
  4048        *   {  'name': ' barney', ' age': 36 } ,
  4049        *   {  'name': ' fred',   ' age': 40 }
  4050        * ];
  4051        *
  4052        * _.p luck(chara cters, 'na me');
  4053        * //  => ['barne y', 'fred' ]
  4054        */
  4055       var pl uck = map;
  4056  
  4057       /**
  4058        * Red uces a col lection to  a value w hich is th e accumula ted result  of runnin g
  4059        * eac h element  in the col lection th rough the  callback,  where each  successiv e
  4060        * cal lback exec ution cons umes the r eturn valu e of the p revious ex ecution. I f
  4061        * `ac cumulator`  is not pr ovided the  first ele ment of th e collecti on will be
  4062        * use d as the i nitial `ac cumulator`  value. Th e callback  is bound  to `thisAr g`
  4063        * and  invoked w ith four a rguments;  (accumulat or, value,  index|key , collecti on).
  4064        *
  4065        * @st atic
  4066        * @me mberOf _
  4067        * @al ias foldl,  inject
  4068        * @ca tegory Col lections
  4069        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  4070        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  4071        * @pa ram {*} [a ccumulator ] Initial  value of t he accumul ator.
  4072        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4073        * @re turns {*}  Returns th e accumula ted value.
  4074        * @ex ample
  4075        *
  4076        * var  sum = _.r educe([1,  2, 3], fun ction(sum,  num) {
  4077        *   r eturn sum  + num;
  4078        * });
  4079        * //  => 6
  4080        *
  4081        * var  mapped =  _.reduce({  'a': 1, ' b': 2, 'c' : 3 }, fun ction(resu lt, num, k ey) {
  4082        *   r esult[key]  = num * 3 ;
  4083        *   r eturn resu lt;
  4084        * },  {});
  4085        * //  => { 'a':  3, 'b': 6,  'c': 9 }
  4086        */
  4087       functi on reduce( collection , callback , accumula tor, thisA rg) {
  4088         var  noaccum =  arguments. length < 3 ;
  4089         call back = lod ash.create Callback(c allback, t hisArg, 4) ;
  4090  
  4091         if ( isArray(co llection))  {
  4092           va r index =  -1,
  4093                length =  collectio n.length;
  4094  
  4095           if  (noaccum)  {
  4096              accumulato r = collec tion[++ind ex];
  4097           }
  4098           wh ile (++ind ex < lengt h) {
  4099              accumulato r = callba ck(accumul ator, coll ection[ind ex], index , collecti on);
  4100           }
  4101         } el se {
  4102           ba seEach(col lection, f unction(va lue, index , collecti on) {
  4103              accumulato r = noaccu m
  4104                ? (noacc um = false , value)
  4105                : callba ck(accumul ator, valu e, index,  collection )
  4106           }) ;
  4107         }
  4108         retu rn accumul ator;
  4109       }
  4110  
  4111       /**
  4112        * Thi s method i s like `_. reduce` ex cept that  it iterate s over ele ments
  4113        * of  a `collect ion` from  right to l eft.
  4114        *
  4115        * @st atic
  4116        * @me mberOf _
  4117        * @al ias foldr
  4118        * @ca tegory Col lections
  4119        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  4120        * @pa ram {Funct ion} [call back=ident ity] The f unction ca lled per i teration.
  4121        * @pa ram {*} [a ccumulator ] Initial  value of t he accumul ator.
  4122        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4123        * @re turns {*}  Returns th e accumula ted value.
  4124        * @ex ample
  4125        *
  4126        * var  list = [[ 0, 1], [2,  3], [4, 5 ]];
  4127        * var  flat = _. reduceRigh t(list, fu nction(a,  b) { retur n a.concat (b); }, [] );
  4128        * //  => [4, 5,  2, 3, 0, 1 ]
  4129        */
  4130       functi on reduceR ight(colle ction, cal lback, acc umulator,  thisArg) {
  4131         var  noaccum =  arguments. length < 3 ;
  4132         call back = lod ash.create Callback(c allback, t hisArg, 4) ;
  4133         forE achRight(c ollection,  function( value, ind ex, collec tion) {
  4134           ac cumulator  = noaccum
  4135              ? (noaccum  = false,  value)
  4136              : callback (accumulat or, value,  index, co llection);
  4137         });
  4138         retu rn accumul ator;
  4139       }
  4140  
  4141       /**
  4142        * The  opposite  of `_.filt er` this m ethod retu rns the el ements of  a
  4143        * col lection th at the cal lback does  **not** r eturn true y for.
  4144        *
  4145        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4146        * cal lback will  return th e property  value of  the given  element.
  4147        *
  4148        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4149        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4150        * els e `false`.
  4151        *
  4152        * @st atic
  4153        * @me mberOf _
  4154        * @ca tegory Col lections
  4155        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  4156        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  4157        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  4158        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  4159        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4160        * @re turns {Arr ay} Return s a new ar ray of ele ments that  failed th e callback  check.
  4161        * @ex ample
  4162        *
  4163        * var  odds = _. reject([1,  2, 3, 4,  5, 6], fun ction(num)  { return  num % 2 ==  0; });
  4164        * //  => [1, 3,  5]
  4165        *
  4166        * var  character s = [
  4167        *   {  'name': ' barney', ' age': 36,  'blocked':  false },
  4168        *   {  'name': ' fred',   ' age': 40,  'blocked':  true }
  4169        * ];
  4170        *
  4171        * //  using "_.p luck" call back short hand
  4172        * _.r eject(char acters, 'b locked');
  4173        * //  => [{ 'nam e': 'barne y', 'age':  36, 'bloc ked': fals e }]
  4174        *
  4175        * //  using "_.w here" call back short hand
  4176        * _.r eject(char acters, {  'age': 36  });
  4177        * //  => [{ 'nam e': 'fred' , 'age': 4 0, 'blocke d': true } ]
  4178        */
  4179       functi on reject( collection , callback , thisArg)  {
  4180         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  4181         retu rn filter( collection , function (value, in dex, colle ction) {
  4182           re turn !call back(value , index, c ollection) ;
  4183         });
  4184       }
  4185  
  4186       /**
  4187        * Ret rieves a r andom elem ent or `n`  random el ements fro m a collec tion.
  4188        *
  4189        * @st atic
  4190        * @me mberOf _
  4191        * @ca tegory Col lections
  4192        * @pa ram {Array |Object|st ring} coll ection The  collectio n to sampl e.
  4193        * @pa ram {numbe r} [n] The  number of  elements  to sample.
  4194        * @pa ram- {Obje ct} [guard ] Allows w orking wit h function s like `_. map`
  4195        *  wi thout usin g their `i ndex` argu ments as ` n`.
  4196        * @re turns {Arr ay} Return s the rand om sample( s) of `col lection`.
  4197        * @ex ample
  4198        *
  4199        * _.s ample([1,  2, 3, 4]);
  4200        * //  => 2
  4201        *
  4202        * _.s ample([1,  2, 3, 4],  2);
  4203        * //  => [3, 1]
  4204        */
  4205       functi on sample( collection , n, guard ) {
  4206         if ( collection  && typeof  collectio n.length ! = 'number' ) {
  4207           co llection =  values(co llection);
  4208         } el se if (sup port.unind exedChars  && isStrin g(collecti on)) {
  4209           co llection =  collectio n.split('' );
  4210         }
  4211         if ( n == null  || guard)  {
  4212           re turn colle ction ? co llection[b aseRandom( 0, collect ion.length  - 1)] : u ndefined;
  4213         }
  4214         var  result = s huffle(col lection);
  4215         resu lt.length  = nativeMi n(nativeMa x(0, n), r esult.leng th);
  4216         retu rn result;
  4217       }
  4218  
  4219       /**
  4220        * Cre ates an ar ray of shu ffled valu es, using  a version  of the Fis her-Yates
  4221        * shu ffle. See  http://en. wikipedia. org/wiki/F isher-Yate s_shuffle.
  4222        *
  4223        * @st atic
  4224        * @me mberOf _
  4225        * @ca tegory Col lections
  4226        * @pa ram {Array |Object|st ring} coll ection The  collectio n to shuff le.
  4227        * @re turns {Arr ay} Return s a new sh uffled col lection.
  4228        * @ex ample
  4229        *
  4230        * _.s huffle([1,  2, 3, 4,  5, 6]);
  4231        * //  => [4, 1,  6, 3, 5, 2 ]
  4232        */
  4233       functi on shuffle (collectio n) {
  4234         var  index = -1 ,
  4235              length = c ollection  ? collecti on.length  : 0,
  4236              result = A rray(typeo f length = = 'number'  ? length  : 0);
  4237  
  4238         forE ach(collec tion, func tion(value ) {
  4239           va r rand = b aseRandom( 0, ++index );
  4240           re sult[index ] = result [rand];
  4241           re sult[rand]  = value;
  4242         });
  4243         retu rn result;
  4244       }
  4245  
  4246       /**
  4247        * Get s the size  of the `c ollection`  by return ing `colle ction.leng th` for ar rays
  4248        * and  array-lik e objects  or the num ber of own  enumerabl e properti es for obj ects.
  4249        *
  4250        * @st atic
  4251        * @me mberOf _
  4252        * @ca tegory Col lections
  4253        * @pa ram {Array |Object|st ring} coll ection The  collectio n to inspe ct.
  4254        * @re turns {num ber} Retur ns `collec tion.lengt h` or numb er of own  enumerable  propertie s.
  4255        * @ex ample
  4256        *
  4257        * _.s ize([1, 2] );
  4258        * //  => 2
  4259        *
  4260        * _.s ize({ 'one ': 1, 'two ': 2, 'thr ee': 3 });
  4261        * //  => 3
  4262        *
  4263        * _.s ize('pebbl es');
  4264        * //  => 7
  4265        */
  4266       functi on size(co llection)  {
  4267         var  length = c ollection  ? collecti on.length  : 0;
  4268         retu rn typeof  length ==  'number' ?  length :  keys(colle ction).len gth;
  4269       }
  4270  
  4271       /**
  4272        * Che cks if the  callback  returns a  truey valu e for **an y** elemen t of a
  4273        * col lection. T he functio n returns  as soon as  it finds  a passing  value and
  4274        * doe s not iter ate over t he entire  collection . The call back is bo und to
  4275        * `th isArg` and  invoked w ith three  arguments;  (value, i ndex|key,  collection ).
  4276        *
  4277        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4278        * cal lback will  return th e property  value of  the given  element.
  4279        *
  4280        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4281        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4282        * els e `false`.
  4283        *
  4284        * @st atic
  4285        * @me mberOf _
  4286        * @al ias any
  4287        * @ca tegory Col lections
  4288        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  4289        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  4290        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  4291        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  4292        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4293        * @re turns {boo lean} Retu rns `true`  if any el ement pass ed the cal lback chec k,
  4294        *  el se `false` .
  4295        * @ex ample
  4296        *
  4297        * _.s ome([null,  0, 'yes',  false], B oolean);
  4298        * //  => true
  4299        *
  4300        * var  character s = [
  4301        *   {  'name': ' barney', ' age': 36,  'blocked':  false },
  4302        *   {  'name': ' fred',   ' age': 40,  'blocked':  true }
  4303        * ];
  4304        *
  4305        * //  using "_.p luck" call back short hand
  4306        * _.s ome(charac ters, 'blo cked');
  4307        * //  => true
  4308        *
  4309        * //  using "_.w here" call back short hand
  4310        * _.s ome(charac ters, { 'a ge': 1 });
  4311        * //  => false
  4312        */
  4313       functi on some(co llection,  callback,  thisArg) {
  4314         var  result;
  4315         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  4316  
  4317         if ( isArray(co llection))  {
  4318           va r index =  -1,
  4319                length =  collectio n.length;
  4320  
  4321           wh ile (++ind ex < lengt h) {
  4322              if ((resul t = callba ck(collect ion[index] , index, c ollection) )) {
  4323                break;
  4324              }
  4325           }
  4326         } el se {
  4327           ba seEach(col lection, f unction(va lue, index , collecti on) {
  4328              return !(r esult = ca llback(val ue, index,  collectio n));
  4329           }) ;
  4330         }
  4331         retu rn !!resul t;
  4332       }
  4333  
  4334       /**
  4335        * Cre ates an ar ray of ele ments, sor ted in asc ending ord er by the  results of
  4336        * run ning each  element in  a collect ion throug h the call back. This  method
  4337        * per forms a st able sort,  that is,  it will pr eserve the  original  sort order
  4338        * of  equal elem ents. The  callback i s bound to  `thisArg`  and invok ed with
  4339        * thr ee argumen ts; (value , index|ke y, collect ion).
  4340        *
  4341        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4342        * cal lback will  return th e property  value of  the given  element.
  4343        *
  4344        * If  an array o f property  names is  provided f or `callba ck` the co llection
  4345        * wil l be sorte d by each  property v alue.
  4346        *
  4347        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4348        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4349        * els e `false`.
  4350        *
  4351        * @st atic
  4352        * @me mberOf _
  4353        * @ca tegory Col lections
  4354        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  4355        * @pa ram {Array |Function| Object|str ing} [call back=ident ity] The f unction ca lled
  4356        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  4357        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  4358        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4359        * @re turns {Arr ay} Return s a new ar ray of sor ted elemen ts.
  4360        * @ex ample
  4361        *
  4362        * _.s ortBy([1,  2, 3], fun ction(num)  { return  Math.sin(n um); });
  4363        * //  => [3, 1,  2]
  4364        *
  4365        * _.s ortBy([1,  2, 3], fun ction(num)  { return  this.sin(n um); }, Ma th);
  4366        * //  => [3, 1,  2]
  4367        *
  4368        * var  character s = [
  4369        *   {  'name': ' barney',   'age': 36  },
  4370        *   {  'name': ' fred',     'age': 40  },
  4371        *   {  'name': ' barney',   'age': 26  },
  4372        *   {  'name': ' fred',     'age': 30  }
  4373        * ];
  4374        *
  4375        * //  using "_.p luck" call back short hand
  4376        * _.m ap(_.sortB y(characte rs, 'age') , _.values );
  4377        * //  => [['barn ey', 26],  ['fred', 3 0], ['barn ey', 36],  ['fred', 4 0]]
  4378        *
  4379        * //  sorting by  multiple  properties
  4380        * _.m ap(_.sortB y(characte rs, ['name ', 'age']) , _.values );
  4381        * //  = > [['bar ney', 26],  ['barney' , 36], ['f red', 30],  ['fred',  40]]
  4382        */
  4383       functi on sortBy( collection , callback , thisArg)  {
  4384         var  index = -1 ,
  4385              isArr = is Array(call back),
  4386              length = c ollection  ? collecti on.length  : 0,
  4387              result = A rray(typeo f length = = 'number'  ? length  : 0);
  4388  
  4389         if ( !isArr) {
  4390           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  4391         }
  4392         forE ach(collec tion, func tion(value , key, col lection) {
  4393           va r object =  result[++ index] = g etObject() ;
  4394           if  (isArr) {
  4395              object.cri teria = ma p(callback , function (key) { re turn value [key]; });
  4396           }  else {
  4397              (object.cr iteria = g etArray()) [0] = call back(value , key, col lection);
  4398           }
  4399           ob ject.index  = index;
  4400           ob ject.value  = value;
  4401         });
  4402  
  4403         leng th = resul t.length;
  4404         resu lt.sort(co mpareAscen ding);
  4405         whil e (length- -) {
  4406           va r object =  result[le ngth];
  4407           re sult[lengt h] = objec t.value;
  4408           if  (!isArr)  {
  4409              releaseArr ay(object. criteria);
  4410           }
  4411           re leaseObjec t(object);
  4412         }
  4413         retu rn result;
  4414       }
  4415  
  4416       /**
  4417        * Con verts the  `collectio n` to an a rray.
  4418        *
  4419        * @st atic
  4420        * @me mberOf _
  4421        * @ca tegory Col lections
  4422        * @pa ram {Array |Object|st ring} coll ection The  collectio n to conve rt.
  4423        * @re turns {Arr ay} Return s the new  converted  array.
  4424        * @ex ample
  4425        *
  4426        * (fu nction() {  return _. toArray(ar guments).s lice(1); } )(1, 2, 3,  4);
  4427        * //  => [2, 3,  4]
  4428        */
  4429       functi on toArray (collectio n) {
  4430         if ( collection  && typeof  collectio n.length = = 'number' ) {
  4431           re turn (supp ort.uninde xedChars & & isString (collectio n))
  4432              ? collecti on.split(' ')
  4433              : slice(co llection);
  4434         }
  4435         retu rn values( collection );
  4436       }
  4437  
  4438       /**
  4439        * Per forms a de ep compari son of eac h element  in a `coll ection` to  the given
  4440        * `pr operties`  object, re turning an  array of  all elemen ts that ha ve equival ent
  4441        * pro perty valu es.
  4442        *
  4443        * @st atic
  4444        * @me mberOf _
  4445        * @ty pe Functio n
  4446        * @ca tegory Col lections
  4447        * @pa ram {Array |Object|st ring} coll ection The  collectio n to itera te over.
  4448        * @pa ram {Objec t} props T he object  of propert y values t o filter b y.
  4449        * @re turns {Arr ay} Return s a new ar ray of ele ments that  have the  given prop erties.
  4450        * @ex ample
  4451        *
  4452        * var  character s = [
  4453        *   {  'name': ' barney', ' age': 36,  'pets': [' hoppy'] },
  4454        *   {  'name': ' fred',   ' age': 40,  'pets': [' baby puss' , 'dino']  }
  4455        * ];
  4456        *
  4457        * _.w here(chara cters, { ' age': 36 } );
  4458        * //  => [{ 'nam e': 'barne y', 'age':  36, 'pets ': ['hoppy '] }]
  4459        *
  4460        * _.w here(chara cters, { ' pets': ['d ino'] });
  4461        * //  => [{ 'nam e': 'fred' , 'age': 4 0, 'pets':  ['baby pu ss', 'dino '] }]
  4462        */
  4463       var wh ere = filt er;
  4464  
  4465       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  4466  
  4467       /**
  4468        * Cre ates an ar ray with a ll falsey  values rem oved. The  values `fa lse`, `nul l`,
  4469        * `0` , `""`, `u ndefined`,  and `NaN`  are all f alsey.
  4470        *
  4471        * @st atic
  4472        * @me mberOf _
  4473        * @ca tegory Arr ays
  4474        * @pa ram {Array } array Th e array to  compact.
  4475        * @re turns {Arr ay} Return s a new ar ray of fil tered valu es.
  4476        * @ex ample
  4477        *
  4478        * _.c ompact([0,  1, false,  2, '', 3] );
  4479        * //  => [1, 2,  3]
  4480        */
  4481       functi on compact (array) {
  4482         var  index = -1 ,
  4483              length = a rray ? arr ay.length  : 0,
  4484              result = [ ];
  4485  
  4486         whil e (++index  < length)  {
  4487           va r value =  array[inde x];
  4488           if  (value) {
  4489              result.pus h(value);
  4490           }
  4491         }
  4492         retu rn result;
  4493       }
  4494  
  4495       /**
  4496        * Cre ates an ar ray exclud ing all va lues of th e provided  arrays us ing strict
  4497        * equ ality for  comparison s, i.e. `= ==`.
  4498        *
  4499        * @st atic
  4500        * @me mberOf _
  4501        * @ca tegory Arr ays
  4502        * @pa ram {Array } array Th e array to  process.
  4503        * @pa ram {...Ar ray} [valu es] The ar rays of va lues to ex clude.
  4504        * @re turns {Arr ay} Return s a new ar ray of fil tered valu es.
  4505        * @ex ample
  4506        *
  4507        * _.d ifference( [1, 2, 3,  4, 5], [5,  2, 10]);
  4508        * //  => [1, 3,  4]
  4509        */
  4510       functi on differe nce(array)  {
  4511         retu rn baseDif ference(ar ray, baseF latten(arg uments, tr ue, true,  1));
  4512       }
  4513  
  4514       /**
  4515        * Thi s method i s like `_. find` exce pt that it  returns t he index o f the firs t
  4516        * ele ment that  passes the  callback  check, ins tead of th e element  itself.
  4517        *
  4518        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4519        * cal lback will  return th e property  value of  the given  element.
  4520        *
  4521        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4522        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4523        * els e `false`.
  4524        *
  4525        * @st atic
  4526        * @me mberOf _
  4527        * @ca tegory Arr ays
  4528        * @pa ram {Array } array Th e array to  search.
  4529        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  4530        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  4531        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  4532        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4533        * @re turns {num ber} Retur ns the ind ex of the  found elem ent, else  `-1`.
  4534        * @ex ample
  4535        *
  4536        * var  character s = [
  4537        *   {  'name': ' barney',   'age': 36,  'blocked' : false },
  4538        *   {  'name': ' fred',     'age': 40,  'blocked' : true },
  4539        *   {  'name': ' pebbles',  'age': 1,   'blocked' : false }
  4540        * ];
  4541        *
  4542        * _.f indIndex(c haracters,  function( chr) {
  4543        *   r eturn chr. age < 20;
  4544        * });
  4545        * //  => 2
  4546        *
  4547        * //  using "_.w here" call back short hand
  4548        * _.f indIndex(c haracters,  { 'age':  36 });
  4549        * //  => 0
  4550        *
  4551        * //  using "_.p luck" call back short hand
  4552        * _.f indIndex(c haracters,  'blocked' );
  4553        * //  => 1
  4554        */
  4555       functi on findInd ex(array,  callback,  thisArg) {
  4556         var  index = -1 ,
  4557              length = a rray ? arr ay.length  : 0;
  4558  
  4559         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  4560         whil e (++index  < length)  {
  4561           if  (callback (array[ind ex], index , array))  {
  4562              return ind ex;
  4563           }
  4564         }
  4565         retu rn -1;
  4566       }
  4567  
  4568       /**
  4569        * Thi s method i s like `_. findIndex`  except th at it iter ates over  elements
  4570        * of  a `collect ion` from  right to l eft.
  4571        *
  4572        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4573        * cal lback will  return th e property  value of  the given  element.
  4574        *
  4575        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4576        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4577        * els e `false`.
  4578        *
  4579        * @st atic
  4580        * @me mberOf _
  4581        * @ca tegory Arr ays
  4582        * @pa ram {Array } array Th e array to  search.
  4583        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  4584        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  4585        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  4586        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4587        * @re turns {num ber} Retur ns the ind ex of the  found elem ent, else  `-1`.
  4588        * @ex ample
  4589        *
  4590        * var  character s = [
  4591        *   {  'name': ' barney',   'age': 36,  'blocked' : true },
  4592        *   {  'name': ' fred',     'age': 40,  'blocked' : false },
  4593        *   {  'name': ' pebbles',  'age': 1,   'blocked' : true }
  4594        * ];
  4595        *
  4596        * _.f indLastInd ex(charact ers, funct ion(chr) {
  4597        *   r eturn chr. age > 30;
  4598        * });
  4599        * //  => 1
  4600        *
  4601        * //  using "_.w here" call back short hand
  4602        * _.f indLastInd ex(charact ers, { 'ag e': 36 });
  4603        * //  => 0
  4604        *
  4605        * //  using "_.p luck" call back short hand
  4606        * _.f indLastInd ex(charact ers, 'bloc ked');
  4607        * //  => 2
  4608        */
  4609       functi on findLas tIndex(arr ay, callba ck, thisAr g) {
  4610         var  length = a rray ? arr ay.length  : 0;
  4611         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  4612         whil e (length- -) {
  4613           if  (callback (array[len gth], leng th, array) ) {
  4614              return len gth;
  4615           }
  4616         }
  4617         retu rn -1;
  4618       }
  4619  
  4620       /**
  4621        * Get s the firs t element  or first ` n` element s of an ar ray. If a  callback
  4622        * is  provided e lements at  the begin ning of th e array ar e returned  as long
  4623        * as  the callba ck returns  truey. Th e callback  is bound  to `thisAr g` and
  4624        * inv oked with  three argu ments; (va lue, index , array).
  4625        *
  4626        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4627        * cal lback will  return th e property  value of  the given  element.
  4628        *
  4629        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4630        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4631        * els e `false`.
  4632        *
  4633        * @st atic
  4634        * @me mberOf _
  4635        * @al ias head,  take
  4636        * @ca tegory Arr ays
  4637        * @pa ram {Array } array Th e array to  query.
  4638        * @pa ram {Funct ion|Object |number|st ring} [cal lback] The  function  called
  4639        *  pe r element  or the num ber of ele ments to r eturn. If  a property  name or
  4640        *  ob ject is pr ovided it  will be us ed to crea te a "_.pl uck" or "_ .where"
  4641        *  st yle callba ck, respec tively.
  4642        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4643        * @re turns {*}  Returns th e first el ement(s) o f `array`.
  4644        * @ex ample
  4645        *
  4646        * _.f irst([1, 2 , 3]);
  4647        * //  => 1
  4648        *
  4649        * _.f irst([1, 2 , 3], 2);
  4650        * //  => [1, 2]
  4651        *
  4652        * _.f irst([1, 2 , 3], func tion(num)  {
  4653        *   r eturn num  < 3;
  4654        * });
  4655        * //  => [1, 2]
  4656        *
  4657        * var  character s = [
  4658        *   {  'name': ' barney',   'blocked':  true,  'e mployer':  'slate' },
  4659        *   {  'name': ' fred',     'blocked':  false, 'e mployer':  'slate' },
  4660        *   {  'name': ' pebbles',  'blocked':  true,  'e mployer':  'na' }
  4661        * ];
  4662        *
  4663        * //  using "_.p luck" call back short hand
  4664        * _.f irst(chara cters, 'bl ocked');
  4665        * //  => [{ 'nam e': 'barne y', 'block ed': true,  'employer ': 'slate'  }]
  4666        *
  4667        * //  using "_.w here" call back short hand
  4668        * _.p luck(_.fir st(charact ers, { 'em ployer': ' slate' }),  'name');
  4669        * //  => ['barne y', 'fred' ]
  4670        */
  4671       functi on first(a rray, call back, this Arg) {
  4672         var  n = 0,
  4673              length = a rray ? arr ay.length  : 0;
  4674  
  4675         if ( typeof cal lback != ' number' &&  callback  != null) {
  4676           va r index =  -1;
  4677           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  4678           wh ile (++ind ex < lengt h && callb ack(array[ index], in dex, array )) {
  4679              n++;
  4680           }
  4681         } el se {
  4682           n  = callback ;
  4683           if  (n == nul l || thisA rg) {
  4684              return arr ay ? array [0] : unde fined;
  4685           }
  4686         }
  4687         retu rn slice(a rray, 0, n ativeMin(n ativeMax(0 , n), leng th));
  4688       }
  4689  
  4690       /**
  4691        * Fla ttens a ne sted array  (the nest ing can be  to any de pth). If ` isShallow`
  4692        * is  truey, the  array wil l only be  flattened  a single l evel. If a  callback
  4693        * is  provided e ach elemen t of the a rray is pa ssed throu gh the cal lback befo re
  4694        * fla ttening. T he callbac k is bound  to `thisA rg` and in voked with  three
  4695        * arg uments; (v alue, inde x, array).
  4696        *
  4697        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4698        * cal lback will  return th e property  value of  the given  element.
  4699        *
  4700        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4701        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4702        * els e `false`.
  4703        *
  4704        * @st atic
  4705        * @me mberOf _
  4706        * @ca tegory Arr ays
  4707        * @pa ram {Array } array Th e array to  flatten.
  4708        * @pa ram {boole an} [isSha llow=false ] A flag t o restrict  flattenin g to a sin gle level.
  4709        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  4710        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  4711        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  4712        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4713        * @re turns {Arr ay} Return s a new fl attened ar ray.
  4714        * @ex ample
  4715        *
  4716        * _.f latten([1,  [2], [3,  [[4]]]]);
  4717        * //  => [1, 2,  3, 4];
  4718        *
  4719        * _.f latten([1,  [2], [3,  [[4]]]], t rue);
  4720        * //  => [1, 2,  3, [[4]]];
  4721        *
  4722        * var  character s = [
  4723        *   {  'name': ' barney', ' age': 30,  'pets': [' hoppy'] },
  4724        *   {  'name': ' fred',   ' age': 40,  'pets': [' baby puss' , 'dino']  }
  4725        * ];
  4726        *
  4727        * //  using "_.p luck" call back short hand
  4728        * _.f latten(cha racters, ' pets');
  4729        * //  => ['hoppy ', 'baby p uss', 'din o']
  4730        */
  4731       functi on flatten (array, is Shallow, c allback, t hisArg) {
  4732         // j uggle argu ments
  4733         if ( typeof isS hallow !=  'boolean'  && isShall ow != null ) {
  4734           th isArg = ca llback;
  4735           ca llback = ( typeof isS hallow !=  'function'  && thisAr g && thisA rg[isShall ow] === ar ray) ? nul l : isShal low;
  4736           is Shallow =  false;
  4737         }
  4738         if ( callback ! = null) {
  4739           ar ray = map( array, cal lback, thi sArg);
  4740         }
  4741         retu rn baseFla tten(array , isShallo w);
  4742       }
  4743  
  4744       /**
  4745        * Get s the inde x at which  the first  occurrenc e of `valu e` is foun d using
  4746        * str ict equali ty for com parisons,  i.e. `===` . If the a rray is al ready sort ed
  4747        * pro viding `tr ue` for `f romIndex`  will run a  faster bi nary searc h.
  4748        *
  4749        * @st atic
  4750        * @me mberOf _
  4751        * @ca tegory Arr ays
  4752        * @pa ram {Array } array Th e array to  search.
  4753        * @pa ram {*} va lue The va lue to sea rch for.
  4754        * @pa ram {boole an|number}  [fromInde x=0] The i ndex to se arch from  or `true`
  4755        *  to  perform a  binary se arch on a  sorted arr ay.
  4756        * @re turns {num ber} Retur ns the ind ex of the  matched va lue or `-1 `.
  4757        * @ex ample
  4758        *
  4759        * _.i ndexOf([1,  2, 3, 1,  2, 3], 2);
  4760        * //  => 1
  4761        *
  4762        * _.i ndexOf([1,  2, 3, 1,  2, 3], 2,  3);
  4763        * //  => 4
  4764        *
  4765        * _.i ndexOf([1,  1, 2, 2,  3, 3], 2,  true);
  4766        * //  => 2
  4767        */
  4768       functi on indexOf (array, va lue, fromI ndex) {
  4769         if ( typeof fro mIndex ==  'number')  {
  4770           va r length =  array ? a rray.lengt h : 0;
  4771           fr omIndex =  (fromIndex  < 0 ? nat iveMax(0,  length + f romIndex)  : fromInde x || 0);
  4772         } el se if (fro mIndex) {
  4773           va r index =  sortedInde x(array, v alue);
  4774           re turn array [index] == = value ?  index : -1 ;
  4775         }
  4776         retu rn baseInd exOf(array , value, f romIndex);
  4777       }
  4778  
  4779       /**
  4780        * Get s all but  the last e lement or  last `n` e lements of  an array.  If a
  4781        * cal lback is p rovided el ements at  the end of  the array  are exclu ded from
  4782        * the  result as  long as t he callbac k returns  truey. The  callback  is bound
  4783        * to  `thisArg`  and invoke d with thr ee argumen ts; (value , index, a rray).
  4784        *
  4785        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4786        * cal lback will  return th e property  value of  the given  element.
  4787        *
  4788        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4789        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4790        * els e `false`.
  4791        *
  4792        * @st atic
  4793        * @me mberOf _
  4794        * @ca tegory Arr ays
  4795        * @pa ram {Array } array Th e array to  query.
  4796        * @pa ram {Funct ion|Object |number|st ring} [cal lback=1] T he functio n called
  4797        *  pe r element  or the num ber of ele ments to e xclude. If  a propert y name or
  4798        *  ob ject is pr ovided it  will be us ed to crea te a "_.pl uck" or "_ .where"
  4799        *  st yle callba ck, respec tively.
  4800        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4801        * @re turns {Arr ay} Return s a slice  of `array` .
  4802        * @ex ample
  4803        *
  4804        * _.i nitial([1,  2, 3]);
  4805        * //  => [1, 2]
  4806        *
  4807        * _.i nitial([1,  2, 3], 2) ;
  4808        * //  => [1]
  4809        *
  4810        * _.i nitial([1,  2, 3], fu nction(num ) {
  4811        *   r eturn num  > 1;
  4812        * });
  4813        * //  => [1]
  4814        *
  4815        * var  character s = [
  4816        *   {  'name': ' barney',   'blocked':  false, 'e mployer':  'slate' },
  4817        *   {  'name': ' fred',     'blocked':  true,  'e mployer':  'slate' },
  4818        *   {  'name': ' pebbles',  'blocked':  true,  'e mployer':  'na' }
  4819        * ];
  4820        *
  4821        * //  using "_.p luck" call back short hand
  4822        * _.i nitial(cha racters, ' blocked');
  4823        * //  => [{ 'nam e': 'barne y',  'bloc ked': fals e, 'employ er': 'slat e' }]
  4824        *
  4825        * //  using "_.w here" call back short hand
  4826        * _.p luck(_.ini tial(chara cters, { ' employer':  'na' }),  'name');
  4827        * //  => ['barne y', 'fred' ]
  4828        */
  4829       functi on initial (array, ca llback, th isArg) {
  4830         var  n = 0,
  4831              length = a rray ? arr ay.length  : 0;
  4832  
  4833         if ( typeof cal lback != ' number' &&  callback  != null) {
  4834           va r index =  length;
  4835           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  4836           wh ile (index -- && call back(array [index], i ndex, arra y)) {
  4837              n++;
  4838           }
  4839         } el se {
  4840           n  = (callbac k == null  || thisArg ) ? 1 : ca llback ||  n;
  4841         }
  4842         retu rn slice(a rray, 0, n ativeMin(n ativeMax(0 , length -  n), lengt h));
  4843       }
  4844  
  4845       /**
  4846        * Cre ates an ar ray of uni que values  present i n all prov ided array s using
  4847        * str ict equali ty for com parisons,  i.e. `===` .
  4848        *
  4849        * @st atic
  4850        * @me mberOf _
  4851        * @ca tegory Arr ays
  4852        * @pa ram {...Ar ray} [arra y] The arr ays to ins pect.
  4853        * @re turns {Arr ay} Return s an array  of shared  values.
  4854        * @ex ample
  4855        *
  4856        * _.i ntersectio n([1, 2, 3 ], [5, 2,  1, 4], [2,  1]);
  4857        * //  => [1, 2]
  4858        */
  4859       functi on interse ction() {
  4860         var  args = [],
  4861              argsIndex  = -1,
  4862              argsLength  = argumen ts.length,
  4863              caches = g etArray(),
  4864              indexOf =  getIndexOf (),
  4865              trustIndex Of = index Of === bas eIndexOf,
  4866              seen = get Array();
  4867  
  4868         whil e (++argsI ndex < arg sLength) {
  4869           va r value =  arguments[ argsIndex] ;
  4870           if  (isArray( value) ||  isArgument s(value))  {
  4871              args.push( value);
  4872              caches.pus h(trustInd exOf && va lue.length  >= largeA rraySize & &
  4873                createCa che(argsIn dex ? args [argsIndex ] : seen)) ;
  4874           }
  4875         }
  4876         var  array = ar gs[0],
  4877              index = -1 ,
  4878              length = a rray ? arr ay.length  : 0,
  4879              result = [ ];
  4880  
  4881         oute r:
  4882         whil e (++index  < length)  {
  4883           va r cache =  caches[0];
  4884           va lue = arra y[index];
  4885  
  4886           if  ((cache ?  cacheInde xOf(cache,  value) :  indexOf(se en, value) ) < 0) {
  4887              argsIndex  = argsLeng th;
  4888              (cache ||  seen).push (value);
  4889              while (--a rgsIndex)  {
  4890                cache =  caches[arg sIndex];
  4891                if ((cac he ? cache IndexOf(ca che, value ) : indexO f(args[arg sIndex], v alue)) < 0 ) {
  4892                  contin ue outer;
  4893                }
  4894              }
  4895              result.pus h(value);
  4896           }
  4897         }
  4898         whil e (argsLen gth--) {
  4899           ca che = cach es[argsLen gth];
  4900           if  (cache) {
  4901              releaseObj ect(cache) ;
  4902           }
  4903         }
  4904         rele aseArray(c aches);
  4905         rele aseArray(s een);
  4906         retu rn result;
  4907       }
  4908  
  4909       /**
  4910        * Get s the last  element o r last `n`  elements  of an arra y. If a ca llback is
  4911        * pro vided elem ents at th e end of t he array a re returne d as long  as the
  4912        * cal lback retu rns truey.  The callb ack is bou nd to `thi sArg` and  invoked
  4913        * wit h three ar guments; ( value, ind ex, array) .
  4914        *
  4915        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4916        * cal lback will  return th e property  value of  the given  element.
  4917        *
  4918        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4919        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4920        * els e `false`.
  4921        *
  4922        * @st atic
  4923        * @me mberOf _
  4924        * @ca tegory Arr ays
  4925        * @pa ram {Array } array Th e array to  query.
  4926        * @pa ram {Funct ion|Object |number|st ring} [cal lback] The  function  called
  4927        *  pe r element  or the num ber of ele ments to r eturn. If  a property  name or
  4928        *  ob ject is pr ovided it  will be us ed to crea te a "_.pl uck" or "_ .where"
  4929        *  st yle callba ck, respec tively.
  4930        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  4931        * @re turns {*}  Returns th e last ele ment(s) of  `array`.
  4932        * @ex ample
  4933        *
  4934        * _.l ast([1, 2,  3]);
  4935        * //  => 3
  4936        *
  4937        * _.l ast([1, 2,  3], 2);
  4938        * //  => [2, 3]
  4939        *
  4940        * _.l ast([1, 2,  3], funct ion(num) {
  4941        *   r eturn num  > 1;
  4942        * });
  4943        * //  => [2, 3]
  4944        *
  4945        * var  character s = [
  4946        *   {  'name': ' barney',   'blocked':  false, 'e mployer':  'slate' },
  4947        *   {  'name': ' fred',     'blocked':  true,  'e mployer':  'slate' },
  4948        *   {  'name': ' pebbles',  'blocked':  true,  'e mployer':  'na' }
  4949        * ];
  4950        *
  4951        * //  using "_.p luck" call back short hand
  4952        * _.p luck(_.las t(characte rs, 'block ed'), 'nam e');
  4953        * //  => ['fred' , 'pebbles ']
  4954        *
  4955        * //  using "_.w here" call back short hand
  4956        * _.l ast(charac ters, { 'e mployer':  'na' });
  4957        * //  => [{ 'nam e': 'pebbl es', 'bloc ked': true , 'employe r': 'na' } ]
  4958        */
  4959       functi on last(ar ray, callb ack, thisA rg) {
  4960         var  n = 0,
  4961              length = a rray ? arr ay.length  : 0;
  4962  
  4963         if ( typeof cal lback != ' number' &&  callback  != null) {
  4964           va r index =  length;
  4965           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  4966           wh ile (index -- && call back(array [index], i ndex, arra y)) {
  4967              n++;
  4968           }
  4969         } el se {
  4970           n  = callback ;
  4971           if  (n == nul l || thisA rg) {
  4972              return arr ay ? array [length -  1] : undef ined;
  4973           }
  4974         }
  4975         retu rn slice(a rray, nati veMax(0, l ength - n) );
  4976       }
  4977  
  4978       /**
  4979        * Get s the inde x at which  the last  occurrence  of `value ` is found  using str ict
  4980        * equ ality for  comparison s, i.e. `= ==`. If `f romIndex`  is negativ e, it is u sed
  4981        * as  the offset  from the  end of the  collectio n.
  4982        *
  4983        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  4984        * cal lback will  return th e property  value of  the given  element.
  4985        *
  4986        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  4987        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  4988        * els e `false`.
  4989        *
  4990        * @st atic
  4991        * @me mberOf _
  4992        * @ca tegory Arr ays
  4993        * @pa ram {Array } array Th e array to  search.
  4994        * @pa ram {*} va lue The va lue to sea rch for.
  4995        * @pa ram {numbe r} [fromIn dex=array. length-1]  The index  to search  from.
  4996        * @re turns {num ber} Retur ns the ind ex of the  matched va lue or `-1 `.
  4997        * @ex ample
  4998        *
  4999        * _.l astIndexOf ([1, 2, 3,  1, 2, 3],  2);
  5000        * //  => 4
  5001        *
  5002        * _.l astIndexOf ([1, 2, 3,  1, 2, 3],  2, 3);
  5003        * //  => 1
  5004        */
  5005       functi on lastInd exOf(array , value, f romIndex)  {
  5006         var  index = ar ray ? arra y.length :  0;
  5007         if ( typeof fro mIndex ==  'number')  {
  5008           in dex = (fro mIndex < 0  ? nativeM ax(0, inde x + fromIn dex) : nat iveMin(fro mIndex, in dex - 1))  + 1;
  5009         }
  5010         whil e (index-- ) {
  5011           if  (array[in dex] === v alue) {
  5012              return ind ex;
  5013           }
  5014         }
  5015         retu rn -1;
  5016       }
  5017  
  5018       /**
  5019        * Rem oves all p rovided va lues from  the given  array usin g strict e quality fo r
  5020        * com parisons,  i.e. `===` .
  5021        *
  5022        * @st atic
  5023        * @me mberOf _
  5024        * @ca tegory Arr ays
  5025        * @pa ram {Array } array Th e array to  modify.
  5026        * @pa ram {...*}  [value] T he values  to remove.
  5027        * @re turns {Arr ay} Return s `array`.
  5028        * @ex ample
  5029        *
  5030        * var  array = [ 1, 2, 3, 1 , 2, 3];
  5031        * _.p ull(array,  2, 3);
  5032        * con sole.log(a rray);
  5033        * //  => [1, 1]
  5034        */
  5035       functi on pull(ar ray) {
  5036         var  args = arg uments,
  5037              argsIndex  = 0,
  5038              argsLength  = args.le ngth,
  5039              length = a rray ? arr ay.length  : 0;
  5040  
  5041         whil e (++argsI ndex < arg sLength) {
  5042           va r index =  -1,
  5043                value =  args[argsI ndex];
  5044           wh ile (++ind ex < lengt h) {
  5045              if (array[ index] ===  value) {
  5046                splice.c all(array,  index--,  1);
  5047                length-- ;
  5048              }
  5049           }
  5050         }
  5051         retu rn array;
  5052       }
  5053  
  5054       /**
  5055        * Cre ates an ar ray of num bers (posi tive and/o r negative ) progress ing from
  5056        * `st art` up to  but not i ncluding ` end`. If ` start` is  less than  `stop` a
  5057        * zer o-length r ange is cr eated unle ss a negat ive `step`  is specif ied.
  5058        *
  5059        * @st atic
  5060        * @me mberOf _
  5061        * @ca tegory Arr ays
  5062        * @pa ram {numbe r} [start= 0] The sta rt of the  range.
  5063        * @pa ram {numbe r} end The  end of th e range.
  5064        * @pa ram {numbe r} [step=1 ] The valu e to incre ment or de crement by .
  5065        * @re turns {Arr ay} Return s a new ra nge array.
  5066        * @ex ample
  5067        *
  5068        * _.r ange(4);
  5069        * //  => [0, 1,  2, 3]
  5070        *
  5071        * _.r ange(1, 5) ;
  5072        * //  => [1, 2,  3, 4]
  5073        *
  5074        * _.r ange(0, 20 , 5);
  5075        * //  => [0, 5,  10, 15]
  5076        *
  5077        * _.r ange(0, -4 , -1);
  5078        * //  => [0, -1,  -2, -3]
  5079        *
  5080        * _.r ange(1, 4,  0);
  5081        * //  => [1, 1,  1]
  5082        *
  5083        * _.r ange(0);
  5084        * //  => []
  5085        */
  5086       functi on range(s tart, end,  step) {
  5087         star t = +start  || 0;
  5088         step  = typeof  step == 'n umber' ? s tep : (+st ep || 1);
  5089  
  5090         if ( end == nul l) {
  5091           en d = start;
  5092           st art = 0;
  5093         }
  5094         // u se `Array( length)` s o engines  like Chakr a and V8 a void slowe r modes
  5095         // h ttp://yout u.be/XAqIp GU8ZZk#t=1 7m25s
  5096         var  index = -1 ,
  5097              length = n ativeMax(0 , ceil((en d - start)  / (step | | 1))),
  5098              result = A rray(lengt h);
  5099  
  5100         whil e (++index  < length)  {
  5101           re sult[index ] = start;
  5102           st art += ste p;
  5103         }
  5104         retu rn result;
  5105       }
  5106  
  5107       /**
  5108        * Rem oves all e lements fr om an arra y that the  callback  returns tr uey for
  5109        * and  returns a n array of  removed e lements. T he callbac k is bound  to `thisA rg`
  5110        * and  invoked w ith three  arguments;  (value, i ndex, arra y).
  5111        *
  5112        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  5113        * cal lback will  return th e property  value of  the given  element.
  5114        *
  5115        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  5116        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  5117        * els e `false`.
  5118        *
  5119        * @st atic
  5120        * @me mberOf _
  5121        * @ca tegory Arr ays
  5122        * @pa ram {Array } array Th e array to  modify.
  5123        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  5124        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  5125        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  5126        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  5127        * @re turns {Arr ay} Return s a new ar ray of rem oved eleme nts.
  5128        * @ex ample
  5129        *
  5130        * var  array = [ 1, 2, 3, 4 , 5, 6];
  5131        * var  evens = _ .remove(ar ray, funct ion(num) {  return nu m % 2 == 0 ; });
  5132        *
  5133        * con sole.log(a rray);
  5134        * //  => [1, 3,  5]
  5135        *
  5136        * con sole.log(e vens);
  5137        * //  => [2, 4,  6]
  5138        */
  5139       functi on remove( array, cal lback, thi sArg) {
  5140         var  index = -1 ,
  5141              length = a rray ? arr ay.length  : 0,
  5142              result = [ ];
  5143  
  5144         call back = lod ash.create Callback(c allback, t hisArg, 3) ;
  5145         whil e (++index  < length)  {
  5146           va r value =  array[inde x];
  5147           if  (callback (value, in dex, array )) {
  5148              result.pus h(value);
  5149              splice.cal l(array, i ndex--, 1) ;
  5150              length--;
  5151           }
  5152         }
  5153         retu rn result;
  5154       }
  5155  
  5156       /**
  5157        * The  opposite  of `_.init ial` this  method get s all but  the first  element or
  5158        * fir st `n` ele ments of a n array. I f a callba ck functio n is provi ded elemen ts
  5159        * at  the beginn ing of the  array are  excluded  from the r esult as l ong as the
  5160        * cal lback retu rns truey.  The callb ack is bou nd to `thi sArg` and  invoked
  5161        * wit h three ar guments; ( value, ind ex, array) .
  5162        *
  5163        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  5164        * cal lback will  return th e property  value of  the given  element.
  5165        *
  5166        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  5167        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  5168        * els e `false`.
  5169        *
  5170        * @st atic
  5171        * @me mberOf _
  5172        * @al ias drop,  tail
  5173        * @ca tegory Arr ays
  5174        * @pa ram {Array } array Th e array to  query.
  5175        * @pa ram {Funct ion|Object |number|st ring} [cal lback=1] T he functio n called
  5176        *  pe r element  or the num ber of ele ments to e xclude. If  a propert y name or
  5177        *  ob ject is pr ovided it  will be us ed to crea te a "_.pl uck" or "_ .where"
  5178        *  st yle callba ck, respec tively.
  5179        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  5180        * @re turns {Arr ay} Return s a slice  of `array` .
  5181        * @ex ample
  5182        *
  5183        * _.r est([1, 2,  3]);
  5184        * //  => [2, 3]
  5185        *
  5186        * _.r est([1, 2,  3], 2);
  5187        * //  => [3]
  5188        *
  5189        * _.r est([1, 2,  3], funct ion(num) {
  5190        *   r eturn num  < 3;
  5191        * });
  5192        * //  => [3]
  5193        *
  5194        * var  character s = [
  5195        *   {  'name': ' barney',   'blocked':  true,  'e mployer':  'slate' },
  5196        *   {  'name': ' fred',     'blocked':  false,  ' employer':  'slate' } ,
  5197        *   {  'name': ' pebbles',  'blocked':  true, 'em ployer': ' na' }
  5198        * ];
  5199        *
  5200        * //  using "_.p luck" call back short hand
  5201        * _.p luck(_.res t(characte rs, 'block ed'), 'nam e');
  5202        * //  => ['fred' , 'pebbles ']
  5203        *
  5204        * //  using "_.w here" call back short hand
  5205        * _.r est(charac ters, { 'e mployer':  'slate' }) ;
  5206        * //  => [{ 'nam e': 'pebbl es', 'bloc ked': true , 'employe r': 'na' } ]
  5207        */
  5208       functi on rest(ar ray, callb ack, thisA rg) {
  5209         if ( typeof cal lback != ' number' &&  callback  != null) {
  5210           va r n = 0,
  5211                index =  -1,
  5212                length =  array ? a rray.lengt h : 0;
  5213  
  5214           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  5215           wh ile (++ind ex < lengt h && callb ack(array[ index], in dex, array )) {
  5216              n++;
  5217           }
  5218         } el se {
  5219           n  = (callbac k == null  || thisArg ) ? 1 : na tiveMax(0,  callback) ;
  5220         }
  5221         retu rn slice(a rray, n);
  5222       }
  5223  
  5224       /**
  5225        * Use s a binary  search to  determine  the small est index  at which a  value
  5226        * sho uld be ins erted into  a given s orted arra y in order  to mainta in the sor t
  5227        * ord er of the  array. If  a callback  is provid ed it will  be execut ed for
  5228        * `va lue` and e ach elemen t of `arra y` to comp ute their  sort ranki ng. The
  5229        * cal lback is b ound to `t hisArg` an d invoked  with one a rgument; ( value).
  5230        *
  5231        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  5232        * cal lback will  return th e property  value of  the given  element.
  5233        *
  5234        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  5235        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  5236        * els e `false`.
  5237        *
  5238        * @st atic
  5239        * @me mberOf _
  5240        * @ca tegory Arr ays
  5241        * @pa ram {Array } array Th e array to  inspect.
  5242        * @pa ram {*} va lue The va lue to eva luate.
  5243        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  5244        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  5245        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  5246        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  5247        * @re turns {num ber} Retur ns the ind ex at whic h `value`  should be  inserted
  5248        *  in to `array` .
  5249        * @ex ample
  5250        *
  5251        * _.s ortedIndex ([20, 30,  50], 40);
  5252        * //  => 2
  5253        *
  5254        * //  using "_.p luck" call back short hand
  5255        * _.s ortedIndex ([{ 'x': 2 0 }, { 'x' : 30 }, {  'x': 50 }] , { 'x': 4 0 }, 'x');
  5256        * //  => 2
  5257        *
  5258        * var  dict = {
  5259        *   ' wordToNumb er': { 'tw enty': 20,  'thirty':  30, 'four ty': 40, ' fifty': 50  }
  5260        * };
  5261        *
  5262        * _.s ortedIndex (['twenty' , 'thirty' , 'fifty'] , 'fourty' , function (word) {
  5263        *   r eturn dict .wordToNum ber[word];
  5264        * });
  5265        * //  => 2
  5266        *
  5267        * _.s ortedIndex (['twenty' , 'thirty' , 'fifty'] , 'fourty' , function (word) {
  5268        *   r eturn this .wordToNum ber[word];
  5269        * },  dict);
  5270        * //  => 2
  5271        */
  5272       functi on sortedI ndex(array , value, c allback, t hisArg) {
  5273         var  low = 0,
  5274              high = arr ay ? array .length :  low;
  5275  
  5276         // e xplicitly  reference  `identity`  for bette r inlining  in Firefo x
  5277         call back = cal lback ? lo dash.creat eCallback( callback,  thisArg, 1 ) : identi ty;
  5278         valu e = callba ck(value);
  5279  
  5280         whil e (low < h igh) {
  5281           va r mid = (l ow + high)  >>> 1;
  5282           (c allback(ar ray[mid])  < value)
  5283              ? low = mi d + 1
  5284              : high = m id;
  5285         }
  5286         retu rn low;
  5287       }
  5288  
  5289       /**
  5290        * Cre ates an ar ray of uni que values , in order , of the p rovided ar rays using
  5291        * str ict equali ty for com parisons,  i.e. `===` .
  5292        *
  5293        * @st atic
  5294        * @me mberOf _
  5295        * @ca tegory Arr ays
  5296        * @pa ram {...Ar ray} [arra y] The arr ays to ins pect.
  5297        * @re turns {Arr ay} Return s an array  of combin ed values.
  5298        * @ex ample
  5299        *
  5300        * _.u nion([1, 2 , 3], [5,  2, 1, 4],  [2, 1]);
  5301        * //  => [1, 2,  3, 5, 4]
  5302        */
  5303       functi on union()  {
  5304         retu rn baseUni q(baseFlat ten(argume nts, true,  true));
  5305       }
  5306  
  5307       /**
  5308        * Cre ates a dup licate-val ue-free ve rsion of a n array us ing strict  equality
  5309        * for  compariso ns, i.e. ` ===`. If t he array i s sorted,  providing
  5310        * `tr ue` for `i sSorted` w ill use a  faster alg orithm. If  a callbac k is provi ded
  5311        * eac h element  of `array`  is passed  through t he callbac k before u niqueness
  5312        * is  computed.  The callba ck is boun d to `this Arg` and i nvoked wit h three
  5313        * arg uments; (v alue, inde x, array).
  5314        *
  5315        * If  a property  name is p rovided fo r `callbac k` the cre ated "_.pl uck" style
  5316        * cal lback will  return th e property  value of  the given  element.
  5317        *
  5318        * If  an object  is provide d for `cal lback` the  created " _.where" s tyle callb ack
  5319        * wil l return ` true` for  elements t hat have t he propert ies of the  given obj ect,
  5320        * els e `false`.
  5321        *
  5322        * @st atic
  5323        * @me mberOf _
  5324        * @al ias unique
  5325        * @ca tegory Arr ays
  5326        * @pa ram {Array } array Th e array to  process.
  5327        * @pa ram {boole an} [isSor ted=false]  A flag to  indicate  that `arra y` is sort ed.
  5328        * @pa ram {Funct ion|Object |string} [ callback=i dentity] T he functio n called
  5329        *  pe r iteratio n. If a pr operty nam e or objec t is provi ded it wil l be used
  5330        *  to  create a  "_.pluck"  or "_.wher e" style c allback, r espectivel y.
  5331        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  5332        * @re turns {Arr ay} Return s a duplic ate-value- free array .
  5333        * @ex ample
  5334        *
  5335        * _.u niq([1, 2,  1, 3, 1]) ;
  5336        * //  => [1, 2,  3]
  5337        *
  5338        * _.u niq([1, 1,  2, 2, 3],  true);
  5339        * //  => [1, 2,  3]
  5340        *
  5341        * _.u niq(['A',  'b', 'C',  'a', 'B',  'c'], func tion(lette r) { retur n letter.t oLowerCase (); });
  5342        * //  => ['A', ' b', 'C']
  5343        *
  5344        * _.u niq([1, 2. 5, 3, 1.5,  2, 3.5],  function(n um) { retu rn this.fl oor(num);  }, Math);
  5345        * //  => [1, 2.5 , 3]
  5346        *
  5347        * //  using "_.p luck" call back short hand
  5348        * _.u niq([{ 'x' : 1 }, { ' x': 2 }, {  'x': 1 }] , 'x');
  5349        * //  => [{ 'x':  1 }, { 'x ': 2 }]
  5350        */
  5351       functi on uniq(ar ray, isSor ted, callb ack, thisA rg) {
  5352         // j uggle argu ments
  5353         if ( typeof isS orted != ' boolean' & & isSorted  != null)  {
  5354           th isArg = ca llback;
  5355           ca llback = ( typeof isS orted != ' function'  && thisArg  && thisAr g[isSorted ] === arra y) ? null  : isSorted ;
  5356           is Sorted = f alse;
  5357         }
  5358         if ( callback ! = null) {
  5359           ca llback = l odash.crea teCallback (callback,  thisArg,  3);
  5360         }
  5361         retu rn baseUni q(array, i sSorted, c allback);
  5362       }
  5363  
  5364       /**
  5365        * Cre ates an ar ray exclud ing all pr ovided val ues using  strict equ ality for
  5366        * com parisons,  i.e. `===` .
  5367        *
  5368        * @st atic
  5369        * @me mberOf _
  5370        * @ca tegory Arr ays
  5371        * @pa ram {Array } array Th e array to  filter.
  5372        * @pa ram {...*}  [value] T he values  to exclude .
  5373        * @re turns {Arr ay} Return s a new ar ray of fil tered valu es.
  5374        * @ex ample
  5375        *
  5376        * _.w ithout([1,  2, 1, 0,  3, 1, 4],  0, 1);
  5377        * //  => [2, 3,  4]
  5378        */
  5379       functi on without (array) {
  5380         retu rn baseDif ference(ar ray, slice (arguments , 1));
  5381       }
  5382  
  5383       /**
  5384        * Cre ates an ar ray that i s the symm etric diff erence of  the provid ed arrays.
  5385        * See  http://en .wikipedia .org/wiki/ Symmetric_ difference .
  5386        *
  5387        * @st atic
  5388        * @me mberOf _
  5389        * @ca tegory Arr ays
  5390        * @pa ram {...Ar ray} [arra y] The arr ays to ins pect.
  5391        * @re turns {Arr ay} Return s an array  of values .
  5392        * @ex ample
  5393        *
  5394        * _.x or([1, 2,  3], [5, 2,  1, 4]);
  5395        * //  => [3, 5,  4]
  5396        *
  5397        * _.x or([1, 2,  5], [2, 3,  5], [3, 4 , 5]);
  5398        * //  => [1, 4,  5]
  5399        */
  5400       functi on xor() {
  5401         var  index = -1 ,
  5402              length = a rguments.l ength;
  5403  
  5404         whil e (++index  < length)  {
  5405           va r array =  arguments[ index];
  5406           if  (isArray( array) ||  isArgument s(array))  {
  5407              var result  = result
  5408                ? baseUn iq(baseDif ference(re sult, arra y).concat( baseDiffer ence(array , result)) )
  5409                : array;
  5410           }
  5411         }
  5412         retu rn result  || [];
  5413       }
  5414  
  5415       /**
  5416        * Cre ates an ar ray of gro uped eleme nts, the f irst of wh ich contai ns the fir st
  5417        * ele ments of t he given a rrays, the  second of  which con tains the  second
  5418        * ele ments of t he given a rrays, and  so on.
  5419        *
  5420        * @st atic
  5421        * @me mberOf _
  5422        * @al ias unzip
  5423        * @ca tegory Arr ays
  5424        * @pa ram {...Ar ray} [arra y] Arrays  to process .
  5425        * @re turns {Arr ay} Return s a new ar ray of gro uped eleme nts.
  5426        * @ex ample
  5427        *
  5428        * _.z ip(['fred' , 'barney' ], [30, 40 ], [true,  false]);
  5429        * //  => [['fred ', 30, tru e], ['barn ey', 40, f alse]]
  5430        */
  5431       functi on zip() {
  5432         var  array = ar guments.le ngth > 1 ?  arguments  : argumen ts[0],
  5433              index = -1 ,
  5434              length = a rray ? max (pluck(arr ay, 'lengt h')) : 0,
  5435              result = A rray(lengt h < 0 ? 0  : length);
  5436  
  5437         whil e (++index  < length)  {
  5438           re sult[index ] = pluck( array, ind ex);
  5439         }
  5440         retu rn result;
  5441       }
  5442  
  5443       /**
  5444        * Cre ates an ob ject compo sed from a rrays of ` keys` and  `values`.  Provide
  5445        * eit her a sing le two dim ensional a rray, i.e.  `[[key1,  value1], [ key2, valu e2]]`
  5446        * or  two arrays , one of ` keys` and  one of cor responding  `values`.
  5447        *
  5448        * @st atic
  5449        * @me mberOf _
  5450        * @al ias object
  5451        * @ca tegory Arr ays
  5452        * @pa ram {Array } keys The  array of  keys.
  5453        * @pa ram {Array } [values= []] The ar ray of val ues.
  5454        * @re turns {Obj ect} Retur ns an obje ct compose d of the g iven keys  and
  5455        *  co rrespondin g values.
  5456        * @ex ample
  5457        *
  5458        * _.z ipObject([ 'fred', 'b arney'], [ 30, 40]);
  5459        * //  => { 'fred ': 30, 'ba rney': 40  }
  5460        */
  5461       functi on zipObje ct(keys, v alues) {
  5462         var  index = -1 ,
  5463              length = k eys ? keys .length :  0,
  5464              result = { };
  5465  
  5466         if ( !values &&  length &&  !isArray( keys[0]))  {
  5467           va lues = [];
  5468         }
  5469         whil e (++index  < length)  {
  5470           va r key = ke ys[index];
  5471           if  (values)  {
  5472              result[key ] = values [index];
  5473           }  else if (k ey) {
  5474              result[key [0]] = key [1];
  5475           }
  5476         }
  5477         retu rn result;
  5478       }
  5479  
  5480       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  5481  
  5482       /**
  5483        * Cre ates a fun ction that  executes  `func`, wi th  the `t his` bindi ng and
  5484        * arg uments of  the create d function , only aft er being c alled `n`  times.
  5485        *
  5486        * @st atic
  5487        * @me mberOf _
  5488        * @ca tegory Fun ctions
  5489        * @pa ram {numbe r} n The n umber of t imes the f unction mu st be call ed before
  5490        *  `f unc` is ex ecuted.
  5491        * @pa ram {Funct ion} func  The functi on to rest rict.
  5492        * @re turns {Fun ction} Ret urns the n ew restric ted functi on.
  5493        * @ex ample
  5494        *
  5495        * var  saves = [ 'profile',  'settings '];
  5496        *
  5497        * var  done = _. after(save s.length,  function()  {
  5498        *   c onsole.log ('Done sav ing!');
  5499        * });
  5500        *
  5501        * _.f orEach(sav es, functi on(type) {
  5502        *   a syncSave({  'type': t ype, 'comp lete': don e });
  5503        * });
  5504        * //  => logs 'D one saving !', after  all saves  have compl eted
  5505        */
  5506       functi on after(n , func) {
  5507         if ( !isFunctio n(func)) {
  5508           th row new Ty peError;
  5509         }
  5510         retu rn functio n() {
  5511           if  (--n < 1)  {
  5512              return fun c.apply(th is, argume nts);
  5513           }
  5514         };
  5515       }
  5516  
  5517       /**
  5518        * Cre ates a fun ction that , when cal led, invok es `func`  with the ` this`
  5519        * bin ding of `t hisArg` an d prepends  any addit ional `bin d` argumen ts to thos e
  5520        * pro vided to t he bound f unction.
  5521        *
  5522        * @st atic
  5523        * @me mberOf _
  5524        * @ca tegory Fun ctions
  5525        * @pa ram {Funct ion} func  The functi on to bind .
  5526        * @pa ram {*} [t hisArg] Th e `this` b inding of  `func`.
  5527        * @pa ram {...*}  [arg] Arg uments to  be partial ly applied .
  5528        * @re turns {Fun ction} Ret urns the n ew bound f unction.
  5529        * @ex ample
  5530        *
  5531        * var  func = fu nction(gre eting) {
  5532        *   r eturn gree ting + ' '  + this.na me;
  5533        * };
  5534        *
  5535        * fun c = _.bind (func, { ' name': 'fr ed' }, 'hi ');
  5536        * fun c();
  5537        * //  => 'hi fre d'
  5538        */
  5539       functi on bind(fu nc, thisAr g) {
  5540         retu rn argumen ts.length  > 2
  5541           ?  createWrap per(func,  17, slice( arguments,  2), null,  thisArg)
  5542           :  createWrap per(func,  1, null, n ull, thisA rg);
  5543       }
  5544  
  5545       /**
  5546        * Bin ds methods  of an obj ect to the  object it self, over writing th e existing
  5547        * met hod. Metho d names ma y be speci fied as in dividual a rguments o r as array s
  5548        * of  method nam es. If no  method nam es are pro vided all  the functi on propert ies
  5549        * of  `object` w ill be bou nd.
  5550        *
  5551        * @st atic
  5552        * @me mberOf _
  5553        * @ca tegory Fun ctions
  5554        * @pa ram {Objec t} object  The object  to bind a nd assign  the bound  methods to .
  5555        * @pa ram {...st ring} [met hodName] T he object  method nam es to
  5556        *  bi nd, specif ied as ind ividual me thod names  or arrays  of method  names.
  5557        * @re turns {Obj ect} Retur ns `object `.
  5558        * @ex ample
  5559        *
  5560        * var  view = {
  5561        *   ' label': 'd ocs',
  5562        *   ' onClick':  function()  { console .log('clic ked ' + th is.label);  }
  5563        * };
  5564        *
  5565        * _.b indAll(vie w);
  5566        * jQu ery('#docs ').on('cli ck', view. onClick);
  5567        * //  => logs 'c licked doc s', when t he button  is clicked
  5568        */
  5569       functi on bindAll (object) {
  5570         var  funcs = ar guments.le ngth > 1 ?  baseFlatt en(argumen ts, true,  false, 1)  : function s(object),
  5571              index = -1 ,
  5572              length = f uncs.lengt h;
  5573  
  5574         whil e (++index  < length)  {
  5575           va r key = fu ncs[index] ;
  5576           ob ject[key]  = createWr apper(obje ct[key], 1 , null, nu ll, object );
  5577         }
  5578         retu rn object;
  5579       }
  5580  
  5581       /**
  5582        * Cre ates a fun ction that , when cal led, invok es the met hod at `ob ject[key]`
  5583        * and  prepends  any additi onal `bind Key` argum ents to th ose provid ed to the  bound
  5584        * fun ction. Thi s method d iffers fro m `_.bind`  by allowi ng bound f unctions t o
  5585        * ref erence met hods that  will be re defined or  don't yet  exist.
  5586        * See  http://mi chaux.ca/a rticles/la zy-functio n-definiti on-pattern .
  5587        *
  5588        * @st atic
  5589        * @me mberOf _
  5590        * @ca tegory Fun ctions
  5591        * @pa ram {Objec t} object  The object  the metho d belongs  to.
  5592        * @pa ram {strin g} key The  key of th e method.
  5593        * @pa ram {...*}  [arg] Arg uments to  be partial ly applied .
  5594        * @re turns {Fun ction} Ret urns the n ew bound f unction.
  5595        * @ex ample
  5596        *
  5597        * var  object =  {
  5598        *   ' name': 'fr ed',
  5599        *   ' greet': fu nction(gre eting) {
  5600        *      return gr eeting + '  ' + this. name;
  5601        *   }
  5602        * };
  5603        *
  5604        * var  func = _. bindKey(ob ject, 'gre et', 'hi') ;
  5605        * fun c();
  5606        * //  => 'hi fre d'
  5607        *
  5608        * obj ect.greet  = function (greeting)  {
  5609        *   r eturn gree ting + 'ya  ' + this. name + '!' ;
  5610        * };
  5611        *
  5612        * fun c();
  5613        * //  => 'hiya f red!'
  5614        */
  5615       functi on bindKey (object, k ey) {
  5616         retu rn argumen ts.length  > 2
  5617           ?  createWrap per(key, 1 9, slice(a rguments,  2), null,  object)
  5618           :  createWrap per(key, 3 , null, nu ll, object );
  5619       }
  5620  
  5621       /**
  5622        * Cre ates a fun ction that  is the co mposition  of the pro vided func tions,
  5623        * whe re each fu nction con sumes the  return val ue of the  function t hat follow s.
  5624        * For  example,  composing  the functi ons `f()`,  `g()`, an d `h()` pr oduces `f( g(h()))`.
  5625        * Eac h function  is execut ed with th e `this` b inding of  the compos ed functio n.
  5626        *
  5627        * @st atic
  5628        * @me mberOf _
  5629        * @ca tegory Fun ctions
  5630        * @pa ram {...Fu nction} [f unc] Funct ions to co mpose.
  5631        * @re turns {Fun ction} Ret urns the n ew compose d function .
  5632        * @ex ample
  5633        *
  5634        * var  realNameM ap = {
  5635        *   ' pebbles':  'penelope'
  5636        * };
  5637        *
  5638        * var  format =  function(n ame) {
  5639        *   n ame = real NameMap[na me.toLower Case()] ||  name;
  5640        *   r eturn name .charAt(0) .toUpperCa se() + nam e.slice(1) .toLowerCa se();
  5641        * };
  5642        *
  5643        * var  greet = f unction(fo rmatted) {
  5644        *   r eturn 'Hiy a ' + form atted + '! ';
  5645        * };
  5646        *
  5647        * var  welcome =  _.compose (greet, fo rmat);
  5648        * wel come('pebb les');
  5649        * //  => 'Hiya P enelope!'
  5650        */
  5651       functi on compose () {
  5652         var  funcs = ar guments,
  5653              length = f uncs.lengt h;
  5654  
  5655         whil e (length- -) {
  5656           if  (!isFunct ion(funcs[ length]))  {
  5657              throw new  TypeError;
  5658           }
  5659         }
  5660         retu rn functio n() {
  5661           va r args = a rguments,
  5662                length =  funcs.len gth;
  5663  
  5664           wh ile (lengt h--) {
  5665              args = [fu ncs[length ].apply(th is, args)] ;
  5666           }
  5667           re turn args[ 0];
  5668         };
  5669       }
  5670  
  5671       /**
  5672        * Cre ates a fun ction whic h accepts  one or mor e argument s of `func ` that whe n
  5673        * inv oked eithe r executes  `func` re turning it s result,  if all `fu nc` argume nts
  5674        * hav e been pro vided, or  returns a  function t hat accept s one or m ore of the
  5675        * rem aining `fu nc` argume nts, and s o on. The  arity of ` func` can  be specifi ed
  5676        * if  `func.leng th` is not  sufficien t.
  5677        *
  5678        * @st atic
  5679        * @me mberOf _
  5680        * @ca tegory Fun ctions
  5681        * @pa ram {Funct ion} func  The functi on to curr y.
  5682        * @pa ram {numbe r} [arity= func.lengt h] The ari ty of `fun c`.
  5683        * @re turns {Fun ction} Ret urns the n ew curried  function.
  5684        * @ex ample
  5685        *
  5686        * var  curried =  _.curry(f unction(a,  b, c) {
  5687        *   c onsole.log (a + b + c );
  5688        * });
  5689        *
  5690        * cur ried(1)(2) (3);
  5691        * //  => 6
  5692        *
  5693        * cur ried(1, 2) (3);
  5694        * //  => 6
  5695        *
  5696        * cur ried(1, 2,  3);
  5697        * //  => 6
  5698        */
  5699       functi on curry(f unc, arity ) {
  5700         arit y = typeof  arity ==  'number' ?  arity : ( +arity ||  func.lengt h);
  5701         retu rn createW rapper(fun c, 4, null , null, nu ll, arity) ;
  5702       }
  5703  
  5704       /**
  5705        * Cre ates a fun ction that  will dela y the exec ution of ` func` unti l after
  5706        * `wa it` millis econds hav e elapsed  since the  last time  it was inv oked.
  5707        * Pro vide an op tions obje ct to indi cate that  `func` sho uld be inv oked on
  5708        * the  leading a nd/or trai ling edge  of the `wa it` timeou t. Subsequ ent calls
  5709        * to  the deboun ced functi on will re turn the r esult of t he last `f unc` call.
  5710        *
  5711        * Not e: If `lea ding` and  `trailing`  options a re `true`  `func` wil l be calle d
  5712        * on  the traili ng edge of  the timeo ut only if  the the d ebounced f unction is
  5713        * inv oked more  than once  during the  `wait` ti meout.
  5714        *
  5715        * @st atic
  5716        * @me mberOf _
  5717        * @ca tegory Fun ctions
  5718        * @pa ram {Funct ion} func  The functi on to debo unce.
  5719        * @pa ram {numbe r} wait Th e number o f millisec onds to de lay.
  5720        * @pa ram {Objec t} [option s] The opt ions objec t.
  5721        * @pa ram {boole an} [optio ns.leading =false] Sp ecify exec ution on t he leading  edge of t he timeout .
  5722        * @pa ram {numbe r} [option s.maxWait]  The maxim um time `f unc` is al lowed to b e delayed  before it' s called.
  5723        * @pa ram {boole an} [optio ns.trailin g=true] Sp ecify exec ution on t he trailin g edge of  the timeou t.
  5724        * @re turns {Fun ction} Ret urns the n ew debounc ed functio n.
  5725        * @ex ample
  5726        *
  5727        * //  avoid cost ly calcula tions whil e the wind ow size is  in flux
  5728        * var  lazyLayou t = _.debo unce(calcu lateLayout , 150);
  5729        * jQu ery(window ).on('resi ze', lazyL ayout);
  5730        *
  5731        * //  execute `s endMail` w hen the cl ick event  is fired,  debouncing  subsequen t calls
  5732        * jQu ery('#post box').on(' click', _. debounce(s endMail, 3 00, {
  5733        *   ' leading':  true,
  5734        *   ' trailing':  false
  5735        * });
  5736        *
  5737        * //  ensure `ba tchLog` is  executed  once after  1 second  of debounc ed calls
  5738        * var  source =  new EventS ource('/st ream');
  5739        * sou rce.addEve ntListener ('message' , _.deboun ce(batchLo g, 250, {
  5740        *   ' maxWait':  1000
  5741        * },  false);
  5742        */
  5743       functi on debounc e(func, wa it, option s) {
  5744         var  args,
  5745              maxTimeout Id,
  5746              result,
  5747              stamp,
  5748              thisArg,
  5749              timeoutId,
  5750              trailingCa ll,
  5751              lastCalled  = 0,
  5752              maxWait =  false,
  5753              trailing =  true;
  5754  
  5755         if ( !isFunctio n(func)) {
  5756           th row new Ty peError;
  5757         }
  5758         wait  = nativeM ax(0, wait ) || 0;
  5759         if ( options == = true) {
  5760           va r leading  = true;
  5761           tr ailing = f alse;
  5762         } el se if (isO bject(opti ons)) {
  5763           le ading = op tions.lead ing;
  5764           ma xWait = 'm axWait' in  options & & (nativeM ax(wait, o ptions.max Wait) || 0 );
  5765           tr ailing = ' trailing'  in options  ? options .trailing  : trailing ;
  5766         }
  5767         var  delayed =  function()  {
  5768           va r remainin g = wait -  (now() -  stamp);
  5769           if  (remainin g <= 0) {
  5770              if (maxTim eoutId) {
  5771                clearTim eout(maxTi meoutId);
  5772              }
  5773              var isCall ed = trail ingCall;
  5774              maxTimeout Id = timeo utId = tra ilingCall  = undefine d;
  5775              if (isCall ed) {
  5776                lastCall ed = now() ;
  5777                result =  func.appl y(thisArg,  args);
  5778                if (!tim eoutId &&  !maxTimeou tId) {
  5779                  args =  thisArg =  null;
  5780                }
  5781              }
  5782           }  else {
  5783              timeoutId  = setTimeo ut(delayed , remainin g);
  5784           }
  5785         };
  5786  
  5787         var  maxDelayed  = functio n() {
  5788           if  (timeoutI d) {
  5789              clearTimeo ut(timeout Id);
  5790           }
  5791           ma xTimeoutId  = timeout Id = trail ingCall =  undefined;
  5792           if  (trailing  || (maxWa it !== wai t)) {
  5793              lastCalled  = now();
  5794              result = f unc.apply( thisArg, a rgs);
  5795              if (!timeo utId && !m axTimeoutI d) {
  5796                args = t hisArg = n ull;
  5797              }
  5798           }
  5799         };
  5800  
  5801         retu rn functio n() {
  5802           ar gs = argum ents;
  5803           st amp = now( );
  5804           th isArg = th is;
  5805           tr ailingCall  = trailin g && (time outId || ! leading);
  5806  
  5807           if  (maxWait  === false)  {
  5808              var leadin gCall = le ading && ! timeoutId;
  5809           }  else {
  5810              if (!maxTi meoutId &&  !leading)  {
  5811                lastCall ed = stamp ;
  5812              }
  5813              var remain ing = maxW ait - (sta mp - lastC alled),
  5814                  isCall ed = remai ning <= 0;
  5815  
  5816              if (isCall ed) {
  5817                if (maxT imeoutId)  {
  5818                  maxTim eoutId = c learTimeou t(maxTimeo utId);
  5819                }
  5820                lastCall ed = stamp ;
  5821                result =  func.appl y(thisArg,  args);
  5822              }
  5823              else if (! maxTimeout Id) {
  5824                maxTimeo utId = set Timeout(ma xDelayed,  remaining) ;
  5825              }
  5826           }
  5827           if  (isCalled  && timeou tId) {
  5828              timeoutId  = clearTim eout(timeo utId);
  5829           }
  5830           el se if (!ti meoutId &&  wait !==  maxWait) {
  5831              timeoutId  = setTimeo ut(delayed , wait);
  5832           }
  5833           if  (leadingC all) {
  5834              isCalled =  true;
  5835              result = f unc.apply( thisArg, a rgs);
  5836           }
  5837           if  (isCalled  && !timeo utId && !m axTimeoutI d) {
  5838              args = thi sArg = nul l;
  5839           }
  5840           re turn resul t;
  5841         };
  5842       }
  5843  
  5844       /**
  5845        * Def ers execut ing the `f unc` funct ion until  the curren t call sta ck has cle ared.
  5846        * Add itional ar guments wi ll be prov ided to `f unc` when  it is invo ked.
  5847        *
  5848        * @st atic
  5849        * @me mberOf _
  5850        * @ca tegory Fun ctions
  5851        * @pa ram {Funct ion} func  The functi on to defe r.
  5852        * @pa ram {...*}  [arg] Arg uments to  invoke the  function  with.
  5853        * @re turns {num ber} Retur ns the tim er id.
  5854        * @ex ample
  5855        *
  5856        * _.d efer(funct ion(text)  { console. log(text);  }, 'defer red');
  5857        * //  logs 'defe rred' afte r one or m ore millis econds
  5858        */
  5859       functi on defer(f unc) {
  5860         if ( !isFunctio n(func)) {
  5861           th row new Ty peError;
  5862         }
  5863         var  args = sli ce(argumen ts, 1);
  5864         retu rn setTime out(functi on() { fun c.apply(un defined, a rgs); }, 1 );
  5865       }
  5866  
  5867       /**
  5868        * Exe cutes the  `func` fun ction afte r `wait` m illisecond s. Additio nal argume nts
  5869        * wil l be provi ded to `fu nc` when i t is invok ed.
  5870        *
  5871        * @st atic
  5872        * @me mberOf _
  5873        * @ca tegory Fun ctions
  5874        * @pa ram {Funct ion} func  The functi on to dela y.
  5875        * @pa ram {numbe r} wait Th e number o f millisec onds to de lay execut ion.
  5876        * @pa ram {...*}  [arg] Arg uments to  invoke the  function  with.
  5877        * @re turns {num ber} Retur ns the tim er id.
  5878        * @ex ample
  5879        *
  5880        * _.d elay(funct ion(text)  { console. log(text);  }, 1000,  'later');
  5881        * //  => logs 'l ater' afte r one seco nd
  5882        */
  5883       functi on delay(f unc, wait)  {
  5884         if ( !isFunctio n(func)) {
  5885           th row new Ty peError;
  5886         }
  5887         var  args = sli ce(argumen ts, 2);
  5888         retu rn setTime out(functi on() { fun c.apply(un defined, a rgs); }, w ait);
  5889       }
  5890  
  5891       /**
  5892        * Cre ates a fun ction that  memoizes  the result  of `func` . If `reso lver` is
  5893        * pro vided it w ill be use d to deter mine the c ache key f or storing  the resul t
  5894        * bas ed on the  arguments  provided t o the memo ized funct ion. By de fault, the
  5895        * fir st argumen t provided  to the me moized fun ction is u sed as the  cache key .
  5896        * The  `func` is  executed  with the ` this` bind ing of the  memoized  function.
  5897        * The  result ca che is exp osed as th e `cache`  property o n the memo ized funct ion.
  5898        *
  5899        * @st atic
  5900        * @me mberOf _
  5901        * @ca tegory Fun ctions
  5902        * @pa ram {Funct ion} func  The functi on to have  its outpu t memoized .
  5903        * @pa ram {Funct ion} [reso lver] A fu nction use d to resol ve the cac he key.
  5904        * @re turns {Fun ction} Ret urns the n ew memoizi ng functio n.
  5905        * @ex ample
  5906        *
  5907        * var  fibonacci  = _.memoi ze(functio n(n) {
  5908        *   r eturn n <  2 ? n : fi bonacci(n  - 1) + fib onacci(n -  2);
  5909        * });
  5910        *
  5911        * fib onacci(9)
  5912        * //  => 34
  5913        *
  5914        * var  data = {
  5915        *   ' fred': { ' name': 'fr ed', 'age' : 40 },
  5916        *   ' pebbles':  { 'name':  'pebbles',  'age': 1  }
  5917        * };
  5918        *
  5919        * //  modifying  the result  cache
  5920        * var  get = _.m emoize(fun ction(name ) { return  data[name ]; }, _.id entity);
  5921        * get ('pebbles' );
  5922        * //  => { 'name ': 'pebble s', 'age':  1 }
  5923        *
  5924        * get .cache.peb bles.name  = 'penelop e';
  5925        * get ('pebbles' );
  5926        * //  => { 'name ': 'penelo pe', 'age' : 1 }
  5927        */
  5928       functi on memoize (func, res olver) {
  5929         if ( !isFunctio n(func)) {
  5930           th row new Ty peError;
  5931         }
  5932         var  memoized =  function( ) {
  5933           va r cache =  memoized.c ache,
  5934                key = re solver ? r esolver.ap ply(this,  arguments)  : keyPref ix + argum ents[0];
  5935  
  5936           re turn hasOw nProperty. call(cache , key)
  5937              ? cache[ke y]
  5938              : (cache[k ey] = func .apply(thi s, argumen ts));
  5939         }
  5940         memo ized.cache  = {};
  5941         retu rn memoize d;
  5942       }
  5943  
  5944       /**
  5945        * Cre ates a fun ction that  is restri cted to ex ecute `fun c` once. R epeat call s to
  5946        * the  function  will retur n the valu e of the f irst call.  The `func ` is execu ted
  5947        * wit h the `thi s` binding  of the cr eated func tion.
  5948        *
  5949        * @st atic
  5950        * @me mberOf _
  5951        * @ca tegory Fun ctions
  5952        * @pa ram {Funct ion} func  The functi on to rest rict.
  5953        * @re turns {Fun ction} Ret urns the n ew restric ted functi on.
  5954        * @ex ample
  5955        *
  5956        * var  initializ e = _.once (createApp lication);
  5957        * ini tialize();
  5958        * ini tialize();
  5959        * //  `initializ e` execute s `createA pplication ` once
  5960        */
  5961       functi on once(fu nc) {
  5962         var  ran,
  5963              result;
  5964  
  5965         if ( !isFunctio n(func)) {
  5966           th row new Ty peError;
  5967         }
  5968         retu rn functio n() {
  5969           if  (ran) {
  5970              return res ult;
  5971           }
  5972           ra n = true;
  5973           re sult = fun c.apply(th is, argume nts);
  5974  
  5975           //  clear the  `func` va riable so  the functi on may be  garbage co llected
  5976           fu nc = null;
  5977           re turn resul t;
  5978         };
  5979       }
  5980  
  5981       /**
  5982        * Cre ates a fun ction that , when cal led, invok es `func`  with any a dditional
  5983        * `pa rtial` arg uments pre pended to  those prov ided to th e new func tion. This
  5984        * met hod is sim ilar to `_ .bind` exc ept it doe s **not**  alter the  `this` bin ding.
  5985        *
  5986        * @st atic
  5987        * @me mberOf _
  5988        * @ca tegory Fun ctions
  5989        * @pa ram {Funct ion} func  The functi on to part ially appl y argument s to.
  5990        * @pa ram {...*}  [arg] Arg uments to  be partial ly applied .
  5991        * @re turns {Fun ction} Ret urns the n ew partial ly applied  function.
  5992        * @ex ample
  5993        *
  5994        * var  greet = f unction(gr eeting, na me) { retu rn greetin g + ' ' +  name; };
  5995        * var  hi = _.pa rtial(gree t, 'hi');
  5996        * hi( 'fred');
  5997        * //  => 'hi fre d'
  5998        */
  5999       functi on partial (func) {
  6000         retu rn createW rapper(fun c, 16, sli ce(argumen ts, 1));
  6001       }
  6002  
  6003       /**
  6004        * Thi s method i s like `_. partial` e xcept that  `partial`  arguments  are
  6005        * app ended to t hose provi ded to the  new funct ion.
  6006        *
  6007        * @st atic
  6008        * @me mberOf _
  6009        * @ca tegory Fun ctions
  6010        * @pa ram {Funct ion} func  The functi on to part ially appl y argument s to.
  6011        * @pa ram {...*}  [arg] Arg uments to  be partial ly applied .
  6012        * @re turns {Fun ction} Ret urns the n ew partial ly applied  function.
  6013        * @ex ample
  6014        *
  6015        * var  defaultsD eep = _.pa rtialRight (_.merge,  _.defaults );
  6016        *
  6017        * var  options =  {
  6018        *   ' variable':  'data',
  6019        *   ' imports':  { 'jq': $  }
  6020        * };
  6021        *
  6022        * def aultsDeep( options, _ .templateS ettings);
  6023        *
  6024        * opt ions.varia ble
  6025        * //  => 'data'
  6026        *
  6027        * opt ions.impor ts
  6028        * //  => { '_':  _, 'jq': $  }
  6029        */
  6030       functi on partial Right(func ) {
  6031         retu rn createW rapper(fun c, 32, nul l, slice(a rguments,  1));
  6032       }
  6033  
  6034       /**
  6035        * Cre ates a fun ction that , when exe cuted, wil l only cal l the `fun c` functio n
  6036        * at  most once  per every  `wait` mil liseconds.  Provide a n options  object to
  6037        * ind icate that  `func` sh ould be in voked on t he leading  and/or tr ailing edg e
  6038        * of  the `wait`  timeout.  Subsequent  calls to  the thrott led functi on will
  6039        * ret urn the re sult of th e last `fu nc` call.
  6040        *
  6041        * Not e: If `lea ding` and  `trailing`  options a re `true`  `func` wil l be calle d
  6042        * on  the traili ng edge of  the timeo ut only if  the the t hrottled f unction is
  6043        * inv oked more  than once  during the  `wait` ti meout.
  6044        *
  6045        * @st atic
  6046        * @me mberOf _
  6047        * @ca tegory Fun ctions
  6048        * @pa ram {Funct ion} func  The functi on to thro ttle.
  6049        * @pa ram {numbe r} wait Th e number o f millisec onds to th rottle exe cutions to .
  6050        * @pa ram {Objec t} [option s] The opt ions objec t.
  6051        * @pa ram {boole an} [optio ns.leading =true] Spe cify execu tion on th e leading  edge of th e timeout.
  6052        * @pa ram {boole an} [optio ns.trailin g=true] Sp ecify exec ution on t he trailin g edge of  the timeou t.
  6053        * @re turns {Fun ction} Ret urns the n ew throttl ed functio n.
  6054        * @ex ample
  6055        *
  6056        * //  avoid exce ssively up dating the  position  while scro lling
  6057        * var  throttled  = _.throt tle(update Position,  100);
  6058        * jQu ery(window ).on('scro ll', throt tled);
  6059        *
  6060        * //  execute `r enewToken`  when the  click even t is fired , but not  more than  once every  5 minutes
  6061        * jQu ery('.inte ractive'). on('click' , _.thrott le(renewTo ken, 30000 0, {
  6062        *   ' trailing':  false
  6063        * })) ;
  6064        */
  6065       functi on throttl e(func, wa it, option s) {
  6066         var  leading =  true,
  6067              trailing =  true;
  6068  
  6069         if ( !isFunctio n(func)) {
  6070           th row new Ty peError;
  6071         }
  6072         if ( options == = false) {
  6073           le ading = fa lse;
  6074         } el se if (isO bject(opti ons)) {
  6075           le ading = 'l eading' in  options ?  options.l eading : l eading;
  6076           tr ailing = ' trailing'  in options  ? options .trailing  : trailing ;
  6077         }
  6078         debo unceOption s.leading  = leading;
  6079         debo unceOption s.maxWait  = wait;
  6080         debo unceOption s.trailing  = trailin g;
  6081  
  6082         retu rn debounc e(func, wa it, deboun ceOptions) ;
  6083       }
  6084  
  6085       /**
  6086        * Cre ates a fun ction that  provides  `value` to  the wrapp er functio n as its
  6087        * fir st argumen t. Additio nal argume nts provid ed to the  function a re appende d
  6088        * to  those prov ided to th e wrapper  function.  The wrappe r is execu ted with
  6089        * the  `this` bi nding of t he created  function.
  6090        *
  6091        * @st atic
  6092        * @me mberOf _
  6093        * @ca tegory Fun ctions
  6094        * @pa ram {*} va lue The va lue to wra p.
  6095        * @pa ram {Funct ion} wrapp er The wra pper funct ion.
  6096        * @re turns {Fun ction} Ret urns the n ew functio n.
  6097        * @ex ample
  6098        *
  6099        * var  p = _.wra p(_.escape , function (func, tex t) {
  6100        *   r eturn '<p> ' + func(t ext) + '</ p>';
  6101        * });
  6102        *
  6103        * p(' Fred, Wilm a, & Pebbl es');
  6104        * //  => '<p>Fre d, Wilma,  &amp; Pebb les</p>'
  6105        */
  6106       functi on wrap(va lue, wrapp er) {
  6107         retu rn createW rapper(wra pper, 16,  [value]);
  6108       }
  6109  
  6110       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  6111  
  6112       /**
  6113        * Cre ates a fun ction that  returns ` value`.
  6114        *
  6115        * @st atic
  6116        * @me mberOf _
  6117        * @ca tegory Uti lities
  6118        * @pa ram {*} va lue The va lue to ret urn from t he new fun ction.
  6119        * @re turns {Fun ction} Ret urns the n ew functio n.
  6120        * @ex ample
  6121        *
  6122        * var  object =  { 'name':  'fred' };
  6123        * var  getter =  _.constant (object);
  6124        * get ter() ===  object;
  6125        * //  => true
  6126        */
  6127       functi on constan t(value) {
  6128         retu rn functio n() {
  6129           re turn value ;
  6130         };
  6131       }
  6132  
  6133       /**
  6134        * Pro duces a ca llback bou nd to an o ptional `t hisArg`. I f `func` i s a proper ty
  6135        * nam e the crea ted callba ck will re turn the p roperty va lue for a  given elem ent.
  6136        * If  `func` is  an object  the create d callback  will retu rn `true`  for elemen ts
  6137        * tha t contain  the equiva lent objec t properti es, otherw ise it wil l return ` false`.
  6138        *
  6139        * @st atic
  6140        * @me mberOf _
  6141        * @ca tegory Uti lities
  6142        * @pa ram {*} [f unc=identi ty] The va lue to con vert to a  callback.
  6143        * @pa ram {*} [t hisArg] Th e `this` b inding of  the create d callback .
  6144        * @pa ram {numbe r} [argCou nt] The nu mber of ar guments th e callback  accepts.
  6145        * @re turns {Fun ction} Ret urns a cal lback func tion.
  6146        * @ex ample
  6147        *
  6148        * var  character s = [
  6149        *   {  'name': ' barney', ' age': 36 } ,
  6150        *   {  'name': ' fred',   ' age': 40 }
  6151        * ];
  6152        *
  6153        * //  wrap to cr eate custo m callback  shorthand s
  6154        * _.c reateCallb ack = _.wr ap(_.creat eCallback,  function( func, call back, this Arg) {
  6155        *   v ar match =  /^(.+?)__ ([gl]t)(.+ )$/.exec(c allback);
  6156        *   r eturn !mat ch ? func( callback,  thisArg) :  function( object) {
  6157        *      return ma tch[2] ==  'gt' ? obj ect[match[ 1]] > matc h[3] : obj ect[match[ 1]] < matc h[3];
  6158        *   } ;
  6159        * });
  6160        *
  6161        * _.f ilter(char acters, 'a ge__gt38') ;
  6162        * //  => [{ 'nam e': 'fred' , 'age': 4 0 }]
  6163        */
  6164       functi on createC allback(fu nc, thisAr g, argCoun t) {
  6165         var  type = typ eof func;
  6166         if ( func == nu ll || type  == 'funct ion') {
  6167           re turn baseC reateCallb ack(func,  thisArg, a rgCount);
  6168         }
  6169         // h andle "_.p luck" styl e callback  shorthand s
  6170         if ( type != 'o bject') {
  6171           re turn prope rty(func);
  6172         }
  6173         var  props = ke ys(func),
  6174              key = prop s[0],
  6175              a = func[k ey];
  6176  
  6177         // h andle "_.w here" styl e callback  shorthand s
  6178         if ( props.leng th == 1 &&  a === a & & !isObjec t(a)) {
  6179           //  fast path  the commo n case of  providing  an object  with a sin gle
  6180           //  property  containing  a primiti ve value
  6181           re turn funct ion(object ) {
  6182              var b = ob ject[key];
  6183              return a = == b && (a  !== 0 ||  (1 / a ==  1 / b));
  6184           };
  6185         }
  6186         retu rn functio n(object)  {
  6187           va r length =  props.len gth,
  6188                result =  false;
  6189  
  6190           wh ile (lengt h--) {
  6191              if (!(resu lt = baseI sEqual(obj ect[props[ length]],  func[props [length]],  null, tru e))) {
  6192                break;
  6193              }
  6194           }
  6195           re turn resul t;
  6196         };
  6197       }
  6198  
  6199       /**
  6200        * Con verts the  characters  `&`, `<`,  `>`, `"`,  and `'` i n `string`  to their
  6201        * cor responding  HTML enti ties.
  6202        *
  6203        * @st atic
  6204        * @me mberOf _
  6205        * @ca tegory Uti lities
  6206        * @pa ram {strin g} string  The string  to escape .
  6207        * @re turns {str ing} Retur ns the esc aped strin g.
  6208        * @ex ample
  6209        *
  6210        * _.e scape('Fre d, Wilma,  & Pebbles' );
  6211        * //  => 'Fred,  Wilma, &am p; Pebbles '
  6212        */
  6213       functi on escape( string) {
  6214         retu rn string  == null ?  '' : Strin g(string). replace(re UnescapedH tml, escap eHtmlChar) ;
  6215       }
  6216  
  6217       /**
  6218        * Thi s method r eturns the  first arg ument prov ided to it .
  6219        *
  6220        * @st atic
  6221        * @me mberOf _
  6222        * @ca tegory Uti lities
  6223        * @pa ram {*} va lue Any va lue.
  6224        * @re turns {*}  Returns `v alue`.
  6225        * @ex ample
  6226        *
  6227        * var  object =  { 'name':  'fred' };
  6228        * _.i dentity(ob ject) ===  object;
  6229        * //  => true
  6230        */
  6231       functi on identit y(value) {
  6232         retu rn value;
  6233       }
  6234  
  6235       /**
  6236        * Add s function  propertie s of a sou rce object  to the de stination  object.
  6237        * If  `object` i s a functi on methods  will be a dded to it s prototyp e as well.
  6238        *
  6239        * @st atic
  6240        * @me mberOf _
  6241        * @ca tegory Uti lities
  6242        * @pa ram {Funct ion|Object } [object= lodash] ob ject The d estination  object.
  6243        * @pa ram {Objec t} source  The object  of functi ons to add .
  6244        * @pa ram {Objec t} [option s] The opt ions objec t.
  6245        * @pa ram {boole an} [optio ns.chain=t rue] Speci fy whether  the funct ions added  are chain able.
  6246        * @ex ample
  6247        *
  6248        * fun ction capi talize(str ing) {
  6249        *   r eturn stri ng.charAt( 0).toUpper Case() + s tring.slic e(1).toLow erCase();
  6250        * }
  6251        *
  6252        * _.m ixin({ 'ca pitalize':  capitaliz e });
  6253        * _.c apitalize( 'fred');
  6254        * //  => 'Fred'
  6255        *
  6256        * _(' fred').cap italize(). value();
  6257        * //  => 'Fred'
  6258        *
  6259        * _.m ixin({ 'ca pitalize':  capitaliz e }, { 'ch ain': fals e });
  6260        * _(' fred').cap italize();
  6261        * //  => 'Fred'
  6262        */
  6263       functi on mixin(o bject, sou rce, optio ns) {
  6264         var  chain = tr ue,
  6265              methodName s = source  && functi ons(source );
  6266  
  6267         if ( !source ||  (!options  && !metho dNames.len gth)) {
  6268           if  (options  == null) {
  6269              options =  source;
  6270           }
  6271           ct or = lodas hWrapper;
  6272           so urce = obj ect;
  6273           ob ject = lod ash;
  6274           me thodNames  = function s(source);
  6275         }
  6276         if ( options == = false) {
  6277           ch ain = fals e;
  6278         } el se if (isO bject(opti ons) && 'c hain' in o ptions) {
  6279           ch ain = opti ons.chain;
  6280         }
  6281         var  ctor = obj ect,
  6282              isFunc = i sFunction( ctor);
  6283  
  6284         forE ach(method Names, fun ction(meth odName) {
  6285           va r func = o bject[meth odName] =  source[met hodName];
  6286           if  (isFunc)  {
  6287              ctor.proto type[metho dName] = f unction()  {
  6288                var chai nAll = thi s.__chain_ _,
  6289                    valu e = this._ _wrapped__ ,
  6290                    args  = [value] ;
  6291  
  6292                push.app ly(args, a rguments);
  6293                var resu lt = func. apply(obje ct, args);
  6294                if (chai n || chain All) {
  6295                  if (va lue === re sult && is Object(res ult)) {
  6296                    retu rn this;
  6297                  }
  6298                  result  = new cto r(result);
  6299                  result .__chain__  = chainAl l;
  6300                }
  6301                return r esult;
  6302              };
  6303           }
  6304         });
  6305       }
  6306  
  6307       /**
  6308        * Rev erts the ' _' variabl e to its p revious va lue and re turns a re ference to
  6309        * the  `lodash`  function.
  6310        *
  6311        * @st atic
  6312        * @me mberOf _
  6313        * @ca tegory Uti lities
  6314        * @re turns {Fun ction} Ret urns the ` lodash` fu nction.
  6315        * @ex ample
  6316        *
  6317        * var  lodash =  _.noConfli ct();
  6318        */
  6319       functi on noConfl ict() {
  6320         cont ext._ = ol dDash;
  6321         retu rn this;
  6322       }
  6323  
  6324       /**
  6325        * A n o-operatio n function .
  6326        *
  6327        * @st atic
  6328        * @me mberOf _
  6329        * @ca tegory Uti lities
  6330        * @ex ample
  6331        *
  6332        * var  object =  { 'name':  'fred' };
  6333        * _.n oop(object ) === unde fined;
  6334        * //  => true
  6335        */
  6336       functi on noop()  {
  6337         // n o operatio n performe d
  6338       }
  6339  
  6340       /**
  6341        * Get s the numb er of mill iseconds t hat have e lapsed sin ce the Uni x epoch
  6342        * (1  January 19 70 00:00:0 0 UTC).
  6343        *
  6344        * @st atic
  6345        * @me mberOf _
  6346        * @ca tegory Uti lities
  6347        * @ex ample
  6348        *
  6349        * var  stamp = _ .now();
  6350        * _.d efer(funct ion() { co nsole.log( _.now() -  stamp); }) ;
  6351        * //  => logs th e number o f millisec onds it to ok for the  deferred  function t o be calle d
  6352        */
  6353       var no w = isNati ve(now = D ate.now) & & now || f unction()  {
  6354         retu rn new Dat e().getTim e();
  6355       };
  6356  
  6357       /**
  6358        * Con verts the  given valu e into an  integer of  the speci fied radix .
  6359        * If  `radix` is  `undefine d` or `0`  a `radix`  of `10` is  used unle ss the
  6360        * `va lue` is a  hexadecima l, in whic h case a ` radix` of  `16` is us ed.
  6361        *
  6362        * Not e: This me thod avoid s differen ces in nat ive ES3 an d ES5 `par seInt`
  6363        * imp lementatio ns. See ht tp://es5.g ithub.io/# E.
  6364        *
  6365        * @st atic
  6366        * @me mberOf _
  6367        * @ca tegory Uti lities
  6368        * @pa ram {strin g} value T he value t o parse.
  6369        * @pa ram {numbe r} [radix]  The radix  used to i nterpret t he value t o parse.
  6370        * @re turns {num ber} Retur ns the new  integer v alue.
  6371        * @ex ample
  6372        *
  6373        * _.p arseInt('0 8');
  6374        * //  => 8
  6375        */
  6376       var pa rseInt = n ativeParse Int(whites pace + '08 ') == 8 ?  nativePars eInt : fun ction(valu e, radix)  {
  6377         // F irefox < 2 1 and Oper a < 15 fol low the ES 3 specifie d implemen tation of  `parseInt`
  6378         retu rn nativeP arseInt(is String(val ue) ? valu e.replace( reLeadingS pacesAndZe ros, '') :  value, ra dix || 0);
  6379       };
  6380  
  6381       /**
  6382        * Cre ates a "_. pluck" sty le functio n, which r eturns the  `key` val ue of a
  6383        * giv en object.
  6384        *
  6385        * @st atic
  6386        * @me mberOf _
  6387        * @ca tegory Uti lities
  6388        * @pa ram {strin g} key The  name of t he propert y to retri eve.
  6389        * @re turns {Fun ction} Ret urns the n ew functio n.
  6390        * @ex ample
  6391        *
  6392        * var  character s = [
  6393        *   {  'name': ' fred',   ' age': 40 } ,
  6394        *   {  'name': ' barney', ' age': 36 }
  6395        * ];
  6396        *
  6397        * var  getName =  _.propert y('name');
  6398        *
  6399        * _.m ap(charact ers, getNa me);
  6400        * //  => ['barne y', 'fred' ]
  6401        *
  6402        * _.s ortBy(char acters, ge tName);
  6403        * //  => [{ 'nam e': 'barne y', 'age':  36 }, { ' name': 'fr ed',   'ag e': 40 }]
  6404        */
  6405       functi on propert y(key) {
  6406         retu rn functio n(object)  {
  6407           re turn objec t[key];
  6408         };
  6409       }
  6410  
  6411       /**
  6412        * Pro duces a ra ndom numbe r between  `min` and  `max` (inc lusive). I f only one
  6413        * arg ument is p rovided a  number bet ween `0` a nd the giv en number  will be
  6414        * ret urned. If  `floating`  is truey  or either  `min` or ` max` are f loats a
  6415        * flo ating-poin t number w ill be ret urned inst ead of an  integer.
  6416        *
  6417        * @st atic
  6418        * @me mberOf _
  6419        * @ca tegory Uti lities
  6420        * @pa ram {numbe r} [min=0]  The minim um possibl e value.
  6421        * @pa ram {numbe r} [max=1]  The maxim um possibl e value.
  6422        * @pa ram {boole an} [float ing=false]  Specify r eturning a  floating- point numb er.
  6423        * @re turns {num ber} Retur ns a rando m number.
  6424        * @ex ample
  6425        *
  6426        * _.r andom(0, 5 );
  6427        * //  => an inte ger betwee n 0 and 5
  6428        *
  6429        * _.r andom(5);
  6430        * //  => also an  integer b etween 0 a nd 5
  6431        *
  6432        * _.r andom(5, t rue);
  6433        * //  => a float ing-point  number bet ween 0 and  5
  6434        *
  6435        * _.r andom(1.2,  5.2);
  6436        * //  => a float ing-point  number bet ween 1.2 a nd 5.2
  6437        */
  6438       functi on random( min, max,  floating)  {
  6439         var  noMin = mi n == null,
  6440              noMax = ma x == null;
  6441  
  6442         if ( floating = = null) {
  6443           if  (typeof m in == 'boo lean' && n oMax) {
  6444              floating =  min;
  6445              min = 1;
  6446           }
  6447           el se if (!no Max && typ eof max ==  'boolean' ) {
  6448              floating =  max;
  6449              noMax = tr ue;
  6450           }
  6451         }
  6452         if ( noMin && n oMax) {
  6453           ma x = 1;
  6454         }
  6455         min  = +min ||  0;
  6456         if ( noMax) {
  6457           ma x = min;
  6458           mi n = 0;
  6459         } el se {
  6460           ma x = +max | | 0;
  6461         }
  6462         if ( floating | | min % 1  || max % 1 ) {
  6463           va r rand = n ativeRando m();
  6464           re turn nativ eMin(min +  (rand * ( max - min  + parseFlo at('1e-' +  ((rand +' ').length  - 1)))), m ax);
  6465         }
  6466         retu rn baseRan dom(min, m ax);
  6467       }
  6468  
  6469       /**
  6470        * Res olves the  value of p roperty `k ey` on `ob ject`. If  `key` is a  function
  6471        * it  will be in voked with  the `this ` binding  of `object ` and its  result ret urned,
  6472        * els e the prop erty value  is return ed. If `ob ject` is f alsey then  `undefine d`
  6473        * is  returned.
  6474        *
  6475        * @st atic
  6476        * @me mberOf _
  6477        * @ca tegory Uti lities
  6478        * @pa ram {Objec t} object  The object  to inspec t.
  6479        * @pa ram {strin g} key The  name of t he propert y to resol ve.
  6480        * @re turns {*}  Returns th e resolved  value.
  6481        * @ex ample
  6482        *
  6483        * var  object =  {
  6484        *   ' cheese': ' crumpets',
  6485        *   ' stuff': fu nction() {
  6486        *      return 'n onsense';
  6487        *   }
  6488        * };
  6489        *
  6490        * _.r esult(obje ct, 'chees e');
  6491        * //  => 'crumpe ts'
  6492        *
  6493        * _.r esult(obje ct, 'stuff ');
  6494        * //  => 'nonsen se'
  6495        */
  6496       functi on result( object, ke y) {
  6497         if ( object) {
  6498           va r value =  object[key ];
  6499           re turn isFun ction(valu e) ? objec t[key]() :  value;
  6500         }
  6501       }
  6502  
  6503       /**
  6504        * A m icro-templ ating meth od that ha ndles arbi trary deli miters, pr eserves
  6505        * whi tespace, a nd correct ly escapes  quotes wi thin inter polated co de.
  6506        *
  6507        * Not e: In the  developmen t build, ` _.template ` utilizes  sourceURL s for easi er
  6508        * deb ugging. Se e http://w ww.html5ro cks.com/en /tutorials /developer tools/sour cemaps/#to c-sourceur l
  6509        *
  6510        * For  more info rmation on  precompil ing templa tes see:
  6511        * htt ps://lodas h.com/cust om-builds
  6512        *
  6513        * For  more info rmation on  Chrome ex tension sa ndboxes se e:
  6514        * htt p://develo per.chrome .com/stabl e/extensio ns/sandbox ingEval.ht ml
  6515        *
  6516        * @st atic
  6517        * @me mberOf _
  6518        * @ca tegory Uti lities
  6519        * @pa ram {strin g} text Th e template  text.
  6520        * @pa ram {Objec t} data Th e data obj ect used t o populate  the text.
  6521        * @pa ram {Objec t} [option s] The opt ions objec t.
  6522        * @pa ram {RegEx p} [option s.escape]  The "escap e" delimit er.
  6523        * @pa ram {RegEx p} [option s.evaluate ] The "eva luate" del imiter.
  6524        * @pa ram {Objec t} [option s.imports]  An object  to import  into the  template a s local va riables.
  6525        * @pa ram {RegEx p} [option s.interpol ate] The " interpolat e" delimit er.
  6526        * @pa ram {strin g} [source URL] The s ourceURL o f the temp late's com piled sour ce.
  6527        * @pa ram {strin g} [variab le] The da ta object  variable n ame.
  6528        * @re turns {Fun ction|stri ng} Return s a compil ed functio n when no  `data` obj ect
  6529        *  is  given, el se it retu rns the in terpolated  text.
  6530        * @ex ample
  6531        *
  6532        * //  using the  "interpola te" delimi ter to cre ate a comp iled templ ate
  6533        * var  compiled  = _.templa te('hello  <%= name % >');
  6534        * com piled({ 'n ame': 'fre d' });
  6535        * //  => 'hello  fred'
  6536        *
  6537        * //  using the  "escape" d elimiter t o escape H TML in dat a property  values
  6538        * _.t emplate('< b><%- valu e %></b>',  { 'value' : '<script >' });
  6539        * //  => '<b>&lt ;script&gt ;</b>'
  6540        *
  6541        * //  using the  "evaluate"  delimiter  to genera te HTML
  6542        * var  list = '< % _.forEac h(people,  function(n ame) { %>< li><%- nam e %></li>< % }); %>';
  6543        * _.t emplate(li st, { 'peo ple': ['fr ed', 'barn ey'] });
  6544        * //  => '<li>fr ed</li><li >barney</l i>'
  6545        *
  6546        * //  using the  ES6 delimi ter as an  alternativ e to the d efault "in terpolate"  delimiter
  6547        * _.t emplate('h ello ${ na me }', { ' name': 'pe bbles' });
  6548        * //  => 'hello  pebbles'
  6549        *
  6550        * //  using the  internal ` print` fun ction in " evaluate"  delimiters
  6551        * _.t emplate('< % print("h ello " + n ame); %>!' , { 'name' : 'barney'  });
  6552        * //  => 'hello  barney!'
  6553        *
  6554        * //  using a cu stom templ ate delimi ters
  6555        * _.t emplateSet tings = {
  6556        *   ' interpolat e': /{{([\ s\S]+?)}}/ g
  6557        * };
  6558        *
  6559        * _.t emplate('h ello {{ na me }}!', {  'name': ' mustache'  });
  6560        * //  => 'hello  mustache!'
  6561        *
  6562        * //  using the  `imports`  option to  import jQu ery
  6563        * var  list = '< % jq.each( people, fu nction(nam e) { %><li ><%- name  %></li><%  }); %>';
  6564        * _.t emplate(li st, { 'peo ple': ['fr ed', 'barn ey'] }, {  'imports':  { 'jq': j Query } }) ;
  6565        * //  => '<li>fr ed</li><li >barney</l i>'
  6566        *
  6567        * //  using the  `sourceURL ` option t o specify  a custom s ourceURL f or the tem plate
  6568        * var  compiled  = _.templa te('hello  <%= name % >', null,  { 'sourceU RL': '/bas ic/greetin g.jst' });
  6569        * com piled(data );
  6570        * //  => find th e source o f "greetin g.jst" und er the Sou rces tab o r Resource s panel of  the web i nspector
  6571        *
  6572        * //  using the  `variable`  option to  ensure a  with-state ment isn't  used in t he compile d template
  6573        * var  compiled  = _.templa te('hi <%=  data.name  %>!', nul l, { 'vari able': 'da ta' });
  6574        * com piled.sour ce;
  6575        * //  => functio n(data) {
  6576        *   v ar __t, __ p = '', __ e = _.esca pe;
  6577        *   _ _p += 'hi  ' + ((__t  = ( data.n ame )) ==  null ? ''  : __t) + ' !';
  6578        *   r eturn __p;
  6579        * }
  6580        *
  6581        * //  using the  `source` p roperty to  inline co mpiled tem plates for  meaningfu l
  6582        * //  line numbe rs in erro r messages  and a sta ck trace
  6583        * fs. writeFileS ync(path.j oin(cwd, ' jst.js'),  '\
  6584        *   v ar JST = { \
  6585        *      "main": '  + _.templ ate(mainTe xt).source  + '\
  6586        *   } ;\
  6587        * ');
  6588        */
  6589       functi on templat e(text, da ta, option s) {
  6590         // b ased on Jo hn Resig's  `tmpl` im plementati on
  6591         // h ttp://ejoh n.org/blog /javascrip t-micro-te mplating/
  6592         // a nd Laura D oktorova's  doT.js
  6593         // h ttps://git hub.com/ol ado/doT
  6594         var  settings =  lodash.te mplateSett ings;
  6595         text  = String( text || '' );
  6596  
  6597         // a void missi ng depende ncies when  `iterator Template`  is not def ined
  6598         opti ons = iter atorTempla te ? defau lts({}, op tions, set tings) : s ettings;
  6599  
  6600         var  imports =  iteratorTe mplate &&  defaults({ }, options .imports,  settings.i mports),
  6601              importsKey s = iterat orTemplate  ? keys(im ports) : [ '_'],
  6602              importsVal ues = iter atorTempla te ? value s(imports)  : [lodash ];
  6603  
  6604         var  isEvaluati ng,
  6605              index = 0,
  6606              interpolat e = option s.interpol ate || reN oMatch,
  6607              source = " __p += '";
  6608  
  6609         // c ompile the  regexp to  match eac h delimite r
  6610         var  reDelimite rs = RegEx p(
  6611           (o ptions.esc ape || reN oMatch).so urce + '|'  +
  6612           in terpolate. source + ' |' +
  6613           (i nterpolate  === reInt erpolate ?  reEsTempl ate : reNo Match).sou rce + '|'  +
  6614           (o ptions.eva luate || r eNoMatch). source + ' |$'
  6615         , 'g ');
  6616  
  6617         text .replace(r eDelimiter s, functio n(match, e scapeValue , interpol ateValue,  esTemplate Value, eva luateValue , offset)  {
  6618           in terpolateV alue || (i nterpolate Value = es TemplateVa lue);
  6619  
  6620           //  escape ch aracters t hat cannot  be includ ed in stri ng literal s
  6621           so urce += te xt.slice(i ndex, offs et).replac e(reUnesca pedString,  escapeStr ingChar);
  6622  
  6623           //  replace d elimiters  with snipp ets
  6624           if  (escapeVa lue) {
  6625              source +=  "' +\n__e( " + escape Value + ")  +\n'";
  6626           }
  6627           if  (evaluate Value) {
  6628              isEvaluati ng = true;
  6629              source +=  "';\n" + e valuateVal ue + ";\n_ _p += '";
  6630           }
  6631           if  (interpol ateValue)  {
  6632              source +=  "' +\n((__ t = (" + i nterpolate Value + ") ) == null  ? '' : __t ) +\n'";
  6633           }
  6634           in dex = offs et + match .length;
  6635  
  6636           //  the JS en gine embed ded in Ado be product s requires  returning  the `matc h`
  6637           //  string in  order to  produce th e correct  `offset` v alue
  6638           re turn match ;
  6639         });
  6640  
  6641         sour ce += "';\ n";
  6642  
  6643         // i f `variabl e` is not  specified,  wrap a wi th-stateme nt around  the genera ted
  6644         // c ode to add  the data  object to  the top of  the scope  chain
  6645         var  variable =  options.v ariable,
  6646              hasVariabl e = variab le;
  6647  
  6648         if ( !hasVariab le) {
  6649           va riable = ' obj';
  6650           so urce = 'wi th (' + va riable + ' ) {\n' + s ource + '\ n}\n';
  6651         }
  6652         // c leanup cod e by strip ping empty  strings
  6653         sour ce = (isEv aluating ?  source.re place(reEm ptyStringL eading, '' ) : source )
  6654           .r eplace(reE mptyString Middle, '$ 1')
  6655           .r eplace(reE mptyString Trailing,  '$1;');
  6656  
  6657         // f rame code  as the fun ction body
  6658         sour ce = 'func tion(' + v ariable +  ') {\n' +
  6659           (h asVariable  ? '' : va riable + '  || (' + v ariable +  ' = {});\n ') +
  6660           "v ar __t, __ p = '', __ e = _.esca pe" +
  6661           (i sEvaluatin g
  6662              ? ', __j =  Array.pro totype.joi n;\n' +
  6663                "functio n print()  { __p += _ _j.call(ar guments, ' ') }\n"
  6664              : ';\n'
  6665           )  +
  6666           so urce +
  6667           'r eturn __p\ n}';
  6668  
  6669         // U se a sourc eURL for e asier debu gging.
  6670         // h ttp://www. html5rocks .com/en/tu torials/de velopertoo ls/sourcem aps/#toc-s ourceurl
  6671         var  sourceURL  = '\n/*\n/ /# sourceU RL=' + (op tions.sour ceURL || ' /lodash/te mplate/sou rce[' + (t emplateCou nter++) +  ']') + '\n */';
  6672  
  6673         try  {
  6674           va r result =  Function( importsKey s, 'return  ' + sourc e + source URL).apply (undefined , importsV alues);
  6675         } ca tch(e) {
  6676           e. source = s ource;
  6677           th row e;
  6678         }
  6679         if ( data) {
  6680           re turn resul t(data);
  6681         }
  6682         // p rovide the  compiled  function's  source by  its `toSt ring` meth od, in
  6683         // s upported e nvironment s, or the  `source` p roperty as  a conveni ence for
  6684         // i nlining co mpiled tem plates dur ing the bu ild proces s
  6685         resu lt.source  = source;
  6686         retu rn result;
  6687       }
  6688  
  6689       /**
  6690        * Exe cutes the  callback ` n` times,  returning  an array o f the resu lts
  6691        * of  each callb ack execut ion. The c allback is  bound to  `thisArg`  and invoke d
  6692        * wit h one argu ment; (ind ex).
  6693        *
  6694        * @st atic
  6695        * @me mberOf _
  6696        * @ca tegory Uti lities
  6697        * @pa ram {numbe r} n The n umber of t imes to ex ecute the  callback.
  6698        * @pa ram {Funct ion} callb ack The fu nction cal led per it eration.
  6699        * @pa ram {*} [t hisArg] Th e `this` b inding of  `callback` .
  6700        * @re turns {Arr ay} Return s an array  of the re sults of e ach `callb ack` execu tion.
  6701        * @ex ample
  6702        *
  6703        * var  diceRolls  = _.times (3, _.part ial(_.rand om, 1, 6)) ;
  6704        * //  => [3, 6,  4]
  6705        *
  6706        * _.t imes(3, fu nction(n)  { mage.cas tSpell(n);  });
  6707        * //  => calls ` mage.castS pell(n)` t hree times , passing  `n` of `0` , `1`, and  `2` respe ctively
  6708        *
  6709        * _.t imes(3, fu nction(n)  { this.cas t(n); }, m age);
  6710        * //  => also ca lls `mage. castSpell( n)` three  times
  6711        */
  6712       functi on times(n , callback , thisArg)  {
  6713         n =  (n = +n) >  -1 ? n :  0;
  6714         var  index = -1 ,
  6715              result = A rray(n);
  6716  
  6717         call back = bas eCreateCal lback(call back, this Arg, 1);
  6718         whil e (++index  < n) {
  6719           re sult[index ] = callba ck(index);
  6720         }
  6721         retu rn result;
  6722       }
  6723  
  6724       /**
  6725        * The  inverse o f `_.escap e` this me thod conve rts the HT ML entitie s
  6726        * `&a mp;`, `&lt ;`, `&gt;` , `&quot;` , and `&#3 9;` in `st ring` to t heir
  6727        * cor responding  character s.
  6728        *
  6729        * @st atic
  6730        * @me mberOf _
  6731        * @ca tegory Uti lities
  6732        * @pa ram {strin g} string  The string  to unesca pe.
  6733        * @re turns {str ing} Retur ns the une scaped str ing.
  6734        * @ex ample
  6735        *
  6736        * _.u nescape('F red, Barne y &amp; Pe bbles');
  6737        * //  => 'Fred,  Barney & P ebbles'
  6738        */
  6739       functi on unescap e(string)  {
  6740         retu rn string  == null ?  '' : Strin g(string). replace(re EscapedHtm l, unescap eHtmlChar) ;
  6741       }
  6742  
  6743       /**
  6744        * Gen erates a u nique ID.  If `prefix ` is provi ded the ID  will be a ppended to  it.
  6745        *
  6746        * @st atic
  6747        * @me mberOf _
  6748        * @ca tegory Uti lities
  6749        * @pa ram {strin g} [prefix ] The valu e to prefi x the ID w ith.
  6750        * @re turns {str ing} Retur ns the uni que ID.
  6751        * @ex ample
  6752        *
  6753        * _.u niqueId('c ontact_');
  6754        * //  => 'contac t_104'
  6755        *
  6756        * _.u niqueId();
  6757        * //  => '105'
  6758        */
  6759       functi on uniqueI d(prefix)  {
  6760         var  id = ++idC ounter;
  6761         retu rn String( prefix ==  null ? ''  : prefix)  + id;
  6762       }
  6763  
  6764       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  6765  
  6766       /**
  6767        * Cre ates a `lo dash` obje ct that wr aps the gi ven value  with expli cit
  6768        * met hod chaini ng enabled .
  6769        *
  6770        * @st atic
  6771        * @me mberOf _
  6772        * @ca tegory Cha ining
  6773        * @pa ram {*} va lue The va lue to wra p.
  6774        * @re turns {Obj ect} Retur ns the wra pper objec t.
  6775        * @ex ample
  6776        *
  6777        * var  character s = [
  6778        *   {  'name': ' barney',   'age': 36  },
  6779        *   {  'name': ' fred',     'age': 40  },
  6780        *   {  'name': ' pebbles',  'age': 1 }
  6781        * ];
  6782        *
  6783        * var  youngest  = _.chain( characters )
  6784        *      .sortBy(' age')
  6785        *      .map(func tion(chr)  { return c hr.name +  ' is ' + c hr.age; })
  6786        *      .first()
  6787        *      .value();
  6788        * //  => 'pebble s is 1'
  6789        */
  6790       functi on chain(v alue) {
  6791         valu e = new lo dashWrappe r(value);
  6792         valu e.__chain_ _ = true;
  6793         retu rn value;
  6794       }
  6795  
  6796       /**
  6797        * Inv okes `inte rceptor` w ith the `v alue` as t he first a rgument an d then
  6798        * ret urns `valu e`. The pu rpose of t his method  is to "ta p into" a  method
  6799        * cha in in orde r to perfo rm operati ons on int ermediate  results wi thin
  6800        * the  chain.
  6801        *
  6802        * @st atic
  6803        * @me mberOf _
  6804        * @ca tegory Cha ining
  6805        * @pa ram {*} va lue The va lue to pro vide to `i nterceptor `.
  6806        * @pa ram {Funct ion} inter ceptor The  function  to invoke.
  6807        * @re turns {*}  Returns `v alue`.
  6808        * @ex ample
  6809        *
  6810        * _([ 1, 2, 3, 4 ])
  6811        *  .t ap(functio n(array) {  array.pop (); })
  6812        *  .r everse()
  6813        *  .v alue();
  6814        * //  => [3, 2,  1]
  6815        */
  6816       functi on tap(val ue, interc eptor) {
  6817         inte rceptor(va lue);
  6818         retu rn value;
  6819       }
  6820  
  6821       /**
  6822        * Ena bles expli cit method  chaining  on the wra pper objec t.
  6823        *
  6824        * @na me chain
  6825        * @me mberOf _
  6826        * @ca tegory Cha ining
  6827        * @re turns {*}  Returns th e wrapper  object.
  6828        * @ex ample
  6829        *
  6830        * var  character s = [
  6831        *   {  'name': ' barney', ' age': 36 } ,
  6832        *   {  'name': ' fred',   ' age': 40 }
  6833        * ];
  6834        *
  6835        * //  without ex plicit cha ining
  6836        * _(c haracters) .first();
  6837        * //  => { 'name ': 'barney ', 'age':  36 }
  6838        *
  6839        * //  with expli cit chaini ng
  6840        * _(c haracters) .chain()
  6841        *   . first()
  6842        *   . pick('age' )
  6843        *   . value();
  6844        * //  => { 'age' : 36 }
  6845        */
  6846       functi on wrapper Chain() {
  6847         this .__chain__  = true;
  6848         retu rn this;
  6849       }
  6850  
  6851       /**
  6852        * Pro duces the  `toString`  result of  the wrapp ed value.
  6853        *
  6854        * @na me toStrin g
  6855        * @me mberOf _
  6856        * @ca tegory Cha ining
  6857        * @re turns {str ing} Retur ns the str ing result .
  6858        * @ex ample
  6859        *
  6860        * _([ 1, 2, 3]). toString() ;
  6861        * //  => '1,2,3'
  6862        */
  6863       functi on wrapper ToString()  {
  6864         retu rn String( this.__wra pped__);
  6865       }
  6866  
  6867       /**
  6868        * Ext racts the  wrapped va lue.
  6869        *
  6870        * @na me valueOf
  6871        * @me mberOf _
  6872        * @al ias value
  6873        * @ca tegory Cha ining
  6874        * @re turns {*}  Returns th e wrapped  value.
  6875        * @ex ample
  6876        *
  6877        * _([ 1, 2, 3]). valueOf();
  6878        * //  => [1, 2,  3]
  6879        */
  6880       functi on wrapper ValueOf()  {
  6881         retu rn this.__ wrapped__;
  6882       }
  6883  
  6884       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  6885  
  6886       // add  functions  that retu rn wrapped  values wh en chainin g
  6887       lodash .after = a fter;
  6888       lodash .assign =  assign;
  6889       lodash .at = at;
  6890       lodash .bind = bi nd;
  6891       lodash .bindAll =  bindAll;
  6892       lodash .bindKey =  bindKey;
  6893       lodash .chain = c hain;
  6894       lodash .compact =  compact;
  6895       lodash .compose =  compose;
  6896       lodash .constant  = constant ;
  6897       lodash .countBy =  countBy;
  6898       lodash .create =  create;
  6899       lodash .createCal lback = cr eateCallba ck;
  6900       lodash .curry = c urry;
  6901       lodash .debounce  = debounce ;
  6902       lodash .defaults  = defaults ;
  6903       lodash .defer = d efer;
  6904       lodash .delay = d elay;
  6905       lodash .differenc e = differ ence;
  6906       lodash .filter =  filter;
  6907       lodash .flatten =  flatten;
  6908       lodash .forEach =  forEach;
  6909       lodash .forEachRi ght = forE achRight;
  6910       lodash .forIn = f orIn;
  6911       lodash .forInRigh t = forInR ight;
  6912       lodash .forOwn =  forOwn;
  6913       lodash .forOwnRig ht = forOw nRight;
  6914       lodash .functions  = functio ns;
  6915       lodash .groupBy =  groupBy;
  6916       lodash .indexBy =  indexBy;
  6917       lodash .initial =  initial;
  6918       lodash .intersect ion = inte rsection;
  6919       lodash .invert =  invert;
  6920       lodash .invoke =  invoke;
  6921       lodash .keys = ke ys;
  6922       lodash .map = map ;
  6923       lodash .mapValues  = mapValu es;
  6924       lodash .max = max ;
  6925       lodash .memoize =  memoize;
  6926       lodash .merge = m erge;
  6927       lodash .min = min ;
  6928       lodash .omit = om it;
  6929       lodash .once = on ce;
  6930       lodash .pairs = p airs;
  6931       lodash .partial =  partial;
  6932       lodash .partialRi ght = part ialRight;
  6933       lodash .pick = pi ck;
  6934       lodash .pluck = p luck;
  6935       lodash .property  = property ;
  6936       lodash .pull = pu ll;
  6937       lodash .range = r ange;
  6938       lodash .reject =  reject;
  6939       lodash .remove =  remove;
  6940       lodash .rest = re st;
  6941       lodash .shuffle =  shuffle;
  6942       lodash .sortBy =  sortBy;
  6943       lodash .tap = tap ;
  6944       lodash .throttle  = throttle ;
  6945       lodash .times = t imes;
  6946       lodash .toArray =  toArray;
  6947       lodash .transform  = transfo rm;
  6948       lodash .union = u nion;
  6949       lodash .uniq = un iq;
  6950       lodash .values =  values;
  6951       lodash .where = w here;
  6952       lodash .without =  without;
  6953       lodash .wrap = wr ap;
  6954       lodash .xor = xor ;
  6955       lodash .zip = zip ;
  6956       lodash .zipObject  = zipObje ct;
  6957  
  6958       // add  aliases
  6959       lodash .collect =  map;
  6960       lodash .drop = re st;
  6961       lodash .each = fo rEach;
  6962       lodash .eachRight  = forEach Right;
  6963       lodash .extend =  assign;
  6964       lodash .methods =  functions ;
  6965       lodash .object =  zipObject;
  6966       lodash .select =  filter;
  6967       lodash .tail = re st;
  6968       lodash .unique =  uniq;
  6969       lodash .unzip = z ip;
  6970  
  6971       // add  functions  to `lodas h.prototyp e`
  6972       mixin( lodash);
  6973  
  6974       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  6975  
  6976       // add  functions  that retu rn unwrapp ed values  when chain ing
  6977       lodash .clone = c lone;
  6978       lodash .cloneDeep  = cloneDe ep;
  6979       lodash .contains  = contains ;
  6980       lodash .escape =  escape;
  6981       lodash .every = e very;
  6982       lodash .find = fi nd;
  6983       lodash .findIndex  = findInd ex;
  6984       lodash .findKey =  findKey;
  6985       lodash .findLast  = findLast ;
  6986       lodash .findLastI ndex = fin dLastIndex ;
  6987       lodash .findLastK ey = findL astKey;
  6988       lodash .has = has ;
  6989       lodash .identity  = identity ;
  6990       lodash .indexOf =  indexOf;
  6991       lodash .isArgumen ts = isArg uments;
  6992       lodash .isArray =  isArray;
  6993       lodash .isBoolean  = isBoole an;
  6994       lodash .isDate =  isDate;
  6995       lodash .isElement  = isEleme nt;
  6996       lodash .isEmpty =  isEmpty;
  6997       lodash .isEqual =  isEqual;
  6998       lodash .isFinite  = isFinite ;
  6999       lodash .isFunctio n = isFunc tion;
  7000       lodash .isNaN = i sNaN;
  7001       lodash .isNull =  isNull;
  7002       lodash .isNumber  = isNumber ;
  7003       lodash .isObject  = isObject ;
  7004       lodash .isPlainOb ject = isP lainObject ;
  7005       lodash .isRegExp  = isRegExp ;
  7006       lodash .isString  = isString ;
  7007       lodash .isUndefin ed = isUnd efined;
  7008       lodash .lastIndex Of = lastI ndexOf;
  7009       lodash .mixin = m ixin;
  7010       lodash .noConflic t = noConf lict;
  7011       lodash .noop = no op;
  7012       lodash .now = now ;
  7013       lodash .parseInt  = parseInt ;
  7014       lodash .random =  random;
  7015       lodash .reduce =  reduce;
  7016       lodash .reduceRig ht = reduc eRight;
  7017       lodash .result =  result;
  7018       lodash .runInCont ext = runI nContext;
  7019       lodash .size = si ze;
  7020       lodash .some = so me;
  7021       lodash .sortedInd ex = sorte dIndex;
  7022       lodash .template  = template ;
  7023       lodash .unescape  = unescape ;
  7024       lodash .uniqueId  = uniqueId ;
  7025  
  7026       // add  aliases
  7027       lodash .all = eve ry;
  7028       lodash .any = som e;
  7029       lodash .detect =  find;
  7030       lodash .findWhere  = find;
  7031       lodash .foldl = r educe;
  7032       lodash .foldr = r educeRight ;
  7033       lodash .include =  contains;
  7034       lodash .inject =  reduce;
  7035  
  7036       mixin( function()  {
  7037         var  source = { }
  7038         forO wn(lodash,  function( func, meth odName) {
  7039           if  (!lodash. prototype[ methodName ]) {
  7040              source[met hodName] =  func;
  7041           }
  7042         });
  7043         retu rn source;
  7044       }(), f alse);
  7045  
  7046       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  7047  
  7048       // add  functions  capable o f returnin g wrapped  and unwrap ped values  when chai ning
  7049       lodash .first = f irst;
  7050       lodash .last = la st;
  7051       lodash .sample =  sample;
  7052  
  7053       // add  aliases
  7054       lodash .take = fi rst;
  7055       lodash .head = fi rst;
  7056  
  7057       forOwn (lodash, f unction(fu nc, method Name) {
  7058         var  callbackab le = metho dName !==  'sample';
  7059         if ( !lodash.pr ototype[me thodName])  {
  7060           lo dash.proto type[metho dName]= fu nction(n,  guard) {
  7061              var chainA ll = this. __chain__,
  7062                  result  = func(th is.__wrapp ed__, n, g uard);
  7063  
  7064              return !ch ainAll &&  (n == null  || (guard  && !(call backable & & typeof n  == 'funct ion')))
  7065                ? result
  7066                : new lo dashWrappe r(result,  chainAll);
  7067           };
  7068         }
  7069       });
  7070  
  7071       /*---- ---------- ---------- ---------- ---------- ---------- ---------- ---------- */
  7072  
  7073       /**
  7074        * The  semantic  version nu mber.
  7075        *
  7076        * @st atic
  7077        * @me mberOf _
  7078        * @ty pe string
  7079        */
  7080       lodash .VERSION =  '2.4.2';
  7081  
  7082       // add  "Chaining " function s to the w rapper
  7083       lodash .prototype .chain = w rapperChai n;
  7084       lodash .prototype .toString  = wrapperT oString;
  7085       lodash .prototype .value = w rapperValu eOf;
  7086       lodash .prototype .valueOf =  wrapperVa lueOf;
  7087  
  7088       // add  `Array` f unctions t hat return  unwrapped  values
  7089       baseEa ch(['join' , 'pop', ' shift'], f unction(me thodName)  {
  7090         var  func = arr ayRef[meth odName];
  7091         loda sh.prototy pe[methodN ame] = fun ction() {
  7092           va r chainAll  = this.__ chain__,
  7093                result =  func.appl y(this.__w rapped__,  arguments) ;
  7094  
  7095           re turn chain All
  7096              ? new loda shWrapper( result, ch ainAll)
  7097              : result;
  7098         };
  7099       });
  7100  
  7101       // add  `Array` f unctions t hat return  the exist ing wrappe d value
  7102       baseEa ch(['push' , 'reverse ', 'sort',  'unshift' ], functio n(methodNa me) {
  7103         var  func = arr ayRef[meth odName];
  7104         loda sh.prototy pe[methodN ame] = fun ction() {
  7105           fu nc.apply(t his.__wrap ped__, arg uments);
  7106           re turn this;
  7107         };
  7108       });
  7109  
  7110       // add  `Array` f unctions t hat return  new wrapp ed values
  7111       baseEa ch(['conca t', 'slice ', 'splice '], functi on(methodN ame) {
  7112         var  func = arr ayRef[meth odName];
  7113         loda sh.prototy pe[methodN ame] = fun ction() {
  7114           re turn new l odashWrapp er(func.ap ply(this._ _wrapped__ , argument s), this._ _chain__);
  7115         };
  7116       });
  7117  
  7118       // avo id array-l ike object  bugs with  `Array#sh ift` and ` Array#spli ce`
  7119       // in  IE < 9, Fi refox < 10 , Narwhal,  and Ringo JS
  7120       if (!s upport.spl iceObjects ) {
  7121         base Each(['pop ', 'shift' , 'splice' ], functio n(methodNa me) {
  7122           va r func = a rrayRef[me thodName],
  7123                isSplice  = methodN ame == 'sp lice';
  7124  
  7125           lo dash.proto type[metho dName] = f unction()  {
  7126              var chainA ll = this. __chain__,
  7127                  value  = this.__w rapped__,
  7128                  result  = func.ap ply(value,  arguments );
  7129  
  7130              if (value. length ===  0) {
  7131                delete v alue[0];
  7132              }
  7133              return (ch ainAll ||  isSplice)
  7134                ? new lo dashWrappe r(result,  chainAll)
  7135                : result ;
  7136           };
  7137         });
  7138       }
  7139  
  7140       // add  pseudo pr ivate prop erty to be  used and  removed du ring the b uild proce ss
  7141       lodash ._baseEach  = baseEac h;
  7142       lodash ._iterator Template =  iteratorT emplate;
  7143       lodash ._shimKeys  = shimKey s;
  7144  
  7145       return  lodash;
  7146     }
  7147  
  7148     /*------ ---------- ---------- ---------- ---------- ---------- ---------- --------*/
  7149  
  7150     // expos e Lo-Dash
  7151     var _ =  runInConte xt();
  7152  
  7153     // some  AMD build  optimizers  like r.js  check for  condition  patterns  like the f ollowing:
  7154     if (type of define  == 'functi on' && typ eof define .amd == 'o bject' &&  define.amd ) {
  7155       // Exp ose Lo-Das h to the g lobal obje ct even wh en an AMD  loader is  present in
  7156       // cas e Lo-Dash  is loaded  with a Req uireJS shi m config.
  7157       // See  http://re quirejs.or g/docs/api .html#conf ig-shim
  7158       root._  = _;
  7159  
  7160       // def ine as an  anonymous  module so,  through p ath mappin g, it can  be
  7161       // ref erenced as  the "unde rscore" mo dule
  7162       define (function( ) {
  7163         retu rn _;
  7164       });
  7165     }
  7166     // check  for `expo rts` after  `define`  in case a  build opti mizer adds  an `expor ts` object
  7167     else if  (freeExpor ts && free Module) {
  7168       // in  Node.js or  RingoJS
  7169       if (mo duleExport s) {
  7170         (fre eModule.ex ports = _) ._ = _;
  7171       }
  7172       // in  Narwhal or  Rhino -re quire
  7173       else {
  7174         free Exports._  = _;
  7175       }
  7176     }
  7177     else {
  7178       // in  a browser  or Rhino
  7179       root._  = _;
  7180     }
  7181   }.call(thi s));