⌈⌋ ⎇ branch:  Bitrhythm


Hex Artifact Content

Artifact 5f00039101a5c0a80a022765c8ce10aa854feda28ce6678fd1b22de1a6f9dca0:


0000: 28 66 75 6e 63 74 69 6f 6e 20 28 67 6c 6f 62 61  (function (globa
0010: 6c 2c 20 66 61 63 74 6f 72 79 29 20 7b 0a 20 20  l, factory) {.  
0020: 74 79 70 65 6f 66 20 65 78 70 6f 72 74 73 20 3d  typeof exports =
0030: 3d 3d 20 27 6f 62 6a 65 63 74 27 20 26 26 20 74  == 'object' && t
0040: 79 70 65 6f 66 20 6d 6f 64 75 6c 65 20 21 3d 3d  ypeof module !==
0050: 20 27 75 6e 64 65 66 69 6e 65 64 27 20 3f 20 6d   'undefined' ? m
0060: 6f 64 75 6c 65 2e 65 78 70 6f 72 74 73 20 3d 20  odule.exports = 
0070: 66 61 63 74 6f 72 79 28 29 20 3a 0a 20 20 74 79  factory() :.  ty
0080: 70 65 6f 66 20 64 65 66 69 6e 65 20 3d 3d 3d 20  peof define === 
0090: 27 66 75 6e 63 74 69 6f 6e 27 20 26 26 20 64 65  'function' && de
00a0: 66 69 6e 65 2e 61 6d 64 20 3f 20 64 65 66 69 6e  fine.amd ? defin
00b0: 65 28 27 75 6e 64 65 72 73 63 6f 72 65 27 2c 20  e('underscore', 
00c0: 66 61 63 74 6f 72 79 29 20 3a 0a 20 20 28 67 6c  factory) :.  (gl
00d0: 6f 62 61 6c 20 3d 20 67 6c 6f 62 61 6c 20 7c 7c  obal = global ||
00e0: 20 73 65 6c 66 2c 20 28 66 75 6e 63 74 69 6f 6e   self, (function
00f0: 20 28 29 20 7b 0a 20 20 20 20 76 61 72 20 63 75   () {.    var cu
0100: 72 72 65 6e 74 20 3d 20 67 6c 6f 62 61 6c 2e 5f  rrent = global._
0110: 3b 0a 20 20 20 20 76 61 72 20 65 78 70 6f 72 74  ;.    var export
0120: 73 20 3d 20 67 6c 6f 62 61 6c 2e 5f 20 3d 20 66  s = global._ = f
0130: 61 63 74 6f 72 79 28 29 3b 0a 20 20 20 20 65 78  actory();.    ex
0140: 70 6f 72 74 73 2e 6e 6f 43 6f 6e 66 6c 69 63 74  ports.noConflict
0150: 20 3d 20 66 75 6e 63 74 69 6f 6e 20 28 29 20 7b   = function () {
0160: 20 67 6c 6f 62 61 6c 2e 5f 20 3d 20 63 75 72 72   global._ = curr
0170: 65 6e 74 3b 20 72 65 74 75 72 6e 20 65 78 70 6f  ent; return expo
0180: 72 74 73 3b 20 7d 3b 0a 20 20 7d 28 29 29 29 3b  rts; };.  }()));
0190: 0a 7d 28 74 68 69 73 2c 20 28 66 75 6e 63 74 69  .}(this, (functi
01a0: 6f 6e 20 28 29 20 7b 0a 20 20 2f 2f 20 20 20 20  on () {.  //    
01b0: 20 55 6e 64 65 72 73 63 6f 72 65 2e 6a 73 20 31   Underscore.js 1
01c0: 2e 31 32 2e 30 0a 20 20 2f 2f 20 20 20 20 20 68  .12.0.  //     h
01d0: 74 74 70 73 3a 2f 2f 75 6e 64 65 72 73 63 6f 72  ttps://underscor
01e0: 65 6a 73 2e 6f 72 67 0a 20 20 2f 2f 20 20 20 20  ejs.org.  //    
01f0: 20 28 63 29 20 32 30 30 39 2d 32 30 32 30 20 4a   (c) 2009-2020 J
0200: 65 72 65 6d 79 20 41 73 68 6b 65 6e 61 73 2c 20  eremy Ashkenas, 
0210: 44 6f 63 75 6d 65 6e 74 43 6c 6f 75 64 20 61 6e  DocumentCloud an
0220: 64 20 49 6e 76 65 73 74 69 67 61 74 69 76 65 20  d Investigative 
0230: 52 65 70 6f 72 74 65 72 73 20 26 20 45 64 69 74  Reporters & Edit
0240: 6f 72 73 0a 20 20 2f 2f 20 20 20 20 20 55 6e 64  ors.  //     Und
0250: 65 72 73 63 6f 72 65 20 6d 61 79 20 62 65 20 66  erscore may be f
0260: 72 65 65 6c 79 20 64 69 73 74 72 69 62 75 74 65  reely distribute
0270: 64 20 75 6e 64 65 72 20 74 68 65 20 4d 49 54 20  d under the MIT 
0280: 6c 69 63 65 6e 73 65 2e 0a 0a 20 20 2f 2f 20 43  license...  // C
0290: 75 72 72 65 6e 74 20 76 65 72 73 69 6f 6e 2e 0a  urrent version..
02a0: 20 20 76 61 72 20 56 45 52 53 49 4f 4e 20 3d 20    var VERSION = 
02b0: 27 31 2e 31 32 2e 30 27 3b 0a 0a 20 20 2f 2f 20  '1.12.0';..  // 
02c0: 45 73 74 61 62 6c 69 73 68 20 74 68 65 20 72 6f  Establish the ro
02d0: 6f 74 20 6f 62 6a 65 63 74 2c 20 60 77 69 6e 64  ot object, `wind
02e0: 6f 77 60 20 28 60 73 65 6c 66 60 29 20 69 6e 20  ow` (`self`) in 
02f0: 74 68 65 20 62 72 6f 77 73 65 72 2c 20 60 67 6c  the browser, `gl
0300: 6f 62 61 6c 60 0a 20 20 2f 2f 20 6f 6e 20 74 68  obal`.  // on th
0310: 65 20 73 65 72 76 65 72 2c 20 6f 72 20 60 74 68  e server, or `th
0320: 69 73 60 20 69 6e 20 73 6f 6d 65 20 76 69 72 74  is` in some virt
0330: 75 61 6c 20 6d 61 63 68 69 6e 65 73 2e 20 57 65  ual machines. We
0340: 20 75 73 65 20 60 73 65 6c 66 60 0a 20 20 2f 2f   use `self`.  //
0350: 20 69 6e 73 74 65 61 64 20 6f 66 20 60 77 69 6e   instead of `win
0360: 64 6f 77 60 20 66 6f 72 20 60 57 65 62 57 6f 72  dow` for `WebWor
0370: 6b 65 72 60 20 73 75 70 70 6f 72 74 2e 0a 20 20  ker` support..  
0380: 76 61 72 20 72 6f 6f 74 20 3d 20 74 79 70 65 6f  var root = typeo
0390: 66 20 73 65 6c 66 20 3d 3d 20 27 6f 62 6a 65 63  f self == 'objec
03a0: 74 27 20 26 26 20 73 65 6c 66 2e 73 65 6c 66 20  t' && self.self 
03b0: 3d 3d 3d 20 73 65 6c 66 20 26 26 20 73 65 6c 66  === self && self
03c0: 20 7c 7c 0a 20 20 20 20 20 20 20 20 20 20 20 20   ||.            
03d0: 74 79 70 65 6f 66 20 67 6c 6f 62 61 6c 20 3d 3d  typeof global ==
03e0: 20 27 6f 62 6a 65 63 74 27 20 26 26 20 67 6c 6f   'object' && glo
03f0: 62 61 6c 2e 67 6c 6f 62 61 6c 20 3d 3d 3d 20 67  bal.global === g
0400: 6c 6f 62 61 6c 20 26 26 20 67 6c 6f 62 61 6c 20  lobal && global 
0410: 7c 7c 0a 20 20 20 20 20 20 20 20 20 20 20 20 46  ||.            F
0420: 75 6e 63 74 69 6f 6e 28 27 72 65 74 75 72 6e 20  unction('return 
0430: 74 68 69 73 27 29 28 29 20 7c 7c 0a 20 20 20 20  this')() ||.    
0440: 20 20 20 20 20 20 20 20 7b 7d 3b 0a 0a 20 20 2f          {};..  /
0450: 2f 20 53 61 76 65 20 62 79 74 65 73 20 69 6e 20  / Save bytes in 
0460: 74 68 65 20 6d 69 6e 69 66 69 65 64 20 28 62 75  the minified (bu
0470: 74 20 6e 6f 74 20 67 7a 69 70 70 65 64 29 20 76  t not gzipped) v
0480: 65 72 73 69 6f 6e 3a 0a 20 20 76 61 72 20 41 72  ersion:.  var Ar
0490: 72 61 79 50 72 6f 74 6f 20 3d 20 41 72 72 61 79  rayProto = Array
04a0: 2e 70 72 6f 74 6f 74 79 70 65 2c 20 4f 62 6a 50  .prototype, ObjP
04b0: 72 6f 74 6f 20 3d 20 4f 62 6a 65 63 74 2e 70 72  roto = Object.pr
04c0: 6f 74 6f 74 79 70 65 3b 0a 20 20 76 61 72 20 53  ototype;.  var S
04d0: 79 6d 62 6f 6c 50 72 6f 74 6f 20 3d 20 74 79 70  ymbolProto = typ
04e0: 65 6f 66 20 53 79 6d 62 6f 6c 20 21 3d 3d 20 27  eof Symbol !== '
04f0: 75 6e 64 65 66 69 6e 65 64 27 20 3f 20 53 79 6d  undefined' ? Sym
0500: 62 6f 6c 2e 70 72 6f 74 6f 74 79 70 65 20 3a 20  bol.prototype : 
0510: 6e 75 6c 6c 3b 0a 0a 20 20 2f 2f 20 43 72 65 61  null;..  // Crea
0520: 74 65 20 71 75 69 63 6b 20 72 65 66 65 72 65 6e  te quick referen
0530: 63 65 20 76 61 72 69 61 62 6c 65 73 20 66 6f 72  ce variables for
0540: 20 73 70 65 65 64 20 61 63 63 65 73 73 20 74 6f   speed access to
0550: 20 63 6f 72 65 20 70 72 6f 74 6f 74 79 70 65 73   core prototypes
0560: 2e 0a 20 20 76 61 72 20 70 75 73 68 20 3d 20 41  ..  var push = A
0570: 72 72 61 79 50 72 6f 74 6f 2e 70 75 73 68 2c 0a  rrayProto.push,.
0580: 20 20 20 20 20 20 73 6c 69 63 65 20 3d 20 41 72        slice = Ar
0590: 72 61 79 50 72 6f 74 6f 2e 73 6c 69 63 65 2c 0a  rayProto.slice,.
05a0: 20 20 20 20 20 20 74 6f 53 74 72 69 6e 67 20 3d        toString =
05b0: 20 4f 62 6a 50 72 6f 74 6f 2e 74 6f 53 74 72 69   ObjProto.toStri
05c0: 6e 67 2c 0a 20 20 20 20 20 20 68 61 73 4f 77 6e  ng,.      hasOwn
05d0: 50 72 6f 70 65 72 74 79 20 3d 20 4f 62 6a 50 72  Property = ObjPr
05e0: 6f 74 6f 2e 68 61 73 4f 77 6e 50 72 6f 70 65 72  oto.hasOwnProper
05f0: 74 79 3b 0a 0a 20 20 2f 2f 20 4d 6f 64 65 72 6e  ty;..  // Modern
0600: 20 66 65 61 74 75 72 65 20 64 65 74 65 63 74 69   feature detecti
0610: 6f 6e 2e 0a 20 20 76 61 72 20 73 75 70 70 6f 72  on..  var suppor
0620: 74 73 41 72 72 61 79 42 75 66 66 65 72 20 3d 20  tsArrayBuffer = 
0630: 74 79 70 65 6f 66 20 41 72 72 61 79 42 75 66 66  typeof ArrayBuff
0640: 65 72 20 21 3d 3d 20 27 75 6e 64 65 66 69 6e 65  er !== 'undefine
0650: 64 27 2c 0a 20 20 20 20 20 20 73 75 70 70 6f 72  d',.      suppor
0660: 74 73 44 61 74 61 56 69 65 77 20 3d 20 74 79 70  tsDataView = typ
0670: 65 6f 66 20 44 61 74 61 56 69 65 77 20 21 3d 3d  eof DataView !==
0680: 20 27 75 6e 64 65 66 69 6e 65 64 27 3b 0a 0a 20   'undefined';.. 
0690: 20 2f 2f 20 41 6c 6c 20 2a 2a 45 43 4d 41 53 63   // All **ECMASc
06a0: 72 69 70 74 20 35 2b 2a 2a 20 6e 61 74 69 76 65  ript 5+** native
06b0: 20 66 75 6e 63 74 69 6f 6e 20 69 6d 70 6c 65 6d   function implem
06c0: 65 6e 74 61 74 69 6f 6e 73 20 74 68 61 74 20 77  entations that w
06d0: 65 20 68 6f 70 65 20 74 6f 20 75 73 65 0a 20 20  e hope to use.  
06e0: 2f 2f 20 61 72 65 20 64 65 63 6c 61 72 65 64 20  // are declared 
06f0: 68 65 72 65 2e 0a 20 20 76 61 72 20 6e 61 74 69  here..  var nati
0700: 76 65 49 73 41 72 72 61 79 20 3d 20 41 72 72 61  veIsArray = Arra
0710: 79 2e 69 73 41 72 72 61 79 2c 0a 20 20 20 20 20  y.isArray,.     
0720: 20 6e 61 74 69 76 65 4b 65 79 73 20 3d 20 4f 62   nativeKeys = Ob
0730: 6a 65 63 74 2e 6b 65 79 73 2c 0a 20 20 20 20 20  ject.keys,.     
0740: 20 6e 61 74 69 76 65 43 72 65 61 74 65 20 3d 20   nativeCreate = 
0750: 4f 62 6a 65 63 74 2e 63 72 65 61 74 65 2c 0a 20  Object.create,. 
0760: 20 20 20 20 20 6e 61 74 69 76 65 49 73 56 69 65       nativeIsVie
0770: 77 20 3d 20 73 75 70 70 6f 72 74 73 41 72 72 61  w = supportsArra
0780: 79 42 75 66 66 65 72 20 26 26 20 41 72 72 61 79  yBuffer && Array
0790: 42 75 66 66 65 72 2e 69 73 56 69 65 77 3b 0a 0a  Buffer.isView;..
07a0: 20 20 2f 2f 20 43 72 65 61 74 65 20 72 65 66 65    // Create refe
07b0: 72 65 6e 63 65 73 20 74 6f 20 74 68 65 73 65 20  rences to these 
07c0: 62 75 69 6c 74 69 6e 20 66 75 6e 63 74 69 6f 6e  builtin function
07d0: 73 20 62 65 63 61 75 73 65 20 77 65 20 6f 76 65  s because we ove
07e0: 72 72 69 64 65 20 74 68 65 6d 2e 0a 20 20 76 61  rride them..  va
07f0: 72 20 5f 69 73 4e 61 4e 20 3d 20 69 73 4e 61 4e  r _isNaN = isNaN
0800: 2c 0a 20 20 20 20 20 20 5f 69 73 46 69 6e 69 74  ,.      _isFinit
0810: 65 20 3d 20 69 73 46 69 6e 69 74 65 3b 0a 0a 20  e = isFinite;.. 
0820: 20 2f 2f 20 4b 65 79 73 20 69 6e 20 49 45 20 3c   // Keys in IE <
0830: 20 39 20 74 68 61 74 20 77 6f 6e 27 74 20 62 65   9 that won't be
0840: 20 69 74 65 72 61 74 65 64 20 62 79 20 60 66 6f   iterated by `fo
0850: 72 20 6b 65 79 20 69 6e 20 2e 2e 2e 60 20 61 6e  r key in ...` an
0860: 64 20 74 68 75 73 20 6d 69 73 73 65 64 2e 0a 20  d thus missed.. 
0870: 20 76 61 72 20 68 61 73 45 6e 75 6d 42 75 67 20   var hasEnumBug 
0880: 3d 20 21 7b 74 6f 53 74 72 69 6e 67 3a 20 6e 75  = !{toString: nu
0890: 6c 6c 7d 2e 70 72 6f 70 65 72 74 79 49 73 45 6e  ll}.propertyIsEn
08a0: 75 6d 65 72 61 62 6c 65 28 27 74 6f 53 74 72 69  umerable('toStri
08b0: 6e 67 27 29 3b 0a 20 20 76 61 72 20 6e 6f 6e 45  ng');.  var nonE
08c0: 6e 75 6d 65 72 61 62 6c 65 50 72 6f 70 73 20 3d  numerableProps =
08d0: 20 5b 27 76 61 6c 75 65 4f 66 27 2c 20 27 69 73   ['valueOf', 'is
08e0: 50 72 6f 74 6f 74 79 70 65 4f 66 27 2c 20 27 74  PrototypeOf', 't
08f0: 6f 53 74 72 69 6e 67 27 2c 0a 20 20 20 20 27 70  oString',.    'p
0900: 72 6f 70 65 72 74 79 49 73 45 6e 75 6d 65 72 61  ropertyIsEnumera
0910: 62 6c 65 27 2c 20 27 68 61 73 4f 77 6e 50 72 6f  ble', 'hasOwnPro
0920: 70 65 72 74 79 27 2c 20 27 74 6f 4c 6f 63 61 6c  perty', 'toLocal
0930: 65 53 74 72 69 6e 67 27 5d 3b 0a 0a 20 20 2f 2f  eString'];..  //
0940: 20 54 68 65 20 6c 61 72 67 65 73 74 20 69 6e 74   The largest int
0950: 65 67 65 72 20 74 68 61 74 20 63 61 6e 20 62 65  eger that can be
0960: 20 72 65 70 72 65 73 65 6e 74 65 64 20 65 78 61   represented exa
0970: 63 74 6c 79 2e 0a 20 20 76 61 72 20 4d 41 58 5f  ctly..  var MAX_
0980: 41 52 52 41 59 5f 49 4e 44 45 58 20 3d 20 4d 61  ARRAY_INDEX = Ma
0990: 74 68 2e 70 6f 77 28 32 2c 20 35 33 29 20 2d 20  th.pow(2, 53) - 
09a0: 31 3b 0a 0a 20 20 2f 2f 20 53 6f 6d 65 20 66 75  1;..  // Some fu
09b0: 6e 63 74 69 6f 6e 73 20 74 61 6b 65 20 61 20 76  nctions take a v
09c0: 61 72 69 61 62 6c 65 20 6e 75 6d 62 65 72 20 6f  ariable number o
09d0: 66 20 61 72 67 75 6d 65 6e 74 73 2c 20 6f 72 20  f arguments, or 
09e0: 61 20 66 65 77 20 65 78 70 65 63 74 65 64 0a 20  a few expected. 
09f0: 20 2f 2f 20 61 72 67 75 6d 65 6e 74 73 20 61 74   // arguments at
0a00: 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 61   the beginning a
0a10: 6e 64 20 74 68 65 6e 20 61 20 76 61 72 69 61 62  nd then a variab
0a20: 6c 65 20 6e 75 6d 62 65 72 20 6f 66 20 76 61 6c  le number of val
0a30: 75 65 73 20 74 6f 20 6f 70 65 72 61 74 65 0a 20  ues to operate. 
0a40: 20 2f 2f 20 6f 6e 2e 20 54 68 69 73 20 68 65 6c   // on. This hel
0a50: 70 65 72 20 61 63 63 75 6d 75 6c 61 74 65 73 20  per accumulates 
0a60: 61 6c 6c 20 72 65 6d 61 69 6e 69 6e 67 20 61 72  all remaining ar
0a70: 67 75 6d 65 6e 74 73 20 70 61 73 74 20 74 68 65  guments past the
0a80: 20 66 75 6e 63 74 69 6f 6e e2 80 99 73 0a 20 20   function...s.  
0a90: 2f 2f 20 61 72 67 75 6d 65 6e 74 20 6c 65 6e 67  // argument leng
0aa0: 74 68 20 28 6f 72 20 61 6e 20 65 78 70 6c 69 63  th (or an explic
0ab0: 69 74 20 60 73 74 61 72 74 49 6e 64 65 78 60 29  it `startIndex`)
0ac0: 2c 20 69 6e 74 6f 20 61 6e 20 61 72 72 61 79 20  , into an array 
0ad0: 74 68 61 74 20 62 65 63 6f 6d 65 73 0a 20 20 2f  that becomes.  /
0ae0: 2f 20 74 68 65 20 6c 61 73 74 20 61 72 67 75 6d  / the last argum
0af0: 65 6e 74 2e 20 53 69 6d 69 6c 61 72 20 74 6f 20  ent. Similar to 
0b00: 45 53 36 e2 80 99 73 20 22 72 65 73 74 20 70 61  ES6...s "rest pa
0b10: 72 61 6d 65 74 65 72 22 2e 0a 20 20 66 75 6e 63  rameter"..  func
0b20: 74 69 6f 6e 20 72 65 73 74 41 72 67 75 6d 65 6e  tion restArgumen
0b30: 74 73 28 66 75 6e 63 2c 20 73 74 61 72 74 49 6e  ts(func, startIn
0b40: 64 65 78 29 20 7b 0a 20 20 20 20 73 74 61 72 74  dex) {.    start
0b50: 49 6e 64 65 78 20 3d 20 73 74 61 72 74 49 6e 64  Index = startInd
0b60: 65 78 20 3d 3d 20 6e 75 6c 6c 20 3f 20 66 75 6e  ex == null ? fun
0b70: 63 2e 6c 65 6e 67 74 68 20 2d 20 31 20 3a 20 2b  c.length - 1 : +
0b80: 73 74 61 72 74 49 6e 64 65 78 3b 0a 20 20 20 20  startIndex;.    
0b90: 72 65 74 75 72 6e 20 66 75 6e 63 74 69 6f 6e 28  return function(
0ba0: 29 20 7b 0a 20 20 20 20 20 20 76 61 72 20 6c 65  ) {.      var le
0bb0: 6e 67 74 68 20 3d 20 4d 61 74 68 2e 6d 61 78 28  ngth = Math.max(
0bc0: 61 72 67 75 6d 65 6e 74 73 2e 6c 65 6e 67 74 68  arguments.length
0bd0: 20 2d 20 73 74 61 72 74 49 6e 64 65 78 2c 20 30   - startIndex, 0
0be0: 29 2c 0a 20 20 20 20 20 20 20 20 20 20 72 65 73  ),.          res
0bf0: 74 20 3d 20 41 72 72 61 79 28 6c 65 6e 67 74 68  t = Array(length
0c00: 29 2c 0a 20 20 20 20 20 20 20 20 20 20 69 6e 64  ),.          ind
0c10: 65 78 20 3d 20 30 3b 0a 20 20 20 20 20 20 66 6f  ex = 0;.      fo
0c20: 72 20 28 3b 20 69 6e 64 65 78 20 3c 20 6c 65 6e  r (; index < len
0c30: 67 74 68 3b 20 69 6e 64 65 78 2b 2b 29 20 7b 0a  gth; index++) {.
0c40: 20 20 20 20 20 20 20 20 72 65 73 74 5b 69 6e 64          rest[ind
0c50: 65 78 5d 20 3d 20 61 72 67 75 6d 65 6e 74 73 5b  ex] = arguments[
0c60: 69 6e 64 65 78 20 2b 20 73 74 61 72 74 49 6e 64  index + startInd
0c70: 65 78 5d 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20  ex];.      }.   
0c80: 20 20 20 73 77 69 74 63 68 20 28 73 74 61 72 74     switch (start
0c90: 49 6e 64 65 78 29 20 7b 0a 20 20 20 20 20 20 20  Index) {.       
0ca0: 20 63 61 73 65 20 30 3a 20 72 65 74 75 72 6e 20   case 0: return 
0cb0: 66 75 6e 63 2e 63 61 6c 6c 28 74 68 69 73 2c 20  func.call(this, 
0cc0: 72 65 73 74 29 3b 0a 20 20 20 20 20 20 20 20 63  rest);.        c
0cd0: 61 73 65 20 31 3a 20 72 65 74 75 72 6e 20 66 75  ase 1: return fu
0ce0: 6e 63 2e 63 61 6c 6c 28 74 68 69 73 2c 20 61 72  nc.call(this, ar
0cf0: 67 75 6d 65 6e 74 73 5b 30 5d 2c 20 72 65 73 74  guments[0], rest
0d00: 29 3b 0a 20 20 20 20 20 20 20 20 63 61 73 65 20  );.        case 
0d10: 32 3a 20 72 65 74 75 72 6e 20 66 75 6e 63 2e 63  2: return func.c
0d20: 61 6c 6c 28 74 68 69 73 2c 20 61 72 67 75 6d 65  all(this, argume
0d30: 6e 74 73 5b 30 5d 2c 20 61 72 67 75 6d 65 6e 74  nts[0], argument
0d40: 73 5b 31 5d 2c 20 72 65 73 74 29 3b 0a 20 20 20  s[1], rest);.   
0d50: 20 20 20 7d 0a 20 20 20 20 20 20 76 61 72 20 61     }.      var a
0d60: 72 67 73 20 3d 20 41 72 72 61 79 28 73 74 61 72  rgs = Array(star
0d70: 74 49 6e 64 65 78 20 2b 20 31 29 3b 0a 20 20 20  tIndex + 1);.   
0d80: 20 20 20 66 6f 72 20 28 69 6e 64 65 78 20 3d 20     for (index = 
0d90: 30 3b 20 69 6e 64 65 78 20 3c 20 73 74 61 72 74  0; index < start
0da0: 49 6e 64 65 78 3b 20 69 6e 64 65 78 2b 2b 29 20  Index; index++) 
0db0: 7b 0a 20 20 20 20 20 20 20 20 61 72 67 73 5b 69  {.        args[i
0dc0: 6e 64 65 78 5d 20 3d 20 61 72 67 75 6d 65 6e 74  ndex] = argument
0dd0: 73 5b 69 6e 64 65 78 5d 3b 0a 20 20 20 20 20 20  s[index];.      
0de0: 7d 0a 20 20 20 20 20 20 61 72 67 73 5b 73 74 61  }.      args[sta
0df0: 72 74 49 6e 64 65 78 5d 20 3d 20 72 65 73 74 3b  rtIndex] = rest;
0e00: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 75  .      return fu
0e10: 6e 63 2e 61 70 70 6c 79 28 74 68 69 73 2c 20 61  nc.apply(this, a
0e20: 72 67 73 29 3b 0a 20 20 20 20 7d 3b 0a 20 20 7d  rgs);.    };.  }
0e30: 0a 0a 20 20 2f 2f 20 49 73 20 61 20 67 69 76 65  ..  // Is a give
0e40: 6e 20 76 61 72 69 61 62 6c 65 20 61 6e 20 6f 62  n variable an ob
0e50: 6a 65 63 74 3f 0a 20 20 66 75 6e 63 74 69 6f 6e  ject?.  function
0e60: 20 69 73 4f 62 6a 65 63 74 28 6f 62 6a 29 20 7b   isObject(obj) {
0e70: 0a 20 20 20 20 76 61 72 20 74 79 70 65 20 3d 20  .    var type = 
0e80: 74 79 70 65 6f 66 20 6f 62 6a 3b 0a 20 20 20 20  typeof obj;.    
0e90: 72 65 74 75 72 6e 20 74 79 70 65 20 3d 3d 3d 20  return type === 
0ea0: 27 66 75 6e 63 74 69 6f 6e 27 20 7c 7c 20 74 79  'function' || ty
0eb0: 70 65 20 3d 3d 3d 20 27 6f 62 6a 65 63 74 27 20  pe === 'object' 
0ec0: 26 26 20 21 21 6f 62 6a 3b 0a 20 20 7d 0a 0a 20  && !!obj;.  }.. 
0ed0: 20 2f 2f 20 49 73 20 61 20 67 69 76 65 6e 20 76   // Is a given v
0ee0: 61 6c 75 65 20 65 71 75 61 6c 20 74 6f 20 6e 75  alue equal to nu
0ef0: 6c 6c 3f 0a 20 20 66 75 6e 63 74 69 6f 6e 20 69  ll?.  function i
0f00: 73 4e 75 6c 6c 28 6f 62 6a 29 20 7b 0a 20 20 20  sNull(obj) {.   
0f10: 20 72 65 74 75 72 6e 20 6f 62 6a 20 3d 3d 3d 20   return obj === 
0f20: 6e 75 6c 6c 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20  null;.  }..  // 
0f30: 49 73 20 61 20 67 69 76 65 6e 20 76 61 72 69 61  Is a given varia
0f40: 62 6c 65 20 75 6e 64 65 66 69 6e 65 64 3f 0a 20  ble undefined?. 
0f50: 20 66 75 6e 63 74 69 6f 6e 20 69 73 55 6e 64 65   function isUnde
0f60: 66 69 6e 65 64 28 6f 62 6a 29 20 7b 0a 20 20 20  fined(obj) {.   
0f70: 20 72 65 74 75 72 6e 20 6f 62 6a 20 3d 3d 3d 20   return obj === 
0f80: 76 6f 69 64 20 30 3b 0a 20 20 7d 0a 0a 20 20 2f  void 0;.  }..  /
0f90: 2f 20 49 73 20 61 20 67 69 76 65 6e 20 76 61 6c  / Is a given val
0fa0: 75 65 20 61 20 62 6f 6f 6c 65 61 6e 3f 0a 20 20  ue a boolean?.  
0fb0: 66 75 6e 63 74 69 6f 6e 20 69 73 42 6f 6f 6c 65  function isBoole
0fc0: 61 6e 28 6f 62 6a 29 20 7b 0a 20 20 20 20 72 65  an(obj) {.    re
0fd0: 74 75 72 6e 20 6f 62 6a 20 3d 3d 3d 20 74 72 75  turn obj === tru
0fe0: 65 20 7c 7c 20 6f 62 6a 20 3d 3d 3d 20 66 61 6c  e || obj === fal
0ff0: 73 65 20 7c 7c 20 74 6f 53 74 72 69 6e 67 2e 63  se || toString.c
1000: 61 6c 6c 28 6f 62 6a 29 20 3d 3d 3d 20 27 5b 6f  all(obj) === '[o
1010: 62 6a 65 63 74 20 42 6f 6f 6c 65 61 6e 5d 27 3b  bject Boolean]';
1020: 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 73 20 61 20  .  }..  // Is a 
1030: 67 69 76 65 6e 20 76 61 6c 75 65 20 61 20 44 4f  given value a DO
1040: 4d 20 65 6c 65 6d 65 6e 74 3f 0a 20 20 66 75 6e  M element?.  fun
1050: 63 74 69 6f 6e 20 69 73 45 6c 65 6d 65 6e 74 28  ction isElement(
1060: 6f 62 6a 29 20 7b 0a 20 20 20 20 72 65 74 75 72  obj) {.    retur
1070: 6e 20 21 21 28 6f 62 6a 20 26 26 20 6f 62 6a 2e  n !!(obj && obj.
1080: 6e 6f 64 65 54 79 70 65 20 3d 3d 3d 20 31 29 3b  nodeType === 1);
1090: 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 6e 74 65 72  .  }..  // Inter
10a0: 6e 61 6c 20 66 75 6e 63 74 69 6f 6e 20 66 6f 72  nal function for
10b0: 20 63 72 65 61 74 69 6e 67 20 61 20 60 74 6f 53   creating a `toS
10c0: 74 72 69 6e 67 60 2d 62 61 73 65 64 20 74 79 70  tring`-based typ
10d0: 65 20 74 65 73 74 65 72 2e 0a 20 20 66 75 6e 63  e tester..  func
10e0: 74 69 6f 6e 20 74 61 67 54 65 73 74 65 72 28 6e  tion tagTester(n
10f0: 61 6d 65 29 20 7b 0a 20 20 20 20 76 61 72 20 74  ame) {.    var t
1100: 61 67 20 3d 20 27 5b 6f 62 6a 65 63 74 20 27 20  ag = '[object ' 
1110: 2b 20 6e 61 6d 65 20 2b 20 27 5d 27 3b 0a 20 20  + name + ']';.  
1120: 20 20 72 65 74 75 72 6e 20 66 75 6e 63 74 69 6f    return functio
1130: 6e 28 6f 62 6a 29 20 7b 0a 20 20 20 20 20 20 72  n(obj) {.      r
1140: 65 74 75 72 6e 20 74 6f 53 74 72 69 6e 67 2e 63  eturn toString.c
1150: 61 6c 6c 28 6f 62 6a 29 20 3d 3d 3d 20 74 61 67  all(obj) === tag
1160: 3b 0a 20 20 20 20 7d 3b 0a 20 20 7d 0a 0a 20 20  ;.    };.  }..  
1170: 76 61 72 20 69 73 53 74 72 69 6e 67 20 3d 20 74  var isString = t
1180: 61 67 54 65 73 74 65 72 28 27 53 74 72 69 6e 67  agTester('String
1190: 27 29 3b 0a 0a 20 20 76 61 72 20 69 73 4e 75 6d  ');..  var isNum
11a0: 62 65 72 20 3d 20 74 61 67 54 65 73 74 65 72 28  ber = tagTester(
11b0: 27 4e 75 6d 62 65 72 27 29 3b 0a 0a 20 20 76 61  'Number');..  va
11c0: 72 20 69 73 44 61 74 65 20 3d 20 74 61 67 54 65  r isDate = tagTe
11d0: 73 74 65 72 28 27 44 61 74 65 27 29 3b 0a 0a 20  ster('Date');.. 
11e0: 20 76 61 72 20 69 73 52 65 67 45 78 70 20 3d 20   var isRegExp = 
11f0: 74 61 67 54 65 73 74 65 72 28 27 52 65 67 45 78  tagTester('RegEx
1200: 70 27 29 3b 0a 0a 20 20 76 61 72 20 69 73 45 72  p');..  var isEr
1210: 72 6f 72 20 3d 20 74 61 67 54 65 73 74 65 72 28  ror = tagTester(
1220: 27 45 72 72 6f 72 27 29 3b 0a 0a 20 20 76 61 72  'Error');..  var
1230: 20 69 73 53 79 6d 62 6f 6c 20 3d 20 74 61 67 54   isSymbol = tagT
1240: 65 73 74 65 72 28 27 53 79 6d 62 6f 6c 27 29 3b  ester('Symbol');
1250: 0a 0a 20 20 76 61 72 20 69 73 41 72 72 61 79 42  ..  var isArrayB
1260: 75 66 66 65 72 20 3d 20 74 61 67 54 65 73 74 65  uffer = tagTeste
1270: 72 28 27 41 72 72 61 79 42 75 66 66 65 72 27 29  r('ArrayBuffer')
1280: 3b 0a 0a 20 20 76 61 72 20 69 73 46 75 6e 63 74  ;..  var isFunct
1290: 69 6f 6e 20 3d 20 74 61 67 54 65 73 74 65 72 28  ion = tagTester(
12a0: 27 46 75 6e 63 74 69 6f 6e 27 29 3b 0a 0a 20 20  'Function');..  
12b0: 2f 2f 20 4f 70 74 69 6d 69 7a 65 20 60 69 73 46  // Optimize `isF
12c0: 75 6e 63 74 69 6f 6e 60 20 69 66 20 61 70 70 72  unction` if appr
12d0: 6f 70 72 69 61 74 65 2e 20 57 6f 72 6b 20 61 72  opriate. Work ar
12e0: 6f 75 6e 64 20 73 6f 6d 65 20 60 74 79 70 65 6f  ound some `typeo
12f0: 66 60 20 62 75 67 73 20 69 6e 20 6f 6c 64 0a 20  f` bugs in old. 
1300: 20 2f 2f 20 76 38 2c 20 49 45 20 31 31 20 28 23   // v8, IE 11 (#
1310: 31 36 32 31 29 2c 20 53 61 66 61 72 69 20 38 20  1621), Safari 8 
1320: 28 23 31 39 32 39 29 2c 20 61 6e 64 20 50 68 61  (#1929), and Pha
1330: 6e 74 6f 6d 4a 53 20 28 23 32 32 33 36 29 2e 0a  ntomJS (#2236)..
1340: 20 20 76 61 72 20 6e 6f 64 65 6c 69 73 74 20 3d    var nodelist =
1350: 20 72 6f 6f 74 2e 64 6f 63 75 6d 65 6e 74 20 26   root.document &
1360: 26 20 72 6f 6f 74 2e 64 6f 63 75 6d 65 6e 74 2e  & root.document.
1370: 63 68 69 6c 64 4e 6f 64 65 73 3b 0a 20 20 69 66  childNodes;.  if
1380: 20 28 74 79 70 65 6f 66 20 2f 2e 2f 20 21 3d 20   (typeof /./ != 
1390: 27 66 75 6e 63 74 69 6f 6e 27 20 26 26 20 74 79  'function' && ty
13a0: 70 65 6f 66 20 49 6e 74 38 41 72 72 61 79 20 21  peof Int8Array !
13b0: 3d 20 27 6f 62 6a 65 63 74 27 20 26 26 20 74 79  = 'object' && ty
13c0: 70 65 6f 66 20 6e 6f 64 65 6c 69 73 74 20 21 3d  peof nodelist !=
13d0: 20 27 66 75 6e 63 74 69 6f 6e 27 29 20 7b 0a 20   'function') {. 
13e0: 20 20 20 69 73 46 75 6e 63 74 69 6f 6e 20 3d 20     isFunction = 
13f0: 66 75 6e 63 74 69 6f 6e 28 6f 62 6a 29 20 7b 0a  function(obj) {.
1400: 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 79 70        return typ
1410: 65 6f 66 20 6f 62 6a 20 3d 3d 20 27 66 75 6e 63  eof obj == 'func
1420: 74 69 6f 6e 27 20 7c 7c 20 66 61 6c 73 65 3b 0a  tion' || false;.
1430: 20 20 20 20 7d 3b 0a 20 20 7d 0a 0a 20 20 76 61      };.  }..  va
1440: 72 20 69 73 46 75 6e 63 74 69 6f 6e 24 31 20 3d  r isFunction$1 =
1450: 20 69 73 46 75 6e 63 74 69 6f 6e 3b 0a 0a 20 20   isFunction;..  
1460: 76 61 72 20 68 61 73 4f 62 6a 65 63 74 54 61 67  var hasObjectTag
1470: 20 3d 20 74 61 67 54 65 73 74 65 72 28 27 4f 62   = tagTester('Ob
1480: 6a 65 63 74 27 29 3b 0a 0a 20 20 2f 2f 20 49 6e  ject');..  // In
1490: 20 49 45 20 31 30 20 2d 20 45 64 67 65 20 31 33   IE 10 - Edge 13
14a0: 2c 20 60 44 61 74 61 56 69 65 77 60 20 68 61 73  , `DataView` has
14b0: 20 73 74 72 69 6e 67 20 74 61 67 20 60 27 5b 6f   string tag `'[o
14c0: 62 6a 65 63 74 20 4f 62 6a 65 63 74 5d 27 60 2e  bject Object]'`.
14d0: 0a 20 20 2f 2f 20 49 6e 20 49 45 20 31 31 2c 20  .  // In IE 11, 
14e0: 74 68 65 20 6d 6f 73 74 20 63 6f 6d 6d 6f 6e 20  the most common 
14f0: 61 6d 6f 6e 67 20 74 68 65 6d 2c 20 74 68 69 73  among them, this
1500: 20 70 72 6f 62 6c 65 6d 20 61 6c 73 6f 20 61 70   problem also ap
1510: 70 6c 69 65 73 20 74 6f 0a 20 20 2f 2f 20 60 4d  plies to.  // `M
1520: 61 70 60 2c 20 60 57 65 61 6b 4d 61 70 60 20 61  ap`, `WeakMap` a
1530: 6e 64 20 60 53 65 74 60 2e 0a 20 20 76 61 72 20  nd `Set`..  var 
1540: 68 61 73 53 74 72 69 6e 67 54 61 67 42 75 67 20  hasStringTagBug 
1550: 3d 20 28 0a 20 20 20 20 20 20 20 20 73 75 70 70  = (.        supp
1560: 6f 72 74 73 44 61 74 61 56 69 65 77 20 26 26 20  ortsDataView && 
1570: 68 61 73 4f 62 6a 65 63 74 54 61 67 28 6e 65 77  hasObjectTag(new
1580: 20 44 61 74 61 56 69 65 77 28 6e 65 77 20 41 72   DataView(new Ar
1590: 72 61 79 42 75 66 66 65 72 28 38 29 29 29 0a 20  rayBuffer(8))). 
15a0: 20 20 20 20 20 29 2c 0a 20 20 20 20 20 20 69 73       ),.      is
15b0: 49 45 31 31 20 3d 20 28 74 79 70 65 6f 66 20 4d  IE11 = (typeof M
15c0: 61 70 20 21 3d 3d 20 27 75 6e 64 65 66 69 6e 65  ap !== 'undefine
15d0: 64 27 20 26 26 20 68 61 73 4f 62 6a 65 63 74 54  d' && hasObjectT
15e0: 61 67 28 6e 65 77 20 4d 61 70 29 29 3b 0a 0a 20  ag(new Map));.. 
15f0: 20 76 61 72 20 69 73 44 61 74 61 56 69 65 77 20   var isDataView 
1600: 3d 20 74 61 67 54 65 73 74 65 72 28 27 44 61 74  = tagTester('Dat
1610: 61 56 69 65 77 27 29 3b 0a 0a 20 20 2f 2f 20 49  aView');..  // I
1620: 6e 20 49 45 20 31 30 20 2d 20 45 64 67 65 20 31  n IE 10 - Edge 1
1630: 33 2c 20 77 65 20 6e 65 65 64 20 61 20 64 69 66  3, we need a dif
1640: 66 65 72 65 6e 74 20 68 65 75 72 69 73 74 69 63  ferent heuristic
1650: 0a 20 20 2f 2f 20 74 6f 20 64 65 74 65 72 6d 69  .  // to determi
1660: 6e 65 20 77 68 65 74 68 65 72 20 61 6e 20 6f 62  ne whether an ob
1670: 6a 65 63 74 20 69 73 20 61 20 60 44 61 74 61 56  ject is a `DataV
1680: 69 65 77 60 2e 0a 20 20 66 75 6e 63 74 69 6f 6e  iew`..  function
1690: 20 69 65 31 30 49 73 44 61 74 61 56 69 65 77 28   ie10IsDataView(
16a0: 6f 62 6a 29 20 7b 0a 20 20 20 20 72 65 74 75 72  obj) {.    retur
16b0: 6e 20 6f 62 6a 20 21 3d 20 6e 75 6c 6c 20 26 26  n obj != null &&
16c0: 20 69 73 46 75 6e 63 74 69 6f 6e 24 31 28 6f 62   isFunction$1(ob
16d0: 6a 2e 67 65 74 49 6e 74 38 29 20 26 26 20 69 73  j.getInt8) && is
16e0: 41 72 72 61 79 42 75 66 66 65 72 28 6f 62 6a 2e  ArrayBuffer(obj.
16f0: 62 75 66 66 65 72 29 3b 0a 20 20 7d 0a 0a 20 20  buffer);.  }..  
1700: 76 61 72 20 69 73 44 61 74 61 56 69 65 77 24 31  var isDataView$1
1710: 20 3d 20 28 68 61 73 53 74 72 69 6e 67 54 61 67   = (hasStringTag
1720: 42 75 67 20 3f 20 69 65 31 30 49 73 44 61 74 61  Bug ? ie10IsData
1730: 56 69 65 77 20 3a 20 69 73 44 61 74 61 56 69 65  View : isDataVie
1740: 77 29 3b 0a 0a 20 20 2f 2f 20 49 73 20 61 20 67  w);..  // Is a g
1750: 69 76 65 6e 20 76 61 6c 75 65 20 61 6e 20 61 72  iven value an ar
1760: 72 61 79 3f 0a 20 20 2f 2f 20 44 65 6c 65 67 61  ray?.  // Delega
1770: 74 65 73 20 74 6f 20 45 43 4d 41 35 27 73 20 6e  tes to ECMA5's n
1780: 61 74 69 76 65 20 60 41 72 72 61 79 2e 69 73 41  ative `Array.isA
1790: 72 72 61 79 60 2e 0a 20 20 76 61 72 20 69 73 41  rray`..  var isA
17a0: 72 72 61 79 20 3d 20 6e 61 74 69 76 65 49 73 41  rray = nativeIsA
17b0: 72 72 61 79 20 7c 7c 20 74 61 67 54 65 73 74 65  rray || tagTeste
17c0: 72 28 27 41 72 72 61 79 27 29 3b 0a 0a 20 20 2f  r('Array');..  /
17d0: 2f 20 49 6e 74 65 72 6e 61 6c 20 66 75 6e 63 74  / Internal funct
17e0: 69 6f 6e 20 74 6f 20 63 68 65 63 6b 20 77 68 65  ion to check whe
17f0: 74 68 65 72 20 60 6b 65 79 60 20 69 73 20 61 6e  ther `key` is an
1800: 20 6f 77 6e 20 70 72 6f 70 65 72 74 79 20 6e 61   own property na
1810: 6d 65 20 6f 66 20 60 6f 62 6a 60 2e 0a 20 20 66  me of `obj`..  f
1820: 75 6e 63 74 69 6f 6e 20 68 61 73 28 6f 62 6a 2c  unction has(obj,
1830: 20 6b 65 79 29 20 7b 0a 20 20 20 20 72 65 74 75   key) {.    retu
1840: 72 6e 20 6f 62 6a 20 21 3d 20 6e 75 6c 6c 20 26  rn obj != null &
1850: 26 20 68 61 73 4f 77 6e 50 72 6f 70 65 72 74 79  & hasOwnProperty
1860: 2e 63 61 6c 6c 28 6f 62 6a 2c 20 6b 65 79 29 3b  .call(obj, key);
1870: 0a 20 20 7d 0a 0a 20 20 76 61 72 20 69 73 41 72  .  }..  var isAr
1880: 67 75 6d 65 6e 74 73 20 3d 20 74 61 67 54 65 73  guments = tagTes
1890: 74 65 72 28 27 41 72 67 75 6d 65 6e 74 73 27 29  ter('Arguments')
18a0: 3b 0a 0a 20 20 2f 2f 20 44 65 66 69 6e 65 20 61  ;..  // Define a
18b0: 20 66 61 6c 6c 62 61 63 6b 20 76 65 72 73 69 6f   fallback versio
18c0: 6e 20 6f 66 20 74 68 65 20 6d 65 74 68 6f 64 20  n of the method 
18d0: 69 6e 20 62 72 6f 77 73 65 72 73 20 28 61 68 65  in browsers (ahe
18e0: 6d 2c 20 49 45 20 3c 20 39 29 2c 20 77 68 65 72  m, IE < 9), wher
18f0: 65 0a 20 20 2f 2f 20 74 68 65 72 65 20 69 73 6e  e.  // there isn
1900: 27 74 20 61 6e 79 20 69 6e 73 70 65 63 74 61 62  't any inspectab
1910: 6c 65 20 22 41 72 67 75 6d 65 6e 74 73 22 20 74  le "Arguments" t
1920: 79 70 65 2e 0a 20 20 28 66 75 6e 63 74 69 6f 6e  ype..  (function
1930: 28 29 20 7b 0a 20 20 20 20 69 66 20 28 21 69 73  () {.    if (!is
1940: 41 72 67 75 6d 65 6e 74 73 28 61 72 67 75 6d 65  Arguments(argume
1950: 6e 74 73 29 29 20 7b 0a 20 20 20 20 20 20 69 73  nts)) {.      is
1960: 41 72 67 75 6d 65 6e 74 73 20 3d 20 66 75 6e 63  Arguments = func
1970: 74 69 6f 6e 28 6f 62 6a 29 20 7b 0a 20 20 20 20  tion(obj) {.    
1980: 20 20 20 20 72 65 74 75 72 6e 20 68 61 73 28 6f      return has(o
1990: 62 6a 2c 20 27 63 61 6c 6c 65 65 27 29 3b 0a 20  bj, 'callee');. 
19a0: 20 20 20 20 20 7d 3b 0a 20 20 20 20 7d 0a 20 20       };.    }.  
19b0: 7d 28 29 29 3b 0a 0a 20 20 76 61 72 20 69 73 41  }());..  var isA
19c0: 72 67 75 6d 65 6e 74 73 24 31 20 3d 20 69 73 41  rguments$1 = isA
19d0: 72 67 75 6d 65 6e 74 73 3b 0a 0a 20 20 2f 2f 20  rguments;..  // 
19e0: 49 73 20 61 20 67 69 76 65 6e 20 6f 62 6a 65 63  Is a given objec
19f0: 74 20 61 20 66 69 6e 69 74 65 20 6e 75 6d 62 65  t a finite numbe
1a00: 72 3f 0a 20 20 66 75 6e 63 74 69 6f 6e 20 69 73  r?.  function is
1a10: 46 69 6e 69 74 65 24 31 28 6f 62 6a 29 20 7b 0a  Finite$1(obj) {.
1a20: 20 20 20 20 72 65 74 75 72 6e 20 21 69 73 53 79      return !isSy
1a30: 6d 62 6f 6c 28 6f 62 6a 29 20 26 26 20 5f 69 73  mbol(obj) && _is
1a40: 46 69 6e 69 74 65 28 6f 62 6a 29 20 26 26 20 21  Finite(obj) && !
1a50: 69 73 4e 61 4e 28 70 61 72 73 65 46 6c 6f 61 74  isNaN(parseFloat
1a60: 28 6f 62 6a 29 29 3b 0a 20 20 7d 0a 0a 20 20 2f  (obj));.  }..  /
1a70: 2f 20 49 73 20 74 68 65 20 67 69 76 65 6e 20 76  / Is the given v
1a80: 61 6c 75 65 20 60 4e 61 4e 60 3f 0a 20 20 66 75  alue `NaN`?.  fu
1a90: 6e 63 74 69 6f 6e 20 69 73 4e 61 4e 24 31 28 6f  nction isNaN$1(o
1aa0: 62 6a 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e  bj) {.    return
1ab0: 20 69 73 4e 75 6d 62 65 72 28 6f 62 6a 29 20 26   isNumber(obj) &
1ac0: 26 20 5f 69 73 4e 61 4e 28 6f 62 6a 29 3b 0a 20  & _isNaN(obj);. 
1ad0: 20 7d 0a 0a 20 20 2f 2f 20 50 72 65 64 69 63 61   }..  // Predica
1ae0: 74 65 2d 67 65 6e 65 72 61 74 69 6e 67 20 66 75  te-generating fu
1af0: 6e 63 74 69 6f 6e 2e 20 4f 66 74 65 6e 20 75 73  nction. Often us
1b00: 65 66 75 6c 20 6f 75 74 73 69 64 65 20 6f 66 20  eful outside of 
1b10: 55 6e 64 65 72 73 63 6f 72 65 2e 0a 20 20 66 75  Underscore..  fu
1b20: 6e 63 74 69 6f 6e 20 63 6f 6e 73 74 61 6e 74 28  nction constant(
1b30: 76 61 6c 75 65 29 20 7b 0a 20 20 20 20 72 65 74  value) {.    ret
1b40: 75 72 6e 20 66 75 6e 63 74 69 6f 6e 28 29 20 7b  urn function() {
1b50: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 76 61  .      return va
1b60: 6c 75 65 3b 0a 20 20 20 20 7d 3b 0a 20 20 7d 0a  lue;.    };.  }.
1b70: 0a 20 20 2f 2f 20 43 6f 6d 6d 6f 6e 20 69 6e 74  .  // Common int
1b80: 65 72 6e 61 6c 20 6c 6f 67 69 63 20 66 6f 72 20  ernal logic for 
1b90: 60 69 73 41 72 72 61 79 4c 69 6b 65 60 20 61 6e  `isArrayLike` an
1ba0: 64 20 60 69 73 42 75 66 66 65 72 4c 69 6b 65 60  d `isBufferLike`
1bb0: 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 63 72 65  ..  function cre
1bc0: 61 74 65 53 69 7a 65 50 72 6f 70 65 72 74 79 43  ateSizePropertyC
1bd0: 68 65 63 6b 28 67 65 74 53 69 7a 65 50 72 6f 70  heck(getSizeProp
1be0: 65 72 74 79 29 20 7b 0a 20 20 20 20 72 65 74 75  erty) {.    retu
1bf0: 72 6e 20 66 75 6e 63 74 69 6f 6e 28 63 6f 6c 6c  rn function(coll
1c00: 65 63 74 69 6f 6e 29 20 7b 0a 20 20 20 20 20 20  ection) {.      
1c10: 76 61 72 20 73 69 7a 65 50 72 6f 70 65 72 74 79  var sizeProperty
1c20: 20 3d 20 67 65 74 53 69 7a 65 50 72 6f 70 65 72   = getSizeProper
1c30: 74 79 28 63 6f 6c 6c 65 63 74 69 6f 6e 29 3b 0a  ty(collection);.
1c40: 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 79 70        return typ
1c50: 65 6f 66 20 73 69 7a 65 50 72 6f 70 65 72 74 79  eof sizeProperty
1c60: 20 3d 3d 20 27 6e 75 6d 62 65 72 27 20 26 26 20   == 'number' && 
1c70: 73 69 7a 65 50 72 6f 70 65 72 74 79 20 3e 3d 20  sizeProperty >= 
1c80: 30 20 26 26 20 73 69 7a 65 50 72 6f 70 65 72 74  0 && sizePropert
1c90: 79 20 3c 3d 20 4d 41 58 5f 41 52 52 41 59 5f 49  y <= MAX_ARRAY_I
1ca0: 4e 44 45 58 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a  NDEX;.    }.  }.
1cb0: 0a 20 20 2f 2f 20 49 6e 74 65 72 6e 61 6c 20 68  .  // Internal h
1cc0: 65 6c 70 65 72 20 74 6f 20 67 65 6e 65 72 61 74  elper to generat
1cd0: 65 20 61 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20  e a function to 
1ce0: 6f 62 74 61 69 6e 20 70 72 6f 70 65 72 74 79 20  obtain property 
1cf0: 60 6b 65 79 60 20 66 72 6f 6d 20 60 6f 62 6a 60  `key` from `obj`
1d00: 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 73 68 61  ..  function sha
1d10: 6c 6c 6f 77 50 72 6f 70 65 72 74 79 28 6b 65 79  llowProperty(key
1d20: 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 66  ) {.    return f
1d30: 75 6e 63 74 69 6f 6e 28 6f 62 6a 29 20 7b 0a 20  unction(obj) {. 
1d40: 20 20 20 20 20 72 65 74 75 72 6e 20 6f 62 6a 20       return obj 
1d50: 3d 3d 20 6e 75 6c 6c 20 3f 20 76 6f 69 64 20 30  == null ? void 0
1d60: 20 3a 20 6f 62 6a 5b 6b 65 79 5d 3b 0a 20 20 20   : obj[key];.   
1d70: 20 7d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 6e   };.  }..  // In
1d80: 74 65 72 6e 61 6c 20 68 65 6c 70 65 72 20 74 6f  ternal helper to
1d90: 20 6f 62 74 61 69 6e 20 74 68 65 20 60 62 79 74   obtain the `byt
1da0: 65 4c 65 6e 67 74 68 60 20 70 72 6f 70 65 72 74  eLength` propert
1db0: 79 20 6f 66 20 61 6e 20 6f 62 6a 65 63 74 2e 0a  y of an object..
1dc0: 20 20 76 61 72 20 67 65 74 42 79 74 65 4c 65 6e    var getByteLen
1dd0: 67 74 68 20 3d 20 73 68 61 6c 6c 6f 77 50 72 6f  gth = shallowPro
1de0: 70 65 72 74 79 28 27 62 79 74 65 4c 65 6e 67 74  perty('byteLengt
1df0: 68 27 29 3b 0a 0a 20 20 2f 2f 20 49 6e 74 65 72  h');..  // Inter
1e00: 6e 61 6c 20 68 65 6c 70 65 72 20 74 6f 20 64 65  nal helper to de
1e10: 74 65 72 6d 69 6e 65 20 77 68 65 74 68 65 72 20  termine whether 
1e20: 77 65 20 73 68 6f 75 6c 64 20 73 70 65 6e 64 20  we should spend 
1e30: 65 78 74 65 6e 73 69 76 65 20 63 68 65 63 6b 73  extensive checks
1e40: 20 61 67 61 69 6e 73 74 0a 20 20 2f 2f 20 60 41   against.  // `A
1e50: 72 72 61 79 42 75 66 66 65 72 60 20 65 74 20 61  rrayBuffer` et a
1e60: 6c 2e 0a 20 20 76 61 72 20 69 73 42 75 66 66 65  l..  var isBuffe
1e70: 72 4c 69 6b 65 20 3d 20 63 72 65 61 74 65 53 69  rLike = createSi
1e80: 7a 65 50 72 6f 70 65 72 74 79 43 68 65 63 6b 28  zePropertyCheck(
1e90: 67 65 74 42 79 74 65 4c 65 6e 67 74 68 29 3b 0a  getByteLength);.
1ea0: 0a 20 20 2f 2f 20 49 73 20 61 20 67 69 76 65 6e  .  // Is a given
1eb0: 20 76 61 6c 75 65 20 61 20 74 79 70 65 64 20 61   value a typed a
1ec0: 72 72 61 79 3f 0a 20 20 76 61 72 20 74 79 70 65  rray?.  var type
1ed0: 64 41 72 72 61 79 50 61 74 74 65 72 6e 20 3d 20  dArrayPattern = 
1ee0: 2f 5c 5b 6f 62 6a 65 63 74 20 28 28 49 7c 55 69  /\[object ((I|Ui
1ef0: 29 6e 74 28 38 7c 31 36 7c 33 32 29 7c 46 6c 6f  )nt(8|16|32)|Flo
1f00: 61 74 28 33 32 7c 36 34 29 7c 55 69 6e 74 38 43  at(32|64)|Uint8C
1f10: 6c 61 6d 70 65 64 7c 42 69 67 28 49 7c 55 69 29  lamped|Big(I|Ui)
1f20: 6e 74 36 34 29 41 72 72 61 79 5c 5d 2f 3b 0a 20  nt64)Array\]/;. 
1f30: 20 66 75 6e 63 74 69 6f 6e 20 69 73 54 79 70 65   function isType
1f40: 64 41 72 72 61 79 28 6f 62 6a 29 20 7b 0a 20 20  dArray(obj) {.  
1f50: 20 20 2f 2f 20 60 41 72 72 61 79 42 75 66 66 65    // `ArrayBuffe
1f60: 72 2e 69 73 56 69 65 77 60 20 69 73 20 74 68 65  r.isView` is the
1f70: 20 6d 6f 73 74 20 66 75 74 75 72 65 2d 70 72 6f   most future-pro
1f80: 6f 66 2c 20 73 6f 20 75 73 65 20 69 74 20 77 68  of, so use it wh
1f90: 65 6e 20 61 76 61 69 6c 61 62 6c 65 2e 0a 20 20  en available..  
1fa0: 20 20 2f 2f 20 4f 74 68 65 72 77 69 73 65 2c 20    // Otherwise, 
1fb0: 66 61 6c 6c 20 62 61 63 6b 20 6f 6e 20 74 68 65  fall back on the
1fc0: 20 61 62 6f 76 65 20 72 65 67 75 6c 61 72 20 65   above regular e
1fd0: 78 70 72 65 73 73 69 6f 6e 2e 0a 20 20 20 20 72  xpression..    r
1fe0: 65 74 75 72 6e 20 6e 61 74 69 76 65 49 73 56 69  eturn nativeIsVi
1ff0: 65 77 20 3f 20 28 6e 61 74 69 76 65 49 73 56 69  ew ? (nativeIsVi
2000: 65 77 28 6f 62 6a 29 20 26 26 20 21 69 73 44 61  ew(obj) && !isDa
2010: 74 61 56 69 65 77 24 31 28 6f 62 6a 29 29 20 3a  taView$1(obj)) :
2020: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2030: 20 20 20 69 73 42 75 66 66 65 72 4c 69 6b 65 28     isBufferLike(
2040: 6f 62 6a 29 20 26 26 20 74 79 70 65 64 41 72 72  obj) && typedArr
2050: 61 79 50 61 74 74 65 72 6e 2e 74 65 73 74 28 74  ayPattern.test(t
2060: 6f 53 74 72 69 6e 67 2e 63 61 6c 6c 28 6f 62 6a  oString.call(obj
2070: 29 29 3b 0a 20 20 7d 0a 0a 20 20 76 61 72 20 69  ));.  }..  var i
2080: 73 54 79 70 65 64 41 72 72 61 79 24 31 20 3d 20  sTypedArray$1 = 
2090: 73 75 70 70 6f 72 74 73 41 72 72 61 79 42 75 66  supportsArrayBuf
20a0: 66 65 72 20 3f 20 69 73 54 79 70 65 64 41 72 72  fer ? isTypedArr
20b0: 61 79 20 3a 20 63 6f 6e 73 74 61 6e 74 28 66 61  ay : constant(fa
20c0: 6c 73 65 29 3b 0a 0a 20 20 2f 2f 20 49 6e 74 65  lse);..  // Inte
20d0: 72 6e 61 6c 20 68 65 6c 70 65 72 20 74 6f 20 6f  rnal helper to o
20e0: 62 74 61 69 6e 20 74 68 65 20 60 6c 65 6e 67 74  btain the `lengt
20f0: 68 60 20 70 72 6f 70 65 72 74 79 20 6f 66 20 61  h` property of a
2100: 6e 20 6f 62 6a 65 63 74 2e 0a 20 20 76 61 72 20  n object..  var 
2110: 67 65 74 4c 65 6e 67 74 68 20 3d 20 73 68 61 6c  getLength = shal
2120: 6c 6f 77 50 72 6f 70 65 72 74 79 28 27 6c 65 6e  lowProperty('len
2130: 67 74 68 27 29 3b 0a 0a 20 20 2f 2f 20 49 6e 74  gth');..  // Int
2140: 65 72 6e 61 6c 20 68 65 6c 70 65 72 20 74 6f 20  ernal helper to 
2150: 63 72 65 61 74 65 20 61 20 73 69 6d 70 6c 65 20  create a simple 
2160: 6c 6f 6f 6b 75 70 20 73 74 72 75 63 74 75 72 65  lookup structure
2170: 2e 0a 20 20 2f 2f 20 60 63 6f 6c 6c 65 63 74 4e  ..  // `collectN
2180: 6f 6e 45 6e 75 6d 50 72 6f 70 73 60 20 75 73 65  onEnumProps` use
2190: 64 20 74 6f 20 64 65 70 65 6e 64 20 6f 6e 20 60  d to depend on `
21a0: 5f 2e 63 6f 6e 74 61 69 6e 73 60 2c 20 62 75 74  _.contains`, but
21b0: 20 74 68 69 73 20 6c 65 64 20 74 6f 0a 20 20 2f   this led to.  /
21c0: 2f 20 63 69 72 63 75 6c 61 72 20 69 6d 70 6f 72  / circular impor
21d0: 74 73 2e 20 60 65 6d 75 6c 61 74 65 64 53 65 74  ts. `emulatedSet
21e0: 60 20 69 73 20 61 20 6f 6e 65 2d 6f 66 66 20 73  ` is a one-off s
21f0: 6f 6c 75 74 69 6f 6e 20 74 68 61 74 20 6f 6e 6c  olution that onl
2200: 79 20 77 6f 72 6b 73 20 66 6f 72 0a 20 20 2f 2f  y works for.  //
2210: 20 61 72 72 61 79 73 20 6f 66 20 73 74 72 69 6e   arrays of strin
2220: 67 73 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 65  gs..  function e
2230: 6d 75 6c 61 74 65 64 53 65 74 28 6b 65 79 73 29  mulatedSet(keys)
2240: 20 7b 0a 20 20 20 20 76 61 72 20 68 61 73 68 20   {.    var hash 
2250: 3d 20 7b 7d 3b 0a 20 20 20 20 66 6f 72 20 28 76  = {};.    for (v
2260: 61 72 20 6c 20 3d 20 6b 65 79 73 2e 6c 65 6e 67  ar l = keys.leng
2270: 74 68 2c 20 69 20 3d 20 30 3b 20 69 20 3c 20 6c  th, i = 0; i < l
2280: 3b 20 2b 2b 69 29 20 68 61 73 68 5b 6b 65 79 73  ; ++i) hash[keys
2290: 5b 69 5d 5d 20 3d 20 74 72 75 65 3b 0a 20 20 20  [i]] = true;.   
22a0: 20 72 65 74 75 72 6e 20 7b 0a 20 20 20 20 20 20   return {.      
22b0: 63 6f 6e 74 61 69 6e 73 3a 20 66 75 6e 63 74 69  contains: functi
22c0: 6f 6e 28 6b 65 79 29 20 7b 20 72 65 74 75 72 6e  on(key) { return
22d0: 20 68 61 73 68 5b 6b 65 79 5d 3b 20 7d 2c 0a 20   hash[key]; },. 
22e0: 20 20 20 20 20 70 75 73 68 3a 20 66 75 6e 63 74       push: funct
22f0: 69 6f 6e 28 6b 65 79 29 20 7b 0a 20 20 20 20 20  ion(key) {.     
2300: 20 20 20 68 61 73 68 5b 6b 65 79 5d 20 3d 20 74     hash[key] = t
2310: 72 75 65 3b 0a 20 20 20 20 20 20 20 20 72 65 74  rue;.        ret
2320: 75 72 6e 20 6b 65 79 73 2e 70 75 73 68 28 6b 65  urn keys.push(ke
2330: 79 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20  y);.      }.    
2340: 7d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 6e 74  };.  }..  // Int
2350: 65 72 6e 61 6c 20 68 65 6c 70 65 72 2e 20 43 68  ernal helper. Ch
2360: 65 63 6b 73 20 60 6b 65 79 73 60 20 66 6f 72 20  ecks `keys` for 
2370: 74 68 65 20 70 72 65 73 65 6e 63 65 20 6f 66 20  the presence of 
2380: 6b 65 79 73 20 69 6e 20 49 45 20 3c 20 39 20 74  keys in IE < 9 t
2390: 68 61 74 20 77 6f 6e 27 74 0a 20 20 2f 2f 20 62  hat won't.  // b
23a0: 65 20 69 74 65 72 61 74 65 64 20 62 79 20 60 66  e iterated by `f
23b0: 6f 72 20 6b 65 79 20 69 6e 20 2e 2e 2e 60 20 61  or key in ...` a
23c0: 6e 64 20 74 68 75 73 20 6d 69 73 73 65 64 2e 20  nd thus missed. 
23d0: 45 78 74 65 6e 64 73 20 60 6b 65 79 73 60 20 69  Extends `keys` i
23e0: 6e 20 70 6c 61 63 65 20 69 66 0a 20 20 2f 2f 20  n place if.  // 
23f0: 6e 65 65 64 65 64 2e 0a 20 20 66 75 6e 63 74 69  needed..  functi
2400: 6f 6e 20 63 6f 6c 6c 65 63 74 4e 6f 6e 45 6e 75  on collectNonEnu
2410: 6d 50 72 6f 70 73 28 6f 62 6a 2c 20 6b 65 79 73  mProps(obj, keys
2420: 29 20 7b 0a 20 20 20 20 6b 65 79 73 20 3d 20 65  ) {.    keys = e
2430: 6d 75 6c 61 74 65 64 53 65 74 28 6b 65 79 73 29  mulatedSet(keys)
2440: 3b 0a 20 20 20 20 76 61 72 20 6e 6f 6e 45 6e 75  ;.    var nonEnu
2450: 6d 49 64 78 20 3d 20 6e 6f 6e 45 6e 75 6d 65 72  mIdx = nonEnumer
2460: 61 62 6c 65 50 72 6f 70 73 2e 6c 65 6e 67 74 68  ableProps.length
2470: 3b 0a 20 20 20 20 76 61 72 20 63 6f 6e 73 74 72  ;.    var constr
2480: 75 63 74 6f 72 20 3d 20 6f 62 6a 2e 63 6f 6e 73  uctor = obj.cons
2490: 74 72 75 63 74 6f 72 3b 0a 20 20 20 20 76 61 72  tructor;.    var
24a0: 20 70 72 6f 74 6f 20 3d 20 69 73 46 75 6e 63 74   proto = isFunct
24b0: 69 6f 6e 24 31 28 63 6f 6e 73 74 72 75 63 74 6f  ion$1(constructo
24c0: 72 29 20 26 26 20 63 6f 6e 73 74 72 75 63 74 6f  r) && constructo
24d0: 72 2e 70 72 6f 74 6f 74 79 70 65 20 7c 7c 20 4f  r.prototype || O
24e0: 62 6a 50 72 6f 74 6f 3b 0a 0a 20 20 20 20 2f 2f  bjProto;..    //
24f0: 20 43 6f 6e 73 74 72 75 63 74 6f 72 20 69 73 20   Constructor is 
2500: 61 20 73 70 65 63 69 61 6c 20 63 61 73 65 2e 0a  a special case..
2510: 20 20 20 20 76 61 72 20 70 72 6f 70 20 3d 20 27      var prop = '
2520: 63 6f 6e 73 74 72 75 63 74 6f 72 27 3b 0a 20 20  constructor';.  
2530: 20 20 69 66 20 28 68 61 73 28 6f 62 6a 2c 20 70    if (has(obj, p
2540: 72 6f 70 29 20 26 26 20 21 6b 65 79 73 2e 63 6f  rop) && !keys.co
2550: 6e 74 61 69 6e 73 28 70 72 6f 70 29 29 20 6b 65  ntains(prop)) ke
2560: 79 73 2e 70 75 73 68 28 70 72 6f 70 29 3b 0a 0a  ys.push(prop);..
2570: 20 20 20 20 77 68 69 6c 65 20 28 6e 6f 6e 45 6e      while (nonEn
2580: 75 6d 49 64 78 2d 2d 29 20 7b 0a 20 20 20 20 20  umIdx--) {.     
2590: 20 70 72 6f 70 20 3d 20 6e 6f 6e 45 6e 75 6d 65   prop = nonEnume
25a0: 72 61 62 6c 65 50 72 6f 70 73 5b 6e 6f 6e 45 6e  rableProps[nonEn
25b0: 75 6d 49 64 78 5d 3b 0a 20 20 20 20 20 20 69 66  umIdx];.      if
25c0: 20 28 70 72 6f 70 20 69 6e 20 6f 62 6a 20 26 26   (prop in obj &&
25d0: 20 6f 62 6a 5b 70 72 6f 70 5d 20 21 3d 3d 20 70   obj[prop] !== p
25e0: 72 6f 74 6f 5b 70 72 6f 70 5d 20 26 26 20 21 6b  roto[prop] && !k
25f0: 65 79 73 2e 63 6f 6e 74 61 69 6e 73 28 70 72 6f  eys.contains(pro
2600: 70 29 29 20 7b 0a 20 20 20 20 20 20 20 20 6b 65  p)) {.        ke
2610: 79 73 2e 70 75 73 68 28 70 72 6f 70 29 3b 0a 20  ys.push(prop);. 
2620: 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20 7d       }.    }.  }
2630: 0a 0a 20 20 2f 2f 20 52 65 74 72 69 65 76 65 20  ..  // Retrieve 
2640: 74 68 65 20 6e 61 6d 65 73 20 6f 66 20 61 6e 20  the names of an 
2650: 6f 62 6a 65 63 74 27 73 20 6f 77 6e 20 70 72 6f  object's own pro
2660: 70 65 72 74 69 65 73 2e 0a 20 20 2f 2f 20 44 65  perties..  // De
2670: 6c 65 67 61 74 65 73 20 74 6f 20 2a 2a 45 43 4d  legates to **ECM
2680: 41 53 63 72 69 70 74 20 35 2a 2a 27 73 20 6e 61  AScript 5**'s na
2690: 74 69 76 65 20 60 4f 62 6a 65 63 74 2e 6b 65 79  tive `Object.key
26a0: 73 60 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 6b  s`..  function k
26b0: 65 79 73 28 6f 62 6a 29 20 7b 0a 20 20 20 20 69  eys(obj) {.    i
26c0: 66 20 28 21 69 73 4f 62 6a 65 63 74 28 6f 62 6a  f (!isObject(obj
26d0: 29 29 20 72 65 74 75 72 6e 20 5b 5d 3b 0a 20 20  )) return [];.  
26e0: 20 20 69 66 20 28 6e 61 74 69 76 65 4b 65 79 73    if (nativeKeys
26f0: 29 20 72 65 74 75 72 6e 20 6e 61 74 69 76 65 4b  ) return nativeK
2700: 65 79 73 28 6f 62 6a 29 3b 0a 20 20 20 20 76 61  eys(obj);.    va
2710: 72 20 6b 65 79 73 20 3d 20 5b 5d 3b 0a 20 20 20  r keys = [];.   
2720: 20 66 6f 72 20 28 76 61 72 20 6b 65 79 20 69 6e   for (var key in
2730: 20 6f 62 6a 29 20 69 66 20 28 68 61 73 28 6f 62   obj) if (has(ob
2740: 6a 2c 20 6b 65 79 29 29 20 6b 65 79 73 2e 70 75  j, key)) keys.pu
2750: 73 68 28 6b 65 79 29 3b 0a 20 20 20 20 2f 2f 20  sh(key);.    // 
2760: 41 68 65 6d 2c 20 49 45 20 3c 20 39 2e 0a 20 20  Ahem, IE < 9..  
2770: 20 20 69 66 20 28 68 61 73 45 6e 75 6d 42 75 67    if (hasEnumBug
2780: 29 20 63 6f 6c 6c 65 63 74 4e 6f 6e 45 6e 75 6d  ) collectNonEnum
2790: 50 72 6f 70 73 28 6f 62 6a 2c 20 6b 65 79 73 29  Props(obj, keys)
27a0: 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 6b 65 79  ;.    return key
27b0: 73 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 73 20  s;.  }..  // Is 
27c0: 61 20 67 69 76 65 6e 20 61 72 72 61 79 2c 20 73  a given array, s
27d0: 74 72 69 6e 67 2c 20 6f 72 20 6f 62 6a 65 63 74  tring, or object
27e0: 20 65 6d 70 74 79 3f 0a 20 20 2f 2f 20 41 6e 20   empty?.  // An 
27f0: 22 65 6d 70 74 79 22 20 6f 62 6a 65 63 74 20 68  "empty" object h
2800: 61 73 20 6e 6f 20 65 6e 75 6d 65 72 61 62 6c 65  as no enumerable
2810: 20 6f 77 6e 2d 70 72 6f 70 65 72 74 69 65 73 2e   own-properties.
2820: 0a 20 20 66 75 6e 63 74 69 6f 6e 20 69 73 45 6d  .  function isEm
2830: 70 74 79 28 6f 62 6a 29 20 7b 0a 20 20 20 20 69  pty(obj) {.    i
2840: 66 20 28 6f 62 6a 20 3d 3d 20 6e 75 6c 6c 29 20  f (obj == null) 
2850: 72 65 74 75 72 6e 20 74 72 75 65 3b 0a 20 20 20  return true;.   
2860: 20 2f 2f 20 53 6b 69 70 20 74 68 65 20 6d 6f 72   // Skip the mor
2870: 65 20 65 78 70 65 6e 73 69 76 65 20 60 74 6f 53  e expensive `toS
2880: 74 72 69 6e 67 60 2d 62 61 73 65 64 20 74 79 70  tring`-based typ
2890: 65 20 63 68 65 63 6b 73 20 69 66 20 60 6f 62 6a  e checks if `obj
28a0: 60 20 68 61 73 20 6e 6f 0a 20 20 20 20 2f 2f 20  ` has no.    // 
28b0: 60 2e 6c 65 6e 67 74 68 60 2e 0a 20 20 20 20 76  `.length`..    v
28c0: 61 72 20 6c 65 6e 67 74 68 20 3d 20 67 65 74 4c  ar length = getL
28d0: 65 6e 67 74 68 28 6f 62 6a 29 3b 0a 20 20 20 20  ength(obj);.    
28e0: 69 66 20 28 74 79 70 65 6f 66 20 6c 65 6e 67 74  if (typeof lengt
28f0: 68 20 3d 3d 20 27 6e 75 6d 62 65 72 27 20 26 26  h == 'number' &&
2900: 20 28 0a 20 20 20 20 20 20 69 73 41 72 72 61 79   (.      isArray
2910: 28 6f 62 6a 29 20 7c 7c 20 69 73 53 74 72 69 6e  (obj) || isStrin
2920: 67 28 6f 62 6a 29 20 7c 7c 20 69 73 41 72 67 75  g(obj) || isArgu
2930: 6d 65 6e 74 73 24 31 28 6f 62 6a 29 0a 20 20 20  ments$1(obj).   
2940: 20 29 29 20 72 65 74 75 72 6e 20 6c 65 6e 67 74   )) return lengt
2950: 68 20 3d 3d 3d 20 30 3b 0a 20 20 20 20 72 65 74  h === 0;.    ret
2960: 75 72 6e 20 67 65 74 4c 65 6e 67 74 68 28 6b 65  urn getLength(ke
2970: 79 73 28 6f 62 6a 29 29 20 3d 3d 3d 20 30 3b 0a  ys(obj)) === 0;.
2980: 20 20 7d 0a 0a 20 20 2f 2f 20 52 65 74 75 72 6e    }..  // Return
2990: 73 20 77 68 65 74 68 65 72 20 61 6e 20 6f 62 6a  s whether an obj
29a0: 65 63 74 20 68 61 73 20 61 20 67 69 76 65 6e 20  ect has a given 
29b0: 73 65 74 20 6f 66 20 60 6b 65 79 3a 76 61 6c 75  set of `key:valu
29c0: 65 60 20 70 61 69 72 73 2e 0a 20 20 66 75 6e 63  e` pairs..  func
29d0: 74 69 6f 6e 20 69 73 4d 61 74 63 68 28 6f 62 6a  tion isMatch(obj
29e0: 65 63 74 2c 20 61 74 74 72 73 29 20 7b 0a 20 20  ect, attrs) {.  
29f0: 20 20 76 61 72 20 5f 6b 65 79 73 20 3d 20 6b 65    var _keys = ke
2a00: 79 73 28 61 74 74 72 73 29 2c 20 6c 65 6e 67 74  ys(attrs), lengt
2a10: 68 20 3d 20 5f 6b 65 79 73 2e 6c 65 6e 67 74 68  h = _keys.length
2a20: 3b 0a 20 20 20 20 69 66 20 28 6f 62 6a 65 63 74  ;.    if (object
2a30: 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 75 72 6e   == null) return
2a40: 20 21 6c 65 6e 67 74 68 3b 0a 20 20 20 20 76 61   !length;.    va
2a50: 72 20 6f 62 6a 20 3d 20 4f 62 6a 65 63 74 28 6f  r obj = Object(o
2a60: 62 6a 65 63 74 29 3b 0a 20 20 20 20 66 6f 72 20  bject);.    for 
2a70: 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20  (var i = 0; i < 
2a80: 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20 7b 0a 20  length; i++) {. 
2a90: 20 20 20 20 20 76 61 72 20 6b 65 79 20 3d 20 5f       var key = _
2aa0: 6b 65 79 73 5b 69 5d 3b 0a 20 20 20 20 20 20 69  keys[i];.      i
2ab0: 66 20 28 61 74 74 72 73 5b 6b 65 79 5d 20 21 3d  f (attrs[key] !=
2ac0: 3d 20 6f 62 6a 5b 6b 65 79 5d 20 7c 7c 20 21 28  = obj[key] || !(
2ad0: 6b 65 79 20 69 6e 20 6f 62 6a 29 29 20 72 65 74  key in obj)) ret
2ae0: 75 72 6e 20 66 61 6c 73 65 3b 0a 20 20 20 20 7d  urn false;.    }
2af0: 0a 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65  .    return true
2b00: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 66 20 55  ;.  }..  // If U
2b10: 6e 64 65 72 73 63 6f 72 65 20 69 73 20 63 61 6c  nderscore is cal
2b20: 6c 65 64 20 61 73 20 61 20 66 75 6e 63 74 69 6f  led as a functio
2b30: 6e 2c 20 69 74 20 72 65 74 75 72 6e 73 20 61 20  n, it returns a 
2b40: 77 72 61 70 70 65 64 20 6f 62 6a 65 63 74 20 74  wrapped object t
2b50: 68 61 74 20 63 61 6e 0a 20 20 2f 2f 20 62 65 20  hat can.  // be 
2b60: 75 73 65 64 20 4f 4f 2d 73 74 79 6c 65 2e 20 54  used OO-style. T
2b70: 68 69 73 20 77 72 61 70 70 65 72 20 68 6f 6c 64  his wrapper hold
2b80: 73 20 61 6c 74 65 72 65 64 20 76 65 72 73 69 6f  s altered versio
2b90: 6e 73 20 6f 66 20 61 6c 6c 20 66 75 6e 63 74 69  ns of all functi
2ba0: 6f 6e 73 20 61 64 64 65 64 0a 20 20 2f 2f 20 74  ons added.  // t
2bb0: 68 72 6f 75 67 68 20 60 5f 2e 6d 69 78 69 6e 60  hrough `_.mixin`
2bc0: 2e 20 57 72 61 70 70 65 64 20 6f 62 6a 65 63 74  . Wrapped object
2bd0: 73 20 6d 61 79 20 62 65 20 63 68 61 69 6e 65 64  s may be chained
2be0: 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 5f 28 6f  ..  function _(o
2bf0: 62 6a 29 20 7b 0a 20 20 20 20 69 66 20 28 6f 62  bj) {.    if (ob
2c00: 6a 20 69 6e 73 74 61 6e 63 65 6f 66 20 5f 29 20  j instanceof _) 
2c10: 72 65 74 75 72 6e 20 6f 62 6a 3b 0a 20 20 20 20  return obj;.    
2c20: 69 66 20 28 21 28 74 68 69 73 20 69 6e 73 74 61  if (!(this insta
2c30: 6e 63 65 6f 66 20 5f 29 29 20 72 65 74 75 72 6e  nceof _)) return
2c40: 20 6e 65 77 20 5f 28 6f 62 6a 29 3b 0a 20 20 20   new _(obj);.   
2c50: 20 74 68 69 73 2e 5f 77 72 61 70 70 65 64 20 3d   this._wrapped =
2c60: 20 6f 62 6a 3b 0a 20 20 7d 0a 0a 20 20 5f 2e 56   obj;.  }..  _.V
2c70: 45 52 53 49 4f 4e 20 3d 20 56 45 52 53 49 4f 4e  ERSION = VERSION
2c80: 3b 0a 0a 20 20 2f 2f 20 45 78 74 72 61 63 74 73  ;..  // Extracts
2c90: 20 74 68 65 20 72 65 73 75 6c 74 20 66 72 6f 6d   the result from
2ca0: 20 61 20 77 72 61 70 70 65 64 20 61 6e 64 20 63   a wrapped and c
2cb0: 68 61 69 6e 65 64 20 6f 62 6a 65 63 74 2e 0a 20  hained object.. 
2cc0: 20 5f 2e 70 72 6f 74 6f 74 79 70 65 2e 76 61 6c   _.prototype.val
2cd0: 75 65 20 3d 20 66 75 6e 63 74 69 6f 6e 28 29 20  ue = function() 
2ce0: 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 74 68 69  {.    return thi
2cf0: 73 2e 5f 77 72 61 70 70 65 64 3b 0a 20 20 7d 3b  s._wrapped;.  };
2d00: 0a 0a 20 20 2f 2f 20 50 72 6f 76 69 64 65 20 75  ..  // Provide u
2d10: 6e 77 72 61 70 70 69 6e 67 20 70 72 6f 78 69 65  nwrapping proxie
2d20: 73 20 66 6f 72 20 73 6f 6d 65 20 6d 65 74 68 6f  s for some metho
2d30: 64 73 20 75 73 65 64 20 69 6e 20 65 6e 67 69 6e  ds used in engin
2d40: 65 20 6f 70 65 72 61 74 69 6f 6e 73 0a 20 20 2f  e operations.  /
2d50: 2f 20 73 75 63 68 20 61 73 20 61 72 69 74 68 6d  / such as arithm
2d60: 65 74 69 63 20 61 6e 64 20 4a 53 4f 4e 20 73 74  etic and JSON st
2d70: 72 69 6e 67 69 66 69 63 61 74 69 6f 6e 2e 0a 20  ringification.. 
2d80: 20 5f 2e 70 72 6f 74 6f 74 79 70 65 2e 76 61 6c   _.prototype.val
2d90: 75 65 4f 66 20 3d 20 5f 2e 70 72 6f 74 6f 74 79  ueOf = _.prototy
2da0: 70 65 2e 74 6f 4a 53 4f 4e 20 3d 20 5f 2e 70 72  pe.toJSON = _.pr
2db0: 6f 74 6f 74 79 70 65 2e 76 61 6c 75 65 3b 0a 0a  ototype.value;..
2dc0: 20 20 5f 2e 70 72 6f 74 6f 74 79 70 65 2e 74 6f    _.prototype.to
2dd0: 53 74 72 69 6e 67 20 3d 20 66 75 6e 63 74 69 6f  String = functio
2de0: 6e 28 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e  n() {.    return
2df0: 20 53 74 72 69 6e 67 28 74 68 69 73 2e 5f 77 72   String(this._wr
2e00: 61 70 70 65 64 29 3b 0a 20 20 7d 3b 0a 0a 20 20  apped);.  };..  
2e10: 2f 2f 20 49 6e 74 65 72 6e 61 6c 20 66 75 6e 63  // Internal func
2e20: 74 69 6f 6e 20 74 6f 20 77 72 61 70 20 6f 72 20  tion to wrap or 
2e30: 73 68 61 6c 6c 6f 77 2d 63 6f 70 79 20 61 6e 20  shallow-copy an 
2e40: 41 72 72 61 79 42 75 66 66 65 72 2c 0a 20 20 2f  ArrayBuffer,.  /
2e50: 2f 20 74 79 70 65 64 20 61 72 72 61 79 20 6f 72  / typed array or
2e60: 20 44 61 74 61 56 69 65 77 20 74 6f 20 61 20 6e   DataView to a n
2e70: 65 77 20 76 69 65 77 2c 20 72 65 75 73 69 6e 67  ew view, reusing
2e80: 20 74 68 65 20 62 75 66 66 65 72 2e 0a 20 20 66   the buffer..  f
2e90: 75 6e 63 74 69 6f 6e 20 74 6f 42 75 66 66 65 72  unction toBuffer
2ea0: 56 69 65 77 28 62 75 66 66 65 72 53 6f 75 72 63  View(bufferSourc
2eb0: 65 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e 20  e) {.    return 
2ec0: 6e 65 77 20 55 69 6e 74 38 41 72 72 61 79 28 0a  new Uint8Array(.
2ed0: 20 20 20 20 20 20 62 75 66 66 65 72 53 6f 75 72        bufferSour
2ee0: 63 65 2e 62 75 66 66 65 72 20 7c 7c 20 62 75 66  ce.buffer || buf
2ef0: 66 65 72 53 6f 75 72 63 65 2c 0a 20 20 20 20 20  ferSource,.     
2f00: 20 62 75 66 66 65 72 53 6f 75 72 63 65 2e 62 79   bufferSource.by
2f10: 74 65 4f 66 66 73 65 74 20 7c 7c 20 30 2c 0a 20  teOffset || 0,. 
2f20: 20 20 20 20 20 67 65 74 42 79 74 65 4c 65 6e 67       getByteLeng
2f30: 74 68 28 62 75 66 66 65 72 53 6f 75 72 63 65 29  th(bufferSource)
2f40: 0a 20 20 20 20 29 3b 0a 20 20 7d 0a 0a 20 20 2f  .    );.  }..  /
2f50: 2f 20 57 65 20 75 73 65 20 74 68 69 73 20 73 74  / We use this st
2f60: 72 69 6e 67 20 74 77 69 63 65 2c 20 73 6f 20 67  ring twice, so g
2f70: 69 76 65 20 69 74 20 61 20 6e 61 6d 65 20 66 6f  ive it a name fo
2f80: 72 20 6d 69 6e 69 66 69 63 61 74 69 6f 6e 2e 0a  r minification..
2f90: 20 20 76 61 72 20 74 61 67 44 61 74 61 56 69 65    var tagDataVie
2fa0: 77 20 3d 20 27 5b 6f 62 6a 65 63 74 20 44 61 74  w = '[object Dat
2fb0: 61 56 69 65 77 5d 27 3b 0a 0a 20 20 2f 2f 20 49  aView]';..  // I
2fc0: 6e 74 65 72 6e 61 6c 20 72 65 63 75 72 73 69 76  nternal recursiv
2fd0: 65 20 63 6f 6d 70 61 72 69 73 6f 6e 20 66 75 6e  e comparison fun
2fe0: 63 74 69 6f 6e 20 66 6f 72 20 60 5f 2e 69 73 45  ction for `_.isE
2ff0: 71 75 61 6c 60 2e 0a 20 20 66 75 6e 63 74 69 6f  qual`..  functio
3000: 6e 20 65 71 28 61 2c 20 62 2c 20 61 53 74 61 63  n eq(a, b, aStac
3010: 6b 2c 20 62 53 74 61 63 6b 29 20 7b 0a 20 20 20  k, bStack) {.   
3020: 20 2f 2f 20 49 64 65 6e 74 69 63 61 6c 20 6f 62   // Identical ob
3030: 6a 65 63 74 73 20 61 72 65 20 65 71 75 61 6c 2e  jects are equal.
3040: 20 60 30 20 3d 3d 3d 20 2d 30 60 2c 20 62 75 74   `0 === -0`, but
3050: 20 74 68 65 79 20 61 72 65 6e 27 74 20 69 64 65   they aren't ide
3060: 6e 74 69 63 61 6c 2e 0a 20 20 20 20 2f 2f 20 53  ntical..    // S
3070: 65 65 20 74 68 65 20 5b 48 61 72 6d 6f 6e 79 20  ee the [Harmony 
3080: 60 65 67 61 6c 60 20 70 72 6f 70 6f 73 61 6c 5d  `egal` proposal]
3090: 28 68 74 74 70 73 3a 2f 2f 77 69 6b 69 2e 65 63  (https://wiki.ec
30a0: 6d 61 73 63 72 69 70 74 2e 6f 72 67 2f 64 6f 6b  mascript.org/dok
30b0: 75 2e 70 68 70 3f 69 64 3d 68 61 72 6d 6f 6e 79  u.php?id=harmony
30c0: 3a 65 67 61 6c 29 2e 0a 20 20 20 20 69 66 20 28  :egal)..    if (
30d0: 61 20 3d 3d 3d 20 62 29 20 72 65 74 75 72 6e 20  a === b) return 
30e0: 61 20 21 3d 3d 20 30 20 7c 7c 20 31 20 2f 20 61  a !== 0 || 1 / a
30f0: 20 3d 3d 3d 20 31 20 2f 20 62 3b 0a 20 20 20 20   === 1 / b;.    
3100: 2f 2f 20 60 6e 75 6c 6c 60 20 6f 72 20 60 75 6e  // `null` or `un
3110: 64 65 66 69 6e 65 64 60 20 6f 6e 6c 79 20 65 71  defined` only eq
3120: 75 61 6c 20 74 6f 20 69 74 73 65 6c 66 20 28 73  ual to itself (s
3130: 74 72 69 63 74 20 63 6f 6d 70 61 72 69 73 6f 6e  trict comparison
3140: 29 2e 0a 20 20 20 20 69 66 20 28 61 20 3d 3d 20  )..    if (a == 
3150: 6e 75 6c 6c 20 7c 7c 20 62 20 3d 3d 20 6e 75 6c  null || b == nul
3160: 6c 29 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b  l) return false;
3170: 0a 20 20 20 20 2f 2f 20 60 4e 61 4e 60 73 20 61  .    // `NaN`s a
3180: 72 65 20 65 71 75 69 76 61 6c 65 6e 74 2c 20 62  re equivalent, b
3190: 75 74 20 6e 6f 6e 2d 72 65 66 6c 65 78 69 76 65  ut non-reflexive
31a0: 2e 0a 20 20 20 20 69 66 20 28 61 20 21 3d 3d 20  ..    if (a !== 
31b0: 61 29 20 72 65 74 75 72 6e 20 62 20 21 3d 3d 20  a) return b !== 
31c0: 62 3b 0a 20 20 20 20 2f 2f 20 45 78 68 61 75 73  b;.    // Exhaus
31d0: 74 20 70 72 69 6d 69 74 69 76 65 20 63 68 65 63  t primitive chec
31e0: 6b 73 0a 20 20 20 20 76 61 72 20 74 79 70 65 20  ks.    var type 
31f0: 3d 20 74 79 70 65 6f 66 20 61 3b 0a 20 20 20 20  = typeof a;.    
3200: 69 66 20 28 74 79 70 65 20 21 3d 3d 20 27 66 75  if (type !== 'fu
3210: 6e 63 74 69 6f 6e 27 20 26 26 20 74 79 70 65 20  nction' && type 
3220: 21 3d 3d 20 27 6f 62 6a 65 63 74 27 20 26 26 20  !== 'object' && 
3230: 74 79 70 65 6f 66 20 62 20 21 3d 20 27 6f 62 6a  typeof b != 'obj
3240: 65 63 74 27 29 20 72 65 74 75 72 6e 20 66 61 6c  ect') return fal
3250: 73 65 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 64  se;.    return d
3260: 65 65 70 45 71 28 61 2c 20 62 2c 20 61 53 74 61  eepEq(a, b, aSta
3270: 63 6b 2c 20 62 53 74 61 63 6b 29 3b 0a 20 20 7d  ck, bStack);.  }
3280: 0a 0a 20 20 2f 2f 20 49 6e 74 65 72 6e 61 6c 20  ..  // Internal 
3290: 72 65 63 75 72 73 69 76 65 20 63 6f 6d 70 61 72  recursive compar
32a0: 69 73 6f 6e 20 66 75 6e 63 74 69 6f 6e 20 66 6f  ison function fo
32b0: 72 20 60 5f 2e 69 73 45 71 75 61 6c 60 2e 0a 20  r `_.isEqual`.. 
32c0: 20 66 75 6e 63 74 69 6f 6e 20 64 65 65 70 45 71   function deepEq
32d0: 28 61 2c 20 62 2c 20 61 53 74 61 63 6b 2c 20 62  (a, b, aStack, b
32e0: 53 74 61 63 6b 29 20 7b 0a 20 20 20 20 2f 2f 20  Stack) {.    // 
32f0: 55 6e 77 72 61 70 20 61 6e 79 20 77 72 61 70 70  Unwrap any wrapp
3300: 65 64 20 6f 62 6a 65 63 74 73 2e 0a 20 20 20 20  ed objects..    
3310: 69 66 20 28 61 20 69 6e 73 74 61 6e 63 65 6f 66  if (a instanceof
3320: 20 5f 29 20 61 20 3d 20 61 2e 5f 77 72 61 70 70   _) a = a._wrapp
3330: 65 64 3b 0a 20 20 20 20 69 66 20 28 62 20 69 6e  ed;.    if (b in
3340: 73 74 61 6e 63 65 6f 66 20 5f 29 20 62 20 3d 20  stanceof _) b = 
3350: 62 2e 5f 77 72 61 70 70 65 64 3b 0a 20 20 20 20  b._wrapped;.    
3360: 2f 2f 20 43 6f 6d 70 61 72 65 20 60 5b 5b 43 6c  // Compare `[[Cl
3370: 61 73 73 5d 5d 60 20 6e 61 6d 65 73 2e 0a 20 20  ass]]` names..  
3380: 20 20 76 61 72 20 63 6c 61 73 73 4e 61 6d 65 20    var className 
3390: 3d 20 74 6f 53 74 72 69 6e 67 2e 63 61 6c 6c 28  = toString.call(
33a0: 61 29 3b 0a 20 20 20 20 69 66 20 28 63 6c 61 73  a);.    if (clas
33b0: 73 4e 61 6d 65 20 21 3d 3d 20 74 6f 53 74 72 69  sName !== toStri
33c0: 6e 67 2e 63 61 6c 6c 28 62 29 29 20 72 65 74 75  ng.call(b)) retu
33d0: 72 6e 20 66 61 6c 73 65 3b 0a 20 20 20 20 2f 2f  rn false;.    //
33e0: 20 57 6f 72 6b 20 61 72 6f 75 6e 64 20 61 20 62   Work around a b
33f0: 75 67 20 69 6e 20 49 45 20 31 30 20 2d 20 45 64  ug in IE 10 - Ed
3400: 67 65 20 31 33 2e 0a 20 20 20 20 69 66 20 28 68  ge 13..    if (h
3410: 61 73 53 74 72 69 6e 67 54 61 67 42 75 67 20 26  asStringTagBug &
3420: 26 20 63 6c 61 73 73 4e 61 6d 65 20 3d 3d 20 27  & className == '
3430: 5b 6f 62 6a 65 63 74 20 4f 62 6a 65 63 74 5d 27  [object Object]'
3440: 20 26 26 20 69 73 44 61 74 61 56 69 65 77 24 31   && isDataView$1
3450: 28 61 29 29 20 7b 0a 20 20 20 20 20 20 69 66 20  (a)) {.      if 
3460: 28 21 69 73 44 61 74 61 56 69 65 77 24 31 28 62  (!isDataView$1(b
3470: 29 29 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b  )) return false;
3480: 0a 20 20 20 20 20 20 63 6c 61 73 73 4e 61 6d 65  .      className
3490: 20 3d 20 74 61 67 44 61 74 61 56 69 65 77 3b 0a   = tagDataView;.
34a0: 20 20 20 20 7d 0a 20 20 20 20 73 77 69 74 63 68      }.    switch
34b0: 20 28 63 6c 61 73 73 4e 61 6d 65 29 20 7b 0a 20   (className) {. 
34c0: 20 20 20 20 20 2f 2f 20 54 68 65 73 65 20 74 79       // These ty
34d0: 70 65 73 20 61 72 65 20 63 6f 6d 70 61 72 65 64  pes are compared
34e0: 20 62 79 20 76 61 6c 75 65 2e 0a 20 20 20 20 20   by value..     
34f0: 20 63 61 73 65 20 27 5b 6f 62 6a 65 63 74 20 52   case '[object R
3500: 65 67 45 78 70 5d 27 3a 0a 20 20 20 20 20 20 20  egExp]':.       
3510: 20 2f 2f 20 52 65 67 45 78 70 73 20 61 72 65 20   // RegExps are 
3520: 63 6f 65 72 63 65 64 20 74 6f 20 73 74 72 69 6e  coerced to strin
3530: 67 73 20 66 6f 72 20 63 6f 6d 70 61 72 69 73 6f  gs for compariso
3540: 6e 20 28 4e 6f 74 65 3a 20 27 27 20 2b 20 2f 61  n (Note: '' + /a
3550: 2f 69 20 3d 3d 3d 20 27 2f 61 2f 69 27 29 0a 20  /i === '/a/i'). 
3560: 20 20 20 20 20 63 61 73 65 20 27 5b 6f 62 6a 65       case '[obje
3570: 63 74 20 53 74 72 69 6e 67 5d 27 3a 0a 20 20 20  ct String]':.   
3580: 20 20 20 20 20 2f 2f 20 50 72 69 6d 69 74 69 76       // Primitiv
3590: 65 73 20 61 6e 64 20 74 68 65 69 72 20 63 6f 72  es and their cor
35a0: 72 65 73 70 6f 6e 64 69 6e 67 20 6f 62 6a 65 63  responding objec
35b0: 74 20 77 72 61 70 70 65 72 73 20 61 72 65 20 65  t wrappers are e
35c0: 71 75 69 76 61 6c 65 6e 74 3b 20 74 68 75 73 2c  quivalent; thus,
35d0: 20 60 22 35 22 60 20 69 73 0a 20 20 20 20 20 20   `"5"` is.      
35e0: 20 20 2f 2f 20 65 71 75 69 76 61 6c 65 6e 74 20    // equivalent 
35f0: 74 6f 20 60 6e 65 77 20 53 74 72 69 6e 67 28 22  to `new String("
3600: 35 22 29 60 2e 0a 20 20 20 20 20 20 20 20 72 65  5")`..        re
3610: 74 75 72 6e 20 27 27 20 2b 20 61 20 3d 3d 3d 20  turn '' + a === 
3620: 27 27 20 2b 20 62 3b 0a 20 20 20 20 20 20 63 61  '' + b;.      ca
3630: 73 65 20 27 5b 6f 62 6a 65 63 74 20 4e 75 6d 62  se '[object Numb
3640: 65 72 5d 27 3a 0a 20 20 20 20 20 20 20 20 2f 2f  er]':.        //
3650: 20 60 4e 61 4e 60 73 20 61 72 65 20 65 71 75 69   `NaN`s are equi
3660: 76 61 6c 65 6e 74 2c 20 62 75 74 20 6e 6f 6e 2d  valent, but non-
3670: 72 65 66 6c 65 78 69 76 65 2e 0a 20 20 20 20 20  reflexive..     
3680: 20 20 20 2f 2f 20 4f 62 6a 65 63 74 28 4e 61 4e     // Object(NaN
3690: 29 20 69 73 20 65 71 75 69 76 61 6c 65 6e 74 20  ) is equivalent 
36a0: 74 6f 20 4e 61 4e 2e 0a 20 20 20 20 20 20 20 20  to NaN..        
36b0: 69 66 20 28 2b 61 20 21 3d 3d 20 2b 61 29 20 72  if (+a !== +a) r
36c0: 65 74 75 72 6e 20 2b 62 20 21 3d 3d 20 2b 62 3b  eturn +b !== +b;
36d0: 0a 20 20 20 20 20 20 20 20 2f 2f 20 41 6e 20 60  .        // An `
36e0: 65 67 61 6c 60 20 63 6f 6d 70 61 72 69 73 6f 6e  egal` comparison
36f0: 20 69 73 20 70 65 72 66 6f 72 6d 65 64 20 66 6f   is performed fo
3700: 72 20 6f 74 68 65 72 20 6e 75 6d 65 72 69 63 20  r other numeric 
3710: 76 61 6c 75 65 73 2e 0a 20 20 20 20 20 20 20 20  values..        
3720: 72 65 74 75 72 6e 20 2b 61 20 3d 3d 3d 20 30 20  return +a === 0 
3730: 3f 20 31 20 2f 20 2b 61 20 3d 3d 3d 20 31 20 2f  ? 1 / +a === 1 /
3740: 20 62 20 3a 20 2b 61 20 3d 3d 3d 20 2b 62 3b 0a   b : +a === +b;.
3750: 20 20 20 20 20 20 63 61 73 65 20 27 5b 6f 62 6a        case '[obj
3760: 65 63 74 20 44 61 74 65 5d 27 3a 0a 20 20 20 20  ect Date]':.    
3770: 20 20 63 61 73 65 20 27 5b 6f 62 6a 65 63 74 20    case '[object 
3780: 42 6f 6f 6c 65 61 6e 5d 27 3a 0a 20 20 20 20 20  Boolean]':.     
3790: 20 20 20 2f 2f 20 43 6f 65 72 63 65 20 64 61 74     // Coerce dat
37a0: 65 73 20 61 6e 64 20 62 6f 6f 6c 65 61 6e 73 20  es and booleans 
37b0: 74 6f 20 6e 75 6d 65 72 69 63 20 70 72 69 6d 69  to numeric primi
37c0: 74 69 76 65 20 76 61 6c 75 65 73 2e 20 44 61 74  tive values. Dat
37d0: 65 73 20 61 72 65 20 63 6f 6d 70 61 72 65 64 20  es are compared 
37e0: 62 79 20 74 68 65 69 72 0a 20 20 20 20 20 20 20  by their.       
37f0: 20 2f 2f 20 6d 69 6c 6c 69 73 65 63 6f 6e 64 20   // millisecond 
3800: 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 73 2e  representations.
3810: 20 4e 6f 74 65 20 74 68 61 74 20 69 6e 76 61 6c   Note that inval
3820: 69 64 20 64 61 74 65 73 20 77 69 74 68 20 6d 69  id dates with mi
3830: 6c 6c 69 73 65 63 6f 6e 64 20 72 65 70 72 65 73  llisecond repres
3840: 65 6e 74 61 74 69 6f 6e 73 0a 20 20 20 20 20 20  entations.      
3850: 20 20 2f 2f 20 6f 66 20 60 4e 61 4e 60 20 61 72    // of `NaN` ar
3860: 65 20 6e 6f 74 20 65 71 75 69 76 61 6c 65 6e 74  e not equivalent
3870: 2e 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e  ..        return
3880: 20 2b 61 20 3d 3d 3d 20 2b 62 3b 0a 20 20 20 20   +a === +b;.    
3890: 20 20 63 61 73 65 20 27 5b 6f 62 6a 65 63 74 20    case '[object 
38a0: 53 79 6d 62 6f 6c 5d 27 3a 0a 20 20 20 20 20 20  Symbol]':.      
38b0: 20 20 72 65 74 75 72 6e 20 53 79 6d 62 6f 6c 50    return SymbolP
38c0: 72 6f 74 6f 2e 76 61 6c 75 65 4f 66 2e 63 61 6c  roto.valueOf.cal
38d0: 6c 28 61 29 20 3d 3d 3d 20 53 79 6d 62 6f 6c 50  l(a) === SymbolP
38e0: 72 6f 74 6f 2e 76 61 6c 75 65 4f 66 2e 63 61 6c  roto.valueOf.cal
38f0: 6c 28 62 29 3b 0a 20 20 20 20 20 20 63 61 73 65  l(b);.      case
3900: 20 27 5b 6f 62 6a 65 63 74 20 41 72 72 61 79 42   '[object ArrayB
3910: 75 66 66 65 72 5d 27 3a 0a 20 20 20 20 20 20 63  uffer]':.      c
3920: 61 73 65 20 74 61 67 44 61 74 61 56 69 65 77 3a  ase tagDataView:
3930: 0a 20 20 20 20 20 20 20 20 2f 2f 20 43 6f 65 72  .        // Coer
3940: 63 65 20 74 6f 20 74 79 70 65 64 20 61 72 72 61  ce to typed arra
3950: 79 20 73 6f 20 77 65 20 63 61 6e 20 66 61 6c 6c  y so we can fall
3960: 20 74 68 72 6f 75 67 68 2e 0a 20 20 20 20 20 20   through..      
3970: 20 20 72 65 74 75 72 6e 20 64 65 65 70 45 71 28    return deepEq(
3980: 74 6f 42 75 66 66 65 72 56 69 65 77 28 61 29 2c  toBufferView(a),
3990: 20 74 6f 42 75 66 66 65 72 56 69 65 77 28 62 29   toBufferView(b)
39a0: 2c 20 61 53 74 61 63 6b 2c 20 62 53 74 61 63 6b  , aStack, bStack
39b0: 29 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 76 61  );.    }..    va
39c0: 72 20 61 72 65 41 72 72 61 79 73 20 3d 20 63 6c  r areArrays = cl
39d0: 61 73 73 4e 61 6d 65 20 3d 3d 3d 20 27 5b 6f 62  assName === '[ob
39e0: 6a 65 63 74 20 41 72 72 61 79 5d 27 3b 0a 20 20  ject Array]';.  
39f0: 20 20 69 66 20 28 21 61 72 65 41 72 72 61 79 73    if (!areArrays
3a00: 20 26 26 20 69 73 54 79 70 65 64 41 72 72 61 79   && isTypedArray
3a10: 24 31 28 61 29 29 20 7b 0a 20 20 20 20 20 20 20  $1(a)) {.       
3a20: 20 76 61 72 20 62 79 74 65 4c 65 6e 67 74 68 20   var byteLength 
3a30: 3d 20 67 65 74 42 79 74 65 4c 65 6e 67 74 68 28  = getByteLength(
3a40: 61 29 3b 0a 20 20 20 20 20 20 20 20 69 66 20 28  a);.        if (
3a50: 62 79 74 65 4c 65 6e 67 74 68 20 21 3d 3d 20 67  byteLength !== g
3a60: 65 74 42 79 74 65 4c 65 6e 67 74 68 28 62 29 29  etByteLength(b))
3a70: 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0a 20   return false;. 
3a80: 20 20 20 20 20 20 20 69 66 20 28 61 2e 62 75 66         if (a.buf
3a90: 66 65 72 20 3d 3d 3d 20 62 2e 62 75 66 66 65 72  fer === b.buffer
3aa0: 20 26 26 20 61 2e 62 79 74 65 4f 66 66 73 65 74   && a.byteOffset
3ab0: 20 3d 3d 3d 20 62 2e 62 79 74 65 4f 66 66 73 65   === b.byteOffse
3ac0: 74 29 20 72 65 74 75 72 6e 20 74 72 75 65 3b 0a  t) return true;.
3ad0: 20 20 20 20 20 20 20 20 61 72 65 41 72 72 61 79          areArray
3ae0: 73 20 3d 20 74 72 75 65 3b 0a 20 20 20 20 7d 0a  s = true;.    }.
3af0: 20 20 20 20 69 66 20 28 21 61 72 65 41 72 72 61      if (!areArra
3b00: 79 73 29 20 7b 0a 20 20 20 20 20 20 69 66 20 28  ys) {.      if (
3b10: 74 79 70 65 6f 66 20 61 20 21 3d 20 27 6f 62 6a  typeof a != 'obj
3b20: 65 63 74 27 20 7c 7c 20 74 79 70 65 6f 66 20 62  ect' || typeof b
3b30: 20 21 3d 20 27 6f 62 6a 65 63 74 27 29 20 72 65   != 'object') re
3b40: 74 75 72 6e 20 66 61 6c 73 65 3b 0a 0a 20 20 20  turn false;..   
3b50: 20 20 20 2f 2f 20 4f 62 6a 65 63 74 73 20 77 69     // Objects wi
3b60: 74 68 20 64 69 66 66 65 72 65 6e 74 20 63 6f 6e  th different con
3b70: 73 74 72 75 63 74 6f 72 73 20 61 72 65 20 6e 6f  structors are no
3b80: 74 20 65 71 75 69 76 61 6c 65 6e 74 2c 20 62 75  t equivalent, bu
3b90: 74 20 60 4f 62 6a 65 63 74 60 73 20 6f 72 20 60  t `Object`s or `
3ba0: 41 72 72 61 79 60 73 0a 20 20 20 20 20 20 2f 2f  Array`s.      //
3bb0: 20 66 72 6f 6d 20 64 69 66 66 65 72 65 6e 74 20   from different 
3bc0: 66 72 61 6d 65 73 20 61 72 65 2e 0a 20 20 20 20  frames are..    
3bd0: 20 20 76 61 72 20 61 43 74 6f 72 20 3d 20 61 2e    var aCtor = a.
3be0: 63 6f 6e 73 74 72 75 63 74 6f 72 2c 20 62 43 74  constructor, bCt
3bf0: 6f 72 20 3d 20 62 2e 63 6f 6e 73 74 72 75 63 74  or = b.construct
3c00: 6f 72 3b 0a 20 20 20 20 20 20 69 66 20 28 61 43  or;.      if (aC
3c10: 74 6f 72 20 21 3d 3d 20 62 43 74 6f 72 20 26 26  tor !== bCtor &&
3c20: 20 21 28 69 73 46 75 6e 63 74 69 6f 6e 24 31 28   !(isFunction$1(
3c30: 61 43 74 6f 72 29 20 26 26 20 61 43 74 6f 72 20  aCtor) && aCtor 
3c40: 69 6e 73 74 61 6e 63 65 6f 66 20 61 43 74 6f 72  instanceof aCtor
3c50: 20 26 26 0a 20 20 20 20 20 20 20 20 20 20 20 20   &&.            
3c60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3c70: 20 20 20 69 73 46 75 6e 63 74 69 6f 6e 24 31 28     isFunction$1(
3c80: 62 43 74 6f 72 29 20 26 26 20 62 43 74 6f 72 20  bCtor) && bCtor 
3c90: 69 6e 73 74 61 6e 63 65 6f 66 20 62 43 74 6f 72  instanceof bCtor
3ca0: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ).              
3cb0: 20 20 20 20 20 20 20 20 20 20 20 20 26 26 20 28              && (
3cc0: 27 63 6f 6e 73 74 72 75 63 74 6f 72 27 20 69 6e  'constructor' in
3cd0: 20 61 20 26 26 20 27 63 6f 6e 73 74 72 75 63 74   a && 'construct
3ce0: 6f 72 27 20 69 6e 20 62 29 29 20 7b 0a 20 20 20  or' in b)) {.   
3cf0: 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73       return fals
3d00: 65 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d  e;.      }.    }
3d10: 0a 20 20 20 20 2f 2f 20 41 73 73 75 6d 65 20 65  .    // Assume e
3d20: 71 75 61 6c 69 74 79 20 66 6f 72 20 63 79 63 6c  quality for cycl
3d30: 69 63 20 73 74 72 75 63 74 75 72 65 73 2e 20 54  ic structures. T
3d40: 68 65 20 61 6c 67 6f 72 69 74 68 6d 20 66 6f 72  he algorithm for
3d50: 20 64 65 74 65 63 74 69 6e 67 20 63 79 63 6c 69   detecting cycli
3d60: 63 0a 20 20 20 20 2f 2f 20 73 74 72 75 63 74 75  c.    // structu
3d70: 72 65 73 20 69 73 20 61 64 61 70 74 65 64 20 66  res is adapted f
3d80: 72 6f 6d 20 45 53 20 35 2e 31 20 73 65 63 74 69  rom ES 5.1 secti
3d90: 6f 6e 20 31 35 2e 31 32 2e 33 2c 20 61 62 73 74  on 15.12.3, abst
3da0: 72 61 63 74 20 6f 70 65 72 61 74 69 6f 6e 20 60  ract operation `
3db0: 4a 4f 60 2e 0a 0a 20 20 20 20 2f 2f 20 49 6e 69  JO`...    // Ini
3dc0: 74 69 61 6c 69 7a 69 6e 67 20 73 74 61 63 6b 20  tializing stack 
3dd0: 6f 66 20 74 72 61 76 65 72 73 65 64 20 6f 62 6a  of traversed obj
3de0: 65 63 74 73 2e 0a 20 20 20 20 2f 2f 20 49 74 27  ects..    // It'
3df0: 73 20 64 6f 6e 65 20 68 65 72 65 20 73 69 6e 63  s done here sinc
3e00: 65 20 77 65 20 6f 6e 6c 79 20 6e 65 65 64 20 74  e we only need t
3e10: 68 65 6d 20 66 6f 72 20 6f 62 6a 65 63 74 73 20  hem for objects 
3e20: 61 6e 64 20 61 72 72 61 79 73 20 63 6f 6d 70 61  and arrays compa
3e30: 72 69 73 6f 6e 2e 0a 20 20 20 20 61 53 74 61 63  rison..    aStac
3e40: 6b 20 3d 20 61 53 74 61 63 6b 20 7c 7c 20 5b 5d  k = aStack || []
3e50: 3b 0a 20 20 20 20 62 53 74 61 63 6b 20 3d 20 62  ;.    bStack = b
3e60: 53 74 61 63 6b 20 7c 7c 20 5b 5d 3b 0a 20 20 20  Stack || [];.   
3e70: 20 76 61 72 20 6c 65 6e 67 74 68 20 3d 20 61 53   var length = aS
3e80: 74 61 63 6b 2e 6c 65 6e 67 74 68 3b 0a 20 20 20  tack.length;.   
3e90: 20 77 68 69 6c 65 20 28 6c 65 6e 67 74 68 2d 2d   while (length--
3ea0: 29 20 7b 0a 20 20 20 20 20 20 2f 2f 20 4c 69 6e  ) {.      // Lin
3eb0: 65 61 72 20 73 65 61 72 63 68 2e 20 50 65 72 66  ear search. Perf
3ec0: 6f 72 6d 61 6e 63 65 20 69 73 20 69 6e 76 65 72  ormance is inver
3ed0: 73 65 6c 79 20 70 72 6f 70 6f 72 74 69 6f 6e 61  sely proportiona
3ee0: 6c 20 74 6f 20 74 68 65 20 6e 75 6d 62 65 72 20  l to the number 
3ef0: 6f 66 0a 20 20 20 20 20 20 2f 2f 20 75 6e 69 71  of.      // uniq
3f00: 75 65 20 6e 65 73 74 65 64 20 73 74 72 75 63 74  ue nested struct
3f10: 75 72 65 73 2e 0a 20 20 20 20 20 20 69 66 20 28  ures..      if (
3f20: 61 53 74 61 63 6b 5b 6c 65 6e 67 74 68 5d 20 3d  aStack[length] =
3f30: 3d 3d 20 61 29 20 72 65 74 75 72 6e 20 62 53 74  == a) return bSt
3f40: 61 63 6b 5b 6c 65 6e 67 74 68 5d 20 3d 3d 3d 20  ack[length] === 
3f50: 62 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 2f 2f  b;.    }..    //
3f60: 20 41 64 64 20 74 68 65 20 66 69 72 73 74 20 6f   Add the first o
3f70: 62 6a 65 63 74 20 74 6f 20 74 68 65 20 73 74 61  bject to the sta
3f80: 63 6b 20 6f 66 20 74 72 61 76 65 72 73 65 64 20  ck of traversed 
3f90: 6f 62 6a 65 63 74 73 2e 0a 20 20 20 20 61 53 74  objects..    aSt
3fa0: 61 63 6b 2e 70 75 73 68 28 61 29 3b 0a 20 20 20  ack.push(a);.   
3fb0: 20 62 53 74 61 63 6b 2e 70 75 73 68 28 62 29 3b   bStack.push(b);
3fc0: 0a 0a 20 20 20 20 2f 2f 20 52 65 63 75 72 73 69  ..    // Recursi
3fd0: 76 65 6c 79 20 63 6f 6d 70 61 72 65 20 6f 62 6a  vely compare obj
3fe0: 65 63 74 73 20 61 6e 64 20 61 72 72 61 79 73 2e  ects and arrays.
3ff0: 0a 20 20 20 20 69 66 20 28 61 72 65 41 72 72 61  .    if (areArra
4000: 79 73 29 20 7b 0a 20 20 20 20 20 20 2f 2f 20 43  ys) {.      // C
4010: 6f 6d 70 61 72 65 20 61 72 72 61 79 20 6c 65 6e  ompare array len
4020: 67 74 68 73 20 74 6f 20 64 65 74 65 72 6d 69 6e  gths to determin
4030: 65 20 69 66 20 61 20 64 65 65 70 20 63 6f 6d 70  e if a deep comp
4040: 61 72 69 73 6f 6e 20 69 73 20 6e 65 63 65 73 73  arison is necess
4050: 61 72 79 2e 0a 20 20 20 20 20 20 6c 65 6e 67 74  ary..      lengt
4060: 68 20 3d 20 61 2e 6c 65 6e 67 74 68 3b 0a 20 20  h = a.length;.  
4070: 20 20 20 20 69 66 20 28 6c 65 6e 67 74 68 20 21      if (length !
4080: 3d 3d 20 62 2e 6c 65 6e 67 74 68 29 20 72 65 74  == b.length) ret
4090: 75 72 6e 20 66 61 6c 73 65 3b 0a 20 20 20 20 20  urn false;.     
40a0: 20 2f 2f 20 44 65 65 70 20 63 6f 6d 70 61 72 65   // Deep compare
40b0: 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 2c 20 69   the contents, i
40c0: 67 6e 6f 72 69 6e 67 20 6e 6f 6e 2d 6e 75 6d 65  gnoring non-nume
40d0: 72 69 63 20 70 72 6f 70 65 72 74 69 65 73 2e 0a  ric properties..
40e0: 20 20 20 20 20 20 77 68 69 6c 65 20 28 6c 65 6e        while (len
40f0: 67 74 68 2d 2d 29 20 7b 0a 20 20 20 20 20 20 20  gth--) {.       
4100: 20 69 66 20 28 21 65 71 28 61 5b 6c 65 6e 67 74   if (!eq(a[lengt
4110: 68 5d 2c 20 62 5b 6c 65 6e 67 74 68 5d 2c 20 61  h], b[length], a
4120: 53 74 61 63 6b 2c 20 62 53 74 61 63 6b 29 29 20  Stack, bStack)) 
4130: 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0a 20 20  return false;.  
4140: 20 20 20 20 7d 0a 20 20 20 20 7d 20 65 6c 73 65      }.    } else
4150: 20 7b 0a 20 20 20 20 20 20 2f 2f 20 44 65 65 70   {.      // Deep
4160: 20 63 6f 6d 70 61 72 65 20 6f 62 6a 65 63 74 73   compare objects
4170: 2e 0a 20 20 20 20 20 20 76 61 72 20 5f 6b 65 79  ..      var _key
4180: 73 20 3d 20 6b 65 79 73 28 61 29 2c 20 6b 65 79  s = keys(a), key
4190: 3b 0a 20 20 20 20 20 20 6c 65 6e 67 74 68 20 3d  ;.      length =
41a0: 20 5f 6b 65 79 73 2e 6c 65 6e 67 74 68 3b 0a 20   _keys.length;. 
41b0: 20 20 20 20 20 2f 2f 20 45 6e 73 75 72 65 20 74       // Ensure t
41c0: 68 61 74 20 62 6f 74 68 20 6f 62 6a 65 63 74 73  hat both objects
41d0: 20 63 6f 6e 74 61 69 6e 20 74 68 65 20 73 61 6d   contain the sam
41e0: 65 20 6e 75 6d 62 65 72 20 6f 66 20 70 72 6f 70  e number of prop
41f0: 65 72 74 69 65 73 20 62 65 66 6f 72 65 20 63 6f  erties before co
4200: 6d 70 61 72 69 6e 67 20 64 65 65 70 20 65 71 75  mparing deep equ
4210: 61 6c 69 74 79 2e 0a 20 20 20 20 20 20 69 66 20  ality..      if 
4220: 28 6b 65 79 73 28 62 29 2e 6c 65 6e 67 74 68 20  (keys(b).length 
4230: 21 3d 3d 20 6c 65 6e 67 74 68 29 20 72 65 74 75  !== length) retu
4240: 72 6e 20 66 61 6c 73 65 3b 0a 20 20 20 20 20 20  rn false;.      
4250: 77 68 69 6c 65 20 28 6c 65 6e 67 74 68 2d 2d 29  while (length--)
4260: 20 7b 0a 20 20 20 20 20 20 20 20 2f 2f 20 44 65   {.        // De
4270: 65 70 20 63 6f 6d 70 61 72 65 20 65 61 63 68 20  ep compare each 
4280: 6d 65 6d 62 65 72 0a 20 20 20 20 20 20 20 20 6b  member.        k
4290: 65 79 20 3d 20 5f 6b 65 79 73 5b 6c 65 6e 67 74  ey = _keys[lengt
42a0: 68 5d 3b 0a 20 20 20 20 20 20 20 20 69 66 20 28  h];.        if (
42b0: 21 28 68 61 73 28 62 2c 20 6b 65 79 29 20 26 26  !(has(b, key) &&
42c0: 20 65 71 28 61 5b 6b 65 79 5d 2c 20 62 5b 6b 65   eq(a[key], b[ke
42d0: 79 5d 2c 20 61 53 74 61 63 6b 2c 20 62 53 74 61  y], aStack, bSta
42e0: 63 6b 29 29 29 20 72 65 74 75 72 6e 20 66 61 6c  ck))) return fal
42f0: 73 65 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20  se;.      }.    
4300: 7d 0a 20 20 20 20 2f 2f 20 52 65 6d 6f 76 65 20  }.    // Remove 
4310: 74 68 65 20 66 69 72 73 74 20 6f 62 6a 65 63 74  the first object
4320: 20 66 72 6f 6d 20 74 68 65 20 73 74 61 63 6b 20   from the stack 
4330: 6f 66 20 74 72 61 76 65 72 73 65 64 20 6f 62 6a  of traversed obj
4340: 65 63 74 73 2e 0a 20 20 20 20 61 53 74 61 63 6b  ects..    aStack
4350: 2e 70 6f 70 28 29 3b 0a 20 20 20 20 62 53 74 61  .pop();.    bSta
4360: 63 6b 2e 70 6f 70 28 29 3b 0a 20 20 20 20 72 65  ck.pop();.    re
4370: 74 75 72 6e 20 74 72 75 65 3b 0a 20 20 7d 0a 0a  turn true;.  }..
4380: 20 20 2f 2f 20 50 65 72 66 6f 72 6d 20 61 20 64    // Perform a d
4390: 65 65 70 20 63 6f 6d 70 61 72 69 73 6f 6e 20 74  eep comparison t
43a0: 6f 20 63 68 65 63 6b 20 69 66 20 74 77 6f 20 6f  o check if two o
43b0: 62 6a 65 63 74 73 20 61 72 65 20 65 71 75 61 6c  bjects are equal
43c0: 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 69 73 45  ..  function isE
43d0: 71 75 61 6c 28 61 2c 20 62 29 20 7b 0a 20 20 20  qual(a, b) {.   
43e0: 20 72 65 74 75 72 6e 20 65 71 28 61 2c 20 62 29   return eq(a, b)
43f0: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52 65 74 72  ;.  }..  // Retr
4400: 69 65 76 65 20 61 6c 6c 20 74 68 65 20 65 6e 75  ieve all the enu
4410: 6d 65 72 61 62 6c 65 20 70 72 6f 70 65 72 74 79  merable property
4420: 20 6e 61 6d 65 73 20 6f 66 20 61 6e 20 6f 62 6a   names of an obj
4430: 65 63 74 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20  ect..  function 
4440: 61 6c 6c 4b 65 79 73 28 6f 62 6a 29 20 7b 0a 20  allKeys(obj) {. 
4450: 20 20 20 69 66 20 28 21 69 73 4f 62 6a 65 63 74     if (!isObject
4460: 28 6f 62 6a 29 29 20 72 65 74 75 72 6e 20 5b 5d  (obj)) return []
4470: 3b 0a 20 20 20 20 76 61 72 20 6b 65 79 73 20 3d  ;.    var keys =
4480: 20 5b 5d 3b 0a 20 20 20 20 66 6f 72 20 28 76 61   [];.    for (va
4490: 72 20 6b 65 79 20 69 6e 20 6f 62 6a 29 20 6b 65  r key in obj) ke
44a0: 79 73 2e 70 75 73 68 28 6b 65 79 29 3b 0a 20 20  ys.push(key);.  
44b0: 20 20 2f 2f 20 41 68 65 6d 2c 20 49 45 20 3c 20    // Ahem, IE < 
44c0: 39 2e 0a 20 20 20 20 69 66 20 28 68 61 73 45 6e  9..    if (hasEn
44d0: 75 6d 42 75 67 29 20 63 6f 6c 6c 65 63 74 4e 6f  umBug) collectNo
44e0: 6e 45 6e 75 6d 50 72 6f 70 73 28 6f 62 6a 2c 20  nEnumProps(obj, 
44f0: 6b 65 79 73 29 3b 0a 20 20 20 20 72 65 74 75 72  keys);.    retur
4500: 6e 20 6b 65 79 73 3b 0a 20 20 7d 0a 0a 20 20 2f  n keys;.  }..  /
4510: 2f 20 53 69 6e 63 65 20 74 68 65 20 72 65 67 75  / Since the regu
4520: 6c 61 72 20 60 4f 62 6a 65 63 74 2e 70 72 6f 74  lar `Object.prot
4530: 6f 74 79 70 65 2e 74 6f 53 74 72 69 6e 67 60 20  otype.toString` 
4540: 74 79 70 65 20 74 65 73 74 73 20 64 6f 6e 27 74  type tests don't
4550: 20 77 6f 72 6b 20 66 6f 72 0a 20 20 2f 2f 20 73   work for.  // s
4560: 6f 6d 65 20 74 79 70 65 73 20 69 6e 20 49 45 20  ome types in IE 
4570: 31 31 2c 20 77 65 20 75 73 65 20 61 20 66 69 6e  11, we use a fin
4580: 67 65 72 70 72 69 6e 74 69 6e 67 20 68 65 75 72  gerprinting heur
4590: 69 73 74 69 63 20 69 6e 73 74 65 61 64 2c 20 62  istic instead, b
45a0: 61 73 65 64 0a 20 20 2f 2f 20 6f 6e 20 74 68 65  ased.  // on the
45b0: 20 6d 65 74 68 6f 64 73 2e 20 49 74 27 73 20 6e   methods. It's n
45c0: 6f 74 20 67 72 65 61 74 2c 20 62 75 74 20 69 74  ot great, but it
45d0: 27 73 20 74 68 65 20 62 65 73 74 20 77 65 20 67  's the best we g
45e0: 6f 74 2e 0a 20 20 2f 2f 20 54 68 65 20 66 69 6e  ot..  // The fin
45f0: 67 65 72 70 72 69 6e 74 20 6d 65 74 68 6f 64 20  gerprint method 
4600: 6c 69 73 74 73 20 61 72 65 20 64 65 66 69 6e 65  lists are define
4610: 64 20 62 65 6c 6f 77 2e 0a 20 20 66 75 6e 63 74  d below..  funct
4620: 69 6f 6e 20 69 65 31 31 66 69 6e 67 65 72 70 72  ion ie11fingerpr
4630: 69 6e 74 28 6d 65 74 68 6f 64 73 29 20 7b 0a 20  int(methods) {. 
4640: 20 20 20 76 61 72 20 6c 65 6e 67 74 68 20 3d 20     var length = 
4650: 67 65 74 4c 65 6e 67 74 68 28 6d 65 74 68 6f 64  getLength(method
4660: 73 29 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 66  s);.    return f
4670: 75 6e 63 74 69 6f 6e 28 6f 62 6a 29 20 7b 0a 20  unction(obj) {. 
4680: 20 20 20 20 20 69 66 20 28 6f 62 6a 20 3d 3d 20       if (obj == 
4690: 6e 75 6c 6c 29 20 72 65 74 75 72 6e 20 66 61 6c  null) return fal
46a0: 73 65 3b 0a 20 20 20 20 20 20 2f 2f 20 60 4d 61  se;.      // `Ma
46b0: 70 60 2c 20 60 57 65 61 6b 4d 61 70 60 20 61 6e  p`, `WeakMap` an
46c0: 64 20 60 53 65 74 60 20 68 61 76 65 20 6e 6f 20  d `Set` have no 
46d0: 65 6e 75 6d 65 72 61 62 6c 65 20 6b 65 79 73 2e  enumerable keys.
46e0: 0a 20 20 20 20 20 20 76 61 72 20 6b 65 79 73 20  .      var keys 
46f0: 3d 20 61 6c 6c 4b 65 79 73 28 6f 62 6a 29 3b 0a  = allKeys(obj);.
4700: 20 20 20 20 20 20 69 66 20 28 67 65 74 4c 65 6e        if (getLen
4710: 67 74 68 28 6b 65 79 73 29 29 20 72 65 74 75 72  gth(keys)) retur
4720: 6e 20 66 61 6c 73 65 3b 0a 20 20 20 20 20 20 66  n false;.      f
4730: 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69  or (var i = 0; i
4740: 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20   < length; i++) 
4750: 7b 0a 20 20 20 20 20 20 20 20 69 66 20 28 21 69  {.        if (!i
4760: 73 46 75 6e 63 74 69 6f 6e 24 31 28 6f 62 6a 5b  sFunction$1(obj[
4770: 6d 65 74 68 6f 64 73 5b 69 5d 5d 29 29 20 72 65  methods[i]])) re
4780: 74 75 72 6e 20 66 61 6c 73 65 3b 0a 20 20 20 20  turn false;.    
4790: 20 20 7d 0a 20 20 20 20 20 20 2f 2f 20 49 66 20    }.      // If 
47a0: 77 65 20 61 72 65 20 74 65 73 74 69 6e 67 20 61  we are testing a
47b0: 67 61 69 6e 73 74 20 60 57 65 61 6b 4d 61 70 60  gainst `WeakMap`
47c0: 2c 20 77 65 20 6e 65 65 64 20 74 6f 20 65 6e 73  , we need to ens
47d0: 75 72 65 20 74 68 61 74 0a 20 20 20 20 20 20 2f  ure that.      /
47e0: 2f 20 60 6f 62 6a 60 20 64 6f 65 73 6e 27 74 20  / `obj` doesn't 
47f0: 68 61 76 65 20 61 20 60 66 6f 72 45 61 63 68 60  have a `forEach`
4800: 20 6d 65 74 68 6f 64 20 69 6e 20 6f 72 64 65 72   method in order
4810: 20 74 6f 20 64 69 73 74 69 6e 67 75 69 73 68 0a   to distinguish.
4820: 20 20 20 20 20 20 2f 2f 20 69 74 20 66 72 6f 6d        // it from
4830: 20 61 20 72 65 67 75 6c 61 72 20 60 4d 61 70 60   a regular `Map`
4840: 2e 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 6d  ..      return m
4850: 65 74 68 6f 64 73 20 21 3d 3d 20 77 65 61 6b 4d  ethods !== weakM
4860: 61 70 4d 65 74 68 6f 64 73 20 7c 7c 20 21 69 73  apMethods || !is
4870: 46 75 6e 63 74 69 6f 6e 24 31 28 6f 62 6a 5b 66  Function$1(obj[f
4880: 6f 72 45 61 63 68 4e 61 6d 65 5d 29 3b 0a 20 20  orEachName]);.  
4890: 20 20 7d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49    };.  }..  // I
48a0: 6e 20 74 68 65 20 69 6e 74 65 72 65 73 74 20 6f  n the interest o
48b0: 66 20 63 6f 6d 70 61 63 74 20 6d 69 6e 69 66 69  f compact minifi
48c0: 63 61 74 69 6f 6e 2c 20 77 65 20 77 72 69 74 65  cation, we write
48d0: 0a 20 20 2f 2f 20 65 61 63 68 20 73 74 72 69 6e  .  // each strin
48e0: 67 20 69 6e 20 74 68 65 20 66 69 6e 67 65 72 70  g in the fingerp
48f0: 72 69 6e 74 73 20 6f 6e 6c 79 20 6f 6e 63 65 2e  rints only once.
4900: 0a 20 20 76 61 72 20 66 6f 72 45 61 63 68 4e 61  .  var forEachNa
4910: 6d 65 20 3d 20 27 66 6f 72 45 61 63 68 27 2c 0a  me = 'forEach',.
4920: 20 20 20 20 20 20 68 61 73 4e 61 6d 65 20 3d 20        hasName = 
4930: 27 68 61 73 27 2c 0a 20 20 20 20 20 20 63 6f 6d  'has',.      com
4940: 6d 6f 6e 49 6e 69 74 20 3d 20 5b 27 63 6c 65 61  monInit = ['clea
4950: 72 27 2c 20 27 64 65 6c 65 74 65 27 5d 2c 0a 20  r', 'delete'],. 
4960: 20 20 20 20 20 6d 61 70 54 61 69 6c 20 3d 20 5b       mapTail = [
4970: 27 67 65 74 27 2c 20 68 61 73 4e 61 6d 65 2c 20  'get', hasName, 
4980: 27 73 65 74 27 5d 3b 0a 0a 20 20 2f 2f 20 60 4d  'set'];..  // `M
4990: 61 70 60 2c 20 60 57 65 61 6b 4d 61 70 60 20 61  ap`, `WeakMap` a
49a0: 6e 64 20 60 53 65 74 60 20 65 61 63 68 20 68 61  nd `Set` each ha
49b0: 76 65 20 73 6c 69 67 68 74 6c 79 20 64 69 66 66  ve slightly diff
49c0: 65 72 65 6e 74 0a 20 20 2f 2f 20 63 6f 6d 62 69  erent.  // combi
49d0: 6e 61 74 69 6f 6e 73 20 6f 66 20 74 68 65 20 61  nations of the a
49e0: 62 6f 76 65 20 73 75 62 6c 69 73 74 73 2e 0a 20  bove sublists.. 
49f0: 20 76 61 72 20 6d 61 70 4d 65 74 68 6f 64 73 20   var mapMethods 
4a00: 3d 20 63 6f 6d 6d 6f 6e 49 6e 69 74 2e 63 6f 6e  = commonInit.con
4a10: 63 61 74 28 66 6f 72 45 61 63 68 4e 61 6d 65 2c  cat(forEachName,
4a20: 20 6d 61 70 54 61 69 6c 29 2c 0a 20 20 20 20 20   mapTail),.     
4a30: 20 77 65 61 6b 4d 61 70 4d 65 74 68 6f 64 73 20   weakMapMethods 
4a40: 3d 20 63 6f 6d 6d 6f 6e 49 6e 69 74 2e 63 6f 6e  = commonInit.con
4a50: 63 61 74 28 6d 61 70 54 61 69 6c 29 2c 0a 20 20  cat(mapTail),.  
4a60: 20 20 20 20 73 65 74 4d 65 74 68 6f 64 73 20 3d      setMethods =
4a70: 20 5b 27 61 64 64 27 5d 2e 63 6f 6e 63 61 74 28   ['add'].concat(
4a80: 63 6f 6d 6d 6f 6e 49 6e 69 74 2c 20 66 6f 72 45  commonInit, forE
4a90: 61 63 68 4e 61 6d 65 2c 20 68 61 73 4e 61 6d 65  achName, hasName
4aa0: 29 3b 0a 0a 20 20 76 61 72 20 69 73 4d 61 70 20  );..  var isMap 
4ab0: 3d 20 69 73 49 45 31 31 20 3f 20 69 65 31 31 66  = isIE11 ? ie11f
4ac0: 69 6e 67 65 72 70 72 69 6e 74 28 6d 61 70 4d 65  ingerprint(mapMe
4ad0: 74 68 6f 64 73 29 20 3a 20 74 61 67 54 65 73 74  thods) : tagTest
4ae0: 65 72 28 27 4d 61 70 27 29 3b 0a 0a 20 20 76 61  er('Map');..  va
4af0: 72 20 69 73 57 65 61 6b 4d 61 70 20 3d 20 69 73  r isWeakMap = is
4b00: 49 45 31 31 20 3f 20 69 65 31 31 66 69 6e 67 65  IE11 ? ie11finge
4b10: 72 70 72 69 6e 74 28 77 65 61 6b 4d 61 70 4d 65  rprint(weakMapMe
4b20: 74 68 6f 64 73 29 20 3a 20 74 61 67 54 65 73 74  thods) : tagTest
4b30: 65 72 28 27 57 65 61 6b 4d 61 70 27 29 3b 0a 0a  er('WeakMap');..
4b40: 20 20 76 61 72 20 69 73 53 65 74 20 3d 20 69 73    var isSet = is
4b50: 49 45 31 31 20 3f 20 69 65 31 31 66 69 6e 67 65  IE11 ? ie11finge
4b60: 72 70 72 69 6e 74 28 73 65 74 4d 65 74 68 6f 64  rprint(setMethod
4b70: 73 29 20 3a 20 74 61 67 54 65 73 74 65 72 28 27  s) : tagTester('
4b80: 53 65 74 27 29 3b 0a 0a 20 20 76 61 72 20 69 73  Set');..  var is
4b90: 57 65 61 6b 53 65 74 20 3d 20 74 61 67 54 65 73  WeakSet = tagTes
4ba0: 74 65 72 28 27 57 65 61 6b 53 65 74 27 29 3b 0a  ter('WeakSet');.
4bb0: 0a 20 20 2f 2f 20 52 65 74 72 69 65 76 65 20 74  .  // Retrieve t
4bc0: 68 65 20 76 61 6c 75 65 73 20 6f 66 20 61 6e 20  he values of an 
4bd0: 6f 62 6a 65 63 74 27 73 20 70 72 6f 70 65 72 74  object's propert
4be0: 69 65 73 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20  ies..  function 
4bf0: 76 61 6c 75 65 73 28 6f 62 6a 29 20 7b 0a 20 20  values(obj) {.  
4c00: 20 20 76 61 72 20 5f 6b 65 79 73 20 3d 20 6b 65    var _keys = ke
4c10: 79 73 28 6f 62 6a 29 3b 0a 20 20 20 20 76 61 72  ys(obj);.    var
4c20: 20 6c 65 6e 67 74 68 20 3d 20 5f 6b 65 79 73 2e   length = _keys.
4c30: 6c 65 6e 67 74 68 3b 0a 20 20 20 20 76 61 72 20  length;.    var 
4c40: 76 61 6c 75 65 73 20 3d 20 41 72 72 61 79 28 6c  values = Array(l
4c50: 65 6e 67 74 68 29 3b 0a 20 20 20 20 66 6f 72 20  ength);.    for 
4c60: 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20  (var i = 0; i < 
4c70: 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20 7b 0a 20  length; i++) {. 
4c80: 20 20 20 20 20 76 61 6c 75 65 73 5b 69 5d 20 3d       values[i] =
4c90: 20 6f 62 6a 5b 5f 6b 65 79 73 5b 69 5d 5d 3b 0a   obj[_keys[i]];.
4ca0: 20 20 20 20 7d 0a 20 20 20 20 72 65 74 75 72 6e      }.    return
4cb0: 20 76 61 6c 75 65 73 3b 0a 20 20 7d 0a 0a 20 20   values;.  }..  
4cc0: 2f 2f 20 43 6f 6e 76 65 72 74 20 61 6e 20 6f 62  // Convert an ob
4cd0: 6a 65 63 74 20 69 6e 74 6f 20 61 20 6c 69 73 74  ject into a list
4ce0: 20 6f 66 20 60 5b 6b 65 79 2c 20 76 61 6c 75 65   of `[key, value
4cf0: 5d 60 20 70 61 69 72 73 2e 0a 20 20 2f 2f 20 54  ]` pairs..  // T
4d00: 68 65 20 6f 70 70 6f 73 69 74 65 20 6f 66 20 60  he opposite of `
4d10: 5f 2e 6f 62 6a 65 63 74 60 20 77 69 74 68 20 6f  _.object` with o
4d20: 6e 65 20 61 72 67 75 6d 65 6e 74 2e 0a 20 20 66  ne argument..  f
4d30: 75 6e 63 74 69 6f 6e 20 70 61 69 72 73 28 6f 62  unction pairs(ob
4d40: 6a 29 20 7b 0a 20 20 20 20 76 61 72 20 5f 6b 65  j) {.    var _ke
4d50: 79 73 20 3d 20 6b 65 79 73 28 6f 62 6a 29 3b 0a  ys = keys(obj);.
4d60: 20 20 20 20 76 61 72 20 6c 65 6e 67 74 68 20 3d      var length =
4d70: 20 5f 6b 65 79 73 2e 6c 65 6e 67 74 68 3b 0a 20   _keys.length;. 
4d80: 20 20 20 76 61 72 20 70 61 69 72 73 20 3d 20 41     var pairs = A
4d90: 72 72 61 79 28 6c 65 6e 67 74 68 29 3b 0a 20 20  rray(length);.  
4da0: 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30    for (var i = 0
4db0: 3b 20 69 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b  ; i < length; i+
4dc0: 2b 29 20 7b 0a 20 20 20 20 20 20 70 61 69 72 73  +) {.      pairs
4dd0: 5b 69 5d 20 3d 20 5b 5f 6b 65 79 73 5b 69 5d 2c  [i] = [_keys[i],
4de0: 20 6f 62 6a 5b 5f 6b 65 79 73 5b 69 5d 5d 5d 3b   obj[_keys[i]]];
4df0: 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 74 75 72  .    }.    retur
4e00: 6e 20 70 61 69 72 73 3b 0a 20 20 7d 0a 0a 20 20  n pairs;.  }..  
4e10: 2f 2f 20 49 6e 76 65 72 74 20 74 68 65 20 6b 65  // Invert the ke
4e20: 79 73 20 61 6e 64 20 76 61 6c 75 65 73 20 6f 66  ys and values of
4e30: 20 61 6e 20 6f 62 6a 65 63 74 2e 20 54 68 65 20   an object. The 
4e40: 76 61 6c 75 65 73 20 6d 75 73 74 20 62 65 20 73  values must be s
4e50: 65 72 69 61 6c 69 7a 61 62 6c 65 2e 0a 20 20 66  erializable..  f
4e60: 75 6e 63 74 69 6f 6e 20 69 6e 76 65 72 74 28 6f  unction invert(o
4e70: 62 6a 29 20 7b 0a 20 20 20 20 76 61 72 20 72 65  bj) {.    var re
4e80: 73 75 6c 74 20 3d 20 7b 7d 3b 0a 20 20 20 20 76  sult = {};.    v
4e90: 61 72 20 5f 6b 65 79 73 20 3d 20 6b 65 79 73 28  ar _keys = keys(
4ea0: 6f 62 6a 29 3b 0a 20 20 20 20 66 6f 72 20 28 76  obj);.    for (v
4eb0: 61 72 20 69 20 3d 20 30 2c 20 6c 65 6e 67 74 68  ar i = 0, length
4ec0: 20 3d 20 5f 6b 65 79 73 2e 6c 65 6e 67 74 68 3b   = _keys.length;
4ed0: 20 69 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b   i < length; i++
4ee0: 29 20 7b 0a 20 20 20 20 20 20 72 65 73 75 6c 74  ) {.      result
4ef0: 5b 6f 62 6a 5b 5f 6b 65 79 73 5b 69 5d 5d 5d 20  [obj[_keys[i]]] 
4f00: 3d 20 5f 6b 65 79 73 5b 69 5d 3b 0a 20 20 20 20  = _keys[i];.    
4f10: 7d 0a 20 20 20 20 72 65 74 75 72 6e 20 72 65 73  }.    return res
4f20: 75 6c 74 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52  ult;.  }..  // R
4f30: 65 74 75 72 6e 20 61 20 73 6f 72 74 65 64 20 6c  eturn a sorted l
4f40: 69 73 74 20 6f 66 20 74 68 65 20 66 75 6e 63 74  ist of the funct
4f50: 69 6f 6e 20 6e 61 6d 65 73 20 61 76 61 69 6c 61  ion names availa
4f60: 62 6c 65 20 6f 6e 20 74 68 65 20 6f 62 6a 65 63  ble on the objec
4f70: 74 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 66 75  t..  function fu
4f80: 6e 63 74 69 6f 6e 73 28 6f 62 6a 29 20 7b 0a 20  nctions(obj) {. 
4f90: 20 20 20 76 61 72 20 6e 61 6d 65 73 20 3d 20 5b     var names = [
4fa0: 5d 3b 0a 20 20 20 20 66 6f 72 20 28 76 61 72 20  ];.    for (var 
4fb0: 6b 65 79 20 69 6e 20 6f 62 6a 29 20 7b 0a 20 20  key in obj) {.  
4fc0: 20 20 20 20 69 66 20 28 69 73 46 75 6e 63 74 69      if (isFuncti
4fd0: 6f 6e 24 31 28 6f 62 6a 5b 6b 65 79 5d 29 29 20  on$1(obj[key])) 
4fe0: 6e 61 6d 65 73 2e 70 75 73 68 28 6b 65 79 29 3b  names.push(key);
4ff0: 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 74 75 72  .    }.    retur
5000: 6e 20 6e 61 6d 65 73 2e 73 6f 72 74 28 29 3b 0a  n names.sort();.
5010: 20 20 7d 0a 0a 20 20 2f 2f 20 41 6e 20 69 6e 74    }..  // An int
5020: 65 72 6e 61 6c 20 66 75 6e 63 74 69 6f 6e 20 66  ernal function f
5030: 6f 72 20 63 72 65 61 74 69 6e 67 20 61 73 73 69  or creating assi
5040: 67 6e 65 72 20 66 75 6e 63 74 69 6f 6e 73 2e 0a  gner functions..
5050: 20 20 66 75 6e 63 74 69 6f 6e 20 63 72 65 61 74    function creat
5060: 65 41 73 73 69 67 6e 65 72 28 6b 65 79 73 46 75  eAssigner(keysFu
5070: 6e 63 2c 20 64 65 66 61 75 6c 74 73 29 20 7b 0a  nc, defaults) {.
5080: 20 20 20 20 72 65 74 75 72 6e 20 66 75 6e 63 74      return funct
5090: 69 6f 6e 28 6f 62 6a 29 20 7b 0a 20 20 20 20 20  ion(obj) {.     
50a0: 20 76 61 72 20 6c 65 6e 67 74 68 20 3d 20 61 72   var length = ar
50b0: 67 75 6d 65 6e 74 73 2e 6c 65 6e 67 74 68 3b 0a  guments.length;.
50c0: 20 20 20 20 20 20 69 66 20 28 64 65 66 61 75 6c        if (defaul
50d0: 74 73 29 20 6f 62 6a 20 3d 20 4f 62 6a 65 63 74  ts) obj = Object
50e0: 28 6f 62 6a 29 3b 0a 20 20 20 20 20 20 69 66 20  (obj);.      if 
50f0: 28 6c 65 6e 67 74 68 20 3c 20 32 20 7c 7c 20 6f  (length < 2 || o
5100: 62 6a 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 75  bj == null) retu
5110: 72 6e 20 6f 62 6a 3b 0a 20 20 20 20 20 20 66 6f  rn obj;.      fo
5120: 72 20 28 76 61 72 20 69 6e 64 65 78 20 3d 20 31  r (var index = 1
5130: 3b 20 69 6e 64 65 78 20 3c 20 6c 65 6e 67 74 68  ; index < length
5140: 3b 20 69 6e 64 65 78 2b 2b 29 20 7b 0a 20 20 20  ; index++) {.   
5150: 20 20 20 20 20 76 61 72 20 73 6f 75 72 63 65 20       var source 
5160: 3d 20 61 72 67 75 6d 65 6e 74 73 5b 69 6e 64 65  = arguments[inde
5170: 78 5d 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  x],.            
5180: 6b 65 79 73 20 3d 20 6b 65 79 73 46 75 6e 63 28  keys = keysFunc(
5190: 73 6f 75 72 63 65 29 2c 0a 20 20 20 20 20 20 20  source),.       
51a0: 20 20 20 20 20 6c 20 3d 20 6b 65 79 73 2e 6c 65       l = keys.le
51b0: 6e 67 74 68 3b 0a 20 20 20 20 20 20 20 20 66 6f  ngth;.        fo
51c0: 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20  r (var i = 0; i 
51d0: 3c 20 6c 3b 20 69 2b 2b 29 20 7b 0a 20 20 20 20  < l; i++) {.    
51e0: 20 20 20 20 20 20 76 61 72 20 6b 65 79 20 3d 20        var key = 
51f0: 6b 65 79 73 5b 69 5d 3b 0a 20 20 20 20 20 20 20  keys[i];.       
5200: 20 20 20 69 66 20 28 21 64 65 66 61 75 6c 74 73     if (!defaults
5210: 20 7c 7c 20 6f 62 6a 5b 6b 65 79 5d 20 3d 3d 3d   || obj[key] ===
5220: 20 76 6f 69 64 20 30 29 20 6f 62 6a 5b 6b 65 79   void 0) obj[key
5230: 5d 20 3d 20 73 6f 75 72 63 65 5b 6b 65 79 5d 3b  ] = source[key];
5240: 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20  .        }.     
5250: 20 7d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20   }.      return 
5260: 6f 62 6a 3b 0a 20 20 20 20 7d 3b 0a 20 20 7d 0a  obj;.    };.  }.
5270: 0a 20 20 2f 2f 20 45 78 74 65 6e 64 20 61 20 67  .  // Extend a g
5280: 69 76 65 6e 20 6f 62 6a 65 63 74 20 77 69 74 68  iven object with
5290: 20 61 6c 6c 20 74 68 65 20 70 72 6f 70 65 72 74   all the propert
52a0: 69 65 73 20 69 6e 20 70 61 73 73 65 64 2d 69 6e  ies in passed-in
52b0: 20 6f 62 6a 65 63 74 28 73 29 2e 0a 20 20 76 61   object(s)..  va
52c0: 72 20 65 78 74 65 6e 64 20 3d 20 63 72 65 61 74  r extend = creat
52d0: 65 41 73 73 69 67 6e 65 72 28 61 6c 6c 4b 65 79  eAssigner(allKey
52e0: 73 29 3b 0a 0a 20 20 2f 2f 20 41 73 73 69 67 6e  s);..  // Assign
52f0: 73 20 61 20 67 69 76 65 6e 20 6f 62 6a 65 63 74  s a given object
5300: 20 77 69 74 68 20 61 6c 6c 20 74 68 65 20 6f 77   with all the ow
5310: 6e 20 70 72 6f 70 65 72 74 69 65 73 20 69 6e 20  n properties in 
5320: 74 68 65 20 70 61 73 73 65 64 2d 69 6e 0a 20 20  the passed-in.  
5330: 2f 2f 20 6f 62 6a 65 63 74 28 73 29 2e 0a 20 20  // object(s)..  
5340: 2f 2f 20 28 68 74 74 70 73 3a 2f 2f 64 65 76 65  // (https://deve
5350: 6c 6f 70 65 72 2e 6d 6f 7a 69 6c 6c 61 2e 6f 72  loper.mozilla.or
5360: 67 2f 64 6f 63 73 2f 57 65 62 2f 4a 61 76 61 53  g/docs/Web/JavaS
5370: 63 72 69 70 74 2f 52 65 66 65 72 65 6e 63 65 2f  cript/Reference/
5380: 47 6c 6f 62 61 6c 5f 4f 62 6a 65 63 74 73 2f 4f  Global_Objects/O
5390: 62 6a 65 63 74 2f 61 73 73 69 67 6e 29 0a 20 20  bject/assign).  
53a0: 76 61 72 20 65 78 74 65 6e 64 4f 77 6e 20 3d 20  var extendOwn = 
53b0: 63 72 65 61 74 65 41 73 73 69 67 6e 65 72 28 6b  createAssigner(k
53c0: 65 79 73 29 3b 0a 0a 20 20 2f 2f 20 46 69 6c 6c  eys);..  // Fill
53d0: 20 69 6e 20 61 20 67 69 76 65 6e 20 6f 62 6a 65   in a given obje
53e0: 63 74 20 77 69 74 68 20 64 65 66 61 75 6c 74 20  ct with default 
53f0: 70 72 6f 70 65 72 74 69 65 73 2e 0a 20 20 76 61  properties..  va
5400: 72 20 64 65 66 61 75 6c 74 73 20 3d 20 63 72 65  r defaults = cre
5410: 61 74 65 41 73 73 69 67 6e 65 72 28 61 6c 6c 4b  ateAssigner(allK
5420: 65 79 73 2c 20 74 72 75 65 29 3b 0a 0a 20 20 2f  eys, true);..  /
5430: 2f 20 43 72 65 61 74 65 20 61 20 6e 61 6b 65 64  / Create a naked
5440: 20 66 75 6e 63 74 69 6f 6e 20 72 65 66 65 72 65   function refere
5450: 6e 63 65 20 66 6f 72 20 73 75 72 72 6f 67 61 74  nce for surrogat
5460: 65 2d 70 72 6f 74 6f 74 79 70 65 2d 73 77 61 70  e-prototype-swap
5470: 70 69 6e 67 2e 0a 20 20 66 75 6e 63 74 69 6f 6e  ping..  function
5480: 20 63 74 6f 72 28 29 20 7b 0a 20 20 20 20 72 65   ctor() {.    re
5490: 74 75 72 6e 20 66 75 6e 63 74 69 6f 6e 28 29 7b  turn function(){
54a0: 7d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 41 6e 20  };.  }..  // An 
54b0: 69 6e 74 65 72 6e 61 6c 20 66 75 6e 63 74 69 6f  internal functio
54c0: 6e 20 66 6f 72 20 63 72 65 61 74 69 6e 67 20 61  n for creating a
54d0: 20 6e 65 77 20 6f 62 6a 65 63 74 20 74 68 61 74   new object that
54e0: 20 69 6e 68 65 72 69 74 73 20 66 72 6f 6d 20 61   inherits from a
54f0: 6e 6f 74 68 65 72 2e 0a 20 20 66 75 6e 63 74 69  nother..  functi
5500: 6f 6e 20 62 61 73 65 43 72 65 61 74 65 28 70 72  on baseCreate(pr
5510: 6f 74 6f 74 79 70 65 29 20 7b 0a 20 20 20 20 69  ototype) {.    i
5520: 66 20 28 21 69 73 4f 62 6a 65 63 74 28 70 72 6f  f (!isObject(pro
5530: 74 6f 74 79 70 65 29 29 20 72 65 74 75 72 6e 20  totype)) return 
5540: 7b 7d 3b 0a 20 20 20 20 69 66 20 28 6e 61 74 69  {};.    if (nati
5550: 76 65 43 72 65 61 74 65 29 20 72 65 74 75 72 6e  veCreate) return
5560: 20 6e 61 74 69 76 65 43 72 65 61 74 65 28 70 72   nativeCreate(pr
5570: 6f 74 6f 74 79 70 65 29 3b 0a 20 20 20 20 76 61  ototype);.    va
5580: 72 20 43 74 6f 72 20 3d 20 63 74 6f 72 28 29 3b  r Ctor = ctor();
5590: 0a 20 20 20 20 43 74 6f 72 2e 70 72 6f 74 6f 74  .    Ctor.protot
55a0: 79 70 65 20 3d 20 70 72 6f 74 6f 74 79 70 65 3b  ype = prototype;
55b0: 0a 20 20 20 20 76 61 72 20 72 65 73 75 6c 74 20  .    var result 
55c0: 3d 20 6e 65 77 20 43 74 6f 72 3b 0a 20 20 20 20  = new Ctor;.    
55d0: 43 74 6f 72 2e 70 72 6f 74 6f 74 79 70 65 20 3d  Ctor.prototype =
55e0: 20 6e 75 6c 6c 3b 0a 20 20 20 20 72 65 74 75 72   null;.    retur
55f0: 6e 20 72 65 73 75 6c 74 3b 0a 20 20 7d 0a 0a 20  n result;.  }.. 
5600: 20 2f 2f 20 43 72 65 61 74 65 73 20 61 6e 20 6f   // Creates an o
5610: 62 6a 65 63 74 20 74 68 61 74 20 69 6e 68 65 72  bject that inher
5620: 69 74 73 20 66 72 6f 6d 20 74 68 65 20 67 69 76  its from the giv
5630: 65 6e 20 70 72 6f 74 6f 74 79 70 65 20 6f 62 6a  en prototype obj
5640: 65 63 74 2e 0a 20 20 2f 2f 20 49 66 20 61 64 64  ect..  // If add
5650: 69 74 69 6f 6e 61 6c 20 70 72 6f 70 65 72 74 69  itional properti
5660: 65 73 20 61 72 65 20 70 72 6f 76 69 64 65 64 20  es are provided 
5670: 74 68 65 6e 20 74 68 65 79 20 77 69 6c 6c 20 62  then they will b
5680: 65 20 61 64 64 65 64 20 74 6f 20 74 68 65 0a 20  e added to the. 
5690: 20 2f 2f 20 63 72 65 61 74 65 64 20 6f 62 6a 65   // created obje
56a0: 63 74 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 63  ct..  function c
56b0: 72 65 61 74 65 28 70 72 6f 74 6f 74 79 70 65 2c  reate(prototype,
56c0: 20 70 72 6f 70 73 29 20 7b 0a 20 20 20 20 76 61   props) {.    va
56d0: 72 20 72 65 73 75 6c 74 20 3d 20 62 61 73 65 43  r result = baseC
56e0: 72 65 61 74 65 28 70 72 6f 74 6f 74 79 70 65 29  reate(prototype)
56f0: 3b 0a 20 20 20 20 69 66 20 28 70 72 6f 70 73 29  ;.    if (props)
5700: 20 65 78 74 65 6e 64 4f 77 6e 28 72 65 73 75 6c   extendOwn(resul
5710: 74 2c 20 70 72 6f 70 73 29 3b 0a 20 20 20 20 72  t, props);.    r
5720: 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a 20 20  eturn result;.  
5730: 7d 0a 0a 20 20 2f 2f 20 43 72 65 61 74 65 20 61  }..  // Create a
5740: 20 28 73 68 61 6c 6c 6f 77 2d 63 6c 6f 6e 65 64   (shallow-cloned
5750: 29 20 64 75 70 6c 69 63 61 74 65 20 6f 66 20 61  ) duplicate of a
5760: 6e 20 6f 62 6a 65 63 74 2e 0a 20 20 66 75 6e 63  n object..  func
5770: 74 69 6f 6e 20 63 6c 6f 6e 65 28 6f 62 6a 29 20  tion clone(obj) 
5780: 7b 0a 20 20 20 20 69 66 20 28 21 69 73 4f 62 6a  {.    if (!isObj
5790: 65 63 74 28 6f 62 6a 29 29 20 72 65 74 75 72 6e  ect(obj)) return
57a0: 20 6f 62 6a 3b 0a 20 20 20 20 72 65 74 75 72 6e   obj;.    return
57b0: 20 69 73 41 72 72 61 79 28 6f 62 6a 29 20 3f 20   isArray(obj) ? 
57c0: 6f 62 6a 2e 73 6c 69 63 65 28 29 20 3a 20 65 78  obj.slice() : ex
57d0: 74 65 6e 64 28 7b 7d 2c 20 6f 62 6a 29 3b 0a 20  tend({}, obj);. 
57e0: 20 7d 0a 0a 20 20 2f 2f 20 49 6e 76 6f 6b 65 73   }..  // Invokes
57f0: 20 60 69 6e 74 65 72 63 65 70 74 6f 72 60 20 77   `interceptor` w
5800: 69 74 68 20 74 68 65 20 60 6f 62 6a 60 20 61 6e  ith the `obj` an
5810: 64 20 74 68 65 6e 20 72 65 74 75 72 6e 73 20 60  d then returns `
5820: 6f 62 6a 60 2e 0a 20 20 2f 2f 20 54 68 65 20 70  obj`..  // The p
5830: 72 69 6d 61 72 79 20 70 75 72 70 6f 73 65 20 6f  rimary purpose o
5840: 66 20 74 68 69 73 20 6d 65 74 68 6f 64 20 69 73  f this method is
5850: 20 74 6f 20 22 74 61 70 20 69 6e 74 6f 22 20 61   to "tap into" a
5860: 20 6d 65 74 68 6f 64 20 63 68 61 69 6e 2c 20 69   method chain, i
5870: 6e 0a 20 20 2f 2f 20 6f 72 64 65 72 20 74 6f 20  n.  // order to 
5880: 70 65 72 66 6f 72 6d 20 6f 70 65 72 61 74 69 6f  perform operatio
5890: 6e 73 20 6f 6e 20 69 6e 74 65 72 6d 65 64 69 61  ns on intermedia
58a0: 74 65 20 72 65 73 75 6c 74 73 20 77 69 74 68 69  te results withi
58b0: 6e 20 74 68 65 20 63 68 61 69 6e 2e 0a 20 20 66  n the chain..  f
58c0: 75 6e 63 74 69 6f 6e 20 74 61 70 28 6f 62 6a 2c  unction tap(obj,
58d0: 20 69 6e 74 65 72 63 65 70 74 6f 72 29 20 7b 0a   interceptor) {.
58e0: 20 20 20 20 69 6e 74 65 72 63 65 70 74 6f 72 28      interceptor(
58f0: 6f 62 6a 29 3b 0a 20 20 20 20 72 65 74 75 72 6e  obj);.    return
5900: 20 6f 62 6a 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20   obj;.  }..  // 
5910: 4e 6f 72 6d 61 6c 69 7a 65 20 61 20 28 64 65 65  Normalize a (dee
5920: 70 29 20 70 72 6f 70 65 72 74 79 20 60 70 61 74  p) property `pat
5930: 68 60 20 74 6f 20 61 72 72 61 79 2e 0a 20 20 2f  h` to array..  /
5940: 2f 20 4c 69 6b 65 20 60 5f 2e 69 74 65 72 61 74  / Like `_.iterat
5950: 65 65 60 2c 20 74 68 69 73 20 66 75 6e 63 74 69  ee`, this functi
5960: 6f 6e 20 63 61 6e 20 62 65 20 63 75 73 74 6f 6d  on can be custom
5970: 69 7a 65 64 2e 0a 20 20 66 75 6e 63 74 69 6f 6e  ized..  function
5980: 20 74 6f 50 61 74 68 28 70 61 74 68 29 20 7b 0a   toPath(path) {.
5990: 20 20 20 20 72 65 74 75 72 6e 20 69 73 41 72 72      return isArr
59a0: 61 79 28 70 61 74 68 29 20 3f 20 70 61 74 68 20  ay(path) ? path 
59b0: 3a 20 5b 70 61 74 68 5d 3b 0a 20 20 7d 0a 20 20  : [path];.  }.  
59c0: 5f 2e 74 6f 50 61 74 68 20 3d 20 74 6f 50 61 74  _.toPath = toPat
59d0: 68 3b 0a 0a 20 20 2f 2f 20 49 6e 74 65 72 6e 61  h;..  // Interna
59e0: 6c 20 77 72 61 70 70 65 72 20 66 6f 72 20 60 5f  l wrapper for `_
59f0: 2e 74 6f 50 61 74 68 60 20 74 6f 20 65 6e 61 62  .toPath` to enab
5a00: 6c 65 20 6d 69 6e 69 66 69 63 61 74 69 6f 6e 2e  le minification.
5a10: 0a 20 20 2f 2f 20 53 69 6d 69 6c 61 72 20 74 6f  .  // Similar to
5a20: 20 60 63 62 60 20 66 6f 72 20 60 5f 2e 69 74 65   `cb` for `_.ite
5a30: 72 61 74 65 65 60 2e 0a 20 20 66 75 6e 63 74 69  ratee`..  functi
5a40: 6f 6e 20 74 6f 50 61 74 68 24 31 28 70 61 74 68  on toPath$1(path
5a50: 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 5f  ) {.    return _
5a60: 2e 74 6f 50 61 74 68 28 70 61 74 68 29 3b 0a 20  .toPath(path);. 
5a70: 20 7d 0a 0a 20 20 2f 2f 20 49 6e 74 65 72 6e 61   }..  // Interna
5a80: 6c 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 6f 62  l function to ob
5a90: 74 61 69 6e 20 61 20 6e 65 73 74 65 64 20 70 72  tain a nested pr
5aa0: 6f 70 65 72 74 79 20 69 6e 20 60 6f 62 6a 60 20  operty in `obj` 
5ab0: 61 6c 6f 6e 67 20 60 70 61 74 68 60 2e 0a 20 20  along `path`..  
5ac0: 66 75 6e 63 74 69 6f 6e 20 64 65 65 70 47 65 74  function deepGet
5ad0: 28 6f 62 6a 2c 20 70 61 74 68 29 20 7b 0a 20 20  (obj, path) {.  
5ae0: 20 20 76 61 72 20 6c 65 6e 67 74 68 20 3d 20 70    var length = p
5af0: 61 74 68 2e 6c 65 6e 67 74 68 3b 0a 20 20 20 20  ath.length;.    
5b00: 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20  for (var i = 0; 
5b10: 69 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b 29  i < length; i++)
5b20: 20 7b 0a 20 20 20 20 20 20 69 66 20 28 6f 62 6a   {.      if (obj
5b30: 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 75 72 6e   == null) return
5b40: 20 76 6f 69 64 20 30 3b 0a 20 20 20 20 20 20 6f   void 0;.      o
5b50: 62 6a 20 3d 20 6f 62 6a 5b 70 61 74 68 5b 69 5d  bj = obj[path[i]
5b60: 5d 3b 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 74  ];.    }.    ret
5b70: 75 72 6e 20 6c 65 6e 67 74 68 20 3f 20 6f 62 6a  urn length ? obj
5b80: 20 3a 20 76 6f 69 64 20 30 3b 0a 20 20 7d 0a 0a   : void 0;.  }..
5b90: 20 20 2f 2f 20 47 65 74 20 74 68 65 20 76 61 6c    // Get the val
5ba0: 75 65 20 6f 66 20 74 68 65 20 28 64 65 65 70 29  ue of the (deep)
5bb0: 20 70 72 6f 70 65 72 74 79 20 6f 6e 20 60 70 61   property on `pa
5bc0: 74 68 60 20 66 72 6f 6d 20 60 6f 62 6a 65 63 74  th` from `object
5bd0: 60 2e 0a 20 20 2f 2f 20 49 66 20 61 6e 79 20 70  `..  // If any p
5be0: 72 6f 70 65 72 74 79 20 69 6e 20 60 70 61 74 68  roperty in `path
5bf0: 60 20 64 6f 65 73 20 6e 6f 74 20 65 78 69 73 74  ` does not exist
5c00: 20 6f 72 20 69 66 20 74 68 65 20 76 61 6c 75 65   or if the value
5c10: 20 69 73 0a 20 20 2f 2f 20 60 75 6e 64 65 66 69   is.  // `undefi
5c20: 6e 65 64 60 2c 20 72 65 74 75 72 6e 20 60 64 65  ned`, return `de
5c30: 66 61 75 6c 74 56 61 6c 75 65 60 20 69 6e 73 74  faultValue` inst
5c40: 65 61 64 2e 0a 20 20 2f 2f 20 54 68 65 20 60 70  ead..  // The `p
5c50: 61 74 68 60 20 69 73 20 6e 6f 72 6d 61 6c 69 7a  ath` is normaliz
5c60: 65 64 20 74 68 72 6f 75 67 68 20 60 5f 2e 74 6f  ed through `_.to
5c70: 50 61 74 68 60 2e 0a 20 20 66 75 6e 63 74 69 6f  Path`..  functio
5c80: 6e 20 67 65 74 28 6f 62 6a 65 63 74 2c 20 70 61  n get(object, pa
5c90: 74 68 2c 20 64 65 66 61 75 6c 74 56 61 6c 75 65  th, defaultValue
5ca0: 29 20 7b 0a 20 20 20 20 76 61 72 20 76 61 6c 75  ) {.    var valu
5cb0: 65 20 3d 20 64 65 65 70 47 65 74 28 6f 62 6a 65  e = deepGet(obje
5cc0: 63 74 2c 20 74 6f 50 61 74 68 24 31 28 70 61 74  ct, toPath$1(pat
5cd0: 68 29 29 3b 0a 20 20 20 20 72 65 74 75 72 6e 20  h));.    return 
5ce0: 69 73 55 6e 64 65 66 69 6e 65 64 28 76 61 6c 75  isUndefined(valu
5cf0: 65 29 20 3f 20 64 65 66 61 75 6c 74 56 61 6c 75  e) ? defaultValu
5d00: 65 20 3a 20 76 61 6c 75 65 3b 0a 20 20 7d 0a 0a  e : value;.  }..
5d10: 20 20 2f 2f 20 53 68 6f 72 74 63 75 74 20 66 75    // Shortcut fu
5d20: 6e 63 74 69 6f 6e 20 66 6f 72 20 63 68 65 63 6b  nction for check
5d30: 69 6e 67 20 69 66 20 61 6e 20 6f 62 6a 65 63 74  ing if an object
5d40: 20 68 61 73 20 61 20 67 69 76 65 6e 20 70 72 6f   has a given pro
5d50: 70 65 72 74 79 20 64 69 72 65 63 74 6c 79 20 6f  perty directly o
5d60: 6e 0a 20 20 2f 2f 20 69 74 73 65 6c 66 20 28 69  n.  // itself (i
5d70: 6e 20 6f 74 68 65 72 20 77 6f 72 64 73 2c 20 6e  n other words, n
5d80: 6f 74 20 6f 6e 20 61 20 70 72 6f 74 6f 74 79 70  ot on a prototyp
5d90: 65 29 2e 20 55 6e 6c 69 6b 65 20 74 68 65 20 69  e). Unlike the i
5da0: 6e 74 65 72 6e 61 6c 20 60 68 61 73 60 0a 20 20  nternal `has`.  
5db0: 2f 2f 20 66 75 6e 63 74 69 6f 6e 2c 20 74 68 69  // function, thi
5dc0: 73 20 70 75 62 6c 69 63 20 76 65 72 73 69 6f 6e  s public version
5dd0: 20 63 61 6e 20 61 6c 73 6f 20 74 72 61 76 65 72   can also traver
5de0: 73 65 20 6e 65 73 74 65 64 20 70 72 6f 70 65 72  se nested proper
5df0: 74 69 65 73 2e 0a 20 20 66 75 6e 63 74 69 6f 6e  ties..  function
5e00: 20 68 61 73 24 31 28 6f 62 6a 2c 20 70 61 74 68   has$1(obj, path
5e10: 29 20 7b 0a 20 20 20 20 70 61 74 68 20 3d 20 74  ) {.    path = t
5e20: 6f 50 61 74 68 24 31 28 70 61 74 68 29 3b 0a 20  oPath$1(path);. 
5e30: 20 20 20 76 61 72 20 6c 65 6e 67 74 68 20 3d 20     var length = 
5e40: 70 61 74 68 2e 6c 65 6e 67 74 68 3b 0a 20 20 20  path.length;.   
5e50: 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b   for (var i = 0;
5e60: 20 69 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b   i < length; i++
5e70: 29 20 7b 0a 20 20 20 20 20 20 76 61 72 20 6b 65  ) {.      var ke
5e80: 79 20 3d 20 70 61 74 68 5b 69 5d 3b 0a 20 20 20  y = path[i];.   
5e90: 20 20 20 69 66 20 28 21 68 61 73 28 6f 62 6a 2c     if (!has(obj,
5ea0: 20 6b 65 79 29 29 20 72 65 74 75 72 6e 20 66 61   key)) return fa
5eb0: 6c 73 65 3b 0a 20 20 20 20 20 20 6f 62 6a 20 3d  lse;.      obj =
5ec0: 20 6f 62 6a 5b 6b 65 79 5d 3b 0a 20 20 20 20 7d   obj[key];.    }
5ed0: 0a 20 20 20 20 72 65 74 75 72 6e 20 21 21 6c 65  .    return !!le
5ee0: 6e 67 74 68 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20  ngth;.  }..  // 
5ef0: 4b 65 65 70 20 74 68 65 20 69 64 65 6e 74 69 74  Keep the identit
5f00: 79 20 66 75 6e 63 74 69 6f 6e 20 61 72 6f 75 6e  y function aroun
5f10: 64 20 66 6f 72 20 64 65 66 61 75 6c 74 20 69 74  d for default it
5f20: 65 72 61 74 65 65 73 2e 0a 20 20 66 75 6e 63 74  eratees..  funct
5f30: 69 6f 6e 20 69 64 65 6e 74 69 74 79 28 76 61 6c  ion identity(val
5f40: 75 65 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e  ue) {.    return
5f50: 20 76 61 6c 75 65 3b 0a 20 20 7d 0a 0a 20 20 2f   value;.  }..  /
5f60: 2f 20 52 65 74 75 72 6e 73 20 61 20 70 72 65 64  / Returns a pred
5f70: 69 63 61 74 65 20 66 6f 72 20 63 68 65 63 6b 69  icate for checki
5f80: 6e 67 20 77 68 65 74 68 65 72 20 61 6e 20 6f 62  ng whether an ob
5f90: 6a 65 63 74 20 68 61 73 20 61 20 67 69 76 65 6e  ject has a given
5fa0: 20 73 65 74 20 6f 66 0a 20 20 2f 2f 20 60 6b 65   set of.  // `ke
5fb0: 79 3a 76 61 6c 75 65 60 20 70 61 69 72 73 2e 0a  y:value` pairs..
5fc0: 20 20 66 75 6e 63 74 69 6f 6e 20 6d 61 74 63 68    function match
5fd0: 65 72 28 61 74 74 72 73 29 20 7b 0a 20 20 20 20  er(attrs) {.    
5fe0: 61 74 74 72 73 20 3d 20 65 78 74 65 6e 64 4f 77  attrs = extendOw
5ff0: 6e 28 7b 7d 2c 20 61 74 74 72 73 29 3b 0a 20 20  n({}, attrs);.  
6000: 20 20 72 65 74 75 72 6e 20 66 75 6e 63 74 69 6f    return functio
6010: 6e 28 6f 62 6a 29 20 7b 0a 20 20 20 20 20 20 72  n(obj) {.      r
6020: 65 74 75 72 6e 20 69 73 4d 61 74 63 68 28 6f 62  eturn isMatch(ob
6030: 6a 2c 20 61 74 74 72 73 29 3b 0a 20 20 20 20 7d  j, attrs);.    }
6040: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 43 72 65 61  ;.  }..  // Crea
6050: 74 65 73 20 61 20 66 75 6e 63 74 69 6f 6e 20 74  tes a function t
6060: 68 61 74 2c 20 77 68 65 6e 20 70 61 73 73 65 64  hat, when passed
6070: 20 61 6e 20 6f 62 6a 65 63 74 2c 20 77 69 6c 6c   an object, will
6080: 20 74 72 61 76 65 72 73 65 20 74 68 61 74 20 6f   traverse that o
6090: 62 6a 65 63 74 e2 80 99 73 0a 20 20 2f 2f 20 70  bject...s.  // p
60a0: 72 6f 70 65 72 74 69 65 73 20 64 6f 77 6e 20 74  roperties down t
60b0: 68 65 20 67 69 76 65 6e 20 60 70 61 74 68 60 2c  he given `path`,
60c0: 20 73 70 65 63 69 66 69 65 64 20 61 73 20 61 6e   specified as an
60d0: 20 61 72 72 61 79 20 6f 66 20 6b 65 79 73 20 6f   array of keys o
60e0: 72 20 69 6e 64 69 63 65 73 2e 0a 20 20 66 75 6e  r indices..  fun
60f0: 63 74 69 6f 6e 20 70 72 6f 70 65 72 74 79 28 70  ction property(p
6100: 61 74 68 29 20 7b 0a 20 20 20 20 70 61 74 68 20  ath) {.    path 
6110: 3d 20 74 6f 50 61 74 68 24 31 28 70 61 74 68 29  = toPath$1(path)
6120: 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 66 75 6e  ;.    return fun
6130: 63 74 69 6f 6e 28 6f 62 6a 29 20 7b 0a 20 20 20  ction(obj) {.   
6140: 20 20 20 72 65 74 75 72 6e 20 64 65 65 70 47 65     return deepGe
6150: 74 28 6f 62 6a 2c 20 70 61 74 68 29 3b 0a 20 20  t(obj, path);.  
6160: 20 20 7d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49    };.  }..  // I
6170: 6e 74 65 72 6e 61 6c 20 66 75 6e 63 74 69 6f 6e  nternal function
6180: 20 74 68 61 74 20 72 65 74 75 72 6e 73 20 61 6e   that returns an
6190: 20 65 66 66 69 63 69 65 6e 74 20 28 66 6f 72 20   efficient (for 
61a0: 63 75 72 72 65 6e 74 20 65 6e 67 69 6e 65 73 29  current engines)
61b0: 20 76 65 72 73 69 6f 6e 0a 20 20 2f 2f 20 6f 66   version.  // of
61c0: 20 74 68 65 20 70 61 73 73 65 64 2d 69 6e 20 63   the passed-in c
61d0: 61 6c 6c 62 61 63 6b 2c 20 74 6f 20 62 65 20 72  allback, to be r
61e0: 65 70 65 61 74 65 64 6c 79 20 61 70 70 6c 69 65  epeatedly applie
61f0: 64 20 69 6e 20 6f 74 68 65 72 20 55 6e 64 65 72  d in other Under
6200: 73 63 6f 72 65 0a 20 20 2f 2f 20 66 75 6e 63 74  score.  // funct
6210: 69 6f 6e 73 2e 0a 20 20 66 75 6e 63 74 69 6f 6e  ions..  function
6220: 20 6f 70 74 69 6d 69 7a 65 43 62 28 66 75 6e 63   optimizeCb(func
6230: 2c 20 63 6f 6e 74 65 78 74 2c 20 61 72 67 43 6f  , context, argCo
6240: 75 6e 74 29 20 7b 0a 20 20 20 20 69 66 20 28 63  unt) {.    if (c
6250: 6f 6e 74 65 78 74 20 3d 3d 3d 20 76 6f 69 64 20  ontext === void 
6260: 30 29 20 72 65 74 75 72 6e 20 66 75 6e 63 3b 0a  0) return func;.
6270: 20 20 20 20 73 77 69 74 63 68 20 28 61 72 67 43      switch (argC
6280: 6f 75 6e 74 20 3d 3d 20 6e 75 6c 6c 20 3f 20 33  ount == null ? 3
6290: 20 3a 20 61 72 67 43 6f 75 6e 74 29 20 7b 0a 20   : argCount) {. 
62a0: 20 20 20 20 20 63 61 73 65 20 31 3a 20 72 65 74       case 1: ret
62b0: 75 72 6e 20 66 75 6e 63 74 69 6f 6e 28 76 61 6c  urn function(val
62c0: 75 65 29 20 7b 0a 20 20 20 20 20 20 20 20 72 65  ue) {.        re
62d0: 74 75 72 6e 20 66 75 6e 63 2e 63 61 6c 6c 28 63  turn func.call(c
62e0: 6f 6e 74 65 78 74 2c 20 76 61 6c 75 65 29 3b 0a  ontext, value);.
62f0: 20 20 20 20 20 20 7d 3b 0a 20 20 20 20 20 20 2f        };.      /
6300: 2f 20 54 68 65 20 32 2d 61 72 67 75 6d 65 6e 74  / The 2-argument
6310: 20 63 61 73 65 20 69 73 20 6f 6d 69 74 74 65 64   case is omitted
6320: 20 62 65 63 61 75 73 65 20 77 65 e2 80 99 72 65   because we...re
6330: 20 6e 6f 74 20 75 73 69 6e 67 20 69 74 2e 0a 20   not using it.. 
6340: 20 20 20 20 20 63 61 73 65 20 33 3a 20 72 65 74       case 3: ret
6350: 75 72 6e 20 66 75 6e 63 74 69 6f 6e 28 76 61 6c  urn function(val
6360: 75 65 2c 20 69 6e 64 65 78 2c 20 63 6f 6c 6c 65  ue, index, colle
6370: 63 74 69 6f 6e 29 20 7b 0a 20 20 20 20 20 20 20  ction) {.       
6380: 20 72 65 74 75 72 6e 20 66 75 6e 63 2e 63 61 6c   return func.cal
6390: 6c 28 63 6f 6e 74 65 78 74 2c 20 76 61 6c 75 65  l(context, value
63a0: 2c 20 69 6e 64 65 78 2c 20 63 6f 6c 6c 65 63 74  , index, collect
63b0: 69 6f 6e 29 3b 0a 20 20 20 20 20 20 7d 3b 0a 20  ion);.      };. 
63c0: 20 20 20 20 20 63 61 73 65 20 34 3a 20 72 65 74       case 4: ret
63d0: 75 72 6e 20 66 75 6e 63 74 69 6f 6e 28 61 63 63  urn function(acc
63e0: 75 6d 75 6c 61 74 6f 72 2c 20 76 61 6c 75 65 2c  umulator, value,
63f0: 20 69 6e 64 65 78 2c 20 63 6f 6c 6c 65 63 74 69   index, collecti
6400: 6f 6e 29 20 7b 0a 20 20 20 20 20 20 20 20 72 65  on) {.        re
6410: 74 75 72 6e 20 66 75 6e 63 2e 63 61 6c 6c 28 63  turn func.call(c
6420: 6f 6e 74 65 78 74 2c 20 61 63 63 75 6d 75 6c 61  ontext, accumula
6430: 74 6f 72 2c 20 76 61 6c 75 65 2c 20 69 6e 64 65  tor, value, inde
6440: 78 2c 20 63 6f 6c 6c 65 63 74 69 6f 6e 29 3b 0a  x, collection);.
6450: 20 20 20 20 20 20 7d 3b 0a 20 20 20 20 7d 0a 20        };.    }. 
6460: 20 20 20 72 65 74 75 72 6e 20 66 75 6e 63 74 69     return functi
6470: 6f 6e 28 29 20 7b 0a 20 20 20 20 20 20 72 65 74  on() {.      ret
6480: 75 72 6e 20 66 75 6e 63 2e 61 70 70 6c 79 28 63  urn func.apply(c
6490: 6f 6e 74 65 78 74 2c 20 61 72 67 75 6d 65 6e 74  ontext, argument
64a0: 73 29 3b 0a 20 20 20 20 7d 3b 0a 20 20 7d 0a 0a  s);.    };.  }..
64b0: 20 20 2f 2f 20 41 6e 20 69 6e 74 65 72 6e 61 6c    // An internal
64c0: 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 67 65 6e   function to gen
64d0: 65 72 61 74 65 20 63 61 6c 6c 62 61 63 6b 73 20  erate callbacks 
64e0: 74 68 61 74 20 63 61 6e 20 62 65 20 61 70 70 6c  that can be appl
64f0: 69 65 64 20 74 6f 20 65 61 63 68 0a 20 20 2f 2f  ied to each.  //
6500: 20 65 6c 65 6d 65 6e 74 20 69 6e 20 61 20 63 6f   element in a co
6510: 6c 6c 65 63 74 69 6f 6e 2c 20 72 65 74 75 72 6e  llection, return
6520: 69 6e 67 20 74 68 65 20 64 65 73 69 72 65 64 20  ing the desired 
6530: 72 65 73 75 6c 74 20 e2 80 94 20 65 69 74 68 65  result ... eithe
6540: 72 20 60 5f 2e 69 64 65 6e 74 69 74 79 60 2c 0a  r `_.identity`,.
6550: 20 20 2f 2f 20 61 6e 20 61 72 62 69 74 72 61 72    // an arbitrar
6560: 79 20 63 61 6c 6c 62 61 63 6b 2c 20 61 20 70 72  y callback, a pr
6570: 6f 70 65 72 74 79 20 6d 61 74 63 68 65 72 2c 20  operty matcher, 
6580: 6f 72 20 61 20 70 72 6f 70 65 72 74 79 20 61 63  or a property ac
6590: 63 65 73 73 6f 72 2e 0a 20 20 66 75 6e 63 74 69  cessor..  functi
65a0: 6f 6e 20 62 61 73 65 49 74 65 72 61 74 65 65 28  on baseIteratee(
65b0: 76 61 6c 75 65 2c 20 63 6f 6e 74 65 78 74 2c 20  value, context, 
65c0: 61 72 67 43 6f 75 6e 74 29 20 7b 0a 20 20 20 20  argCount) {.    
65d0: 69 66 20 28 76 61 6c 75 65 20 3d 3d 20 6e 75 6c  if (value == nul
65e0: 6c 29 20 72 65 74 75 72 6e 20 69 64 65 6e 74 69  l) return identi
65f0: 74 79 3b 0a 20 20 20 20 69 66 20 28 69 73 46 75  ty;.    if (isFu
6600: 6e 63 74 69 6f 6e 24 31 28 76 61 6c 75 65 29 29  nction$1(value))
6610: 20 72 65 74 75 72 6e 20 6f 70 74 69 6d 69 7a 65   return optimize
6620: 43 62 28 76 61 6c 75 65 2c 20 63 6f 6e 74 65 78  Cb(value, contex
6630: 74 2c 20 61 72 67 43 6f 75 6e 74 29 3b 0a 20 20  t, argCount);.  
6640: 20 20 69 66 20 28 69 73 4f 62 6a 65 63 74 28 76    if (isObject(v
6650: 61 6c 75 65 29 20 26 26 20 21 69 73 41 72 72 61  alue) && !isArra
6660: 79 28 76 61 6c 75 65 29 29 20 72 65 74 75 72 6e  y(value)) return
6670: 20 6d 61 74 63 68 65 72 28 76 61 6c 75 65 29 3b   matcher(value);
6680: 0a 20 20 20 20 72 65 74 75 72 6e 20 70 72 6f 70  .    return prop
6690: 65 72 74 79 28 76 61 6c 75 65 29 3b 0a 20 20 7d  erty(value);.  }
66a0: 0a 0a 20 20 2f 2f 20 45 78 74 65 72 6e 61 6c 20  ..  // External 
66b0: 77 72 61 70 70 65 72 20 66 6f 72 20 6f 75 72 20  wrapper for our 
66c0: 63 61 6c 6c 62 61 63 6b 20 67 65 6e 65 72 61 74  callback generat
66d0: 6f 72 2e 20 55 73 65 72 73 20 6d 61 79 20 63 75  or. Users may cu
66e0: 73 74 6f 6d 69 7a 65 0a 20 20 2f 2f 20 60 5f 2e  stomize.  // `_.
66f0: 69 74 65 72 61 74 65 65 60 20 69 66 20 74 68 65  iteratee` if the
6700: 79 20 77 61 6e 74 20 61 64 64 69 74 69 6f 6e 61  y want additiona
6710: 6c 20 70 72 65 64 69 63 61 74 65 2f 69 74 65 72  l predicate/iter
6720: 61 74 65 65 20 73 68 6f 72 74 68 61 6e 64 20 73  atee shorthand s
6730: 74 79 6c 65 73 2e 0a 20 20 2f 2f 20 54 68 69 73  tyles..  // This
6740: 20 61 62 73 74 72 61 63 74 69 6f 6e 20 68 69 64   abstraction hid
6750: 65 73 20 74 68 65 20 69 6e 74 65 72 6e 61 6c 2d  es the internal-
6760: 6f 6e 6c 79 20 60 61 72 67 43 6f 75 6e 74 60 20  only `argCount` 
6770: 61 72 67 75 6d 65 6e 74 2e 0a 20 20 66 75 6e 63  argument..  func
6780: 74 69 6f 6e 20 69 74 65 72 61 74 65 65 28 76 61  tion iteratee(va
6790: 6c 75 65 2c 20 63 6f 6e 74 65 78 74 29 20 7b 0a  lue, context) {.
67a0: 20 20 20 20 72 65 74 75 72 6e 20 62 61 73 65 49      return baseI
67b0: 74 65 72 61 74 65 65 28 76 61 6c 75 65 2c 20 63  teratee(value, c
67c0: 6f 6e 74 65 78 74 2c 20 49 6e 66 69 6e 69 74 79  ontext, Infinity
67d0: 29 3b 0a 20 20 7d 0a 20 20 5f 2e 69 74 65 72 61  );.  }.  _.itera
67e0: 74 65 65 20 3d 20 69 74 65 72 61 74 65 65 3b 0a  tee = iteratee;.
67f0: 0a 20 20 2f 2f 20 54 68 65 20 66 75 6e 63 74 69  .  // The functi
6800: 6f 6e 20 77 65 20 63 61 6c 6c 20 69 6e 74 65 72  on we call inter
6810: 6e 61 6c 6c 79 20 74 6f 20 67 65 6e 65 72 61 74  nally to generat
6820: 65 20 61 20 63 61 6c 6c 62 61 63 6b 2e 20 49 74  e a callback. It
6830: 20 69 6e 76 6f 6b 65 73 0a 20 20 2f 2f 20 60 5f   invokes.  // `_
6840: 2e 69 74 65 72 61 74 65 65 60 20 69 66 20 6f 76  .iteratee` if ov
6850: 65 72 72 69 64 64 65 6e 2c 20 6f 74 68 65 72 77  erridden, otherw
6860: 69 73 65 20 60 62 61 73 65 49 74 65 72 61 74 65  ise `baseIterate
6870: 65 60 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 63  e`..  function c
6880: 62 28 76 61 6c 75 65 2c 20 63 6f 6e 74 65 78 74  b(value, context
6890: 2c 20 61 72 67 43 6f 75 6e 74 29 20 7b 0a 20 20  , argCount) {.  
68a0: 20 20 69 66 20 28 5f 2e 69 74 65 72 61 74 65 65    if (_.iteratee
68b0: 20 21 3d 3d 20 69 74 65 72 61 74 65 65 29 20 72   !== iteratee) r
68c0: 65 74 75 72 6e 20 5f 2e 69 74 65 72 61 74 65 65  eturn _.iteratee
68d0: 28 76 61 6c 75 65 2c 20 63 6f 6e 74 65 78 74 29  (value, context)
68e0: 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 62 61 73  ;.    return bas
68f0: 65 49 74 65 72 61 74 65 65 28 76 61 6c 75 65 2c  eIteratee(value,
6900: 20 63 6f 6e 74 65 78 74 2c 20 61 72 67 43 6f 75   context, argCou
6910: 6e 74 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52  nt);.  }..  // R
6920: 65 74 75 72 6e 73 20 74 68 65 20 72 65 73 75 6c  eturns the resul
6930: 74 73 20 6f 66 20 61 70 70 6c 79 69 6e 67 20 74  ts of applying t
6940: 68 65 20 60 69 74 65 72 61 74 65 65 60 20 74 6f  he `iteratee` to
6950: 20 65 61 63 68 20 65 6c 65 6d 65 6e 74 20 6f 66   each element of
6960: 20 60 6f 62 6a 60 2e 0a 20 20 2f 2f 20 49 6e 20   `obj`..  // In 
6970: 63 6f 6e 74 72 61 73 74 20 74 6f 20 60 5f 2e 6d  contrast to `_.m
6980: 61 70 60 20 69 74 20 72 65 74 75 72 6e 73 20 61  ap` it returns a
6990: 6e 20 6f 62 6a 65 63 74 2e 0a 20 20 66 75 6e 63  n object..  func
69a0: 74 69 6f 6e 20 6d 61 70 4f 62 6a 65 63 74 28 6f  tion mapObject(o
69b0: 62 6a 2c 20 69 74 65 72 61 74 65 65 2c 20 63 6f  bj, iteratee, co
69c0: 6e 74 65 78 74 29 20 7b 0a 20 20 20 20 69 74 65  ntext) {.    ite
69d0: 72 61 74 65 65 20 3d 20 63 62 28 69 74 65 72 61  ratee = cb(itera
69e0: 74 65 65 2c 20 63 6f 6e 74 65 78 74 29 3b 0a 20  tee, context);. 
69f0: 20 20 20 76 61 72 20 5f 6b 65 79 73 20 3d 20 6b     var _keys = k
6a00: 65 79 73 28 6f 62 6a 29 2c 0a 20 20 20 20 20 20  eys(obj),.      
6a10: 20 20 6c 65 6e 67 74 68 20 3d 20 5f 6b 65 79 73    length = _keys
6a20: 2e 6c 65 6e 67 74 68 2c 0a 20 20 20 20 20 20 20  .length,.       
6a30: 20 72 65 73 75 6c 74 73 20 3d 20 7b 7d 3b 0a 20   results = {};. 
6a40: 20 20 20 66 6f 72 20 28 76 61 72 20 69 6e 64 65     for (var inde
6a50: 78 20 3d 20 30 3b 20 69 6e 64 65 78 20 3c 20 6c  x = 0; index < l
6a60: 65 6e 67 74 68 3b 20 69 6e 64 65 78 2b 2b 29 20  ength; index++) 
6a70: 7b 0a 20 20 20 20 20 20 76 61 72 20 63 75 72 72  {.      var curr
6a80: 65 6e 74 4b 65 79 20 3d 20 5f 6b 65 79 73 5b 69  entKey = _keys[i
6a90: 6e 64 65 78 5d 3b 0a 20 20 20 20 20 20 72 65 73  ndex];.      res
6aa0: 75 6c 74 73 5b 63 75 72 72 65 6e 74 4b 65 79 5d  ults[currentKey]
6ab0: 20 3d 20 69 74 65 72 61 74 65 65 28 6f 62 6a 5b   = iteratee(obj[
6ac0: 63 75 72 72 65 6e 74 4b 65 79 5d 2c 20 63 75 72  currentKey], cur
6ad0: 72 65 6e 74 4b 65 79 2c 20 6f 62 6a 29 3b 0a 20  rentKey, obj);. 
6ae0: 20 20 20 7d 0a 20 20 20 20 72 65 74 75 72 6e 20     }.    return 
6af0: 72 65 73 75 6c 74 73 3b 0a 20 20 7d 0a 0a 20 20  results;.  }..  
6b00: 2f 2f 20 50 72 65 64 69 63 61 74 65 2d 67 65 6e  // Predicate-gen
6b10: 65 72 61 74 69 6e 67 20 66 75 6e 63 74 69 6f 6e  erating function
6b20: 2e 20 4f 66 74 65 6e 20 75 73 65 66 75 6c 20 6f  . Often useful o
6b30: 75 74 73 69 64 65 20 6f 66 20 55 6e 64 65 72 73  utside of Unders
6b40: 63 6f 72 65 2e 0a 20 20 66 75 6e 63 74 69 6f 6e  core..  function
6b50: 20 6e 6f 6f 70 28 29 7b 7d 0a 0a 20 20 2f 2f 20   noop(){}..  // 
6b60: 47 65 6e 65 72 61 74 65 73 20 61 20 66 75 6e 63  Generates a func
6b70: 74 69 6f 6e 20 66 6f 72 20 61 20 67 69 76 65 6e  tion for a given
6b80: 20 6f 62 6a 65 63 74 20 74 68 61 74 20 72 65 74   object that ret
6b90: 75 72 6e 73 20 61 20 67 69 76 65 6e 20 70 72 6f  urns a given pro
6ba0: 70 65 72 74 79 2e 0a 20 20 66 75 6e 63 74 69 6f  perty..  functio
6bb0: 6e 20 70 72 6f 70 65 72 74 79 4f 66 28 6f 62 6a  n propertyOf(obj
6bc0: 29 20 7b 0a 20 20 20 20 69 66 20 28 6f 62 6a 20  ) {.    if (obj 
6bd0: 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 75 72 6e 20  == null) return 
6be0: 6e 6f 6f 70 3b 0a 20 20 20 20 72 65 74 75 72 6e  noop;.    return
6bf0: 20 66 75 6e 63 74 69 6f 6e 28 70 61 74 68 29 20   function(path) 
6c00: 7b 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 67  {.      return g
6c10: 65 74 28 6f 62 6a 2c 20 70 61 74 68 29 3b 0a 20  et(obj, path);. 
6c20: 20 20 20 7d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20     };.  }..  // 
6c30: 52 75 6e 20 61 20 66 75 6e 63 74 69 6f 6e 20 2a  Run a function *
6c40: 2a 6e 2a 2a 20 74 69 6d 65 73 2e 0a 20 20 66 75  *n** times..  fu
6c50: 6e 63 74 69 6f 6e 20 74 69 6d 65 73 28 6e 2c 20  nction times(n, 
6c60: 69 74 65 72 61 74 65 65 2c 20 63 6f 6e 74 65 78  iteratee, contex
6c70: 74 29 20 7b 0a 20 20 20 20 76 61 72 20 61 63 63  t) {.    var acc
6c80: 75 6d 20 3d 20 41 72 72 61 79 28 4d 61 74 68 2e  um = Array(Math.
6c90: 6d 61 78 28 30 2c 20 6e 29 29 3b 0a 20 20 20 20  max(0, n));.    
6ca0: 69 74 65 72 61 74 65 65 20 3d 20 6f 70 74 69 6d  iteratee = optim
6cb0: 69 7a 65 43 62 28 69 74 65 72 61 74 65 65 2c 20  izeCb(iteratee, 
6cc0: 63 6f 6e 74 65 78 74 2c 20 31 29 3b 0a 20 20 20  context, 1);.   
6cd0: 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b   for (var i = 0;
6ce0: 20 69 20 3c 20 6e 3b 20 69 2b 2b 29 20 61 63 63   i < n; i++) acc
6cf0: 75 6d 5b 69 5d 20 3d 20 69 74 65 72 61 74 65 65  um[i] = iteratee
6d00: 28 69 29 3b 0a 20 20 20 20 72 65 74 75 72 6e 20  (i);.    return 
6d10: 61 63 63 75 6d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f  accum;.  }..  //
6d20: 20 52 65 74 75 72 6e 20 61 20 72 61 6e 64 6f 6d   Return a random
6d30: 20 69 6e 74 65 67 65 72 20 62 65 74 77 65 65 6e   integer between
6d40: 20 60 6d 69 6e 60 20 61 6e 64 20 60 6d 61 78 60   `min` and `max`
6d50: 20 28 69 6e 63 6c 75 73 69 76 65 29 2e 0a 20 20   (inclusive)..  
6d60: 66 75 6e 63 74 69 6f 6e 20 72 61 6e 64 6f 6d 28  function random(
6d70: 6d 69 6e 2c 20 6d 61 78 29 20 7b 0a 20 20 20 20  min, max) {.    
6d80: 69 66 20 28 6d 61 78 20 3d 3d 20 6e 75 6c 6c 29  if (max == null)
6d90: 20 7b 0a 20 20 20 20 20 20 6d 61 78 20 3d 20 6d   {.      max = m
6da0: 69 6e 3b 0a 20 20 20 20 20 20 6d 69 6e 20 3d 20  in;.      min = 
6db0: 30 3b 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 74  0;.    }.    ret
6dc0: 75 72 6e 20 6d 69 6e 20 2b 20 4d 61 74 68 2e 66  urn min + Math.f
6dd0: 6c 6f 6f 72 28 4d 61 74 68 2e 72 61 6e 64 6f 6d  loor(Math.random
6de0: 28 29 20 2a 20 28 6d 61 78 20 2d 20 6d 69 6e 20  () * (max - min 
6df0: 2b 20 31 29 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2f  + 1));.  }..  //
6e00: 20 41 20 28 70 6f 73 73 69 62 6c 79 20 66 61 73   A (possibly fas
6e10: 74 65 72 29 20 77 61 79 20 74 6f 20 67 65 74 20  ter) way to get 
6e20: 74 68 65 20 63 75 72 72 65 6e 74 20 74 69 6d 65  the current time
6e30: 73 74 61 6d 70 20 61 73 20 61 6e 20 69 6e 74 65  stamp as an inte
6e40: 67 65 72 2e 0a 20 20 76 61 72 20 6e 6f 77 20 3d  ger..  var now =
6e50: 20 44 61 74 65 2e 6e 6f 77 20 7c 7c 20 66 75 6e   Date.now || fun
6e60: 63 74 69 6f 6e 28 29 20 7b 0a 20 20 20 20 72 65  ction() {.    re
6e70: 74 75 72 6e 20 6e 65 77 20 44 61 74 65 28 29 2e  turn new Date().
6e80: 67 65 74 54 69 6d 65 28 29 3b 0a 20 20 7d 3b 0a  getTime();.  };.
6e90: 0a 20 20 2f 2f 20 49 6e 74 65 72 6e 61 6c 20 68  .  // Internal h
6ea0: 65 6c 70 65 72 20 74 6f 20 67 65 6e 65 72 61 74  elper to generat
6eb0: 65 20 66 75 6e 63 74 69 6f 6e 73 20 66 6f 72 20  e functions for 
6ec0: 65 73 63 61 70 69 6e 67 20 61 6e 64 20 75 6e 65  escaping and une
6ed0: 73 63 61 70 69 6e 67 20 73 74 72 69 6e 67 73 0a  scaping strings.
6ee0: 20 20 2f 2f 20 74 6f 2f 66 72 6f 6d 20 48 54 4d    // to/from HTM
6ef0: 4c 20 69 6e 74 65 72 70 6f 6c 61 74 69 6f 6e 2e  L interpolation.
6f00: 0a 20 20 66 75 6e 63 74 69 6f 6e 20 63 72 65 61  .  function crea
6f10: 74 65 45 73 63 61 70 65 72 28 6d 61 70 29 20 7b  teEscaper(map) {
6f20: 0a 20 20 20 20 76 61 72 20 65 73 63 61 70 65 72  .    var escaper
6f30: 20 3d 20 66 75 6e 63 74 69 6f 6e 28 6d 61 74 63   = function(matc
6f40: 68 29 20 7b 0a 20 20 20 20 20 20 72 65 74 75 72  h) {.      retur
6f50: 6e 20 6d 61 70 5b 6d 61 74 63 68 5d 3b 0a 20 20  n map[match];.  
6f60: 20 20 7d 3b 0a 20 20 20 20 2f 2f 20 52 65 67 65    };.    // Rege
6f70: 78 65 73 20 66 6f 72 20 69 64 65 6e 74 69 66 79  xes for identify
6f80: 69 6e 67 20 61 20 6b 65 79 20 74 68 61 74 20 6e  ing a key that n
6f90: 65 65 64 73 20 74 6f 20 62 65 20 65 73 63 61 70  eeds to be escap
6fa0: 65 64 2e 0a 20 20 20 20 76 61 72 20 73 6f 75 72  ed..    var sour
6fb0: 63 65 20 3d 20 27 28 3f 3a 27 20 2b 20 6b 65 79  ce = '(?:' + key
6fc0: 73 28 6d 61 70 29 2e 6a 6f 69 6e 28 27 7c 27 29  s(map).join('|')
6fd0: 20 2b 20 27 29 27 3b 0a 20 20 20 20 76 61 72 20   + ')';.    var 
6fe0: 74 65 73 74 52 65 67 65 78 70 20 3d 20 52 65 67  testRegexp = Reg
6ff0: 45 78 70 28 73 6f 75 72 63 65 29 3b 0a 20 20 20  Exp(source);.   
7000: 20 76 61 72 20 72 65 70 6c 61 63 65 52 65 67 65   var replaceRege
7010: 78 70 20 3d 20 52 65 67 45 78 70 28 73 6f 75 72  xp = RegExp(sour
7020: 63 65 2c 20 27 67 27 29 3b 0a 20 20 20 20 72 65  ce, 'g');.    re
7030: 74 75 72 6e 20 66 75 6e 63 74 69 6f 6e 28 73 74  turn function(st
7040: 72 69 6e 67 29 20 7b 0a 20 20 20 20 20 20 73 74  ring) {.      st
7050: 72 69 6e 67 20 3d 20 73 74 72 69 6e 67 20 3d 3d  ring = string ==
7060: 20 6e 75 6c 6c 20 3f 20 27 27 20 3a 20 27 27 20   null ? '' : '' 
7070: 2b 20 73 74 72 69 6e 67 3b 0a 20 20 20 20 20 20  + string;.      
7080: 72 65 74 75 72 6e 20 74 65 73 74 52 65 67 65 78  return testRegex
7090: 70 2e 74 65 73 74 28 73 74 72 69 6e 67 29 20 3f  p.test(string) ?
70a0: 20 73 74 72 69 6e 67 2e 72 65 70 6c 61 63 65 28   string.replace(
70b0: 72 65 70 6c 61 63 65 52 65 67 65 78 70 2c 20 65  replaceRegexp, e
70c0: 73 63 61 70 65 72 29 20 3a 20 73 74 72 69 6e 67  scaper) : string
70d0: 3b 0a 20 20 20 20 7d 3b 0a 20 20 7d 0a 0a 20 20  ;.    };.  }..  
70e0: 2f 2f 20 49 6e 74 65 72 6e 61 6c 20 6c 69 73 74  // Internal list
70f0: 20 6f 66 20 48 54 4d 4c 20 65 6e 74 69 74 69 65   of HTML entitie
7100: 73 20 66 6f 72 20 65 73 63 61 70 69 6e 67 2e 0a  s for escaping..
7110: 20 20 76 61 72 20 65 73 63 61 70 65 4d 61 70 20    var escapeMap 
7120: 3d 20 7b 0a 20 20 20 20 27 26 27 3a 20 27 26 61  = {.    '&': '&a
7130: 6d 70 3b 27 2c 0a 20 20 20 20 27 3c 27 3a 20 27  mp;',.    '<': '
7140: 26 6c 74 3b 27 2c 0a 20 20 20 20 27 3e 27 3a 20  &lt;',.    '>': 
7150: 27 26 67 74 3b 27 2c 0a 20 20 20 20 27 22 27 3a  '&gt;',.    '"':
7160: 20 27 26 71 75 6f 74 3b 27 2c 0a 20 20 20 20 22   '&quot;',.    "
7170: 27 22 3a 20 27 26 23 78 32 37 3b 27 2c 0a 20 20  '": '&#x27;',.  
7180: 20 20 27 60 27 3a 20 27 26 23 78 36 30 3b 27 0a    '`': '&#x60;'.
7190: 20 20 7d 3b 0a 0a 20 20 2f 2f 20 46 75 6e 63 74    };..  // Funct
71a0: 69 6f 6e 20 66 6f 72 20 65 73 63 61 70 69 6e 67  ion for escaping
71b0: 20 73 74 72 69 6e 67 73 20 74 6f 20 48 54 4d 4c   strings to HTML
71c0: 20 69 6e 74 65 72 70 6f 6c 61 74 69 6f 6e 2e 0a   interpolation..
71d0: 20 20 76 61 72 20 5f 65 73 63 61 70 65 20 3d 20    var _escape = 
71e0: 63 72 65 61 74 65 45 73 63 61 70 65 72 28 65 73  createEscaper(es
71f0: 63 61 70 65 4d 61 70 29 3b 0a 0a 20 20 2f 2f 20  capeMap);..  // 
7200: 49 6e 74 65 72 6e 61 6c 20 6c 69 73 74 20 6f 66  Internal list of
7210: 20 48 54 4d 4c 20 65 6e 74 69 74 69 65 73 20 66   HTML entities f
7220: 6f 72 20 75 6e 65 73 63 61 70 69 6e 67 2e 0a 20  or unescaping.. 
7230: 20 76 61 72 20 75 6e 65 73 63 61 70 65 4d 61 70   var unescapeMap
7240: 20 3d 20 69 6e 76 65 72 74 28 65 73 63 61 70 65   = invert(escape
7250: 4d 61 70 29 3b 0a 0a 20 20 2f 2f 20 46 75 6e 63  Map);..  // Func
7260: 74 69 6f 6e 20 66 6f 72 20 75 6e 65 73 63 61 70  tion for unescap
7270: 69 6e 67 20 73 74 72 69 6e 67 73 20 66 72 6f 6d  ing strings from
7280: 20 48 54 4d 4c 20 69 6e 74 65 72 70 6f 6c 61 74   HTML interpolat
7290: 69 6f 6e 2e 0a 20 20 76 61 72 20 5f 75 6e 65 73  ion..  var _unes
72a0: 63 61 70 65 20 3d 20 63 72 65 61 74 65 45 73 63  cape = createEsc
72b0: 61 70 65 72 28 75 6e 65 73 63 61 70 65 4d 61 70  aper(unescapeMap
72c0: 29 3b 0a 0a 20 20 2f 2f 20 42 79 20 64 65 66 61  );..  // By defa
72d0: 75 6c 74 2c 20 55 6e 64 65 72 73 63 6f 72 65 20  ult, Underscore 
72e0: 75 73 65 73 20 45 52 42 2d 73 74 79 6c 65 20 74  uses ERB-style t
72f0: 65 6d 70 6c 61 74 65 20 64 65 6c 69 6d 69 74 65  emplate delimite
7300: 72 73 2e 20 43 68 61 6e 67 65 20 74 68 65 0a 20  rs. Change the. 
7310: 20 2f 2f 20 66 6f 6c 6c 6f 77 69 6e 67 20 74 65   // following te
7320: 6d 70 6c 61 74 65 20 73 65 74 74 69 6e 67 73 20  mplate settings 
7330: 74 6f 20 75 73 65 20 61 6c 74 65 72 6e 61 74 69  to use alternati
7340: 76 65 20 64 65 6c 69 6d 69 74 65 72 73 2e 0a 20  ve delimiters.. 
7350: 20 76 61 72 20 74 65 6d 70 6c 61 74 65 53 65 74   var templateSet
7360: 74 69 6e 67 73 20 3d 20 5f 2e 74 65 6d 70 6c 61  tings = _.templa
7370: 74 65 53 65 74 74 69 6e 67 73 20 3d 20 7b 0a 20  teSettings = {. 
7380: 20 20 20 65 76 61 6c 75 61 74 65 3a 20 2f 3c 25     evaluate: /<%
7390: 28 5b 5c 73 5c 53 5d 2b 3f 29 25 3e 2f 67 2c 0a  ([\s\S]+?)%>/g,.
73a0: 20 20 20 20 69 6e 74 65 72 70 6f 6c 61 74 65 3a      interpolate:
73b0: 20 2f 3c 25 3d 28 5b 5c 73 5c 53 5d 2b 3f 29 25   /<%=([\s\S]+?)%
73c0: 3e 2f 67 2c 0a 20 20 20 20 65 73 63 61 70 65 3a  >/g,.    escape:
73d0: 20 2f 3c 25 2d 28 5b 5c 73 5c 53 5d 2b 3f 29 25   /<%-([\s\S]+?)%
73e0: 3e 2f 67 0a 20 20 7d 3b 0a 0a 20 20 2f 2f 20 57  >/g.  };..  // W
73f0: 68 65 6e 20 63 75 73 74 6f 6d 69 7a 69 6e 67 20  hen customizing 
7400: 60 5f 2e 74 65 6d 70 6c 61 74 65 53 65 74 74 69  `_.templateSetti
7410: 6e 67 73 60 2c 20 69 66 20 79 6f 75 20 64 6f 6e  ngs`, if you don
7420: 27 74 20 77 61 6e 74 20 74 6f 20 64 65 66 69 6e  't want to defin
7430: 65 20 61 6e 0a 20 20 2f 2f 20 69 6e 74 65 72 70  e an.  // interp
7440: 6f 6c 61 74 69 6f 6e 2c 20 65 76 61 6c 75 61 74  olation, evaluat
7450: 69 6f 6e 20 6f 72 20 65 73 63 61 70 69 6e 67 20  ion or escaping 
7460: 72 65 67 65 78 2c 20 77 65 20 6e 65 65 64 20 6f  regex, we need o
7470: 6e 65 20 74 68 61 74 20 69 73 0a 20 20 2f 2f 20  ne that is.  // 
7480: 67 75 61 72 61 6e 74 65 65 64 20 6e 6f 74 20 74  guaranteed not t
7490: 6f 20 6d 61 74 63 68 2e 0a 20 20 76 61 72 20 6e  o match..  var n
74a0: 6f 4d 61 74 63 68 20 3d 20 2f 28 2e 29 5e 2f 3b  oMatch = /(.)^/;
74b0: 0a 0a 20 20 2f 2f 20 43 65 72 74 61 69 6e 20 63  ..  // Certain c
74c0: 68 61 72 61 63 74 65 72 73 20 6e 65 65 64 20 74  haracters need t
74d0: 6f 20 62 65 20 65 73 63 61 70 65 64 20 73 6f 20  o be escaped so 
74e0: 74 68 61 74 20 74 68 65 79 20 63 61 6e 20 62 65  that they can be
74f0: 20 70 75 74 20 69 6e 74 6f 20 61 0a 20 20 2f 2f   put into a.  //
7500: 20 73 74 72 69 6e 67 20 6c 69 74 65 72 61 6c 2e   string literal.
7510: 0a 20 20 76 61 72 20 65 73 63 61 70 65 73 20 3d  .  var escapes =
7520: 20 7b 0a 20 20 20 20 22 27 22 3a 20 22 27 22 2c   {.    "'": "'",
7530: 0a 20 20 20 20 27 5c 5c 27 3a 20 27 5c 5c 27 2c  .    '\\': '\\',
7540: 0a 20 20 20 20 27 5c 72 27 3a 20 27 72 27 2c 0a  .    '\r': 'r',.
7550: 20 20 20 20 27 5c 6e 27 3a 20 27 6e 27 2c 0a 20      '\n': 'n',. 
7560: 20 20 20 27 5c 75 32 30 32 38 27 3a 20 27 75 32     '\u2028': 'u2
7570: 30 32 38 27 2c 0a 20 20 20 20 27 5c 75 32 30 32  028',.    '\u202
7580: 39 27 3a 20 27 75 32 30 32 39 27 0a 20 20 7d 3b  9': 'u2029'.  };
7590: 0a 0a 20 20 76 61 72 20 65 73 63 61 70 65 52 65  ..  var escapeRe
75a0: 67 45 78 70 20 3d 20 2f 5c 5c 7c 27 7c 5c 72 7c  gExp = /\\|'|\r|
75b0: 5c 6e 7c 5c 75 32 30 32 38 7c 5c 75 32 30 32 39  \n|\u2028|\u2029
75c0: 2f 67 3b 0a 0a 20 20 66 75 6e 63 74 69 6f 6e 20  /g;..  function 
75d0: 65 73 63 61 70 65 43 68 61 72 28 6d 61 74 63 68  escapeChar(match
75e0: 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 27  ) {.    return '
75f0: 5c 5c 27 20 2b 20 65 73 63 61 70 65 73 5b 6d 61  \\' + escapes[ma
7600: 74 63 68 5d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20  tch];.  }..  // 
7610: 4a 61 76 61 53 63 72 69 70 74 20 6d 69 63 72 6f  JavaScript micro
7620: 2d 74 65 6d 70 6c 61 74 69 6e 67 2c 20 73 69 6d  -templating, sim
7630: 69 6c 61 72 20 74 6f 20 4a 6f 68 6e 20 52 65 73  ilar to John Res
7640: 69 67 27 73 20 69 6d 70 6c 65 6d 65 6e 74 61 74  ig's implementat
7650: 69 6f 6e 2e 0a 20 20 2f 2f 20 55 6e 64 65 72 73  ion..  // Unders
7660: 63 6f 72 65 20 74 65 6d 70 6c 61 74 69 6e 67 20  core templating 
7670: 68 61 6e 64 6c 65 73 20 61 72 62 69 74 72 61 72  handles arbitrar
7680: 79 20 64 65 6c 69 6d 69 74 65 72 73 2c 20 70 72  y delimiters, pr
7690: 65 73 65 72 76 65 73 20 77 68 69 74 65 73 70 61  eserves whitespa
76a0: 63 65 2c 0a 20 20 2f 2f 20 61 6e 64 20 63 6f 72  ce,.  // and cor
76b0: 72 65 63 74 6c 79 20 65 73 63 61 70 65 73 20 71  rectly escapes q
76c0: 75 6f 74 65 73 20 77 69 74 68 69 6e 20 69 6e 74  uotes within int
76d0: 65 72 70 6f 6c 61 74 65 64 20 63 6f 64 65 2e 0a  erpolated code..
76e0: 20 20 2f 2f 20 4e 42 3a 20 60 6f 6c 64 53 65 74    // NB: `oldSet
76f0: 74 69 6e 67 73 60 20 6f 6e 6c 79 20 65 78 69 73  tings` only exis
7700: 74 73 20 66 6f 72 20 62 61 63 6b 77 61 72 64 73  ts for backwards
7710: 20 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 2e 0a   compatibility..
7720: 20 20 66 75 6e 63 74 69 6f 6e 20 74 65 6d 70 6c    function templ
7730: 61 74 65 28 74 65 78 74 2c 20 73 65 74 74 69 6e  ate(text, settin
7740: 67 73 2c 20 6f 6c 64 53 65 74 74 69 6e 67 73 29  gs, oldSettings)
7750: 20 7b 0a 20 20 20 20 69 66 20 28 21 73 65 74 74   {.    if (!sett
7760: 69 6e 67 73 20 26 26 20 6f 6c 64 53 65 74 74 69  ings && oldSetti
7770: 6e 67 73 29 20 73 65 74 74 69 6e 67 73 20 3d 20  ngs) settings = 
7780: 6f 6c 64 53 65 74 74 69 6e 67 73 3b 0a 20 20 20  oldSettings;.   
7790: 20 73 65 74 74 69 6e 67 73 20 3d 20 64 65 66 61   settings = defa
77a0: 75 6c 74 73 28 7b 7d 2c 20 73 65 74 74 69 6e 67  ults({}, setting
77b0: 73 2c 20 5f 2e 74 65 6d 70 6c 61 74 65 53 65 74  s, _.templateSet
77c0: 74 69 6e 67 73 29 3b 0a 0a 20 20 20 20 2f 2f 20  tings);..    // 
77d0: 43 6f 6d 62 69 6e 65 20 64 65 6c 69 6d 69 74 65  Combine delimite
77e0: 72 73 20 69 6e 74 6f 20 6f 6e 65 20 72 65 67 75  rs into one regu
77f0: 6c 61 72 20 65 78 70 72 65 73 73 69 6f 6e 20 76  lar expression v
7800: 69 61 20 61 6c 74 65 72 6e 61 74 69 6f 6e 2e 0a  ia alternation..
7810: 20 20 20 20 76 61 72 20 6d 61 74 63 68 65 72 20      var matcher 
7820: 3d 20 52 65 67 45 78 70 28 5b 0a 20 20 20 20 20  = RegExp([.     
7830: 20 28 73 65 74 74 69 6e 67 73 2e 65 73 63 61 70   (settings.escap
7840: 65 20 7c 7c 20 6e 6f 4d 61 74 63 68 29 2e 73 6f  e || noMatch).so
7850: 75 72 63 65 2c 0a 20 20 20 20 20 20 28 73 65 74  urce,.      (set
7860: 74 69 6e 67 73 2e 69 6e 74 65 72 70 6f 6c 61 74  tings.interpolat
7870: 65 20 7c 7c 20 6e 6f 4d 61 74 63 68 29 2e 73 6f  e || noMatch).so
7880: 75 72 63 65 2c 0a 20 20 20 20 20 20 28 73 65 74  urce,.      (set
7890: 74 69 6e 67 73 2e 65 76 61 6c 75 61 74 65 20 7c  tings.evaluate |
78a0: 7c 20 6e 6f 4d 61 74 63 68 29 2e 73 6f 75 72 63  | noMatch).sourc
78b0: 65 0a 20 20 20 20 5d 2e 6a 6f 69 6e 28 27 7c 27  e.    ].join('|'
78c0: 29 20 2b 20 27 7c 24 27 2c 20 27 67 27 29 3b 0a  ) + '|$', 'g');.
78d0: 0a 20 20 20 20 2f 2f 20 43 6f 6d 70 69 6c 65 20  .    // Compile 
78e0: 74 68 65 20 74 65 6d 70 6c 61 74 65 20 73 6f 75  the template sou
78f0: 72 63 65 2c 20 65 73 63 61 70 69 6e 67 20 73 74  rce, escaping st
7900: 72 69 6e 67 20 6c 69 74 65 72 61 6c 73 20 61 70  ring literals ap
7910: 70 72 6f 70 72 69 61 74 65 6c 79 2e 0a 20 20 20  propriately..   
7920: 20 76 61 72 20 69 6e 64 65 78 20 3d 20 30 3b 0a   var index = 0;.
7930: 20 20 20 20 76 61 72 20 73 6f 75 72 63 65 20 3d      var source =
7940: 20 22 5f 5f 70 2b 3d 27 22 3b 0a 20 20 20 20 74   "__p+='";.    t
7950: 65 78 74 2e 72 65 70 6c 61 63 65 28 6d 61 74 63  ext.replace(matc
7960: 68 65 72 2c 20 66 75 6e 63 74 69 6f 6e 28 6d 61  her, function(ma
7970: 74 63 68 2c 20 65 73 63 61 70 65 2c 20 69 6e 74  tch, escape, int
7980: 65 72 70 6f 6c 61 74 65 2c 20 65 76 61 6c 75 61  erpolate, evalua
7990: 74 65 2c 20 6f 66 66 73 65 74 29 20 7b 0a 20 20  te, offset) {.  
79a0: 20 20 20 20 73 6f 75 72 63 65 20 2b 3d 20 74 65      source += te
79b0: 78 74 2e 73 6c 69 63 65 28 69 6e 64 65 78 2c 20  xt.slice(index, 
79c0: 6f 66 66 73 65 74 29 2e 72 65 70 6c 61 63 65 28  offset).replace(
79d0: 65 73 63 61 70 65 52 65 67 45 78 70 2c 20 65 73  escapeRegExp, es
79e0: 63 61 70 65 43 68 61 72 29 3b 0a 20 20 20 20 20  capeChar);.     
79f0: 20 69 6e 64 65 78 20 3d 20 6f 66 66 73 65 74 20   index = offset 
7a00: 2b 20 6d 61 74 63 68 2e 6c 65 6e 67 74 68 3b 0a  + match.length;.
7a10: 0a 20 20 20 20 20 20 69 66 20 28 65 73 63 61 70  .      if (escap
7a20: 65 29 20 7b 0a 20 20 20 20 20 20 20 20 73 6f 75  e) {.        sou
7a30: 72 63 65 20 2b 3d 20 22 27 2b 5c 6e 28 28 5f 5f  rce += "'+\n((__
7a40: 74 3d 28 22 20 2b 20 65 73 63 61 70 65 20 2b 20  t=(" + escape + 
7a50: 22 29 29 3d 3d 6e 75 6c 6c 3f 27 27 3a 5f 2e 65  "))==null?'':_.e
7a60: 73 63 61 70 65 28 5f 5f 74 29 29 2b 5c 6e 27 22  scape(__t))+\n'"
7a70: 3b 0a 20 20 20 20 20 20 7d 20 65 6c 73 65 20 69  ;.      } else i
7a80: 66 20 28 69 6e 74 65 72 70 6f 6c 61 74 65 29 20  f (interpolate) 
7a90: 7b 0a 20 20 20 20 20 20 20 20 73 6f 75 72 63 65  {.        source
7aa0: 20 2b 3d 20 22 27 2b 5c 6e 28 28 5f 5f 74 3d 28   += "'+\n((__t=(
7ab0: 22 20 2b 20 69 6e 74 65 72 70 6f 6c 61 74 65 20  " + interpolate 
7ac0: 2b 20 22 29 29 3d 3d 6e 75 6c 6c 3f 27 27 3a 5f  + "))==null?'':_
7ad0: 5f 74 29 2b 5c 6e 27 22 3b 0a 20 20 20 20 20 20  _t)+\n'";.      
7ae0: 7d 20 65 6c 73 65 20 69 66 20 28 65 76 61 6c 75  } else if (evalu
7af0: 61 74 65 29 20 7b 0a 20 20 20 20 20 20 20 20 73  ate) {.        s
7b00: 6f 75 72 63 65 20 2b 3d 20 22 27 3b 5c 6e 22 20  ource += "';\n" 
7b10: 2b 20 65 76 61 6c 75 61 74 65 20 2b 20 22 5c 6e  + evaluate + "\n
7b20: 5f 5f 70 2b 3d 27 22 3b 0a 20 20 20 20 20 20 7d  __p+='";.      }
7b30: 0a 0a 20 20 20 20 20 20 2f 2f 20 41 64 6f 62 65  ..      // Adobe
7b40: 20 56 4d 73 20 6e 65 65 64 20 74 68 65 20 6d 61   VMs need the ma
7b50: 74 63 68 20 72 65 74 75 72 6e 65 64 20 74 6f 20  tch returned to 
7b60: 70 72 6f 64 75 63 65 20 74 68 65 20 63 6f 72 72  produce the corr
7b70: 65 63 74 20 6f 66 66 73 65 74 2e 0a 20 20 20 20  ect offset..    
7b80: 20 20 72 65 74 75 72 6e 20 6d 61 74 63 68 3b 0a    return match;.
7b90: 20 20 20 20 7d 29 3b 0a 20 20 20 20 73 6f 75 72      });.    sour
7ba0: 63 65 20 2b 3d 20 22 27 3b 5c 6e 22 3b 0a 0a 20  ce += "';\n";.. 
7bb0: 20 20 20 2f 2f 20 49 66 20 61 20 76 61 72 69 61     // If a varia
7bc0: 62 6c 65 20 69 73 20 6e 6f 74 20 73 70 65 63 69  ble is not speci
7bd0: 66 69 65 64 2c 20 70 6c 61 63 65 20 64 61 74 61  fied, place data
7be0: 20 76 61 6c 75 65 73 20 69 6e 20 6c 6f 63 61 6c   values in local
7bf0: 20 73 63 6f 70 65 2e 0a 20 20 20 20 69 66 20 28   scope..    if (
7c00: 21 73 65 74 74 69 6e 67 73 2e 76 61 72 69 61 62  !settings.variab
7c10: 6c 65 29 20 73 6f 75 72 63 65 20 3d 20 27 77 69  le) source = 'wi
7c20: 74 68 28 6f 62 6a 7c 7c 7b 7d 29 7b 5c 6e 27 20  th(obj||{}){\n' 
7c30: 2b 20 73 6f 75 72 63 65 20 2b 20 27 7d 5c 6e 27  + source + '}\n'
7c40: 3b 0a 0a 20 20 20 20 73 6f 75 72 63 65 20 3d 20  ;..    source = 
7c50: 22 76 61 72 20 5f 5f 74 2c 5f 5f 70 3d 27 27 2c  "var __t,__p='',
7c60: 5f 5f 6a 3d 41 72 72 61 79 2e 70 72 6f 74 6f 74  __j=Array.protot
7c70: 79 70 65 2e 6a 6f 69 6e 2c 22 20 2b 0a 20 20 20  ype.join," +.   
7c80: 20 20 20 22 70 72 69 6e 74 3d 66 75 6e 63 74 69     "print=functi
7c90: 6f 6e 28 29 7b 5f 5f 70 2b 3d 5f 5f 6a 2e 63 61  on(){__p+=__j.ca
7ca0: 6c 6c 28 61 72 67 75 6d 65 6e 74 73 2c 27 27 29  ll(arguments,'')
7cb0: 3b 7d 3b 5c 6e 22 20 2b 0a 20 20 20 20 20 20 73  ;};\n" +.      s
7cc0: 6f 75 72 63 65 20 2b 20 27 72 65 74 75 72 6e 20  ource + 'return 
7cd0: 5f 5f 70 3b 5c 6e 27 3b 0a 0a 20 20 20 20 76 61  __p;\n';..    va
7ce0: 72 20 72 65 6e 64 65 72 3b 0a 20 20 20 20 74 72  r render;.    tr
7cf0: 79 20 7b 0a 20 20 20 20 20 20 72 65 6e 64 65 72  y {.      render
7d00: 20 3d 20 6e 65 77 20 46 75 6e 63 74 69 6f 6e 28   = new Function(
7d10: 73 65 74 74 69 6e 67 73 2e 76 61 72 69 61 62 6c  settings.variabl
7d20: 65 20 7c 7c 20 27 6f 62 6a 27 2c 20 27 5f 27 2c  e || 'obj', '_',
7d30: 20 73 6f 75 72 63 65 29 3b 0a 20 20 20 20 7d 20   source);.    } 
7d40: 63 61 74 63 68 20 28 65 29 20 7b 0a 20 20 20 20  catch (e) {.    
7d50: 20 20 65 2e 73 6f 75 72 63 65 20 3d 20 73 6f 75    e.source = sou
7d60: 72 63 65 3b 0a 20 20 20 20 20 20 74 68 72 6f 77  rce;.      throw
7d70: 20 65 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 76   e;.    }..    v
7d80: 61 72 20 74 65 6d 70 6c 61 74 65 20 3d 20 66 75  ar template = fu
7d90: 6e 63 74 69 6f 6e 28 64 61 74 61 29 20 7b 0a 20  nction(data) {. 
7da0: 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 6e 64       return rend
7db0: 65 72 2e 63 61 6c 6c 28 74 68 69 73 2c 20 64 61  er.call(this, da
7dc0: 74 61 2c 20 5f 29 3b 0a 20 20 20 20 7d 3b 0a 0a  ta, _);.    };..
7dd0: 20 20 20 20 2f 2f 20 50 72 6f 76 69 64 65 20 74      // Provide t
7de0: 68 65 20 63 6f 6d 70 69 6c 65 64 20 73 6f 75 72  he compiled sour
7df0: 63 65 20 61 73 20 61 20 63 6f 6e 76 65 6e 69 65  ce as a convenie
7e00: 6e 63 65 20 66 6f 72 20 70 72 65 63 6f 6d 70 69  nce for precompi
7e10: 6c 61 74 69 6f 6e 2e 0a 20 20 20 20 76 61 72 20  lation..    var 
7e20: 61 72 67 75 6d 65 6e 74 20 3d 20 73 65 74 74 69  argument = setti
7e30: 6e 67 73 2e 76 61 72 69 61 62 6c 65 20 7c 7c 20  ngs.variable || 
7e40: 27 6f 62 6a 27 3b 0a 20 20 20 20 74 65 6d 70 6c  'obj';.    templ
7e50: 61 74 65 2e 73 6f 75 72 63 65 20 3d 20 27 66 75  ate.source = 'fu
7e60: 6e 63 74 69 6f 6e 28 27 20 2b 20 61 72 67 75 6d  nction(' + argum
7e70: 65 6e 74 20 2b 20 27 29 7b 5c 6e 27 20 2b 20 73  ent + '){\n' + s
7e80: 6f 75 72 63 65 20 2b 20 27 7d 27 3b 0a 0a 20 20  ource + '}';..  
7e90: 20 20 72 65 74 75 72 6e 20 74 65 6d 70 6c 61 74    return templat
7ea0: 65 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 54 72 61  e;.  }..  // Tra
7eb0: 76 65 72 73 65 73 20 74 68 65 20 63 68 69 6c 64  verses the child
7ec0: 72 65 6e 20 6f 66 20 60 6f 62 6a 60 20 61 6c 6f  ren of `obj` alo
7ed0: 6e 67 20 60 70 61 74 68 60 2e 20 49 66 20 61 20  ng `path`. If a 
7ee0: 63 68 69 6c 64 20 69 73 20 61 20 66 75 6e 63 74  child is a funct
7ef0: 69 6f 6e 2c 20 69 74 0a 20 20 2f 2f 20 69 73 20  ion, it.  // is 
7f00: 69 6e 76 6f 6b 65 64 20 77 69 74 68 20 69 74 73  invoked with its
7f10: 20 70 61 72 65 6e 74 20 61 73 20 63 6f 6e 74 65   parent as conte
7f20: 78 74 2e 20 52 65 74 75 72 6e 73 20 74 68 65 20  xt. Returns the 
7f30: 76 61 6c 75 65 20 6f 66 20 74 68 65 20 66 69 6e  value of the fin
7f40: 61 6c 0a 20 20 2f 2f 20 63 68 69 6c 64 2c 20 6f  al.  // child, o
7f50: 72 20 60 66 61 6c 6c 62 61 63 6b 60 20 69 66 20  r `fallback` if 
7f60: 61 6e 79 20 63 68 69 6c 64 20 69 73 20 75 6e 64  any child is und
7f70: 65 66 69 6e 65 64 2e 0a 20 20 66 75 6e 63 74 69  efined..  functi
7f80: 6f 6e 20 72 65 73 75 6c 74 28 6f 62 6a 2c 20 70  on result(obj, p
7f90: 61 74 68 2c 20 66 61 6c 6c 62 61 63 6b 29 20 7b  ath, fallback) {
7fa0: 0a 20 20 20 20 70 61 74 68 20 3d 20 74 6f 50 61  .    path = toPa
7fb0: 74 68 24 31 28 70 61 74 68 29 3b 0a 20 20 20 20  th$1(path);.    
7fc0: 76 61 72 20 6c 65 6e 67 74 68 20 3d 20 70 61 74  var length = pat
7fd0: 68 2e 6c 65 6e 67 74 68 3b 0a 20 20 20 20 69 66  h.length;.    if
7fe0: 20 28 21 6c 65 6e 67 74 68 29 20 7b 0a 20 20 20   (!length) {.   
7ff0: 20 20 20 72 65 74 75 72 6e 20 69 73 46 75 6e 63     return isFunc
8000: 74 69 6f 6e 24 31 28 66 61 6c 6c 62 61 63 6b 29  tion$1(fallback)
8010: 20 3f 20 66 61 6c 6c 62 61 63 6b 2e 63 61 6c 6c   ? fallback.call
8020: 28 6f 62 6a 29 20 3a 20 66 61 6c 6c 62 61 63 6b  (obj) : fallback
8030: 3b 0a 20 20 20 20 7d 0a 20 20 20 20 66 6f 72 20  ;.    }.    for 
8040: 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20  (var i = 0; i < 
8050: 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20 7b 0a 20  length; i++) {. 
8060: 20 20 20 20 20 76 61 72 20 70 72 6f 70 20 3d 20       var prop = 
8070: 6f 62 6a 20 3d 3d 20 6e 75 6c 6c 20 3f 20 76 6f  obj == null ? vo
8080: 69 64 20 30 20 3a 20 6f 62 6a 5b 70 61 74 68 5b  id 0 : obj[path[
8090: 69 5d 5d 3b 0a 20 20 20 20 20 20 69 66 20 28 70  i]];.      if (p
80a0: 72 6f 70 20 3d 3d 3d 20 76 6f 69 64 20 30 29 20  rop === void 0) 
80b0: 7b 0a 20 20 20 20 20 20 20 20 70 72 6f 70 20 3d  {.        prop =
80c0: 20 66 61 6c 6c 62 61 63 6b 3b 0a 20 20 20 20 20   fallback;.     
80d0: 20 20 20 69 20 3d 20 6c 65 6e 67 74 68 3b 20 2f     i = length; /
80e0: 2f 20 45 6e 73 75 72 65 20 77 65 20 64 6f 6e 27  / Ensure we don'
80f0: 74 20 63 6f 6e 74 69 6e 75 65 20 69 74 65 72 61  t continue itera
8100: 74 69 6e 67 2e 0a 20 20 20 20 20 20 7d 0a 20 20  ting..      }.  
8110: 20 20 20 20 6f 62 6a 20 3d 20 69 73 46 75 6e 63      obj = isFunc
8120: 74 69 6f 6e 24 31 28 70 72 6f 70 29 20 3f 20 70  tion$1(prop) ? p
8130: 72 6f 70 2e 63 61 6c 6c 28 6f 62 6a 29 20 3a 20  rop.call(obj) : 
8140: 70 72 6f 70 3b 0a 20 20 20 20 7d 0a 20 20 20 20  prop;.    }.    
8150: 72 65 74 75 72 6e 20 6f 62 6a 3b 0a 20 20 7d 0a  return obj;.  }.
8160: 0a 20 20 2f 2f 20 47 65 6e 65 72 61 74 65 20 61  .  // Generate a
8170: 20 75 6e 69 71 75 65 20 69 6e 74 65 67 65 72 20   unique integer 
8180: 69 64 20 28 75 6e 69 71 75 65 20 77 69 74 68 69  id (unique withi
8190: 6e 20 74 68 65 20 65 6e 74 69 72 65 20 63 6c 69  n the entire cli
81a0: 65 6e 74 20 73 65 73 73 69 6f 6e 29 2e 0a 20 20  ent session)..  
81b0: 2f 2f 20 55 73 65 66 75 6c 20 66 6f 72 20 74 65  // Useful for te
81c0: 6d 70 6f 72 61 72 79 20 44 4f 4d 20 69 64 73 2e  mporary DOM ids.
81d0: 0a 20 20 76 61 72 20 69 64 43 6f 75 6e 74 65 72  .  var idCounter
81e0: 20 3d 20 30 3b 0a 20 20 66 75 6e 63 74 69 6f 6e   = 0;.  function
81f0: 20 75 6e 69 71 75 65 49 64 28 70 72 65 66 69 78   uniqueId(prefix
8200: 29 20 7b 0a 20 20 20 20 76 61 72 20 69 64 20 3d  ) {.    var id =
8210: 20 2b 2b 69 64 43 6f 75 6e 74 65 72 20 2b 20 27   ++idCounter + '
8220: 27 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 70 72  ';.    return pr
8230: 65 66 69 78 20 3f 20 70 72 65 66 69 78 20 2b 20  efix ? prefix + 
8240: 69 64 20 3a 20 69 64 3b 0a 20 20 7d 0a 0a 20 20  id : id;.  }..  
8250: 2f 2f 20 53 74 61 72 74 20 63 68 61 69 6e 69 6e  // Start chainin
8260: 67 20 61 20 77 72 61 70 70 65 64 20 55 6e 64 65  g a wrapped Unde
8270: 72 73 63 6f 72 65 20 6f 62 6a 65 63 74 2e 0a 20  rscore object.. 
8280: 20 66 75 6e 63 74 69 6f 6e 20 63 68 61 69 6e 28   function chain(
8290: 6f 62 6a 29 20 7b 0a 20 20 20 20 76 61 72 20 69  obj) {.    var i
82a0: 6e 73 74 61 6e 63 65 20 3d 20 5f 28 6f 62 6a 29  nstance = _(obj)
82b0: 3b 0a 20 20 20 20 69 6e 73 74 61 6e 63 65 2e 5f  ;.    instance._
82c0: 63 68 61 69 6e 20 3d 20 74 72 75 65 3b 0a 20 20  chain = true;.  
82d0: 20 20 72 65 74 75 72 6e 20 69 6e 73 74 61 6e 63    return instanc
82e0: 65 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 6e 74  e;.  }..  // Int
82f0: 65 72 6e 61 6c 20 66 75 6e 63 74 69 6f 6e 20 74  ernal function t
8300: 6f 20 65 78 65 63 75 74 65 20 60 73 6f 75 72 63  o execute `sourc
8310: 65 46 75 6e 63 60 20 62 6f 75 6e 64 20 74 6f 20  eFunc` bound to 
8320: 60 63 6f 6e 74 65 78 74 60 20 77 69 74 68 20 6f  `context` with o
8330: 70 74 69 6f 6e 61 6c 0a 20 20 2f 2f 20 60 61 72  ptional.  // `ar
8340: 67 73 60 2e 20 44 65 74 65 72 6d 69 6e 65 73 20  gs`. Determines 
8350: 77 68 65 74 68 65 72 20 74 6f 20 65 78 65 63 75  whether to execu
8360: 74 65 20 61 20 66 75 6e 63 74 69 6f 6e 20 61 73  te a function as
8370: 20 61 20 63 6f 6e 73 74 72 75 63 74 6f 72 20 6f   a constructor o
8380: 72 20 61 73 20 61 0a 20 20 2f 2f 20 6e 6f 72 6d  r as a.  // norm
8390: 61 6c 20 66 75 6e 63 74 69 6f 6e 2e 0a 20 20 66  al function..  f
83a0: 75 6e 63 74 69 6f 6e 20 65 78 65 63 75 74 65 42  unction executeB
83b0: 6f 75 6e 64 28 73 6f 75 72 63 65 46 75 6e 63 2c  ound(sourceFunc,
83c0: 20 62 6f 75 6e 64 46 75 6e 63 2c 20 63 6f 6e 74   boundFunc, cont
83d0: 65 78 74 2c 20 63 61 6c 6c 69 6e 67 43 6f 6e 74  ext, callingCont
83e0: 65 78 74 2c 20 61 72 67 73 29 20 7b 0a 20 20 20  ext, args) {.   
83f0: 20 69 66 20 28 21 28 63 61 6c 6c 69 6e 67 43 6f   if (!(callingCo
8400: 6e 74 65 78 74 20 69 6e 73 74 61 6e 63 65 6f 66  ntext instanceof
8410: 20 62 6f 75 6e 64 46 75 6e 63 29 29 20 72 65 74   boundFunc)) ret
8420: 75 72 6e 20 73 6f 75 72 63 65 46 75 6e 63 2e 61  urn sourceFunc.a
8430: 70 70 6c 79 28 63 6f 6e 74 65 78 74 2c 20 61 72  pply(context, ar
8440: 67 73 29 3b 0a 20 20 20 20 76 61 72 20 73 65 6c  gs);.    var sel
8450: 66 20 3d 20 62 61 73 65 43 72 65 61 74 65 28 73  f = baseCreate(s
8460: 6f 75 72 63 65 46 75 6e 63 2e 70 72 6f 74 6f 74  ourceFunc.protot
8470: 79 70 65 29 3b 0a 20 20 20 20 76 61 72 20 72 65  ype);.    var re
8480: 73 75 6c 74 20 3d 20 73 6f 75 72 63 65 46 75 6e  sult = sourceFun
8490: 63 2e 61 70 70 6c 79 28 73 65 6c 66 2c 20 61 72  c.apply(self, ar
84a0: 67 73 29 3b 0a 20 20 20 20 69 66 20 28 69 73 4f  gs);.    if (isO
84b0: 62 6a 65 63 74 28 72 65 73 75 6c 74 29 29 20 72  bject(result)) r
84c0: 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a 20 20  eturn result;.  
84d0: 20 20 72 65 74 75 72 6e 20 73 65 6c 66 3b 0a 20    return self;. 
84e0: 20 7d 0a 0a 20 20 2f 2f 20 50 61 72 74 69 61 6c   }..  // Partial
84f0: 6c 79 20 61 70 70 6c 79 20 61 20 66 75 6e 63 74  ly apply a funct
8500: 69 6f 6e 20 62 79 20 63 72 65 61 74 69 6e 67 20  ion by creating 
8510: 61 20 76 65 72 73 69 6f 6e 20 74 68 61 74 20 68  a version that h
8520: 61 73 20 68 61 64 20 73 6f 6d 65 20 6f 66 20 69  as had some of i
8530: 74 73 0a 20 20 2f 2f 20 61 72 67 75 6d 65 6e 74  ts.  // argument
8540: 73 20 70 72 65 2d 66 69 6c 6c 65 64 2c 20 77 69  s pre-filled, wi
8550: 74 68 6f 75 74 20 63 68 61 6e 67 69 6e 67 20 69  thout changing i
8560: 74 73 20 64 79 6e 61 6d 69 63 20 60 74 68 69 73  ts dynamic `this
8570: 60 20 63 6f 6e 74 65 78 74 2e 20 60 5f 60 20 61  ` context. `_` a
8580: 63 74 73 0a 20 20 2f 2f 20 61 73 20 61 20 70 6c  cts.  // as a pl
8590: 61 63 65 68 6f 6c 64 65 72 20 62 79 20 64 65 66  aceholder by def
85a0: 61 75 6c 74 2c 20 61 6c 6c 6f 77 69 6e 67 20 61  ault, allowing a
85b0: 6e 79 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20 6f  ny combination o
85c0: 66 20 61 72 67 75 6d 65 6e 74 73 20 74 6f 20 62  f arguments to b
85d0: 65 0a 20 20 2f 2f 20 70 72 65 2d 66 69 6c 6c 65  e.  // pre-fille
85e0: 64 2e 20 53 65 74 20 60 5f 2e 70 61 72 74 69 61  d. Set `_.partia
85f0: 6c 2e 70 6c 61 63 65 68 6f 6c 64 65 72 60 20 66  l.placeholder` f
8600: 6f 72 20 61 20 63 75 73 74 6f 6d 20 70 6c 61 63  or a custom plac
8610: 65 68 6f 6c 64 65 72 20 61 72 67 75 6d 65 6e 74  eholder argument
8620: 2e 0a 20 20 76 61 72 20 70 61 72 74 69 61 6c 20  ..  var partial 
8630: 3d 20 72 65 73 74 41 72 67 75 6d 65 6e 74 73 28  = restArguments(
8640: 66 75 6e 63 74 69 6f 6e 28 66 75 6e 63 2c 20 62  function(func, b
8650: 6f 75 6e 64 41 72 67 73 29 20 7b 0a 20 20 20 20  oundArgs) {.    
8660: 76 61 72 20 70 6c 61 63 65 68 6f 6c 64 65 72 20  var placeholder 
8670: 3d 20 70 61 72 74 69 61 6c 2e 70 6c 61 63 65 68  = partial.placeh
8680: 6f 6c 64 65 72 3b 0a 20 20 20 20 76 61 72 20 62  older;.    var b
8690: 6f 75 6e 64 20 3d 20 66 75 6e 63 74 69 6f 6e 28  ound = function(
86a0: 29 20 7b 0a 20 20 20 20 20 20 76 61 72 20 70 6f  ) {.      var po
86b0: 73 69 74 69 6f 6e 20 3d 20 30 2c 20 6c 65 6e 67  sition = 0, leng
86c0: 74 68 20 3d 20 62 6f 75 6e 64 41 72 67 73 2e 6c  th = boundArgs.l
86d0: 65 6e 67 74 68 3b 0a 20 20 20 20 20 20 76 61 72  ength;.      var
86e0: 20 61 72 67 73 20 3d 20 41 72 72 61 79 28 6c 65   args = Array(le
86f0: 6e 67 74 68 29 3b 0a 20 20 20 20 20 20 66 6f 72  ngth);.      for
8700: 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c   (var i = 0; i <
8710: 20 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20 7b 0a   length; i++) {.
8720: 20 20 20 20 20 20 20 20 61 72 67 73 5b 69 5d 20          args[i] 
8730: 3d 20 62 6f 75 6e 64 41 72 67 73 5b 69 5d 20 3d  = boundArgs[i] =
8740: 3d 3d 20 70 6c 61 63 65 68 6f 6c 64 65 72 20 3f  == placeholder ?
8750: 20 61 72 67 75 6d 65 6e 74 73 5b 70 6f 73 69 74   arguments[posit
8760: 69 6f 6e 2b 2b 5d 20 3a 20 62 6f 75 6e 64 41 72  ion++] : boundAr
8770: 67 73 5b 69 5d 3b 0a 20 20 20 20 20 20 7d 0a 20  gs[i];.      }. 
8780: 20 20 20 20 20 77 68 69 6c 65 20 28 70 6f 73 69       while (posi
8790: 74 69 6f 6e 20 3c 20 61 72 67 75 6d 65 6e 74 73  tion < arguments
87a0: 2e 6c 65 6e 67 74 68 29 20 61 72 67 73 2e 70 75  .length) args.pu
87b0: 73 68 28 61 72 67 75 6d 65 6e 74 73 5b 70 6f 73  sh(arguments[pos
87c0: 69 74 69 6f 6e 2b 2b 5d 29 3b 0a 20 20 20 20 20  ition++]);.     
87d0: 20 72 65 74 75 72 6e 20 65 78 65 63 75 74 65 42   return executeB
87e0: 6f 75 6e 64 28 66 75 6e 63 2c 20 62 6f 75 6e 64  ound(func, bound
87f0: 2c 20 74 68 69 73 2c 20 74 68 69 73 2c 20 61 72  , this, this, ar
8800: 67 73 29 3b 0a 20 20 20 20 7d 3b 0a 20 20 20 20  gs);.    };.    
8810: 72 65 74 75 72 6e 20 62 6f 75 6e 64 3b 0a 20 20  return bound;.  
8820: 7d 29 3b 0a 0a 20 20 70 61 72 74 69 61 6c 2e 70  });..  partial.p
8830: 6c 61 63 65 68 6f 6c 64 65 72 20 3d 20 5f 3b 0a  laceholder = _;.
8840: 0a 20 20 2f 2f 20 43 72 65 61 74 65 20 61 20 66  .  // Create a f
8850: 75 6e 63 74 69 6f 6e 20 62 6f 75 6e 64 20 74 6f  unction bound to
8860: 20 61 20 67 69 76 65 6e 20 6f 62 6a 65 63 74 20   a given object 
8870: 28 61 73 73 69 67 6e 69 6e 67 20 60 74 68 69 73  (assigning `this
8880: 60 2c 20 61 6e 64 20 61 72 67 75 6d 65 6e 74 73  `, and arguments
8890: 2c 0a 20 20 2f 2f 20 6f 70 74 69 6f 6e 61 6c 6c  ,.  // optionall
88a0: 79 29 2e 0a 20 20 76 61 72 20 62 69 6e 64 20 3d  y)..  var bind =
88b0: 20 72 65 73 74 41 72 67 75 6d 65 6e 74 73 28 66   restArguments(f
88c0: 75 6e 63 74 69 6f 6e 28 66 75 6e 63 2c 20 63 6f  unction(func, co
88d0: 6e 74 65 78 74 2c 20 61 72 67 73 29 20 7b 0a 20  ntext, args) {. 
88e0: 20 20 20 69 66 20 28 21 69 73 46 75 6e 63 74 69     if (!isFuncti
88f0: 6f 6e 24 31 28 66 75 6e 63 29 29 20 74 68 72 6f  on$1(func)) thro
8900: 77 20 6e 65 77 20 54 79 70 65 45 72 72 6f 72 28  w new TypeError(
8910: 27 42 69 6e 64 20 6d 75 73 74 20 62 65 20 63 61  'Bind must be ca
8920: 6c 6c 65 64 20 6f 6e 20 61 20 66 75 6e 63 74 69  lled on a functi
8930: 6f 6e 27 29 3b 0a 20 20 20 20 76 61 72 20 62 6f  on');.    var bo
8940: 75 6e 64 20 3d 20 72 65 73 74 41 72 67 75 6d 65  und = restArgume
8950: 6e 74 73 28 66 75 6e 63 74 69 6f 6e 28 63 61 6c  nts(function(cal
8960: 6c 41 72 67 73 29 20 7b 0a 20 20 20 20 20 20 72  lArgs) {.      r
8970: 65 74 75 72 6e 20 65 78 65 63 75 74 65 42 6f 75  eturn executeBou
8980: 6e 64 28 66 75 6e 63 2c 20 62 6f 75 6e 64 2c 20  nd(func, bound, 
8990: 63 6f 6e 74 65 78 74 2c 20 74 68 69 73 2c 20 61  context, this, a
89a0: 72 67 73 2e 63 6f 6e 63 61 74 28 63 61 6c 6c 41  rgs.concat(callA
89b0: 72 67 73 29 29 3b 0a 20 20 20 20 7d 29 3b 0a 20  rgs));.    });. 
89c0: 20 20 20 72 65 74 75 72 6e 20 62 6f 75 6e 64 3b     return bound;
89d0: 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 49 6e 74  .  });..  // Int
89e0: 65 72 6e 61 6c 20 68 65 6c 70 65 72 20 66 6f 72  ernal helper for
89f0: 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 6d 65 74 68   collection meth
8a00: 6f 64 73 20 74 6f 20 64 65 74 65 72 6d 69 6e 65  ods to determine
8a10: 20 77 68 65 74 68 65 72 20 61 20 63 6f 6c 6c 65   whether a colle
8a20: 63 74 69 6f 6e 0a 20 20 2f 2f 20 73 68 6f 75 6c  ction.  // shoul
8a30: 64 20 62 65 20 69 74 65 72 61 74 65 64 20 61 73  d be iterated as
8a40: 20 61 6e 20 61 72 72 61 79 20 6f 72 20 61 73 20   an array or as 
8a50: 61 6e 20 6f 62 6a 65 63 74 2e 0a 20 20 2f 2f 20  an object..  // 
8a60: 52 65 6c 61 74 65 64 3a 20 68 74 74 70 73 3a 2f  Related: https:/
8a70: 2f 70 65 6f 70 6c 65 2e 6d 6f 7a 69 6c 6c 61 2e  /people.mozilla.
8a80: 6f 72 67 2f 7e 6a 6f 72 65 6e 64 6f 72 66 66 2f  org/~jorendorff/
8a90: 65 73 36 2d 64 72 61 66 74 2e 68 74 6d 6c 23 73  es6-draft.html#s
8aa0: 65 63 2d 74 6f 6c 65 6e 67 74 68 0a 20 20 2f 2f  ec-tolength.  //
8ab0: 20 41 76 6f 69 64 73 20 61 20 76 65 72 79 20 6e   Avoids a very n
8ac0: 61 73 74 79 20 69 4f 53 20 38 20 4a 49 54 20 62  asty iOS 8 JIT b
8ad0: 75 67 20 6f 6e 20 41 52 4d 2d 36 34 2e 20 23 32  ug on ARM-64. #2
8ae0: 30 39 34 0a 20 20 76 61 72 20 69 73 41 72 72 61  094.  var isArra
8af0: 79 4c 69 6b 65 20 3d 20 63 72 65 61 74 65 53 69  yLike = createSi
8b00: 7a 65 50 72 6f 70 65 72 74 79 43 68 65 63 6b 28  zePropertyCheck(
8b10: 67 65 74 4c 65 6e 67 74 68 29 3b 0a 0a 20 20 2f  getLength);..  /
8b20: 2f 20 49 6e 74 65 72 6e 61 6c 20 69 6d 70 6c 65  / Internal imple
8b30: 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 61 20 72  mentation of a r
8b40: 65 63 75 72 73 69 76 65 20 60 66 6c 61 74 74 65  ecursive `flatte
8b50: 6e 60 20 66 75 6e 63 74 69 6f 6e 2e 0a 20 20 66  n` function..  f
8b60: 75 6e 63 74 69 6f 6e 20 66 6c 61 74 74 65 6e 28  unction flatten(
8b70: 69 6e 70 75 74 2c 20 64 65 70 74 68 2c 20 73 74  input, depth, st
8b80: 72 69 63 74 2c 20 6f 75 74 70 75 74 29 20 7b 0a  rict, output) {.
8b90: 20 20 20 20 6f 75 74 70 75 74 20 3d 20 6f 75 74      output = out
8ba0: 70 75 74 20 7c 7c 20 5b 5d 3b 0a 20 20 20 20 69  put || [];.    i
8bb0: 66 20 28 21 64 65 70 74 68 20 26 26 20 64 65 70  f (!depth && dep
8bc0: 74 68 20 21 3d 3d 20 30 29 20 7b 0a 20 20 20 20  th !== 0) {.    
8bd0: 20 20 64 65 70 74 68 20 3d 20 49 6e 66 69 6e 69    depth = Infini
8be0: 74 79 3b 0a 20 20 20 20 7d 20 65 6c 73 65 20 69  ty;.    } else i
8bf0: 66 20 28 64 65 70 74 68 20 3c 3d 20 30 29 20 7b  f (depth <= 0) {
8c00: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 6f 75  .      return ou
8c10: 74 70 75 74 2e 63 6f 6e 63 61 74 28 69 6e 70 75  tput.concat(inpu
8c20: 74 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 76 61  t);.    }.    va
8c30: 72 20 69 64 78 20 3d 20 6f 75 74 70 75 74 2e 6c  r idx = output.l
8c40: 65 6e 67 74 68 3b 0a 20 20 20 20 66 6f 72 20 28  ength;.    for (
8c50: 76 61 72 20 69 20 3d 20 30 2c 20 6c 65 6e 67 74  var i = 0, lengt
8c60: 68 20 3d 20 67 65 74 4c 65 6e 67 74 68 28 69 6e  h = getLength(in
8c70: 70 75 74 29 3b 20 69 20 3c 20 6c 65 6e 67 74 68  put); i < length
8c80: 3b 20 69 2b 2b 29 20 7b 0a 20 20 20 20 20 20 76  ; i++) {.      v
8c90: 61 72 20 76 61 6c 75 65 20 3d 20 69 6e 70 75 74  ar value = input
8ca0: 5b 69 5d 3b 0a 20 20 20 20 20 20 69 66 20 28 69  [i];.      if (i
8cb0: 73 41 72 72 61 79 4c 69 6b 65 28 76 61 6c 75 65  sArrayLike(value
8cc0: 29 20 26 26 20 28 69 73 41 72 72 61 79 28 76 61  ) && (isArray(va
8cd0: 6c 75 65 29 20 7c 7c 20 69 73 41 72 67 75 6d 65  lue) || isArgume
8ce0: 6e 74 73 24 31 28 76 61 6c 75 65 29 29 29 20 7b  nts$1(value))) {
8cf0: 0a 20 20 20 20 20 20 20 20 2f 2f 20 46 6c 61 74  .        // Flat
8d00: 74 65 6e 20 63 75 72 72 65 6e 74 20 6c 65 76 65  ten current leve
8d10: 6c 20 6f 66 20 61 72 72 61 79 20 6f 72 20 61 72  l of array or ar
8d20: 67 75 6d 65 6e 74 73 20 6f 62 6a 65 63 74 2e 0a  guments object..
8d30: 20 20 20 20 20 20 20 20 69 66 20 28 64 65 70 74          if (dept
8d40: 68 20 3e 20 31 29 20 7b 0a 20 20 20 20 20 20 20  h > 1) {.       
8d50: 20 20 20 66 6c 61 74 74 65 6e 28 76 61 6c 75 65     flatten(value
8d60: 2c 20 64 65 70 74 68 20 2d 20 31 2c 20 73 74 72  , depth - 1, str
8d70: 69 63 74 2c 20 6f 75 74 70 75 74 29 3b 0a 20 20  ict, output);.  
8d80: 20 20 20 20 20 20 20 20 69 64 78 20 3d 20 6f 75          idx = ou
8d90: 74 70 75 74 2e 6c 65 6e 67 74 68 3b 0a 20 20 20  tput.length;.   
8da0: 20 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20       } else {.  
8db0: 20 20 20 20 20 20 20 20 76 61 72 20 6a 20 3d 20          var j = 
8dc0: 30 2c 20 6c 65 6e 20 3d 20 76 61 6c 75 65 2e 6c  0, len = value.l
8dd0: 65 6e 67 74 68 3b 0a 20 20 20 20 20 20 20 20 20  ength;.         
8de0: 20 77 68 69 6c 65 20 28 6a 20 3c 20 6c 65 6e 29   while (j < len)
8df0: 20 6f 75 74 70 75 74 5b 69 64 78 2b 2b 5d 20 3d   output[idx++] =
8e00: 20 76 61 6c 75 65 5b 6a 2b 2b 5d 3b 0a 20 20 20   value[j++];.   
8e10: 20 20 20 20 20 7d 0a 20 20 20 20 20 20 7d 20 65       }.      } e
8e20: 6c 73 65 20 69 66 20 28 21 73 74 72 69 63 74 29  lse if (!strict)
8e30: 20 7b 0a 20 20 20 20 20 20 20 20 6f 75 74 70 75   {.        outpu
8e40: 74 5b 69 64 78 2b 2b 5d 20 3d 20 76 61 6c 75 65  t[idx++] = value
8e50: 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a  ;.      }.    }.
8e60: 20 20 20 20 72 65 74 75 72 6e 20 6f 75 74 70 75      return outpu
8e70: 74 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 42 69 6e  t;.  }..  // Bin
8e80: 64 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 61 6e  d a number of an
8e90: 20 6f 62 6a 65 63 74 27 73 20 6d 65 74 68 6f 64   object's method
8ea0: 73 20 74 6f 20 74 68 61 74 20 6f 62 6a 65 63 74  s to that object
8eb0: 2e 20 52 65 6d 61 69 6e 69 6e 67 20 61 72 67 75  . Remaining argu
8ec0: 6d 65 6e 74 73 0a 20 20 2f 2f 20 61 72 65 20 74  ments.  // are t
8ed0: 68 65 20 6d 65 74 68 6f 64 20 6e 61 6d 65 73 20  he method names 
8ee0: 74 6f 20 62 65 20 62 6f 75 6e 64 2e 20 55 73 65  to be bound. Use
8ef0: 66 75 6c 20 66 6f 72 20 65 6e 73 75 72 69 6e 67  ful for ensuring
8f00: 20 74 68 61 74 20 61 6c 6c 20 63 61 6c 6c 62 61   that all callba
8f10: 63 6b 73 0a 20 20 2f 2f 20 64 65 66 69 6e 65 64  cks.  // defined
8f20: 20 6f 6e 20 61 6e 20 6f 62 6a 65 63 74 20 62 65   on an object be
8f30: 6c 6f 6e 67 20 74 6f 20 69 74 2e 0a 20 20 76 61  long to it..  va
8f40: 72 20 62 69 6e 64 41 6c 6c 20 3d 20 72 65 73 74  r bindAll = rest
8f50: 41 72 67 75 6d 65 6e 74 73 28 66 75 6e 63 74 69  Arguments(functi
8f60: 6f 6e 28 6f 62 6a 2c 20 6b 65 79 73 29 20 7b 0a  on(obj, keys) {.
8f70: 20 20 20 20 6b 65 79 73 20 3d 20 66 6c 61 74 74      keys = flatt
8f80: 65 6e 28 6b 65 79 73 2c 20 66 61 6c 73 65 2c 20  en(keys, false, 
8f90: 66 61 6c 73 65 29 3b 0a 20 20 20 20 76 61 72 20  false);.    var 
8fa0: 69 6e 64 65 78 20 3d 20 6b 65 79 73 2e 6c 65 6e  index = keys.len
8fb0: 67 74 68 3b 0a 20 20 20 20 69 66 20 28 69 6e 64  gth;.    if (ind
8fc0: 65 78 20 3c 20 31 29 20 74 68 72 6f 77 20 6e 65  ex < 1) throw ne
8fd0: 77 20 45 72 72 6f 72 28 27 62 69 6e 64 41 6c 6c  w Error('bindAll
8fe0: 20 6d 75 73 74 20 62 65 20 70 61 73 73 65 64 20   must be passed 
8ff0: 66 75 6e 63 74 69 6f 6e 20 6e 61 6d 65 73 27 29  function names')
9000: 3b 0a 20 20 20 20 77 68 69 6c 65 20 28 69 6e 64  ;.    while (ind
9010: 65 78 2d 2d 29 20 7b 0a 20 20 20 20 20 20 76 61  ex--) {.      va
9020: 72 20 6b 65 79 20 3d 20 6b 65 79 73 5b 69 6e 64  r key = keys[ind
9030: 65 78 5d 3b 0a 20 20 20 20 20 20 6f 62 6a 5b 6b  ex];.      obj[k
9040: 65 79 5d 20 3d 20 62 69 6e 64 28 6f 62 6a 5b 6b  ey] = bind(obj[k
9050: 65 79 5d 2c 20 6f 62 6a 29 3b 0a 20 20 20 20 7d  ey], obj);.    }
9060: 0a 20 20 20 20 72 65 74 75 72 6e 20 6f 62 6a 3b  .    return obj;
9070: 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 4d 65 6d  .  });..  // Mem
9080: 6f 69 7a 65 20 61 6e 20 65 78 70 65 6e 73 69 76  oize an expensiv
9090: 65 20 66 75 6e 63 74 69 6f 6e 20 62 79 20 73 74  e function by st
90a0: 6f 72 69 6e 67 20 69 74 73 20 72 65 73 75 6c 74  oring its result
90b0: 73 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 6d 65  s..  function me
90c0: 6d 6f 69 7a 65 28 66 75 6e 63 2c 20 68 61 73 68  moize(func, hash
90d0: 65 72 29 20 7b 0a 20 20 20 20 76 61 72 20 6d 65  er) {.    var me
90e0: 6d 6f 69 7a 65 20 3d 20 66 75 6e 63 74 69 6f 6e  moize = function
90f0: 28 6b 65 79 29 20 7b 0a 20 20 20 20 20 20 76 61  (key) {.      va
9100: 72 20 63 61 63 68 65 20 3d 20 6d 65 6d 6f 69 7a  r cache = memoiz
9110: 65 2e 63 61 63 68 65 3b 0a 20 20 20 20 20 20 76  e.cache;.      v
9120: 61 72 20 61 64 64 72 65 73 73 20 3d 20 27 27 20  ar address = '' 
9130: 2b 20 28 68 61 73 68 65 72 20 3f 20 68 61 73 68  + (hasher ? hash
9140: 65 72 2e 61 70 70 6c 79 28 74 68 69 73 2c 20 61  er.apply(this, a
9150: 72 67 75 6d 65 6e 74 73 29 20 3a 20 6b 65 79 29  rguments) : key)
9160: 3b 0a 20 20 20 20 20 20 69 66 20 28 21 68 61 73  ;.      if (!has
9170: 28 63 61 63 68 65 2c 20 61 64 64 72 65 73 73 29  (cache, address)
9180: 29 20 63 61 63 68 65 5b 61 64 64 72 65 73 73 5d  ) cache[address]
9190: 20 3d 20 66 75 6e 63 2e 61 70 70 6c 79 28 74 68   = func.apply(th
91a0: 69 73 2c 20 61 72 67 75 6d 65 6e 74 73 29 3b 0a  is, arguments);.
91b0: 20 20 20 20 20 20 72 65 74 75 72 6e 20 63 61 63        return cac
91c0: 68 65 5b 61 64 64 72 65 73 73 5d 3b 0a 20 20 20  he[address];.   
91d0: 20 7d 3b 0a 20 20 20 20 6d 65 6d 6f 69 7a 65 2e   };.    memoize.
91e0: 63 61 63 68 65 20 3d 20 7b 7d 3b 0a 20 20 20 20  cache = {};.    
91f0: 72 65 74 75 72 6e 20 6d 65 6d 6f 69 7a 65 3b 0a  return memoize;.
9200: 20 20 7d 0a 0a 20 20 2f 2f 20 44 65 6c 61 79 73    }..  // Delays
9210: 20 61 20 66 75 6e 63 74 69 6f 6e 20 66 6f 72 20   a function for 
9220: 74 68 65 20 67 69 76 65 6e 20 6e 75 6d 62 65 72  the given number
9230: 20 6f 66 20 6d 69 6c 6c 69 73 65 63 6f 6e 64 73   of milliseconds
9240: 2c 20 61 6e 64 20 74 68 65 6e 20 63 61 6c 6c 73  , and then calls
9250: 0a 20 20 2f 2f 20 69 74 20 77 69 74 68 20 74 68  .  // it with th
9260: 65 20 61 72 67 75 6d 65 6e 74 73 20 73 75 70 70  e arguments supp
9270: 6c 69 65 64 2e 0a 20 20 76 61 72 20 64 65 6c 61  lied..  var dela
9280: 79 20 3d 20 72 65 73 74 41 72 67 75 6d 65 6e 74  y = restArgument
9290: 73 28 66 75 6e 63 74 69 6f 6e 28 66 75 6e 63 2c  s(function(func,
92a0: 20 77 61 69 74 2c 20 61 72 67 73 29 20 7b 0a 20   wait, args) {. 
92b0: 20 20 20 72 65 74 75 72 6e 20 73 65 74 54 69 6d     return setTim
92c0: 65 6f 75 74 28 66 75 6e 63 74 69 6f 6e 28 29 20  eout(function() 
92d0: 7b 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 66  {.      return f
92e0: 75 6e 63 2e 61 70 70 6c 79 28 6e 75 6c 6c 2c 20  unc.apply(null, 
92f0: 61 72 67 73 29 3b 0a 20 20 20 20 7d 2c 20 77 61  args);.    }, wa
9300: 69 74 29 3b 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f  it);.  });..  //
9310: 20 44 65 66 65 72 73 20 61 20 66 75 6e 63 74 69   Defers a functi
9320: 6f 6e 2c 20 73 63 68 65 64 75 6c 69 6e 67 20 69  on, scheduling i
9330: 74 20 74 6f 20 72 75 6e 20 61 66 74 65 72 20 74  t to run after t
9340: 68 65 20 63 75 72 72 65 6e 74 20 63 61 6c 6c 20  he current call 
9350: 73 74 61 63 6b 20 68 61 73 0a 20 20 2f 2f 20 63  stack has.  // c
9360: 6c 65 61 72 65 64 2e 0a 20 20 76 61 72 20 64 65  leared..  var de
9370: 66 65 72 20 3d 20 70 61 72 74 69 61 6c 28 64 65  fer = partial(de
9380: 6c 61 79 2c 20 5f 2c 20 31 29 3b 0a 0a 20 20 2f  lay, _, 1);..  /
9390: 2f 20 52 65 74 75 72 6e 73 20 61 20 66 75 6e 63  / Returns a func
93a0: 74 69 6f 6e 2c 20 74 68 61 74 2c 20 77 68 65 6e  tion, that, when
93b0: 20 69 6e 76 6f 6b 65 64 2c 20 77 69 6c 6c 20 6f   invoked, will o
93c0: 6e 6c 79 20 62 65 20 74 72 69 67 67 65 72 65 64  nly be triggered
93d0: 20 61 74 20 6d 6f 73 74 20 6f 6e 63 65 0a 20 20   at most once.  
93e0: 2f 2f 20 64 75 72 69 6e 67 20 61 20 67 69 76 65  // during a give
93f0: 6e 20 77 69 6e 64 6f 77 20 6f 66 20 74 69 6d 65  n window of time
9400: 2e 20 4e 6f 72 6d 61 6c 6c 79 2c 20 74 68 65 20  . Normally, the 
9410: 74 68 72 6f 74 74 6c 65 64 20 66 75 6e 63 74 69  throttled functi
9420: 6f 6e 20 77 69 6c 6c 20 72 75 6e 0a 20 20 2f 2f  on will run.  //
9430: 20 61 73 20 6d 75 63 68 20 61 73 20 69 74 20 63   as much as it c
9440: 61 6e 2c 20 77 69 74 68 6f 75 74 20 65 76 65 72  an, without ever
9450: 20 67 6f 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e   going more than
9460: 20 6f 6e 63 65 20 70 65 72 20 60 77 61 69 74 60   once per `wait`
9470: 20 64 75 72 61 74 69 6f 6e 3b 0a 20 20 2f 2f 20   duration;.  // 
9480: 62 75 74 20 69 66 20 79 6f 75 27 64 20 6c 69 6b  but if you'd lik
9490: 65 20 74 6f 20 64 69 73 61 62 6c 65 20 74 68 65  e to disable the
94a0: 20 65 78 65 63 75 74 69 6f 6e 20 6f 6e 20 74 68   execution on th
94b0: 65 20 6c 65 61 64 69 6e 67 20 65 64 67 65 2c 20  e leading edge, 
94c0: 70 61 73 73 0a 20 20 2f 2f 20 60 7b 6c 65 61 64  pass.  // `{lead
94d0: 69 6e 67 3a 20 66 61 6c 73 65 7d 60 2e 20 54 6f  ing: false}`. To
94e0: 20 64 69 73 61 62 6c 65 20 65 78 65 63 75 74 69   disable executi
94f0: 6f 6e 20 6f 6e 20 74 68 65 20 74 72 61 69 6c 69  on on the traili
9500: 6e 67 20 65 64 67 65 2c 20 64 69 74 74 6f 2e 0a  ng edge, ditto..
9510: 20 20 66 75 6e 63 74 69 6f 6e 20 74 68 72 6f 74    function throt
9520: 74 6c 65 28 66 75 6e 63 2c 20 77 61 69 74 2c 20  tle(func, wait, 
9530: 6f 70 74 69 6f 6e 73 29 20 7b 0a 20 20 20 20 76  options) {.    v
9540: 61 72 20 74 69 6d 65 6f 75 74 2c 20 63 6f 6e 74  ar timeout, cont
9550: 65 78 74 2c 20 61 72 67 73 2c 20 72 65 73 75 6c  ext, args, resul
9560: 74 3b 0a 20 20 20 20 76 61 72 20 70 72 65 76 69  t;.    var previ
9570: 6f 75 73 20 3d 20 30 3b 0a 20 20 20 20 69 66 20  ous = 0;.    if 
9580: 28 21 6f 70 74 69 6f 6e 73 29 20 6f 70 74 69 6f  (!options) optio
9590: 6e 73 20 3d 20 7b 7d 3b 0a 0a 20 20 20 20 76 61  ns = {};..    va
95a0: 72 20 6c 61 74 65 72 20 3d 20 66 75 6e 63 74 69  r later = functi
95b0: 6f 6e 28 29 20 7b 0a 20 20 20 20 20 20 70 72 65  on() {.      pre
95c0: 76 69 6f 75 73 20 3d 20 6f 70 74 69 6f 6e 73 2e  vious = options.
95d0: 6c 65 61 64 69 6e 67 20 3d 3d 3d 20 66 61 6c 73  leading === fals
95e0: 65 20 3f 20 30 20 3a 20 6e 6f 77 28 29 3b 0a 20  e ? 0 : now();. 
95f0: 20 20 20 20 20 74 69 6d 65 6f 75 74 20 3d 20 6e       timeout = n
9600: 75 6c 6c 3b 0a 20 20 20 20 20 20 72 65 73 75 6c  ull;.      resul
9610: 74 20 3d 20 66 75 6e 63 2e 61 70 70 6c 79 28 63  t = func.apply(c
9620: 6f 6e 74 65 78 74 2c 20 61 72 67 73 29 3b 0a 20  ontext, args);. 
9630: 20 20 20 20 20 69 66 20 28 21 74 69 6d 65 6f 75       if (!timeou
9640: 74 29 20 63 6f 6e 74 65 78 74 20 3d 20 61 72 67  t) context = arg
9650: 73 20 3d 20 6e 75 6c 6c 3b 0a 20 20 20 20 7d 3b  s = null;.    };
9660: 0a 0a 20 20 20 20 76 61 72 20 74 68 72 6f 74 74  ..    var thrott
9670: 6c 65 64 20 3d 20 66 75 6e 63 74 69 6f 6e 28 29  led = function()
9680: 20 7b 0a 20 20 20 20 20 20 76 61 72 20 5f 6e 6f   {.      var _no
9690: 77 20 3d 20 6e 6f 77 28 29 3b 0a 20 20 20 20 20  w = now();.     
96a0: 20 69 66 20 28 21 70 72 65 76 69 6f 75 73 20 26   if (!previous &
96b0: 26 20 6f 70 74 69 6f 6e 73 2e 6c 65 61 64 69 6e  & options.leadin
96c0: 67 20 3d 3d 3d 20 66 61 6c 73 65 29 20 70 72 65  g === false) pre
96d0: 76 69 6f 75 73 20 3d 20 5f 6e 6f 77 3b 0a 20 20  vious = _now;.  
96e0: 20 20 20 20 76 61 72 20 72 65 6d 61 69 6e 69 6e      var remainin
96f0: 67 20 3d 20 77 61 69 74 20 2d 20 28 5f 6e 6f 77  g = wait - (_now
9700: 20 2d 20 70 72 65 76 69 6f 75 73 29 3b 0a 20 20   - previous);.  
9710: 20 20 20 20 63 6f 6e 74 65 78 74 20 3d 20 74 68      context = th
9720: 69 73 3b 0a 20 20 20 20 20 20 61 72 67 73 20 3d  is;.      args =
9730: 20 61 72 67 75 6d 65 6e 74 73 3b 0a 20 20 20 20   arguments;.    
9740: 20 20 69 66 20 28 72 65 6d 61 69 6e 69 6e 67 20    if (remaining 
9750: 3c 3d 20 30 20 7c 7c 20 72 65 6d 61 69 6e 69 6e  <= 0 || remainin
9760: 67 20 3e 20 77 61 69 74 29 20 7b 0a 20 20 20 20  g > wait) {.    
9770: 20 20 20 20 69 66 20 28 74 69 6d 65 6f 75 74 29      if (timeout)
9780: 20 7b 0a 20 20 20 20 20 20 20 20 20 20 63 6c 65   {.          cle
9790: 61 72 54 69 6d 65 6f 75 74 28 74 69 6d 65 6f 75  arTimeout(timeou
97a0: 74 29 3b 0a 20 20 20 20 20 20 20 20 20 20 74 69  t);.          ti
97b0: 6d 65 6f 75 74 20 3d 20 6e 75 6c 6c 3b 0a 20 20  meout = null;.  
97c0: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20        }.        
97d0: 70 72 65 76 69 6f 75 73 20 3d 20 5f 6e 6f 77 3b  previous = _now;
97e0: 0a 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 20  .        result 
97f0: 3d 20 66 75 6e 63 2e 61 70 70 6c 79 28 63 6f 6e  = func.apply(con
9800: 74 65 78 74 2c 20 61 72 67 73 29 3b 0a 20 20 20  text, args);.   
9810: 20 20 20 20 20 69 66 20 28 21 74 69 6d 65 6f 75       if (!timeou
9820: 74 29 20 63 6f 6e 74 65 78 74 20 3d 20 61 72 67  t) context = arg
9830: 73 20 3d 20 6e 75 6c 6c 3b 0a 20 20 20 20 20 20  s = null;.      
9840: 7d 20 65 6c 73 65 20 69 66 20 28 21 74 69 6d 65  } else if (!time
9850: 6f 75 74 20 26 26 20 6f 70 74 69 6f 6e 73 2e 74  out && options.t
9860: 72 61 69 6c 69 6e 67 20 21 3d 3d 20 66 61 6c 73  railing !== fals
9870: 65 29 20 7b 0a 20 20 20 20 20 20 20 20 74 69 6d  e) {.        tim
9880: 65 6f 75 74 20 3d 20 73 65 74 54 69 6d 65 6f 75  eout = setTimeou
9890: 74 28 6c 61 74 65 72 2c 20 72 65 6d 61 69 6e 69  t(later, remaini
98a0: 6e 67 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20  ng);.      }.   
98b0: 20 20 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74     return result
98c0: 3b 0a 20 20 20 20 7d 3b 0a 0a 20 20 20 20 74 68  ;.    };..    th
98d0: 72 6f 74 74 6c 65 64 2e 63 61 6e 63 65 6c 20 3d  rottled.cancel =
98e0: 20 66 75 6e 63 74 69 6f 6e 28 29 20 7b 0a 20 20   function() {.  
98f0: 20 20 20 20 63 6c 65 61 72 54 69 6d 65 6f 75 74      clearTimeout
9900: 28 74 69 6d 65 6f 75 74 29 3b 0a 20 20 20 20 20  (timeout);.     
9910: 20 70 72 65 76 69 6f 75 73 20 3d 20 30 3b 0a 20   previous = 0;. 
9920: 20 20 20 20 20 74 69 6d 65 6f 75 74 20 3d 20 63       timeout = c
9930: 6f 6e 74 65 78 74 20 3d 20 61 72 67 73 20 3d 20  ontext = args = 
9940: 6e 75 6c 6c 3b 0a 20 20 20 20 7d 3b 0a 0a 20 20  null;.    };..  
9950: 20 20 72 65 74 75 72 6e 20 74 68 72 6f 74 74 6c    return throttl
9960: 65 64 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 57 68  ed;.  }..  // Wh
9970: 65 6e 20 61 20 73 65 71 75 65 6e 63 65 20 6f 66  en a sequence of
9980: 20 63 61 6c 6c 73 20 6f 66 20 74 68 65 20 72 65   calls of the re
9990: 74 75 72 6e 65 64 20 66 75 6e 63 74 69 6f 6e 20  turned function 
99a0: 65 6e 64 73 2c 20 74 68 65 20 61 72 67 75 6d 65  ends, the argume
99b0: 6e 74 0a 20 20 2f 2f 20 66 75 6e 63 74 69 6f 6e  nt.  // function
99c0: 20 69 73 20 74 72 69 67 67 65 72 65 64 2e 20 54   is triggered. T
99d0: 68 65 20 65 6e 64 20 6f 66 20 61 20 73 65 71 75  he end of a sequ
99e0: 65 6e 63 65 20 69 73 20 64 65 66 69 6e 65 64 20  ence is defined 
99f0: 62 79 20 74 68 65 20 60 77 61 69 74 60 0a 20 20  by the `wait`.  
9a00: 2f 2f 20 70 61 72 61 6d 65 74 65 72 2e 20 49 66  // parameter. If
9a10: 20 60 69 6d 6d 65 64 69 61 74 65 60 20 69 73 20   `immediate` is 
9a20: 70 61 73 73 65 64 2c 20 74 68 65 20 61 72 67 75  passed, the argu
9a30: 6d 65 6e 74 20 66 75 6e 63 74 69 6f 6e 20 77 69  ment function wi
9a40: 6c 6c 20 62 65 0a 20 20 2f 2f 20 74 72 69 67 67  ll be.  // trigg
9a50: 65 72 65 64 20 61 74 20 74 68 65 20 62 65 67 69  ered at the begi
9a60: 6e 6e 69 6e 67 20 6f 66 20 74 68 65 20 73 65 71  nning of the seq
9a70: 75 65 6e 63 65 20 69 6e 73 74 65 61 64 20 6f 66  uence instead of
9a80: 20 61 74 20 74 68 65 20 65 6e 64 2e 0a 20 20 66   at the end..  f
9a90: 75 6e 63 74 69 6f 6e 20 64 65 62 6f 75 6e 63 65  unction debounce
9aa0: 28 66 75 6e 63 2c 20 77 61 69 74 2c 20 69 6d 6d  (func, wait, imm
9ab0: 65 64 69 61 74 65 29 20 7b 0a 20 20 20 20 76 61  ediate) {.    va
9ac0: 72 20 74 69 6d 65 6f 75 74 2c 20 70 72 65 76 69  r timeout, previ
9ad0: 6f 75 73 2c 20 61 72 67 73 2c 20 72 65 73 75 6c  ous, args, resul
9ae0: 74 2c 20 63 6f 6e 74 65 78 74 3b 0a 0a 20 20 20  t, context;..   
9af0: 20 76 61 72 20 6c 61 74 65 72 20 3d 20 66 75 6e   var later = fun
9b00: 63 74 69 6f 6e 28 29 20 7b 0a 20 20 20 20 20 20  ction() {.      
9b10: 76 61 72 20 70 61 73 73 65 64 20 3d 20 6e 6f 77  var passed = now
9b20: 28 29 20 2d 20 70 72 65 76 69 6f 75 73 3b 0a 20  () - previous;. 
9b30: 20 20 20 20 20 69 66 20 28 77 61 69 74 20 3e 20       if (wait > 
9b40: 70 61 73 73 65 64 29 20 7b 0a 20 20 20 20 20 20  passed) {.      
9b50: 20 20 74 69 6d 65 6f 75 74 20 3d 20 73 65 74 54    timeout = setT
9b60: 69 6d 65 6f 75 74 28 6c 61 74 65 72 2c 20 77 61  imeout(later, wa
9b70: 69 74 20 2d 20 70 61 73 73 65 64 29 3b 0a 20 20  it - passed);.  
9b80: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20      } else {.   
9b90: 20 20 20 20 20 74 69 6d 65 6f 75 74 20 3d 20 6e       timeout = n
9ba0: 75 6c 6c 3b 0a 20 20 20 20 20 20 20 20 69 66 20  ull;.        if 
9bb0: 28 21 69 6d 6d 65 64 69 61 74 65 29 20 72 65 73  (!immediate) res
9bc0: 75 6c 74 20 3d 20 66 75 6e 63 2e 61 70 70 6c 79  ult = func.apply
9bd0: 28 63 6f 6e 74 65 78 74 2c 20 61 72 67 73 29 3b  (context, args);
9be0: 0a 20 20 20 20 20 20 20 20 2f 2f 20 54 68 69 73  .        // This
9bf0: 20 63 68 65 63 6b 20 69 73 20 6e 65 65 64 65 64   check is needed
9c00: 20 62 65 63 61 75 73 65 20 60 66 75 6e 63 60 20   because `func` 
9c10: 63 61 6e 20 72 65 63 75 72 73 69 76 65 6c 79 20  can recursively 
9c20: 69 6e 76 6f 6b 65 20 60 64 65 62 6f 75 6e 63 65  invoke `debounce
9c30: 64 60 2e 0a 20 20 20 20 20 20 20 20 69 66 20 28  d`..        if (
9c40: 21 74 69 6d 65 6f 75 74 29 20 61 72 67 73 20 3d  !timeout) args =
9c50: 20 63 6f 6e 74 65 78 74 20 3d 20 6e 75 6c 6c 3b   context = null;
9c60: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 3b 0a  .      }.    };.
9c70: 0a 20 20 20 20 76 61 72 20 64 65 62 6f 75 6e 63  .    var debounc
9c80: 65 64 20 3d 20 72 65 73 74 41 72 67 75 6d 65 6e  ed = restArgumen
9c90: 74 73 28 66 75 6e 63 74 69 6f 6e 28 5f 61 72 67  ts(function(_arg
9ca0: 73 29 20 7b 0a 20 20 20 20 20 20 63 6f 6e 74 65  s) {.      conte
9cb0: 78 74 20 3d 20 74 68 69 73 3b 0a 20 20 20 20 20  xt = this;.     
9cc0: 20 61 72 67 73 20 3d 20 5f 61 72 67 73 3b 0a 20   args = _args;. 
9cd0: 20 20 20 20 20 70 72 65 76 69 6f 75 73 20 3d 20       previous = 
9ce0: 6e 6f 77 28 29 3b 0a 20 20 20 20 20 20 69 66 20  now();.      if 
9cf0: 28 21 74 69 6d 65 6f 75 74 29 20 7b 0a 20 20 20  (!timeout) {.   
9d00: 20 20 20 20 20 74 69 6d 65 6f 75 74 20 3d 20 73       timeout = s
9d10: 65 74 54 69 6d 65 6f 75 74 28 6c 61 74 65 72 2c  etTimeout(later,
9d20: 20 77 61 69 74 29 3b 0a 20 20 20 20 20 20 20 20   wait);.        
9d30: 69 66 20 28 69 6d 6d 65 64 69 61 74 65 29 20 72  if (immediate) r
9d40: 65 73 75 6c 74 20 3d 20 66 75 6e 63 2e 61 70 70  esult = func.app
9d50: 6c 79 28 63 6f 6e 74 65 78 74 2c 20 61 72 67 73  ly(context, args
9d60: 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20  );.      }.     
9d70: 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a   return result;.
9d80: 20 20 20 20 7d 29 3b 0a 0a 20 20 20 20 64 65 62      });..    deb
9d90: 6f 75 6e 63 65 64 2e 63 61 6e 63 65 6c 20 3d 20  ounced.cancel = 
9da0: 66 75 6e 63 74 69 6f 6e 28 29 20 7b 0a 20 20 20  function() {.   
9db0: 20 20 20 63 6c 65 61 72 54 69 6d 65 6f 75 74 28     clearTimeout(
9dc0: 74 69 6d 65 6f 75 74 29 3b 0a 20 20 20 20 20 20  timeout);.      
9dd0: 74 69 6d 65 6f 75 74 20 3d 20 61 72 67 73 20 3d  timeout = args =
9de0: 20 63 6f 6e 74 65 78 74 20 3d 20 6e 75 6c 6c 3b   context = null;
9df0: 0a 20 20 20 20 7d 3b 0a 0a 20 20 20 20 72 65 74  .    };..    ret
9e00: 75 72 6e 20 64 65 62 6f 75 6e 63 65 64 3b 0a 20  urn debounced;. 
9e10: 20 7d 0a 0a 20 20 2f 2f 20 52 65 74 75 72 6e 73   }..  // Returns
9e20: 20 74 68 65 20 66 69 72 73 74 20 66 75 6e 63 74   the first funct
9e30: 69 6f 6e 20 70 61 73 73 65 64 20 61 73 20 61 6e  ion passed as an
9e40: 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 74 68 65   argument to the
9e50: 20 73 65 63 6f 6e 64 2c 0a 20 20 2f 2f 20 61 6c   second,.  // al
9e60: 6c 6f 77 69 6e 67 20 79 6f 75 20 74 6f 20 61 64  lowing you to ad
9e70: 6a 75 73 74 20 61 72 67 75 6d 65 6e 74 73 2c 20  just arguments, 
9e80: 72 75 6e 20 63 6f 64 65 20 62 65 66 6f 72 65 20  run code before 
9e90: 61 6e 64 20 61 66 74 65 72 2c 20 61 6e 64 0a 20  and after, and. 
9ea0: 20 2f 2f 20 63 6f 6e 64 69 74 69 6f 6e 61 6c 6c   // conditionall
9eb0: 79 20 65 78 65 63 75 74 65 20 74 68 65 20 6f 72  y execute the or
9ec0: 69 67 69 6e 61 6c 20 66 75 6e 63 74 69 6f 6e 2e  iginal function.
9ed0: 0a 20 20 66 75 6e 63 74 69 6f 6e 20 77 72 61 70  .  function wrap
9ee0: 28 66 75 6e 63 2c 20 77 72 61 70 70 65 72 29 20  (func, wrapper) 
9ef0: 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 70 61 72  {.    return par
9f00: 74 69 61 6c 28 77 72 61 70 70 65 72 2c 20 66 75  tial(wrapper, fu
9f10: 6e 63 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52  nc);.  }..  // R
9f20: 65 74 75 72 6e 73 20 61 20 6e 65 67 61 74 65 64  eturns a negated
9f30: 20 76 65 72 73 69 6f 6e 20 6f 66 20 74 68 65 20   version of the 
9f40: 70 61 73 73 65 64 2d 69 6e 20 70 72 65 64 69 63  passed-in predic
9f50: 61 74 65 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20  ate..  function 
9f60: 6e 65 67 61 74 65 28 70 72 65 64 69 63 61 74 65  negate(predicate
9f70: 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 66  ) {.    return f
9f80: 75 6e 63 74 69 6f 6e 28 29 20 7b 0a 20 20 20 20  unction() {.    
9f90: 20 20 72 65 74 75 72 6e 20 21 70 72 65 64 69 63    return !predic
9fa0: 61 74 65 2e 61 70 70 6c 79 28 74 68 69 73 2c 20  ate.apply(this, 
9fb0: 61 72 67 75 6d 65 6e 74 73 29 3b 0a 20 20 20 20  arguments);.    
9fc0: 7d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52 65 74  };.  }..  // Ret
9fd0: 75 72 6e 73 20 61 20 66 75 6e 63 74 69 6f 6e 20  urns a function 
9fe0: 74 68 61 74 20 69 73 20 74 68 65 20 63 6f 6d 70  that is the comp
9ff0: 6f 73 69 74 69 6f 6e 20 6f 66 20 61 20 6c 69 73  osition of a lis
a000: 74 20 6f 66 20 66 75 6e 63 74 69 6f 6e 73 2c 20  t of functions, 
a010: 65 61 63 68 0a 20 20 2f 2f 20 63 6f 6e 73 75 6d  each.  // consum
a020: 69 6e 67 20 74 68 65 20 72 65 74 75 72 6e 20 76  ing the return v
a030: 61 6c 75 65 20 6f 66 20 74 68 65 20 66 75 6e 63  alue of the func
a040: 74 69 6f 6e 20 74 68 61 74 20 66 6f 6c 6c 6f 77  tion that follow
a050: 73 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 63 6f  s..  function co
a060: 6d 70 6f 73 65 28 29 20 7b 0a 20 20 20 20 76 61  mpose() {.    va
a070: 72 20 61 72 67 73 20 3d 20 61 72 67 75 6d 65 6e  r args = argumen
a080: 74 73 3b 0a 20 20 20 20 76 61 72 20 73 74 61 72  ts;.    var star
a090: 74 20 3d 20 61 72 67 73 2e 6c 65 6e 67 74 68 20  t = args.length 
a0a0: 2d 20 31 3b 0a 20 20 20 20 72 65 74 75 72 6e 20  - 1;.    return 
a0b0: 66 75 6e 63 74 69 6f 6e 28 29 20 7b 0a 20 20 20  function() {.   
a0c0: 20 20 20 76 61 72 20 69 20 3d 20 73 74 61 72 74     var i = start
a0d0: 3b 0a 20 20 20 20 20 20 76 61 72 20 72 65 73 75  ;.      var resu
a0e0: 6c 74 20 3d 20 61 72 67 73 5b 73 74 61 72 74 5d  lt = args[start]
a0f0: 2e 61 70 70 6c 79 28 74 68 69 73 2c 20 61 72 67  .apply(this, arg
a100: 75 6d 65 6e 74 73 29 3b 0a 20 20 20 20 20 20 77  uments);.      w
a110: 68 69 6c 65 20 28 69 2d 2d 29 20 72 65 73 75 6c  hile (i--) resul
a120: 74 20 3d 20 61 72 67 73 5b 69 5d 2e 63 61 6c 6c  t = args[i].call
a130: 28 74 68 69 73 2c 20 72 65 73 75 6c 74 29 3b 0a  (this, result);.
a140: 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 73        return res
a150: 75 6c 74 3b 0a 20 20 20 20 7d 3b 0a 20 20 7d 0a  ult;.    };.  }.
a160: 0a 20 20 2f 2f 20 52 65 74 75 72 6e 73 20 61 20  .  // Returns a 
a170: 66 75 6e 63 74 69 6f 6e 20 74 68 61 74 20 77 69  function that wi
a180: 6c 6c 20 6f 6e 6c 79 20 62 65 20 65 78 65 63 75  ll only be execu
a190: 74 65 64 20 6f 6e 20 61 6e 64 20 61 66 74 65 72  ted on and after
a1a0: 20 74 68 65 20 4e 74 68 20 63 61 6c 6c 2e 0a 20   the Nth call.. 
a1b0: 20 66 75 6e 63 74 69 6f 6e 20 61 66 74 65 72 28   function after(
a1c0: 74 69 6d 65 73 2c 20 66 75 6e 63 29 20 7b 0a 20  times, func) {. 
a1d0: 20 20 20 72 65 74 75 72 6e 20 66 75 6e 63 74 69     return functi
a1e0: 6f 6e 28 29 20 7b 0a 20 20 20 20 20 20 69 66 20  on() {.      if 
a1f0: 28 2d 2d 74 69 6d 65 73 20 3c 20 31 29 20 7b 0a  (--times < 1) {.
a200: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66          return f
a210: 75 6e 63 2e 61 70 70 6c 79 28 74 68 69 73 2c 20  unc.apply(this, 
a220: 61 72 67 75 6d 65 6e 74 73 29 3b 0a 20 20 20 20  arguments);.    
a230: 20 20 7d 0a 20 20 20 20 7d 3b 0a 20 20 7d 0a 0a    }.    };.  }..
a240: 20 20 2f 2f 20 52 65 74 75 72 6e 73 20 61 20 66    // Returns a f
a250: 75 6e 63 74 69 6f 6e 20 74 68 61 74 20 77 69 6c  unction that wil
a260: 6c 20 6f 6e 6c 79 20 62 65 20 65 78 65 63 75 74  l only be execut
a270: 65 64 20 75 70 20 74 6f 20 28 62 75 74 20 6e 6f  ed up to (but no
a280: 74 20 69 6e 63 6c 75 64 69 6e 67 29 20 74 68 65  t including) the
a290: 0a 20 20 2f 2f 20 4e 74 68 20 63 61 6c 6c 2e 0a  .  // Nth call..
a2a0: 20 20 66 75 6e 63 74 69 6f 6e 20 62 65 66 6f 72    function befor
a2b0: 65 28 74 69 6d 65 73 2c 20 66 75 6e 63 29 20 7b  e(times, func) {
a2c0: 0a 20 20 20 20 76 61 72 20 6d 65 6d 6f 3b 0a 20  .    var memo;. 
a2d0: 20 20 20 72 65 74 75 72 6e 20 66 75 6e 63 74 69     return functi
a2e0: 6f 6e 28 29 20 7b 0a 20 20 20 20 20 20 69 66 20  on() {.      if 
a2f0: 28 2d 2d 74 69 6d 65 73 20 3e 20 30 29 20 7b 0a  (--times > 0) {.
a300: 20 20 20 20 20 20 20 20 6d 65 6d 6f 20 3d 20 66          memo = f
a310: 75 6e 63 2e 61 70 70 6c 79 28 74 68 69 73 2c 20  unc.apply(this, 
a320: 61 72 67 75 6d 65 6e 74 73 29 3b 0a 20 20 20 20  arguments);.    
a330: 20 20 7d 0a 20 20 20 20 20 20 69 66 20 28 74 69    }.      if (ti
a340: 6d 65 73 20 3c 3d 20 31 29 20 66 75 6e 63 20 3d  mes <= 1) func =
a350: 20 6e 75 6c 6c 3b 0a 20 20 20 20 20 20 72 65 74   null;.      ret
a360: 75 72 6e 20 6d 65 6d 6f 3b 0a 20 20 20 20 7d 3b  urn memo;.    };
a370: 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52 65 74 75 72  .  }..  // Retur
a380: 6e 73 20 61 20 66 75 6e 63 74 69 6f 6e 20 74 68  ns a function th
a390: 61 74 20 77 69 6c 6c 20 62 65 20 65 78 65 63 75  at will be execu
a3a0: 74 65 64 20 61 74 20 6d 6f 73 74 20 6f 6e 65 20  ted at most one 
a3b0: 74 69 6d 65 2c 20 6e 6f 20 6d 61 74 74 65 72 20  time, no matter 
a3c0: 68 6f 77 0a 20 20 2f 2f 20 6f 66 74 65 6e 20 79  how.  // often y
a3d0: 6f 75 20 63 61 6c 6c 20 69 74 2e 20 55 73 65 66  ou call it. Usef
a3e0: 75 6c 20 66 6f 72 20 6c 61 7a 79 20 69 6e 69 74  ul for lazy init
a3f0: 69 61 6c 69 7a 61 74 69 6f 6e 2e 0a 20 20 76 61  ialization..  va
a400: 72 20 6f 6e 63 65 20 3d 20 70 61 72 74 69 61 6c  r once = partial
a410: 28 62 65 66 6f 72 65 2c 20 32 29 3b 0a 0a 20 20  (before, 2);..  
a420: 2f 2f 20 52 65 74 75 72 6e 73 20 74 68 65 20 66  // Returns the f
a430: 69 72 73 74 20 6b 65 79 20 6f 6e 20 61 6e 20 6f  irst key on an o
a440: 62 6a 65 63 74 20 74 68 61 74 20 70 61 73 73 65  bject that passe
a450: 73 20 61 20 74 72 75 74 68 20 74 65 73 74 2e 0a  s a truth test..
a460: 20 20 66 75 6e 63 74 69 6f 6e 20 66 69 6e 64 4b    function findK
a470: 65 79 28 6f 62 6a 2c 20 70 72 65 64 69 63 61 74  ey(obj, predicat
a480: 65 2c 20 63 6f 6e 74 65 78 74 29 20 7b 0a 20 20  e, context) {.  
a490: 20 20 70 72 65 64 69 63 61 74 65 20 3d 20 63 62    predicate = cb
a4a0: 28 70 72 65 64 69 63 61 74 65 2c 20 63 6f 6e 74  (predicate, cont
a4b0: 65 78 74 29 3b 0a 20 20 20 20 76 61 72 20 5f 6b  ext);.    var _k
a4c0: 65 79 73 20 3d 20 6b 65 79 73 28 6f 62 6a 29 2c  eys = keys(obj),
a4d0: 20 6b 65 79 3b 0a 20 20 20 20 66 6f 72 20 28 76   key;.    for (v
a4e0: 61 72 20 69 20 3d 20 30 2c 20 6c 65 6e 67 74 68  ar i = 0, length
a4f0: 20 3d 20 5f 6b 65 79 73 2e 6c 65 6e 67 74 68 3b   = _keys.length;
a500: 20 69 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b   i < length; i++
a510: 29 20 7b 0a 20 20 20 20 20 20 6b 65 79 20 3d 20  ) {.      key = 
a520: 5f 6b 65 79 73 5b 69 5d 3b 0a 20 20 20 20 20 20  _keys[i];.      
a530: 69 66 20 28 70 72 65 64 69 63 61 74 65 28 6f 62  if (predicate(ob
a540: 6a 5b 6b 65 79 5d 2c 20 6b 65 79 2c 20 6f 62 6a  j[key], key, obj
a550: 29 29 20 72 65 74 75 72 6e 20 6b 65 79 3b 0a 20  )) return key;. 
a560: 20 20 20 7d 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49     }.  }..  // I
a570: 6e 74 65 72 6e 61 6c 20 66 75 6e 63 74 69 6f 6e  nternal function
a580: 20 74 6f 20 67 65 6e 65 72 61 74 65 20 60 5f 2e   to generate `_.
a590: 66 69 6e 64 49 6e 64 65 78 60 20 61 6e 64 20 60  findIndex` and `
a5a0: 5f 2e 66 69 6e 64 4c 61 73 74 49 6e 64 65 78 60  _.findLastIndex`
a5b0: 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 63 72 65  ..  function cre
a5c0: 61 74 65 50 72 65 64 69 63 61 74 65 49 6e 64 65  atePredicateInde
a5d0: 78 46 69 6e 64 65 72 28 64 69 72 29 20 7b 0a 20  xFinder(dir) {. 
a5e0: 20 20 20 72 65 74 75 72 6e 20 66 75 6e 63 74 69     return functi
a5f0: 6f 6e 28 61 72 72 61 79 2c 20 70 72 65 64 69 63  on(array, predic
a600: 61 74 65 2c 20 63 6f 6e 74 65 78 74 29 20 7b 0a  ate, context) {.
a610: 20 20 20 20 20 20 70 72 65 64 69 63 61 74 65 20        predicate 
a620: 3d 20 63 62 28 70 72 65 64 69 63 61 74 65 2c 20  = cb(predicate, 
a630: 63 6f 6e 74 65 78 74 29 3b 0a 20 20 20 20 20 20  context);.      
a640: 76 61 72 20 6c 65 6e 67 74 68 20 3d 20 67 65 74  var length = get
a650: 4c 65 6e 67 74 68 28 61 72 72 61 79 29 3b 0a 20  Length(array);. 
a660: 20 20 20 20 20 76 61 72 20 69 6e 64 65 78 20 3d       var index =
a670: 20 64 69 72 20 3e 20 30 20 3f 20 30 20 3a 20 6c   dir > 0 ? 0 : l
a680: 65 6e 67 74 68 20 2d 20 31 3b 0a 20 20 20 20 20  ength - 1;.     
a690: 20 66 6f 72 20 28 3b 20 69 6e 64 65 78 20 3e 3d   for (; index >=
a6a0: 20 30 20 26 26 20 69 6e 64 65 78 20 3c 20 6c 65   0 && index < le
a6b0: 6e 67 74 68 3b 20 69 6e 64 65 78 20 2b 3d 20 64  ngth; index += d
a6c0: 69 72 29 20 7b 0a 20 20 20 20 20 20 20 20 69 66  ir) {.        if
a6d0: 20 28 70 72 65 64 69 63 61 74 65 28 61 72 72 61   (predicate(arra
a6e0: 79 5b 69 6e 64 65 78 5d 2c 20 69 6e 64 65 78 2c  y[index], index,
a6f0: 20 61 72 72 61 79 29 29 20 72 65 74 75 72 6e 20   array)) return 
a700: 69 6e 64 65 78 3b 0a 20 20 20 20 20 20 7d 0a 20  index;.      }. 
a710: 20 20 20 20 20 72 65 74 75 72 6e 20 2d 31 3b 0a       return -1;.
a720: 20 20 20 20 7d 3b 0a 20 20 7d 0a 0a 20 20 2f 2f      };.  }..  //
a730: 20 52 65 74 75 72 6e 73 20 74 68 65 20 66 69 72   Returns the fir
a740: 73 74 20 69 6e 64 65 78 20 6f 6e 20 61 6e 20 61  st index on an a
a750: 72 72 61 79 2d 6c 69 6b 65 20 74 68 61 74 20 70  rray-like that p
a760: 61 73 73 65 73 20 61 20 74 72 75 74 68 20 74 65  asses a truth te
a770: 73 74 2e 0a 20 20 76 61 72 20 66 69 6e 64 49 6e  st..  var findIn
a780: 64 65 78 20 3d 20 63 72 65 61 74 65 50 72 65 64  dex = createPred
a790: 69 63 61 74 65 49 6e 64 65 78 46 69 6e 64 65 72  icateIndexFinder
a7a0: 28 31 29 3b 0a 0a 20 20 2f 2f 20 52 65 74 75 72  (1);..  // Retur
a7b0: 6e 73 20 74 68 65 20 6c 61 73 74 20 69 6e 64 65  ns the last inde
a7c0: 78 20 6f 6e 20 61 6e 20 61 72 72 61 79 2d 6c 69  x on an array-li
a7d0: 6b 65 20 74 68 61 74 20 70 61 73 73 65 73 20 61  ke that passes a
a7e0: 20 74 72 75 74 68 20 74 65 73 74 2e 0a 20 20 76   truth test..  v
a7f0: 61 72 20 66 69 6e 64 4c 61 73 74 49 6e 64 65 78  ar findLastIndex
a800: 20 3d 20 63 72 65 61 74 65 50 72 65 64 69 63 61   = createPredica
a810: 74 65 49 6e 64 65 78 46 69 6e 64 65 72 28 2d 31  teIndexFinder(-1
a820: 29 3b 0a 0a 20 20 2f 2f 20 55 73 65 20 61 20 63  );..  // Use a c
a830: 6f 6d 70 61 72 61 74 6f 72 20 66 75 6e 63 74 69  omparator functi
a840: 6f 6e 20 74 6f 20 66 69 67 75 72 65 20 6f 75 74  on to figure out
a850: 20 74 68 65 20 73 6d 61 6c 6c 65 73 74 20 69 6e   the smallest in
a860: 64 65 78 20 61 74 20 77 68 69 63 68 0a 20 20 2f  dex at which.  /
a870: 2f 20 61 6e 20 6f 62 6a 65 63 74 20 73 68 6f 75  / an object shou
a880: 6c 64 20 62 65 20 69 6e 73 65 72 74 65 64 20 73  ld be inserted s
a890: 6f 20 61 73 20 74 6f 20 6d 61 69 6e 74 61 69 6e  o as to maintain
a8a0: 20 6f 72 64 65 72 2e 20 55 73 65 73 20 62 69 6e   order. Uses bin
a8b0: 61 72 79 20 73 65 61 72 63 68 2e 0a 20 20 66 75  ary search..  fu
a8c0: 6e 63 74 69 6f 6e 20 73 6f 72 74 65 64 49 6e 64  nction sortedInd
a8d0: 65 78 28 61 72 72 61 79 2c 20 6f 62 6a 2c 20 69  ex(array, obj, i
a8e0: 74 65 72 61 74 65 65 2c 20 63 6f 6e 74 65 78 74  teratee, context
a8f0: 29 20 7b 0a 20 20 20 20 69 74 65 72 61 74 65 65  ) {.    iteratee
a900: 20 3d 20 63 62 28 69 74 65 72 61 74 65 65 2c 20   = cb(iteratee, 
a910: 63 6f 6e 74 65 78 74 2c 20 31 29 3b 0a 20 20 20  context, 1);.   
a920: 20 76 61 72 20 76 61 6c 75 65 20 3d 20 69 74 65   var value = ite
a930: 72 61 74 65 65 28 6f 62 6a 29 3b 0a 20 20 20 20  ratee(obj);.    
a940: 76 61 72 20 6c 6f 77 20 3d 20 30 2c 20 68 69 67  var low = 0, hig
a950: 68 20 3d 20 67 65 74 4c 65 6e 67 74 68 28 61 72  h = getLength(ar
a960: 72 61 79 29 3b 0a 20 20 20 20 77 68 69 6c 65 20  ray);.    while 
a970: 28 6c 6f 77 20 3c 20 68 69 67 68 29 20 7b 0a 20  (low < high) {. 
a980: 20 20 20 20 20 76 61 72 20 6d 69 64 20 3d 20 4d       var mid = M
a990: 61 74 68 2e 66 6c 6f 6f 72 28 28 6c 6f 77 20 2b  ath.floor((low +
a9a0: 20 68 69 67 68 29 20 2f 20 32 29 3b 0a 20 20 20   high) / 2);.   
a9b0: 20 20 20 69 66 20 28 69 74 65 72 61 74 65 65 28     if (iteratee(
a9c0: 61 72 72 61 79 5b 6d 69 64 5d 29 20 3c 20 76 61  array[mid]) < va
a9d0: 6c 75 65 29 20 6c 6f 77 20 3d 20 6d 69 64 20 2b  lue) low = mid +
a9e0: 20 31 3b 20 65 6c 73 65 20 68 69 67 68 20 3d 20   1; else high = 
a9f0: 6d 69 64 3b 0a 20 20 20 20 7d 0a 20 20 20 20 72  mid;.    }.    r
aa00: 65 74 75 72 6e 20 6c 6f 77 3b 0a 20 20 7d 0a 0a  eturn low;.  }..
aa10: 20 20 2f 2f 20 49 6e 74 65 72 6e 61 6c 20 66 75    // Internal fu
aa20: 6e 63 74 69 6f 6e 20 74 6f 20 67 65 6e 65 72 61  nction to genera
aa30: 74 65 20 74 68 65 20 60 5f 2e 69 6e 64 65 78 4f  te the `_.indexO
aa40: 66 60 20 61 6e 64 20 60 5f 2e 6c 61 73 74 49 6e  f` and `_.lastIn
aa50: 64 65 78 4f 66 60 20 66 75 6e 63 74 69 6f 6e 73  dexOf` functions
aa60: 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 63 72 65  ..  function cre
aa70: 61 74 65 49 6e 64 65 78 46 69 6e 64 65 72 28 64  ateIndexFinder(d
aa80: 69 72 2c 20 70 72 65 64 69 63 61 74 65 46 69 6e  ir, predicateFin
aa90: 64 2c 20 73 6f 72 74 65 64 49 6e 64 65 78 29 20  d, sortedIndex) 
aaa0: 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 66 75 6e  {.    return fun
aab0: 63 74 69 6f 6e 28 61 72 72 61 79 2c 20 69 74 65  ction(array, ite
aac0: 6d 2c 20 69 64 78 29 20 7b 0a 20 20 20 20 20 20  m, idx) {.      
aad0: 76 61 72 20 69 20 3d 20 30 2c 20 6c 65 6e 67 74  var i = 0, lengt
aae0: 68 20 3d 20 67 65 74 4c 65 6e 67 74 68 28 61 72  h = getLength(ar
aaf0: 72 61 79 29 3b 0a 20 20 20 20 20 20 69 66 20 28  ray);.      if (
ab00: 74 79 70 65 6f 66 20 69 64 78 20 3d 3d 20 27 6e  typeof idx == 'n
ab10: 75 6d 62 65 72 27 29 20 7b 0a 20 20 20 20 20 20  umber') {.      
ab20: 20 20 69 66 20 28 64 69 72 20 3e 20 30 29 20 7b    if (dir > 0) {
ab30: 0a 20 20 20 20 20 20 20 20 20 20 69 20 3d 20 69  .          i = i
ab40: 64 78 20 3e 3d 20 30 20 3f 20 69 64 78 20 3a 20  dx >= 0 ? idx : 
ab50: 4d 61 74 68 2e 6d 61 78 28 69 64 78 20 2b 20 6c  Math.max(idx + l
ab60: 65 6e 67 74 68 2c 20 69 29 3b 0a 20 20 20 20 20  ength, i);.     
ab70: 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20     } else {.    
ab80: 20 20 20 20 20 20 6c 65 6e 67 74 68 20 3d 20 69        length = i
ab90: 64 78 20 3e 3d 20 30 20 3f 20 4d 61 74 68 2e 6d  dx >= 0 ? Math.m
aba0: 69 6e 28 69 64 78 20 2b 20 31 2c 20 6c 65 6e 67  in(idx + 1, leng
abb0: 74 68 29 20 3a 20 69 64 78 20 2b 20 6c 65 6e 67  th) : idx + leng
abc0: 74 68 20 2b 20 31 3b 0a 20 20 20 20 20 20 20 20  th + 1;.        
abd0: 7d 0a 20 20 20 20 20 20 7d 20 65 6c 73 65 20 69  }.      } else i
abe0: 66 20 28 73 6f 72 74 65 64 49 6e 64 65 78 20 26  f (sortedIndex &
abf0: 26 20 69 64 78 20 26 26 20 6c 65 6e 67 74 68 29  & idx && length)
ac00: 20 7b 0a 20 20 20 20 20 20 20 20 69 64 78 20 3d   {.        idx =
ac10: 20 73 6f 72 74 65 64 49 6e 64 65 78 28 61 72 72   sortedIndex(arr
ac20: 61 79 2c 20 69 74 65 6d 29 3b 0a 20 20 20 20 20  ay, item);.     
ac30: 20 20 20 72 65 74 75 72 6e 20 61 72 72 61 79 5b     return array[
ac40: 69 64 78 5d 20 3d 3d 3d 20 69 74 65 6d 20 3f 20  idx] === item ? 
ac50: 69 64 78 20 3a 20 2d 31 3b 0a 20 20 20 20 20 20  idx : -1;.      
ac60: 7d 0a 20 20 20 20 20 20 69 66 20 28 69 74 65 6d  }.      if (item
ac70: 20 21 3d 3d 20 69 74 65 6d 29 20 7b 0a 20 20 20   !== item) {.   
ac80: 20 20 20 20 20 69 64 78 20 3d 20 70 72 65 64 69       idx = predi
ac90: 63 61 74 65 46 69 6e 64 28 73 6c 69 63 65 2e 63  cateFind(slice.c
aca0: 61 6c 6c 28 61 72 72 61 79 2c 20 69 2c 20 6c 65  all(array, i, le
acb0: 6e 67 74 68 29 2c 20 69 73 4e 61 4e 24 31 29 3b  ngth), isNaN$1);
acc0: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20  .        return 
acd0: 69 64 78 20 3e 3d 20 30 20 3f 20 69 64 78 20 2b  idx >= 0 ? idx +
ace0: 20 69 20 3a 20 2d 31 3b 0a 20 20 20 20 20 20 7d   i : -1;.      }
acf0: 0a 20 20 20 20 20 20 66 6f 72 20 28 69 64 78 20  .      for (idx 
ad00: 3d 20 64 69 72 20 3e 20 30 20 3f 20 69 20 3a 20  = dir > 0 ? i : 
ad10: 6c 65 6e 67 74 68 20 2d 20 31 3b 20 69 64 78 20  length - 1; idx 
ad20: 3e 3d 20 30 20 26 26 20 69 64 78 20 3c 20 6c 65  >= 0 && idx < le
ad30: 6e 67 74 68 3b 20 69 64 78 20 2b 3d 20 64 69 72  ngth; idx += dir
ad40: 29 20 7b 0a 20 20 20 20 20 20 20 20 69 66 20 28  ) {.        if (
ad50: 61 72 72 61 79 5b 69 64 78 5d 20 3d 3d 3d 20 69  array[idx] === i
ad60: 74 65 6d 29 20 72 65 74 75 72 6e 20 69 64 78 3b  tem) return idx;
ad70: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 72  .      }.      r
ad80: 65 74 75 72 6e 20 2d 31 3b 0a 20 20 20 20 7d 3b  eturn -1;.    };
ad90: 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52 65 74 75 72  .  }..  // Retur
ada0: 6e 20 74 68 65 20 70 6f 73 69 74 69 6f 6e 20 6f  n the position o
adb0: 66 20 74 68 65 20 66 69 72 73 74 20 6f 63 63 75  f the first occu
adc0: 72 72 65 6e 63 65 20 6f 66 20 61 6e 20 69 74 65  rrence of an ite
add0: 6d 20 69 6e 20 61 6e 20 61 72 72 61 79 2c 0a 20  m in an array,. 
ade0: 20 2f 2f 20 6f 72 20 2d 31 20 69 66 20 74 68 65   // or -1 if the
adf0: 20 69 74 65 6d 20 69 73 20 6e 6f 74 20 69 6e 63   item is not inc
ae00: 6c 75 64 65 64 20 69 6e 20 74 68 65 20 61 72 72  luded in the arr
ae10: 61 79 2e 0a 20 20 2f 2f 20 49 66 20 74 68 65 20  ay..  // If the 
ae20: 61 72 72 61 79 20 69 73 20 6c 61 72 67 65 20 61  array is large a
ae30: 6e 64 20 61 6c 72 65 61 64 79 20 69 6e 20 73 6f  nd already in so
ae40: 72 74 20 6f 72 64 65 72 2c 20 70 61 73 73 20 60  rt order, pass `
ae50: 74 72 75 65 60 0a 20 20 2f 2f 20 66 6f 72 20 2a  true`.  // for *
ae60: 2a 69 73 53 6f 72 74 65 64 2a 2a 20 74 6f 20 75  *isSorted** to u
ae70: 73 65 20 62 69 6e 61 72 79 20 73 65 61 72 63 68  se binary search
ae80: 2e 0a 20 20 76 61 72 20 69 6e 64 65 78 4f 66 20  ..  var indexOf 
ae90: 3d 20 63 72 65 61 74 65 49 6e 64 65 78 46 69 6e  = createIndexFin
aea0: 64 65 72 28 31 2c 20 66 69 6e 64 49 6e 64 65 78  der(1, findIndex
aeb0: 2c 20 73 6f 72 74 65 64 49 6e 64 65 78 29 3b 0a  , sortedIndex);.
aec0: 0a 20 20 2f 2f 20 52 65 74 75 72 6e 20 74 68 65  .  // Return the
aed0: 20 70 6f 73 69 74 69 6f 6e 20 6f 66 20 74 68 65   position of the
aee0: 20 6c 61 73 74 20 6f 63 63 75 72 72 65 6e 63 65   last occurrence
aef0: 20 6f 66 20 61 6e 20 69 74 65 6d 20 69 6e 20 61   of an item in a
af00: 6e 20 61 72 72 61 79 2c 0a 20 20 2f 2f 20 6f 72  n array,.  // or
af10: 20 2d 31 20 69 66 20 74 68 65 20 69 74 65 6d 20   -1 if the item 
af20: 69 73 20 6e 6f 74 20 69 6e 63 6c 75 64 65 64 20  is not included 
af30: 69 6e 20 74 68 65 20 61 72 72 61 79 2e 0a 20 20  in the array..  
af40: 76 61 72 20 6c 61 73 74 49 6e 64 65 78 4f 66 20  var lastIndexOf 
af50: 3d 20 63 72 65 61 74 65 49 6e 64 65 78 46 69 6e  = createIndexFin
af60: 64 65 72 28 2d 31 2c 20 66 69 6e 64 4c 61 73 74  der(-1, findLast
af70: 49 6e 64 65 78 29 3b 0a 0a 20 20 2f 2f 20 52 65  Index);..  // Re
af80: 74 75 72 6e 20 74 68 65 20 66 69 72 73 74 20 76  turn the first v
af90: 61 6c 75 65 20 77 68 69 63 68 20 70 61 73 73 65  alue which passe
afa0: 73 20 61 20 74 72 75 74 68 20 74 65 73 74 2e 0a  s a truth test..
afb0: 20 20 66 75 6e 63 74 69 6f 6e 20 66 69 6e 64 28    function find(
afc0: 6f 62 6a 2c 20 70 72 65 64 69 63 61 74 65 2c 20  obj, predicate, 
afd0: 63 6f 6e 74 65 78 74 29 20 7b 0a 20 20 20 20 76  context) {.    v
afe0: 61 72 20 6b 65 79 46 69 6e 64 65 72 20 3d 20 69  ar keyFinder = i
aff0: 73 41 72 72 61 79 4c 69 6b 65 28 6f 62 6a 29 20  sArrayLike(obj) 
b000: 3f 20 66 69 6e 64 49 6e 64 65 78 20 3a 20 66 69  ? findIndex : fi
b010: 6e 64 4b 65 79 3b 0a 20 20 20 20 76 61 72 20 6b  ndKey;.    var k
b020: 65 79 20 3d 20 6b 65 79 46 69 6e 64 65 72 28 6f  ey = keyFinder(o
b030: 62 6a 2c 20 70 72 65 64 69 63 61 74 65 2c 20 63  bj, predicate, c
b040: 6f 6e 74 65 78 74 29 3b 0a 20 20 20 20 69 66 20  ontext);.    if 
b050: 28 6b 65 79 20 21 3d 3d 20 76 6f 69 64 20 30 20  (key !== void 0 
b060: 26 26 20 6b 65 79 20 21 3d 3d 20 2d 31 29 20 72  && key !== -1) r
b070: 65 74 75 72 6e 20 6f 62 6a 5b 6b 65 79 5d 3b 0a  eturn obj[key];.
b080: 20 20 7d 0a 0a 20 20 2f 2f 20 43 6f 6e 76 65 6e    }..  // Conven
b090: 69 65 6e 63 65 20 76 65 72 73 69 6f 6e 20 6f 66  ience version of
b0a0: 20 61 20 63 6f 6d 6d 6f 6e 20 75 73 65 20 63 61   a common use ca
b0b0: 73 65 20 6f 66 20 60 5f 2e 66 69 6e 64 60 3a 20  se of `_.find`: 
b0c0: 67 65 74 74 69 6e 67 20 74 68 65 20 66 69 72 73  getting the firs
b0d0: 74 0a 20 20 2f 2f 20 6f 62 6a 65 63 74 20 63 6f  t.  // object co
b0e0: 6e 74 61 69 6e 69 6e 67 20 73 70 65 63 69 66 69  ntaining specifi
b0f0: 63 20 60 6b 65 79 3a 76 61 6c 75 65 60 20 70 61  c `key:value` pa
b100: 69 72 73 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20  irs..  function 
b110: 66 69 6e 64 57 68 65 72 65 28 6f 62 6a 2c 20 61  findWhere(obj, a
b120: 74 74 72 73 29 20 7b 0a 20 20 20 20 72 65 74 75  ttrs) {.    retu
b130: 72 6e 20 66 69 6e 64 28 6f 62 6a 2c 20 6d 61 74  rn find(obj, mat
b140: 63 68 65 72 28 61 74 74 72 73 29 29 3b 0a 20 20  cher(attrs));.  
b150: 7d 0a 0a 20 20 2f 2f 20 54 68 65 20 63 6f 72 6e  }..  // The corn
b160: 65 72 73 74 6f 6e 65 20 66 6f 72 20 63 6f 6c 6c  erstone for coll
b170: 65 63 74 69 6f 6e 20 66 75 6e 63 74 69 6f 6e 73  ection functions
b180: 2c 20 61 6e 20 60 65 61 63 68 60 0a 20 20 2f 2f  , an `each`.  //
b190: 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 2c   implementation,
b1a0: 20 61 6b 61 20 60 66 6f 72 45 61 63 68 60 2e 0a   aka `forEach`..
b1b0: 20 20 2f 2f 20 48 61 6e 64 6c 65 73 20 72 61 77    // Handles raw
b1c0: 20 6f 62 6a 65 63 74 73 20 69 6e 20 61 64 64 69   objects in addi
b1d0: 74 69 6f 6e 20 74 6f 20 61 72 72 61 79 2d 6c 69  tion to array-li
b1e0: 6b 65 73 2e 20 54 72 65 61 74 73 20 61 6c 6c 0a  kes. Treats all.
b1f0: 20 20 2f 2f 20 73 70 61 72 73 65 20 61 72 72 61    // sparse arra
b200: 79 2d 6c 69 6b 65 73 20 61 73 20 69 66 20 74 68  y-likes as if th
b210: 65 79 20 77 65 72 65 20 64 65 6e 73 65 2e 0a 20  ey were dense.. 
b220: 20 66 75 6e 63 74 69 6f 6e 20 65 61 63 68 28 6f   function each(o
b230: 62 6a 2c 20 69 74 65 72 61 74 65 65 2c 20 63 6f  bj, iteratee, co
b240: 6e 74 65 78 74 29 20 7b 0a 20 20 20 20 69 74 65  ntext) {.    ite
b250: 72 61 74 65 65 20 3d 20 6f 70 74 69 6d 69 7a 65  ratee = optimize
b260: 43 62 28 69 74 65 72 61 74 65 65 2c 20 63 6f 6e  Cb(iteratee, con
b270: 74 65 78 74 29 3b 0a 20 20 20 20 76 61 72 20 69  text);.    var i
b280: 2c 20 6c 65 6e 67 74 68 3b 0a 20 20 20 20 69 66  , length;.    if
b290: 20 28 69 73 41 72 72 61 79 4c 69 6b 65 28 6f 62   (isArrayLike(ob
b2a0: 6a 29 29 20 7b 0a 20 20 20 20 20 20 66 6f 72 20  j)) {.      for 
b2b0: 28 69 20 3d 20 30 2c 20 6c 65 6e 67 74 68 20 3d  (i = 0, length =
b2c0: 20 6f 62 6a 2e 6c 65 6e 67 74 68 3b 20 69 20 3c   obj.length; i <
b2d0: 20 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20 7b 0a   length; i++) {.
b2e0: 20 20 20 20 20 20 20 20 69 74 65 72 61 74 65 65          iteratee
b2f0: 28 6f 62 6a 5b 69 5d 2c 20 69 2c 20 6f 62 6a 29  (obj[i], i, obj)
b300: 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 20  ;.      }.    } 
b310: 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 76 61 72  else {.      var
b320: 20 5f 6b 65 79 73 20 3d 20 6b 65 79 73 28 6f 62   _keys = keys(ob
b330: 6a 29 3b 0a 20 20 20 20 20 20 66 6f 72 20 28 69  j);.      for (i
b340: 20 3d 20 30 2c 20 6c 65 6e 67 74 68 20 3d 20 5f   = 0, length = _
b350: 6b 65 79 73 2e 6c 65 6e 67 74 68 3b 20 69 20 3c  keys.length; i <
b360: 20 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20 7b 0a   length; i++) {.
b370: 20 20 20 20 20 20 20 20 69 74 65 72 61 74 65 65          iteratee
b380: 28 6f 62 6a 5b 5f 6b 65 79 73 5b 69 5d 5d 2c 20  (obj[_keys[i]], 
b390: 5f 6b 65 79 73 5b 69 5d 2c 20 6f 62 6a 29 3b 0a  _keys[i], obj);.
b3a0: 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20        }.    }.  
b3b0: 20 20 72 65 74 75 72 6e 20 6f 62 6a 3b 0a 20 20    return obj;.  
b3c0: 7d 0a 0a 20 20 2f 2f 20 52 65 74 75 72 6e 20 74  }..  // Return t
b3d0: 68 65 20 72 65 73 75 6c 74 73 20 6f 66 20 61 70  he results of ap
b3e0: 70 6c 79 69 6e 67 20 74 68 65 20 69 74 65 72 61  plying the itera
b3f0: 74 65 65 20 74 6f 20 65 61 63 68 20 65 6c 65 6d  tee to each elem
b400: 65 6e 74 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20  ent..  function 
b410: 6d 61 70 28 6f 62 6a 2c 20 69 74 65 72 61 74 65  map(obj, iterate
b420: 65 2c 20 63 6f 6e 74 65 78 74 29 20 7b 0a 20 20  e, context) {.  
b430: 20 20 69 74 65 72 61 74 65 65 20 3d 20 63 62 28    iteratee = cb(
b440: 69 74 65 72 61 74 65 65 2c 20 63 6f 6e 74 65 78  iteratee, contex
b450: 74 29 3b 0a 20 20 20 20 76 61 72 20 5f 6b 65 79  t);.    var _key
b460: 73 20 3d 20 21 69 73 41 72 72 61 79 4c 69 6b 65  s = !isArrayLike
b470: 28 6f 62 6a 29 20 26 26 20 6b 65 79 73 28 6f 62  (obj) && keys(ob
b480: 6a 29 2c 0a 20 20 20 20 20 20 20 20 6c 65 6e 67  j),.        leng
b490: 74 68 20 3d 20 28 5f 6b 65 79 73 20 7c 7c 20 6f  th = (_keys || o
b4a0: 62 6a 29 2e 6c 65 6e 67 74 68 2c 0a 20 20 20 20  bj).length,.    
b4b0: 20 20 20 20 72 65 73 75 6c 74 73 20 3d 20 41 72      results = Ar
b4c0: 72 61 79 28 6c 65 6e 67 74 68 29 3b 0a 20 20 20  ray(length);.   
b4d0: 20 66 6f 72 20 28 76 61 72 20 69 6e 64 65 78 20   for (var index 
b4e0: 3d 20 30 3b 20 69 6e 64 65 78 20 3c 20 6c 65 6e  = 0; index < len
b4f0: 67 74 68 3b 20 69 6e 64 65 78 2b 2b 29 20 7b 0a  gth; index++) {.
b500: 20 20 20 20 20 20 76 61 72 20 63 75 72 72 65 6e        var curren
b510: 74 4b 65 79 20 3d 20 5f 6b 65 79 73 20 3f 20 5f  tKey = _keys ? _
b520: 6b 65 79 73 5b 69 6e 64 65 78 5d 20 3a 20 69 6e  keys[index] : in
b530: 64 65 78 3b 0a 20 20 20 20 20 20 72 65 73 75 6c  dex;.      resul
b540: 74 73 5b 69 6e 64 65 78 5d 20 3d 20 69 74 65 72  ts[index] = iter
b550: 61 74 65 65 28 6f 62 6a 5b 63 75 72 72 65 6e 74  atee(obj[current
b560: 4b 65 79 5d 2c 20 63 75 72 72 65 6e 74 4b 65 79  Key], currentKey
b570: 2c 20 6f 62 6a 29 3b 0a 20 20 20 20 7d 0a 20 20  , obj);.    }.  
b580: 20 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74 73    return results
b590: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 6e 74 65  ;.  }..  // Inte
b5a0: 72 6e 61 6c 20 68 65 6c 70 65 72 20 74 6f 20 63  rnal helper to c
b5b0: 72 65 61 74 65 20 61 20 72 65 64 75 63 69 6e 67  reate a reducing
b5c0: 20 66 75 6e 63 74 69 6f 6e 2c 20 69 74 65 72 61   function, itera
b5d0: 74 69 6e 67 20 6c 65 66 74 20 6f 72 20 72 69 67  ting left or rig
b5e0: 68 74 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 63  ht..  function c
b5f0: 72 65 61 74 65 52 65 64 75 63 65 28 64 69 72 29  reateReduce(dir)
b600: 20 7b 0a 20 20 20 20 2f 2f 20 57 72 61 70 20 63   {.    // Wrap c
b610: 6f 64 65 20 74 68 61 74 20 72 65 61 73 73 69 67  ode that reassig
b620: 6e 73 20 61 72 67 75 6d 65 6e 74 20 76 61 72 69  ns argument vari
b630: 61 62 6c 65 73 20 69 6e 20 61 20 73 65 70 61 72  ables in a separ
b640: 61 74 65 20 66 75 6e 63 74 69 6f 6e 20 74 68 61  ate function tha
b650: 6e 0a 20 20 20 20 2f 2f 20 74 68 65 20 6f 6e 65  n.    // the one
b660: 20 74 68 61 74 20 61 63 63 65 73 73 65 73 20 60   that accesses `
b670: 61 72 67 75 6d 65 6e 74 73 2e 6c 65 6e 67 74 68  arguments.length
b680: 60 20 74 6f 20 61 76 6f 69 64 20 61 20 70 65 72  ` to avoid a per
b690: 66 20 68 69 74 2e 20 28 23 31 39 39 31 29 0a 20  f hit. (#1991). 
b6a0: 20 20 20 76 61 72 20 72 65 64 75 63 65 72 20 3d     var reducer =
b6b0: 20 66 75 6e 63 74 69 6f 6e 28 6f 62 6a 2c 20 69   function(obj, i
b6c0: 74 65 72 61 74 65 65 2c 20 6d 65 6d 6f 2c 20 69  teratee, memo, i
b6d0: 6e 69 74 69 61 6c 29 20 7b 0a 20 20 20 20 20 20  nitial) {.      
b6e0: 76 61 72 20 5f 6b 65 79 73 20 3d 20 21 69 73 41  var _keys = !isA
b6f0: 72 72 61 79 4c 69 6b 65 28 6f 62 6a 29 20 26 26  rrayLike(obj) &&
b700: 20 6b 65 79 73 28 6f 62 6a 29 2c 0a 20 20 20 20   keys(obj),.    
b710: 20 20 20 20 20 20 6c 65 6e 67 74 68 20 3d 20 28        length = (
b720: 5f 6b 65 79 73 20 7c 7c 20 6f 62 6a 29 2e 6c 65  _keys || obj).le
b730: 6e 67 74 68 2c 0a 20 20 20 20 20 20 20 20 20 20  ngth,.          
b740: 69 6e 64 65 78 20 3d 20 64 69 72 20 3e 20 30 20  index = dir > 0 
b750: 3f 20 30 20 3a 20 6c 65 6e 67 74 68 20 2d 20 31  ? 0 : length - 1
b760: 3b 0a 20 20 20 20 20 20 69 66 20 28 21 69 6e 69  ;.      if (!ini
b770: 74 69 61 6c 29 20 7b 0a 20 20 20 20 20 20 20 20  tial) {.        
b780: 6d 65 6d 6f 20 3d 20 6f 62 6a 5b 5f 6b 65 79 73  memo = obj[_keys
b790: 20 3f 20 5f 6b 65 79 73 5b 69 6e 64 65 78 5d 20   ? _keys[index] 
b7a0: 3a 20 69 6e 64 65 78 5d 3b 0a 20 20 20 20 20 20  : index];.      
b7b0: 20 20 69 6e 64 65 78 20 2b 3d 20 64 69 72 3b 0a    index += dir;.
b7c0: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 66 6f        }.      fo
b7d0: 72 20 28 3b 20 69 6e 64 65 78 20 3e 3d 20 30 20  r (; index >= 0 
b7e0: 26 26 20 69 6e 64 65 78 20 3c 20 6c 65 6e 67 74  && index < lengt
b7f0: 68 3b 20 69 6e 64 65 78 20 2b 3d 20 64 69 72 29  h; index += dir)
b800: 20 7b 0a 20 20 20 20 20 20 20 20 76 61 72 20 63   {.        var c
b810: 75 72 72 65 6e 74 4b 65 79 20 3d 20 5f 6b 65 79  urrentKey = _key
b820: 73 20 3f 20 5f 6b 65 79 73 5b 69 6e 64 65 78 5d  s ? _keys[index]
b830: 20 3a 20 69 6e 64 65 78 3b 0a 20 20 20 20 20 20   : index;.      
b840: 20 20 6d 65 6d 6f 20 3d 20 69 74 65 72 61 74 65    memo = iterate
b850: 65 28 6d 65 6d 6f 2c 20 6f 62 6a 5b 63 75 72 72  e(memo, obj[curr
b860: 65 6e 74 4b 65 79 5d 2c 20 63 75 72 72 65 6e 74  entKey], current
b870: 4b 65 79 2c 20 6f 62 6a 29 3b 0a 20 20 20 20 20  Key, obj);.     
b880: 20 7d 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20   }.      return 
b890: 6d 65 6d 6f 3b 0a 20 20 20 20 7d 3b 0a 0a 20 20  memo;.    };..  
b8a0: 20 20 72 65 74 75 72 6e 20 66 75 6e 63 74 69 6f    return functio
b8b0: 6e 28 6f 62 6a 2c 20 69 74 65 72 61 74 65 65 2c  n(obj, iteratee,
b8c0: 20 6d 65 6d 6f 2c 20 63 6f 6e 74 65 78 74 29 20   memo, context) 
b8d0: 7b 0a 20 20 20 20 20 20 76 61 72 20 69 6e 69 74  {.      var init
b8e0: 69 61 6c 20 3d 20 61 72 67 75 6d 65 6e 74 73 2e  ial = arguments.
b8f0: 6c 65 6e 67 74 68 20 3e 3d 20 33 3b 0a 20 20 20  length >= 3;.   
b900: 20 20 20 72 65 74 75 72 6e 20 72 65 64 75 63 65     return reduce
b910: 72 28 6f 62 6a 2c 20 6f 70 74 69 6d 69 7a 65 43  r(obj, optimizeC
b920: 62 28 69 74 65 72 61 74 65 65 2c 20 63 6f 6e 74  b(iteratee, cont
b930: 65 78 74 2c 20 34 29 2c 20 6d 65 6d 6f 2c 20 69  ext, 4), memo, i
b940: 6e 69 74 69 61 6c 29 3b 0a 20 20 20 20 7d 3b 0a  nitial);.    };.
b950: 20 20 7d 0a 0a 20 20 2f 2f 20 2a 2a 52 65 64 75    }..  // **Redu
b960: 63 65 2a 2a 20 62 75 69 6c 64 73 20 75 70 20 61  ce** builds up a
b970: 20 73 69 6e 67 6c 65 20 72 65 73 75 6c 74 20 66   single result f
b980: 72 6f 6d 20 61 20 6c 69 73 74 20 6f 66 20 76 61  rom a list of va
b990: 6c 75 65 73 2c 20 61 6b 61 20 60 69 6e 6a 65 63  lues, aka `injec
b9a0: 74 60 2c 0a 20 20 2f 2f 20 6f 72 20 60 66 6f 6c  t`,.  // or `fol
b9b0: 64 6c 60 2e 0a 20 20 76 61 72 20 72 65 64 75 63  dl`..  var reduc
b9c0: 65 20 3d 20 63 72 65 61 74 65 52 65 64 75 63 65  e = createReduce
b9d0: 28 31 29 3b 0a 0a 20 20 2f 2f 20 54 68 65 20 72  (1);..  // The r
b9e0: 69 67 68 74 2d 61 73 73 6f 63 69 61 74 69 76 65  ight-associative
b9f0: 20 76 65 72 73 69 6f 6e 20 6f 66 20 72 65 64 75   version of redu
ba00: 63 65 2c 20 61 6c 73 6f 20 6b 6e 6f 77 6e 20 61  ce, also known a
ba10: 73 20 60 66 6f 6c 64 72 60 2e 0a 20 20 76 61 72  s `foldr`..  var
ba20: 20 72 65 64 75 63 65 52 69 67 68 74 20 3d 20 63   reduceRight = c
ba30: 72 65 61 74 65 52 65 64 75 63 65 28 2d 31 29 3b  reateReduce(-1);
ba40: 0a 0a 20 20 2f 2f 20 52 65 74 75 72 6e 20 61 6c  ..  // Return al
ba50: 6c 20 74 68 65 20 65 6c 65 6d 65 6e 74 73 20 74  l the elements t
ba60: 68 61 74 20 70 61 73 73 20 61 20 74 72 75 74 68  hat pass a truth
ba70: 20 74 65 73 74 2e 0a 20 20 66 75 6e 63 74 69 6f   test..  functio
ba80: 6e 20 66 69 6c 74 65 72 28 6f 62 6a 2c 20 70 72  n filter(obj, pr
ba90: 65 64 69 63 61 74 65 2c 20 63 6f 6e 74 65 78 74  edicate, context
baa0: 29 20 7b 0a 20 20 20 20 76 61 72 20 72 65 73 75  ) {.    var resu
bab0: 6c 74 73 20 3d 20 5b 5d 3b 0a 20 20 20 20 70 72  lts = [];.    pr
bac0: 65 64 69 63 61 74 65 20 3d 20 63 62 28 70 72 65  edicate = cb(pre
bad0: 64 69 63 61 74 65 2c 20 63 6f 6e 74 65 78 74 29  dicate, context)
bae0: 3b 0a 20 20 20 20 65 61 63 68 28 6f 62 6a 2c 20  ;.    each(obj, 
baf0: 66 75 6e 63 74 69 6f 6e 28 76 61 6c 75 65 2c 20  function(value, 
bb00: 69 6e 64 65 78 2c 20 6c 69 73 74 29 20 7b 0a 20  index, list) {. 
bb10: 20 20 20 20 20 69 66 20 28 70 72 65 64 69 63 61       if (predica
bb20: 74 65 28 76 61 6c 75 65 2c 20 69 6e 64 65 78 2c  te(value, index,
bb30: 20 6c 69 73 74 29 29 20 72 65 73 75 6c 74 73 2e   list)) results.
bb40: 70 75 73 68 28 76 61 6c 75 65 29 3b 0a 20 20 20  push(value);.   
bb50: 20 7d 29 3b 0a 20 20 20 20 72 65 74 75 72 6e 20   });.    return 
bb60: 72 65 73 75 6c 74 73 3b 0a 20 20 7d 0a 0a 20 20  results;.  }..  
bb70: 2f 2f 20 52 65 74 75 72 6e 20 61 6c 6c 20 74 68  // Return all th
bb80: 65 20 65 6c 65 6d 65 6e 74 73 20 66 6f 72 20 77  e elements for w
bb90: 68 69 63 68 20 61 20 74 72 75 74 68 20 74 65 73  hich a truth tes
bba0: 74 20 66 61 69 6c 73 2e 0a 20 20 66 75 6e 63 74  t fails..  funct
bbb0: 69 6f 6e 20 72 65 6a 65 63 74 28 6f 62 6a 2c 20  ion reject(obj, 
bbc0: 70 72 65 64 69 63 61 74 65 2c 20 63 6f 6e 74 65  predicate, conte
bbd0: 78 74 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e  xt) {.    return
bbe0: 20 66 69 6c 74 65 72 28 6f 62 6a 2c 20 6e 65 67   filter(obj, neg
bbf0: 61 74 65 28 63 62 28 70 72 65 64 69 63 61 74 65  ate(cb(predicate
bc00: 29 29 2c 20 63 6f 6e 74 65 78 74 29 3b 0a 20 20  )), context);.  
bc10: 7d 0a 0a 20 20 2f 2f 20 44 65 74 65 72 6d 69 6e  }..  // Determin
bc20: 65 20 77 68 65 74 68 65 72 20 61 6c 6c 20 6f 66  e whether all of
bc30: 20 74 68 65 20 65 6c 65 6d 65 6e 74 73 20 70 61   the elements pa
bc40: 73 73 20 61 20 74 72 75 74 68 20 74 65 73 74 2e  ss a truth test.
bc50: 0a 20 20 66 75 6e 63 74 69 6f 6e 20 65 76 65 72  .  function ever
bc60: 79 28 6f 62 6a 2c 20 70 72 65 64 69 63 61 74 65  y(obj, predicate
bc70: 2c 20 63 6f 6e 74 65 78 74 29 20 7b 0a 20 20 20  , context) {.   
bc80: 20 70 72 65 64 69 63 61 74 65 20 3d 20 63 62 28   predicate = cb(
bc90: 70 72 65 64 69 63 61 74 65 2c 20 63 6f 6e 74 65  predicate, conte
bca0: 78 74 29 3b 0a 20 20 20 20 76 61 72 20 5f 6b 65  xt);.    var _ke
bcb0: 79 73 20 3d 20 21 69 73 41 72 72 61 79 4c 69 6b  ys = !isArrayLik
bcc0: 65 28 6f 62 6a 29 20 26 26 20 6b 65 79 73 28 6f  e(obj) && keys(o
bcd0: 62 6a 29 2c 0a 20 20 20 20 20 20 20 20 6c 65 6e  bj),.        len
bce0: 67 74 68 20 3d 20 28 5f 6b 65 79 73 20 7c 7c 20  gth = (_keys || 
bcf0: 6f 62 6a 29 2e 6c 65 6e 67 74 68 3b 0a 20 20 20  obj).length;.   
bd00: 20 66 6f 72 20 28 76 61 72 20 69 6e 64 65 78 20   for (var index 
bd10: 3d 20 30 3b 20 69 6e 64 65 78 20 3c 20 6c 65 6e  = 0; index < len
bd20: 67 74 68 3b 20 69 6e 64 65 78 2b 2b 29 20 7b 0a  gth; index++) {.
bd30: 20 20 20 20 20 20 76 61 72 20 63 75 72 72 65 6e        var curren
bd40: 74 4b 65 79 20 3d 20 5f 6b 65 79 73 20 3f 20 5f  tKey = _keys ? _
bd50: 6b 65 79 73 5b 69 6e 64 65 78 5d 20 3a 20 69 6e  keys[index] : in
bd60: 64 65 78 3b 0a 20 20 20 20 20 20 69 66 20 28 21  dex;.      if (!
bd70: 70 72 65 64 69 63 61 74 65 28 6f 62 6a 5b 63 75  predicate(obj[cu
bd80: 72 72 65 6e 74 4b 65 79 5d 2c 20 63 75 72 72 65  rrentKey], curre
bd90: 6e 74 4b 65 79 2c 20 6f 62 6a 29 29 20 72 65 74  ntKey, obj)) ret
bda0: 75 72 6e 20 66 61 6c 73 65 3b 0a 20 20 20 20 7d  urn false;.    }
bdb0: 0a 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65  .    return true
bdc0: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 44 65 74 65  ;.  }..  // Dete
bdd0: 72 6d 69 6e 65 20 69 66 20 61 74 20 6c 65 61 73  rmine if at leas
bde0: 74 20 6f 6e 65 20 65 6c 65 6d 65 6e 74 20 69 6e  t one element in
bdf0: 20 74 68 65 20 6f 62 6a 65 63 74 20 70 61 73 73   the object pass
be00: 65 73 20 61 20 74 72 75 74 68 20 74 65 73 74 2e  es a truth test.
be10: 0a 20 20 66 75 6e 63 74 69 6f 6e 20 73 6f 6d 65  .  function some
be20: 28 6f 62 6a 2c 20 70 72 65 64 69 63 61 74 65 2c  (obj, predicate,
be30: 20 63 6f 6e 74 65 78 74 29 20 7b 0a 20 20 20 20   context) {.    
be40: 70 72 65 64 69 63 61 74 65 20 3d 20 63 62 28 70  predicate = cb(p
be50: 72 65 64 69 63 61 74 65 2c 20 63 6f 6e 74 65 78  redicate, contex
be60: 74 29 3b 0a 20 20 20 20 76 61 72 20 5f 6b 65 79  t);.    var _key
be70: 73 20 3d 20 21 69 73 41 72 72 61 79 4c 69 6b 65  s = !isArrayLike
be80: 28 6f 62 6a 29 20 26 26 20 6b 65 79 73 28 6f 62  (obj) && keys(ob
be90: 6a 29 2c 0a 20 20 20 20 20 20 20 20 6c 65 6e 67  j),.        leng
bea0: 74 68 20 3d 20 28 5f 6b 65 79 73 20 7c 7c 20 6f  th = (_keys || o
beb0: 62 6a 29 2e 6c 65 6e 67 74 68 3b 0a 20 20 20 20  bj).length;.    
bec0: 66 6f 72 20 28 76 61 72 20 69 6e 64 65 78 20 3d  for (var index =
bed0: 20 30 3b 20 69 6e 64 65 78 20 3c 20 6c 65 6e 67   0; index < leng
bee0: 74 68 3b 20 69 6e 64 65 78 2b 2b 29 20 7b 0a 20  th; index++) {. 
bef0: 20 20 20 20 20 76 61 72 20 63 75 72 72 65 6e 74       var current
bf00: 4b 65 79 20 3d 20 5f 6b 65 79 73 20 3f 20 5f 6b  Key = _keys ? _k
bf10: 65 79 73 5b 69 6e 64 65 78 5d 20 3a 20 69 6e 64  eys[index] : ind
bf20: 65 78 3b 0a 20 20 20 20 20 20 69 66 20 28 70 72  ex;.      if (pr
bf30: 65 64 69 63 61 74 65 28 6f 62 6a 5b 63 75 72 72  edicate(obj[curr
bf40: 65 6e 74 4b 65 79 5d 2c 20 63 75 72 72 65 6e 74  entKey], current
bf50: 4b 65 79 2c 20 6f 62 6a 29 29 20 72 65 74 75 72  Key, obj)) retur
bf60: 6e 20 74 72 75 65 3b 0a 20 20 20 20 7d 0a 20 20  n true;.    }.  
bf70: 20 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0a    return false;.
bf80: 20 20 7d 0a 0a 20 20 2f 2f 20 44 65 74 65 72 6d    }..  // Determ
bf90: 69 6e 65 20 69 66 20 74 68 65 20 61 72 72 61 79  ine if the array
bfa0: 20 6f 72 20 6f 62 6a 65 63 74 20 63 6f 6e 74 61   or object conta
bfb0: 69 6e 73 20 61 20 67 69 76 65 6e 20 69 74 65 6d  ins a given item
bfc0: 20 28 75 73 69 6e 67 20 60 3d 3d 3d 60 29 2e 0a   (using `===`)..
bfd0: 20 20 66 75 6e 63 74 69 6f 6e 20 63 6f 6e 74 61    function conta
bfe0: 69 6e 73 28 6f 62 6a 2c 20 69 74 65 6d 2c 20 66  ins(obj, item, f
bff0: 72 6f 6d 49 6e 64 65 78 2c 20 67 75 61 72 64 29  romIndex, guard)
c000: 20 7b 0a 20 20 20 20 69 66 20 28 21 69 73 41 72   {.    if (!isAr
c010: 72 61 79 4c 69 6b 65 28 6f 62 6a 29 29 20 6f 62  rayLike(obj)) ob
c020: 6a 20 3d 20 76 61 6c 75 65 73 28 6f 62 6a 29 3b  j = values(obj);
c030: 0a 20 20 20 20 69 66 20 28 74 79 70 65 6f 66 20  .    if (typeof 
c040: 66 72 6f 6d 49 6e 64 65 78 20 21 3d 20 27 6e 75  fromIndex != 'nu
c050: 6d 62 65 72 27 20 7c 7c 20 67 75 61 72 64 29 20  mber' || guard) 
c060: 66 72 6f 6d 49 6e 64 65 78 20 3d 20 30 3b 0a 20  fromIndex = 0;. 
c070: 20 20 20 72 65 74 75 72 6e 20 69 6e 64 65 78 4f     return indexO
c080: 66 28 6f 62 6a 2c 20 69 74 65 6d 2c 20 66 72 6f  f(obj, item, fro
c090: 6d 49 6e 64 65 78 29 20 3e 3d 20 30 3b 0a 20 20  mIndex) >= 0;.  
c0a0: 7d 0a 0a 20 20 2f 2f 20 49 6e 76 6f 6b 65 20 61  }..  // Invoke a
c0b0: 20 6d 65 74 68 6f 64 20 28 77 69 74 68 20 61 72   method (with ar
c0c0: 67 75 6d 65 6e 74 73 29 20 6f 6e 20 65 76 65 72  guments) on ever
c0d0: 79 20 69 74 65 6d 20 69 6e 20 61 20 63 6f 6c 6c  y item in a coll
c0e0: 65 63 74 69 6f 6e 2e 0a 20 20 76 61 72 20 69 6e  ection..  var in
c0f0: 76 6f 6b 65 20 3d 20 72 65 73 74 41 72 67 75 6d  voke = restArgum
c100: 65 6e 74 73 28 66 75 6e 63 74 69 6f 6e 28 6f 62  ents(function(ob
c110: 6a 2c 20 70 61 74 68 2c 20 61 72 67 73 29 20 7b  j, path, args) {
c120: 0a 20 20 20 20 76 61 72 20 63 6f 6e 74 65 78 74  .    var context
c130: 50 61 74 68 2c 20 66 75 6e 63 3b 0a 20 20 20 20  Path, func;.    
c140: 69 66 20 28 69 73 46 75 6e 63 74 69 6f 6e 24 31  if (isFunction$1
c150: 28 70 61 74 68 29 29 20 7b 0a 20 20 20 20 20 20  (path)) {.      
c160: 66 75 6e 63 20 3d 20 70 61 74 68 3b 0a 20 20 20  func = path;.   
c170: 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 20   } else {.      
c180: 70 61 74 68 20 3d 20 74 6f 50 61 74 68 24 31 28  path = toPath$1(
c190: 70 61 74 68 29 3b 0a 20 20 20 20 20 20 63 6f 6e  path);.      con
c1a0: 74 65 78 74 50 61 74 68 20 3d 20 70 61 74 68 2e  textPath = path.
c1b0: 73 6c 69 63 65 28 30 2c 20 2d 31 29 3b 0a 20 20  slice(0, -1);.  
c1c0: 20 20 20 20 70 61 74 68 20 3d 20 70 61 74 68 5b      path = path[
c1d0: 70 61 74 68 2e 6c 65 6e 67 74 68 20 2d 20 31 5d  path.length - 1]
c1e0: 3b 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 74 75  ;.    }.    retu
c1f0: 72 6e 20 6d 61 70 28 6f 62 6a 2c 20 66 75 6e 63  rn map(obj, func
c200: 74 69 6f 6e 28 63 6f 6e 74 65 78 74 29 20 7b 0a  tion(context) {.
c210: 20 20 20 20 20 20 76 61 72 20 6d 65 74 68 6f 64        var method
c220: 20 3d 20 66 75 6e 63 3b 0a 20 20 20 20 20 20 69   = func;.      i
c230: 66 20 28 21 6d 65 74 68 6f 64 29 20 7b 0a 20 20  f (!method) {.  
c240: 20 20 20 20 20 20 69 66 20 28 63 6f 6e 74 65 78        if (contex
c250: 74 50 61 74 68 20 26 26 20 63 6f 6e 74 65 78 74  tPath && context
c260: 50 61 74 68 2e 6c 65 6e 67 74 68 29 20 7b 0a 20  Path.length) {. 
c270: 20 20 20 20 20 20 20 20 20 63 6f 6e 74 65 78 74           context
c280: 20 3d 20 64 65 65 70 47 65 74 28 63 6f 6e 74 65   = deepGet(conte
c290: 78 74 2c 20 63 6f 6e 74 65 78 74 50 61 74 68 29  xt, contextPath)
c2a0: 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20  ;.        }.    
c2b0: 20 20 20 20 69 66 20 28 63 6f 6e 74 65 78 74 20      if (context 
c2c0: 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 75 72 6e 20  == null) return 
c2d0: 76 6f 69 64 20 30 3b 0a 20 20 20 20 20 20 20 20  void 0;.        
c2e0: 6d 65 74 68 6f 64 20 3d 20 63 6f 6e 74 65 78 74  method = context
c2f0: 5b 70 61 74 68 5d 3b 0a 20 20 20 20 20 20 7d 0a  [path];.      }.
c300: 20 20 20 20 20 20 72 65 74 75 72 6e 20 6d 65 74        return met
c310: 68 6f 64 20 3d 3d 20 6e 75 6c 6c 20 3f 20 6d 65  hod == null ? me
c320: 74 68 6f 64 20 3a 20 6d 65 74 68 6f 64 2e 61 70  thod : method.ap
c330: 70 6c 79 28 63 6f 6e 74 65 78 74 2c 20 61 72 67  ply(context, arg
c340: 73 29 3b 0a 20 20 20 20 7d 29 3b 0a 20 20 7d 29  s);.    });.  })
c350: 3b 0a 0a 20 20 2f 2f 20 43 6f 6e 76 65 6e 69 65  ;..  // Convenie
c360: 6e 63 65 20 76 65 72 73 69 6f 6e 20 6f 66 20 61  nce version of a
c370: 20 63 6f 6d 6d 6f 6e 20 75 73 65 20 63 61 73 65   common use case
c380: 20 6f 66 20 60 5f 2e 6d 61 70 60 3a 20 66 65 74   of `_.map`: fet
c390: 63 68 69 6e 67 20 61 20 70 72 6f 70 65 72 74 79  ching a property
c3a0: 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 70 6c 75  ..  function plu
c3b0: 63 6b 28 6f 62 6a 2c 20 6b 65 79 29 20 7b 0a 20  ck(obj, key) {. 
c3c0: 20 20 20 72 65 74 75 72 6e 20 6d 61 70 28 6f 62     return map(ob
c3d0: 6a 2c 20 70 72 6f 70 65 72 74 79 28 6b 65 79 29  j, property(key)
c3e0: 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 43 6f 6e  );.  }..  // Con
c3f0: 76 65 6e 69 65 6e 63 65 20 76 65 72 73 69 6f 6e  venience version
c400: 20 6f 66 20 61 20 63 6f 6d 6d 6f 6e 20 75 73 65   of a common use
c410: 20 63 61 73 65 20 6f 66 20 60 5f 2e 66 69 6c 74   case of `_.filt
c420: 65 72 60 3a 20 73 65 6c 65 63 74 69 6e 67 20 6f  er`: selecting o
c430: 6e 6c 79 0a 20 20 2f 2f 20 6f 62 6a 65 63 74 73  nly.  // objects
c440: 20 63 6f 6e 74 61 69 6e 69 6e 67 20 73 70 65 63   containing spec
c450: 69 66 69 63 20 60 6b 65 79 3a 76 61 6c 75 65 60  ific `key:value`
c460: 20 70 61 69 72 73 2e 0a 20 20 66 75 6e 63 74 69   pairs..  functi
c470: 6f 6e 20 77 68 65 72 65 28 6f 62 6a 2c 20 61 74  on where(obj, at
c480: 74 72 73 29 20 7b 0a 20 20 20 20 72 65 74 75 72  trs) {.    retur
c490: 6e 20 66 69 6c 74 65 72 28 6f 62 6a 2c 20 6d 61  n filter(obj, ma
c4a0: 74 63 68 65 72 28 61 74 74 72 73 29 29 3b 0a 20  tcher(attrs));. 
c4b0: 20 7d 0a 0a 20 20 2f 2f 20 52 65 74 75 72 6e 20   }..  // Return 
c4c0: 74 68 65 20 6d 61 78 69 6d 75 6d 20 65 6c 65 6d  the maximum elem
c4d0: 65 6e 74 20 28 6f 72 20 65 6c 65 6d 65 6e 74 2d  ent (or element-
c4e0: 62 61 73 65 64 20 63 6f 6d 70 75 74 61 74 69 6f  based computatio
c4f0: 6e 29 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 6d  n)..  function m
c500: 61 78 28 6f 62 6a 2c 20 69 74 65 72 61 74 65 65  ax(obj, iteratee
c510: 2c 20 63 6f 6e 74 65 78 74 29 20 7b 0a 20 20 20  , context) {.   
c520: 20 76 61 72 20 72 65 73 75 6c 74 20 3d 20 2d 49   var result = -I
c530: 6e 66 69 6e 69 74 79 2c 20 6c 61 73 74 43 6f 6d  nfinity, lastCom
c540: 70 75 74 65 64 20 3d 20 2d 49 6e 66 69 6e 69 74  puted = -Infinit
c550: 79 2c 0a 20 20 20 20 20 20 20 20 76 61 6c 75 65  y,.        value
c560: 2c 20 63 6f 6d 70 75 74 65 64 3b 0a 20 20 20 20  , computed;.    
c570: 69 66 20 28 69 74 65 72 61 74 65 65 20 3d 3d 20  if (iteratee == 
c580: 6e 75 6c 6c 20 7c 7c 20 74 79 70 65 6f 66 20 69  null || typeof i
c590: 74 65 72 61 74 65 65 20 3d 3d 20 27 6e 75 6d 62  teratee == 'numb
c5a0: 65 72 27 20 26 26 20 74 79 70 65 6f 66 20 6f 62  er' && typeof ob
c5b0: 6a 5b 30 5d 20 21 3d 20 27 6f 62 6a 65 63 74 27  j[0] != 'object'
c5c0: 20 26 26 20 6f 62 6a 20 21 3d 20 6e 75 6c 6c 29   && obj != null)
c5d0: 20 7b 0a 20 20 20 20 20 20 6f 62 6a 20 3d 20 69   {.      obj = i
c5e0: 73 41 72 72 61 79 4c 69 6b 65 28 6f 62 6a 29 20  sArrayLike(obj) 
c5f0: 3f 20 6f 62 6a 20 3a 20 76 61 6c 75 65 73 28 6f  ? obj : values(o
c600: 62 6a 29 3b 0a 20 20 20 20 20 20 66 6f 72 20 28  bj);.      for (
c610: 76 61 72 20 69 20 3d 20 30 2c 20 6c 65 6e 67 74  var i = 0, lengt
c620: 68 20 3d 20 6f 62 6a 2e 6c 65 6e 67 74 68 3b 20  h = obj.length; 
c630: 69 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b 29  i < length; i++)
c640: 20 7b 0a 20 20 20 20 20 20 20 20 76 61 6c 75 65   {.        value
c650: 20 3d 20 6f 62 6a 5b 69 5d 3b 0a 20 20 20 20 20   = obj[i];.     
c660: 20 20 20 69 66 20 28 76 61 6c 75 65 20 21 3d 20     if (value != 
c670: 6e 75 6c 6c 20 26 26 20 76 61 6c 75 65 20 3e 20  null && value > 
c680: 72 65 73 75 6c 74 29 20 7b 0a 20 20 20 20 20 20  result) {.      
c690: 20 20 20 20 72 65 73 75 6c 74 20 3d 20 76 61 6c      result = val
c6a0: 75 65 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20 20  ue;.        }.  
c6b0: 20 20 20 20 7d 0a 20 20 20 20 7d 20 65 6c 73 65      }.    } else
c6c0: 20 7b 0a 20 20 20 20 20 20 69 74 65 72 61 74 65   {.      iterate
c6d0: 65 20 3d 20 63 62 28 69 74 65 72 61 74 65 65 2c  e = cb(iteratee,
c6e0: 20 63 6f 6e 74 65 78 74 29 3b 0a 20 20 20 20 20   context);.     
c6f0: 20 65 61 63 68 28 6f 62 6a 2c 20 66 75 6e 63 74   each(obj, funct
c700: 69 6f 6e 28 76 2c 20 69 6e 64 65 78 2c 20 6c 69  ion(v, index, li
c710: 73 74 29 20 7b 0a 20 20 20 20 20 20 20 20 63 6f  st) {.        co
c720: 6d 70 75 74 65 64 20 3d 20 69 74 65 72 61 74 65  mputed = iterate
c730: 65 28 76 2c 20 69 6e 64 65 78 2c 20 6c 69 73 74  e(v, index, list
c740: 29 3b 0a 20 20 20 20 20 20 20 20 69 66 20 28 63  );.        if (c
c750: 6f 6d 70 75 74 65 64 20 3e 20 6c 61 73 74 43 6f  omputed > lastCo
c760: 6d 70 75 74 65 64 20 7c 7c 20 63 6f 6d 70 75 74  mputed || comput
c770: 65 64 20 3d 3d 3d 20 2d 49 6e 66 69 6e 69 74 79  ed === -Infinity
c780: 20 26 26 20 72 65 73 75 6c 74 20 3d 3d 3d 20 2d   && result === -
c790: 49 6e 66 69 6e 69 74 79 29 20 7b 0a 20 20 20 20  Infinity) {.    
c7a0: 20 20 20 20 20 20 72 65 73 75 6c 74 20 3d 20 76        result = v
c7b0: 3b 0a 20 20 20 20 20 20 20 20 20 20 6c 61 73 74  ;.          last
c7c0: 43 6f 6d 70 75 74 65 64 20 3d 20 63 6f 6d 70 75  Computed = compu
c7d0: 74 65 64 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20  ted;.        }. 
c7e0: 20 20 20 20 20 7d 29 3b 0a 20 20 20 20 7d 0a 20       });.    }. 
c7f0: 20 20 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74     return result
c800: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52 65 74 75  ;.  }..  // Retu
c810: 72 6e 20 74 68 65 20 6d 69 6e 69 6d 75 6d 20 65  rn the minimum e
c820: 6c 65 6d 65 6e 74 20 28 6f 72 20 65 6c 65 6d 65  lement (or eleme
c830: 6e 74 2d 62 61 73 65 64 20 63 6f 6d 70 75 74 61  nt-based computa
c840: 74 69 6f 6e 29 2e 0a 20 20 66 75 6e 63 74 69 6f  tion)..  functio
c850: 6e 20 6d 69 6e 28 6f 62 6a 2c 20 69 74 65 72 61  n min(obj, itera
c860: 74 65 65 2c 20 63 6f 6e 74 65 78 74 29 20 7b 0a  tee, context) {.
c870: 20 20 20 20 76 61 72 20 72 65 73 75 6c 74 20 3d      var result =
c880: 20 49 6e 66 69 6e 69 74 79 2c 20 6c 61 73 74 43   Infinity, lastC
c890: 6f 6d 70 75 74 65 64 20 3d 20 49 6e 66 69 6e 69  omputed = Infini
c8a0: 74 79 2c 0a 20 20 20 20 20 20 20 20 76 61 6c 75  ty,.        valu
c8b0: 65 2c 20 63 6f 6d 70 75 74 65 64 3b 0a 20 20 20  e, computed;.   
c8c0: 20 69 66 20 28 69 74 65 72 61 74 65 65 20 3d 3d   if (iteratee ==
c8d0: 20 6e 75 6c 6c 20 7c 7c 20 74 79 70 65 6f 66 20   null || typeof 
c8e0: 69 74 65 72 61 74 65 65 20 3d 3d 20 27 6e 75 6d  iteratee == 'num
c8f0: 62 65 72 27 20 26 26 20 74 79 70 65 6f 66 20 6f  ber' && typeof o
c900: 62 6a 5b 30 5d 20 21 3d 20 27 6f 62 6a 65 63 74  bj[0] != 'object
c910: 27 20 26 26 20 6f 62 6a 20 21 3d 20 6e 75 6c 6c  ' && obj != null
c920: 29 20 7b 0a 20 20 20 20 20 20 6f 62 6a 20 3d 20  ) {.      obj = 
c930: 69 73 41 72 72 61 79 4c 69 6b 65 28 6f 62 6a 29  isArrayLike(obj)
c940: 20 3f 20 6f 62 6a 20 3a 20 76 61 6c 75 65 73 28   ? obj : values(
c950: 6f 62 6a 29 3b 0a 20 20 20 20 20 20 66 6f 72 20  obj);.      for 
c960: 28 76 61 72 20 69 20 3d 20 30 2c 20 6c 65 6e 67  (var i = 0, leng
c970: 74 68 20 3d 20 6f 62 6a 2e 6c 65 6e 67 74 68 3b  th = obj.length;
c980: 20 69 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b   i < length; i++
c990: 29 20 7b 0a 20 20 20 20 20 20 20 20 76 61 6c 75  ) {.        valu
c9a0: 65 20 3d 20 6f 62 6a 5b 69 5d 3b 0a 20 20 20 20  e = obj[i];.    
c9b0: 20 20 20 20 69 66 20 28 76 61 6c 75 65 20 21 3d      if (value !=
c9c0: 20 6e 75 6c 6c 20 26 26 20 76 61 6c 75 65 20 3c   null && value <
c9d0: 20 72 65 73 75 6c 74 29 20 7b 0a 20 20 20 20 20   result) {.     
c9e0: 20 20 20 20 20 72 65 73 75 6c 74 20 3d 20 76 61       result = va
c9f0: 6c 75 65 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20  lue;.        }. 
ca00: 20 20 20 20 20 7d 0a 20 20 20 20 7d 20 65 6c 73       }.    } els
ca10: 65 20 7b 0a 20 20 20 20 20 20 69 74 65 72 61 74  e {.      iterat
ca20: 65 65 20 3d 20 63 62 28 69 74 65 72 61 74 65 65  ee = cb(iteratee
ca30: 2c 20 63 6f 6e 74 65 78 74 29 3b 0a 20 20 20 20  , context);.    
ca40: 20 20 65 61 63 68 28 6f 62 6a 2c 20 66 75 6e 63    each(obj, func
ca50: 74 69 6f 6e 28 76 2c 20 69 6e 64 65 78 2c 20 6c  tion(v, index, l
ca60: 69 73 74 29 20 7b 0a 20 20 20 20 20 20 20 20 63  ist) {.        c
ca70: 6f 6d 70 75 74 65 64 20 3d 20 69 74 65 72 61 74  omputed = iterat
ca80: 65 65 28 76 2c 20 69 6e 64 65 78 2c 20 6c 69 73  ee(v, index, lis
ca90: 74 29 3b 0a 20 20 20 20 20 20 20 20 69 66 20 28  t);.        if (
caa0: 63 6f 6d 70 75 74 65 64 20 3c 20 6c 61 73 74 43  computed < lastC
cab0: 6f 6d 70 75 74 65 64 20 7c 7c 20 63 6f 6d 70 75  omputed || compu
cac0: 74 65 64 20 3d 3d 3d 20 49 6e 66 69 6e 69 74 79  ted === Infinity
cad0: 20 26 26 20 72 65 73 75 6c 74 20 3d 3d 3d 20 49   && result === I
cae0: 6e 66 69 6e 69 74 79 29 20 7b 0a 20 20 20 20 20  nfinity) {.     
caf0: 20 20 20 20 20 72 65 73 75 6c 74 20 3d 20 76 3b       result = v;
cb00: 0a 20 20 20 20 20 20 20 20 20 20 6c 61 73 74 43  .          lastC
cb10: 6f 6d 70 75 74 65 64 20 3d 20 63 6f 6d 70 75 74  omputed = comput
cb20: 65 64 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20 20  ed;.        }.  
cb30: 20 20 20 20 7d 29 3b 0a 20 20 20 20 7d 0a 20 20      });.    }.  
cb40: 20 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74 3b    return result;
cb50: 0a 20 20 7d 0a 0a 20 20 2f 2f 20 53 61 6d 70 6c  .  }..  // Sampl
cb60: 65 20 2a 2a 6e 2a 2a 20 72 61 6e 64 6f 6d 20 76  e **n** random v
cb70: 61 6c 75 65 73 20 66 72 6f 6d 20 61 20 63 6f 6c  alues from a col
cb80: 6c 65 63 74 69 6f 6e 20 75 73 69 6e 67 20 74 68  lection using th
cb90: 65 20 6d 6f 64 65 72 6e 20 76 65 72 73 69 6f 6e  e modern version
cba0: 20 6f 66 20 74 68 65 0a 20 20 2f 2f 20 5b 46 69   of the.  // [Fi
cbb0: 73 68 65 72 2d 59 61 74 65 73 20 73 68 75 66 66  sher-Yates shuff
cbc0: 6c 65 5d 28 68 74 74 70 73 3a 2f 2f 65 6e 2e 77  le](https://en.w
cbd0: 69 6b 69 70 65 64 69 61 2e 6f 72 67 2f 77 69 6b  ikipedia.org/wik
cbe0: 69 2f 46 69 73 68 65 72 e2 80 93 59 61 74 65 73  i/Fisher...Yates
cbf0: 5f 73 68 75 66 66 6c 65 29 2e 0a 20 20 2f 2f 20  _shuffle)..  // 
cc00: 49 66 20 2a 2a 6e 2a 2a 20 69 73 20 6e 6f 74 20  If **n** is not 
cc10: 73 70 65 63 69 66 69 65 64 2c 20 72 65 74 75 72  specified, retur
cc20: 6e 73 20 61 20 73 69 6e 67 6c 65 20 72 61 6e 64  ns a single rand
cc30: 6f 6d 20 65 6c 65 6d 65 6e 74 2e 0a 20 20 2f 2f  om element..  //
cc40: 20 54 68 65 20 69 6e 74 65 72 6e 61 6c 20 60 67   The internal `g
cc50: 75 61 72 64 60 20 61 72 67 75 6d 65 6e 74 20 61  uard` argument a
cc60: 6c 6c 6f 77 73 20 69 74 20 74 6f 20 77 6f 72 6b  llows it to work
cc70: 20 77 69 74 68 20 60 5f 2e 6d 61 70 60 2e 0a 20   with `_.map`.. 
cc80: 20 66 75 6e 63 74 69 6f 6e 20 73 61 6d 70 6c 65   function sample
cc90: 28 6f 62 6a 2c 20 6e 2c 20 67 75 61 72 64 29 20  (obj, n, guard) 
cca0: 7b 0a 20 20 20 20 69 66 20 28 6e 20 3d 3d 20 6e  {.    if (n == n
ccb0: 75 6c 6c 20 7c 7c 20 67 75 61 72 64 29 20 7b 0a  ull || guard) {.
ccc0: 20 20 20 20 20 20 69 66 20 28 21 69 73 41 72 72        if (!isArr
ccd0: 61 79 4c 69 6b 65 28 6f 62 6a 29 29 20 6f 62 6a  ayLike(obj)) obj
cce0: 20 3d 20 76 61 6c 75 65 73 28 6f 62 6a 29 3b 0a   = values(obj);.
ccf0: 20 20 20 20 20 20 72 65 74 75 72 6e 20 6f 62 6a        return obj
cd00: 5b 72 61 6e 64 6f 6d 28 6f 62 6a 2e 6c 65 6e 67  [random(obj.leng
cd10: 74 68 20 2d 20 31 29 5d 3b 0a 20 20 20 20 7d 0a  th - 1)];.    }.
cd20: 20 20 20 20 76 61 72 20 73 61 6d 70 6c 65 20 3d      var sample =
cd30: 20 69 73 41 72 72 61 79 4c 69 6b 65 28 6f 62 6a   isArrayLike(obj
cd40: 29 20 3f 20 63 6c 6f 6e 65 28 6f 62 6a 29 20 3a  ) ? clone(obj) :
cd50: 20 76 61 6c 75 65 73 28 6f 62 6a 29 3b 0a 20 20   values(obj);.  
cd60: 20 20 76 61 72 20 6c 65 6e 67 74 68 20 3d 20 67    var length = g
cd70: 65 74 4c 65 6e 67 74 68 28 73 61 6d 70 6c 65 29  etLength(sample)
cd80: 3b 0a 20 20 20 20 6e 20 3d 20 4d 61 74 68 2e 6d  ;.    n = Math.m
cd90: 61 78 28 4d 61 74 68 2e 6d 69 6e 28 6e 2c 20 6c  ax(Math.min(n, l
cda0: 65 6e 67 74 68 29 2c 20 30 29 3b 0a 20 20 20 20  ength), 0);.    
cdb0: 76 61 72 20 6c 61 73 74 20 3d 20 6c 65 6e 67 74  var last = lengt
cdc0: 68 20 2d 20 31 3b 0a 20 20 20 20 66 6f 72 20 28  h - 1;.    for (
cdd0: 76 61 72 20 69 6e 64 65 78 20 3d 20 30 3b 20 69  var index = 0; i
cde0: 6e 64 65 78 20 3c 20 6e 3b 20 69 6e 64 65 78 2b  ndex < n; index+
cdf0: 2b 29 20 7b 0a 20 20 20 20 20 20 76 61 72 20 72  +) {.      var r
ce00: 61 6e 64 20 3d 20 72 61 6e 64 6f 6d 28 69 6e 64  and = random(ind
ce10: 65 78 2c 20 6c 61 73 74 29 3b 0a 20 20 20 20 20  ex, last);.     
ce20: 20 76 61 72 20 74 65 6d 70 20 3d 20 73 61 6d 70   var temp = samp
ce30: 6c 65 5b 69 6e 64 65 78 5d 3b 0a 20 20 20 20 20  le[index];.     
ce40: 20 73 61 6d 70 6c 65 5b 69 6e 64 65 78 5d 20 3d   sample[index] =
ce50: 20 73 61 6d 70 6c 65 5b 72 61 6e 64 5d 3b 0a 20   sample[rand];. 
ce60: 20 20 20 20 20 73 61 6d 70 6c 65 5b 72 61 6e 64       sample[rand
ce70: 5d 20 3d 20 74 65 6d 70 3b 0a 20 20 20 20 7d 0a  ] = temp;.    }.
ce80: 20 20 20 20 72 65 74 75 72 6e 20 73 61 6d 70 6c      return sampl
ce90: 65 2e 73 6c 69 63 65 28 30 2c 20 6e 29 3b 0a 20  e.slice(0, n);. 
cea0: 20 7d 0a 0a 20 20 2f 2f 20 53 68 75 66 66 6c 65   }..  // Shuffle
ceb0: 20 61 20 63 6f 6c 6c 65 63 74 69 6f 6e 2e 0a 20   a collection.. 
cec0: 20 66 75 6e 63 74 69 6f 6e 20 73 68 75 66 66 6c   function shuffl
ced0: 65 28 6f 62 6a 29 20 7b 0a 20 20 20 20 72 65 74  e(obj) {.    ret
cee0: 75 72 6e 20 73 61 6d 70 6c 65 28 6f 62 6a 2c 20  urn sample(obj, 
cef0: 49 6e 66 69 6e 69 74 79 29 3b 0a 20 20 7d 0a 0a  Infinity);.  }..
cf00: 20 20 2f 2f 20 53 6f 72 74 20 74 68 65 20 6f 62    // Sort the ob
cf10: 6a 65 63 74 27 73 20 76 61 6c 75 65 73 20 62 79  ject's values by
cf20: 20 61 20 63 72 69 74 65 72 69 6f 6e 20 70 72 6f   a criterion pro
cf30: 64 75 63 65 64 20 62 79 20 61 6e 20 69 74 65 72  duced by an iter
cf40: 61 74 65 65 2e 0a 20 20 66 75 6e 63 74 69 6f 6e  atee..  function
cf50: 20 73 6f 72 74 42 79 28 6f 62 6a 2c 20 69 74 65   sortBy(obj, ite
cf60: 72 61 74 65 65 2c 20 63 6f 6e 74 65 78 74 29 20  ratee, context) 
cf70: 7b 0a 20 20 20 20 76 61 72 20 69 6e 64 65 78 20  {.    var index 
cf80: 3d 20 30 3b 0a 20 20 20 20 69 74 65 72 61 74 65  = 0;.    iterate
cf90: 65 20 3d 20 63 62 28 69 74 65 72 61 74 65 65 2c  e = cb(iteratee,
cfa0: 20 63 6f 6e 74 65 78 74 29 3b 0a 20 20 20 20 72   context);.    r
cfb0: 65 74 75 72 6e 20 70 6c 75 63 6b 28 6d 61 70 28  eturn pluck(map(
cfc0: 6f 62 6a 2c 20 66 75 6e 63 74 69 6f 6e 28 76 61  obj, function(va
cfd0: 6c 75 65 2c 20 6b 65 79 2c 20 6c 69 73 74 29 20  lue, key, list) 
cfe0: 7b 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 7b  {.      return {
cff0: 0a 20 20 20 20 20 20 20 20 76 61 6c 75 65 3a 20  .        value: 
d000: 76 61 6c 75 65 2c 0a 20 20 20 20 20 20 20 20 69  value,.        i
d010: 6e 64 65 78 3a 20 69 6e 64 65 78 2b 2b 2c 0a 20  ndex: index++,. 
d020: 20 20 20 20 20 20 20 63 72 69 74 65 72 69 61 3a         criteria:
d030: 20 69 74 65 72 61 74 65 65 28 76 61 6c 75 65 2c   iteratee(value,
d040: 20 6b 65 79 2c 20 6c 69 73 74 29 0a 20 20 20 20   key, list).    
d050: 20 20 7d 3b 0a 20 20 20 20 7d 29 2e 73 6f 72 74    };.    }).sort
d060: 28 66 75 6e 63 74 69 6f 6e 28 6c 65 66 74 2c 20  (function(left, 
d070: 72 69 67 68 74 29 20 7b 0a 20 20 20 20 20 20 76  right) {.      v
d080: 61 72 20 61 20 3d 20 6c 65 66 74 2e 63 72 69 74  ar a = left.crit
d090: 65 72 69 61 3b 0a 20 20 20 20 20 20 76 61 72 20  eria;.      var 
d0a0: 62 20 3d 20 72 69 67 68 74 2e 63 72 69 74 65 72  b = right.criter
d0b0: 69 61 3b 0a 20 20 20 20 20 20 69 66 20 28 61 20  ia;.      if (a 
d0c0: 21 3d 3d 20 62 29 20 7b 0a 20 20 20 20 20 20 20  !== b) {.       
d0d0: 20 69 66 20 28 61 20 3e 20 62 20 7c 7c 20 61 20   if (a > b || a 
d0e0: 3d 3d 3d 20 76 6f 69 64 20 30 29 20 72 65 74 75  === void 0) retu
d0f0: 72 6e 20 31 3b 0a 20 20 20 20 20 20 20 20 69 66  rn 1;.        if
d100: 20 28 61 20 3c 20 62 20 7c 7c 20 62 20 3d 3d 3d   (a < b || b ===
d110: 20 76 6f 69 64 20 30 29 20 72 65 74 75 72 6e 20   void 0) return 
d120: 2d 31 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20  -1;.      }.    
d130: 20 20 72 65 74 75 72 6e 20 6c 65 66 74 2e 69 6e    return left.in
d140: 64 65 78 20 2d 20 72 69 67 68 74 2e 69 6e 64 65  dex - right.inde
d150: 78 3b 0a 20 20 20 20 7d 29 2c 20 27 76 61 6c 75  x;.    }), 'valu
d160: 65 27 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 41  e');.  }..  // A
d170: 6e 20 69 6e 74 65 72 6e 61 6c 20 66 75 6e 63 74  n internal funct
d180: 69 6f 6e 20 75 73 65 64 20 66 6f 72 20 61 67 67  ion used for agg
d190: 72 65 67 61 74 65 20 22 67 72 6f 75 70 20 62 79  regate "group by
d1a0: 22 20 6f 70 65 72 61 74 69 6f 6e 73 2e 0a 20 20  " operations..  
d1b0: 66 75 6e 63 74 69 6f 6e 20 67 72 6f 75 70 28 62  function group(b
d1c0: 65 68 61 76 69 6f 72 2c 20 70 61 72 74 69 74 69  ehavior, partiti
d1d0: 6f 6e 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e  on) {.    return
d1e0: 20 66 75 6e 63 74 69 6f 6e 28 6f 62 6a 2c 20 69   function(obj, i
d1f0: 74 65 72 61 74 65 65 2c 20 63 6f 6e 74 65 78 74  teratee, context
d200: 29 20 7b 0a 20 20 20 20 20 20 76 61 72 20 72 65  ) {.      var re
d210: 73 75 6c 74 20 3d 20 70 61 72 74 69 74 69 6f 6e  sult = partition
d220: 20 3f 20 5b 5b 5d 2c 20 5b 5d 5d 20 3a 20 7b 7d   ? [[], []] : {}
d230: 3b 0a 20 20 20 20 20 20 69 74 65 72 61 74 65 65  ;.      iteratee
d240: 20 3d 20 63 62 28 69 74 65 72 61 74 65 65 2c 20   = cb(iteratee, 
d250: 63 6f 6e 74 65 78 74 29 3b 0a 20 20 20 20 20 20  context);.      
d260: 65 61 63 68 28 6f 62 6a 2c 20 66 75 6e 63 74 69  each(obj, functi
d270: 6f 6e 28 76 61 6c 75 65 2c 20 69 6e 64 65 78 29  on(value, index)
d280: 20 7b 0a 20 20 20 20 20 20 20 20 76 61 72 20 6b   {.        var k
d290: 65 79 20 3d 20 69 74 65 72 61 74 65 65 28 76 61  ey = iteratee(va
d2a0: 6c 75 65 2c 20 69 6e 64 65 78 2c 20 6f 62 6a 29  lue, index, obj)
d2b0: 3b 0a 20 20 20 20 20 20 20 20 62 65 68 61 76 69  ;.        behavi
d2c0: 6f 72 28 72 65 73 75 6c 74 2c 20 76 61 6c 75 65  or(result, value
d2d0: 2c 20 6b 65 79 29 3b 0a 20 20 20 20 20 20 7d 29  , key);.      })
d2e0: 3b 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 72  ;.      return r
d2f0: 65 73 75 6c 74 3b 0a 20 20 20 20 7d 3b 0a 20 20  esult;.    };.  
d300: 7d 0a 0a 20 20 2f 2f 20 47 72 6f 75 70 73 20 74  }..  // Groups t
d310: 68 65 20 6f 62 6a 65 63 74 27 73 20 76 61 6c 75  he object's valu
d320: 65 73 20 62 79 20 61 20 63 72 69 74 65 72 69 6f  es by a criterio
d330: 6e 2e 20 50 61 73 73 20 65 69 74 68 65 72 20 61  n. Pass either a
d340: 20 73 74 72 69 6e 67 20 61 74 74 72 69 62 75 74   string attribut
d350: 65 0a 20 20 2f 2f 20 74 6f 20 67 72 6f 75 70 20  e.  // to group 
d360: 62 79 2c 20 6f 72 20 61 20 66 75 6e 63 74 69 6f  by, or a functio
d370: 6e 20 74 68 61 74 20 72 65 74 75 72 6e 73 20 74  n that returns t
d380: 68 65 20 63 72 69 74 65 72 69 6f 6e 2e 0a 20 20  he criterion..  
d390: 76 61 72 20 67 72 6f 75 70 42 79 20 3d 20 67 72  var groupBy = gr
d3a0: 6f 75 70 28 66 75 6e 63 74 69 6f 6e 28 72 65 73  oup(function(res
d3b0: 75 6c 74 2c 20 76 61 6c 75 65 2c 20 6b 65 79 29  ult, value, key)
d3c0: 20 7b 0a 20 20 20 20 69 66 20 28 68 61 73 28 72   {.    if (has(r
d3d0: 65 73 75 6c 74 2c 20 6b 65 79 29 29 20 72 65 73  esult, key)) res
d3e0: 75 6c 74 5b 6b 65 79 5d 2e 70 75 73 68 28 76 61  ult[key].push(va
d3f0: 6c 75 65 29 3b 20 65 6c 73 65 20 72 65 73 75 6c  lue); else resul
d400: 74 5b 6b 65 79 5d 20 3d 20 5b 76 61 6c 75 65 5d  t[key] = [value]
d410: 3b 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 49 6e  ;.  });..  // In
d420: 64 65 78 65 73 20 74 68 65 20 6f 62 6a 65 63 74  dexes the object
d430: 27 73 20 76 61 6c 75 65 73 20 62 79 20 61 20 63  's values by a c
d440: 72 69 74 65 72 69 6f 6e 2c 20 73 69 6d 69 6c 61  riterion, simila
d450: 72 20 74 6f 20 60 5f 2e 67 72 6f 75 70 42 79 60  r to `_.groupBy`
d460: 2c 20 62 75 74 20 66 6f 72 0a 20 20 2f 2f 20 77  , but for.  // w
d470: 68 65 6e 20 79 6f 75 20 6b 6e 6f 77 20 74 68 61  hen you know tha
d480: 74 20 79 6f 75 72 20 69 6e 64 65 78 20 76 61 6c  t your index val
d490: 75 65 73 20 77 69 6c 6c 20 62 65 20 75 6e 69 71  ues will be uniq
d4a0: 75 65 2e 0a 20 20 76 61 72 20 69 6e 64 65 78 42  ue..  var indexB
d4b0: 79 20 3d 20 67 72 6f 75 70 28 66 75 6e 63 74 69  y = group(functi
d4c0: 6f 6e 28 72 65 73 75 6c 74 2c 20 76 61 6c 75 65  on(result, value
d4d0: 2c 20 6b 65 79 29 20 7b 0a 20 20 20 20 72 65 73  , key) {.    res
d4e0: 75 6c 74 5b 6b 65 79 5d 20 3d 20 76 61 6c 75 65  ult[key] = value
d4f0: 3b 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 43 6f  ;.  });..  // Co
d500: 75 6e 74 73 20 69 6e 73 74 61 6e 63 65 73 20 6f  unts instances o
d510: 66 20 61 6e 20 6f 62 6a 65 63 74 20 74 68 61 74  f an object that
d520: 20 67 72 6f 75 70 20 62 79 20 61 20 63 65 72 74   group by a cert
d530: 61 69 6e 20 63 72 69 74 65 72 69 6f 6e 2e 20 50  ain criterion. P
d540: 61 73 73 0a 20 20 2f 2f 20 65 69 74 68 65 72 20  ass.  // either 
d550: 61 20 73 74 72 69 6e 67 20 61 74 74 72 69 62 75  a string attribu
d560: 74 65 20 74 6f 20 63 6f 75 6e 74 20 62 79 2c 20  te to count by, 
d570: 6f 72 20 61 20 66 75 6e 63 74 69 6f 6e 20 74 68  or a function th
d580: 61 74 20 72 65 74 75 72 6e 73 20 74 68 65 0a 20  at returns the. 
d590: 20 2f 2f 20 63 72 69 74 65 72 69 6f 6e 2e 0a 20   // criterion.. 
d5a0: 20 76 61 72 20 63 6f 75 6e 74 42 79 20 3d 20 67   var countBy = g
d5b0: 72 6f 75 70 28 66 75 6e 63 74 69 6f 6e 28 72 65  roup(function(re
d5c0: 73 75 6c 74 2c 20 76 61 6c 75 65 2c 20 6b 65 79  sult, value, key
d5d0: 29 20 7b 0a 20 20 20 20 69 66 20 28 68 61 73 28  ) {.    if (has(
d5e0: 72 65 73 75 6c 74 2c 20 6b 65 79 29 29 20 72 65  result, key)) re
d5f0: 73 75 6c 74 5b 6b 65 79 5d 2b 2b 3b 20 65 6c 73  sult[key]++; els
d600: 65 20 72 65 73 75 6c 74 5b 6b 65 79 5d 20 3d 20  e result[key] = 
d610: 31 3b 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 53  1;.  });..  // S
d620: 70 6c 69 74 20 61 20 63 6f 6c 6c 65 63 74 69 6f  plit a collectio
d630: 6e 20 69 6e 74 6f 20 74 77 6f 20 61 72 72 61 79  n into two array
d640: 73 3a 20 6f 6e 65 20 77 68 6f 73 65 20 65 6c 65  s: one whose ele
d650: 6d 65 6e 74 73 20 61 6c 6c 20 70 61 73 73 20 74  ments all pass t
d660: 68 65 20 67 69 76 65 6e 0a 20 20 2f 2f 20 74 72  he given.  // tr
d670: 75 74 68 20 74 65 73 74 2c 20 61 6e 64 20 6f 6e  uth test, and on
d680: 65 20 77 68 6f 73 65 20 65 6c 65 6d 65 6e 74 73  e whose elements
d690: 20 61 6c 6c 20 64 6f 20 6e 6f 74 20 70 61 73 73   all do not pass
d6a0: 20 74 68 65 20 74 72 75 74 68 20 74 65 73 74 2e   the truth test.
d6b0: 0a 20 20 76 61 72 20 70 61 72 74 69 74 69 6f 6e  .  var partition
d6c0: 20 3d 20 67 72 6f 75 70 28 66 75 6e 63 74 69 6f   = group(functio
d6d0: 6e 28 72 65 73 75 6c 74 2c 20 76 61 6c 75 65 2c  n(result, value,
d6e0: 20 70 61 73 73 29 20 7b 0a 20 20 20 20 72 65 73   pass) {.    res
d6f0: 75 6c 74 5b 70 61 73 73 20 3f 20 30 20 3a 20 31  ult[pass ? 0 : 1
d700: 5d 2e 70 75 73 68 28 76 61 6c 75 65 29 3b 0a 20  ].push(value);. 
d710: 20 7d 2c 20 74 72 75 65 29 3b 0a 0a 20 20 2f 2f   }, true);..  //
d720: 20 53 61 66 65 6c 79 20 63 72 65 61 74 65 20 61   Safely create a
d730: 20 72 65 61 6c 2c 20 6c 69 76 65 20 61 72 72 61   real, live arra
d740: 79 20 66 72 6f 6d 20 61 6e 79 74 68 69 6e 67 20  y from anything 
d750: 69 74 65 72 61 62 6c 65 2e 0a 20 20 76 61 72 20  iterable..  var 
d760: 72 65 53 74 72 53 79 6d 62 6f 6c 20 3d 20 2f 5b  reStrSymbol = /[
d770: 5e 5c 75 64 38 30 30 2d 5c 75 64 66 66 66 5d 7c  ^\ud800-\udfff]|
d780: 5b 5c 75 64 38 30 30 2d 5c 75 64 62 66 66 5d 5b  [\ud800-\udbff][
d790: 5c 75 64 63 30 30 2d 5c 75 64 66 66 66 5d 7c 5b  \udc00-\udfff]|[
d7a0: 5c 75 64 38 30 30 2d 5c 75 64 66 66 66 5d 2f 67  \ud800-\udfff]/g
d7b0: 3b 0a 20 20 66 75 6e 63 74 69 6f 6e 20 74 6f 41  ;.  function toA
d7c0: 72 72 61 79 28 6f 62 6a 29 20 7b 0a 20 20 20 20  rray(obj) {.    
d7d0: 69 66 20 28 21 6f 62 6a 29 20 72 65 74 75 72 6e  if (!obj) return
d7e0: 20 5b 5d 3b 0a 20 20 20 20 69 66 20 28 69 73 41   [];.    if (isA
d7f0: 72 72 61 79 28 6f 62 6a 29 29 20 72 65 74 75 72  rray(obj)) retur
d800: 6e 20 73 6c 69 63 65 2e 63 61 6c 6c 28 6f 62 6a  n slice.call(obj
d810: 29 3b 0a 20 20 20 20 69 66 20 28 69 73 53 74 72  );.    if (isStr
d820: 69 6e 67 28 6f 62 6a 29 29 20 7b 0a 20 20 20 20  ing(obj)) {.    
d830: 20 20 2f 2f 20 4b 65 65 70 20 73 75 72 72 6f 67    // Keep surrog
d840: 61 74 65 20 70 61 69 72 20 63 68 61 72 61 63 74  ate pair charact
d850: 65 72 73 20 74 6f 67 65 74 68 65 72 2e 0a 20 20  ers together..  
d860: 20 20 20 20 72 65 74 75 72 6e 20 6f 62 6a 2e 6d      return obj.m
d870: 61 74 63 68 28 72 65 53 74 72 53 79 6d 62 6f 6c  atch(reStrSymbol
d880: 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 69 66 20  );.    }.    if 
d890: 28 69 73 41 72 72 61 79 4c 69 6b 65 28 6f 62 6a  (isArrayLike(obj
d8a0: 29 29 20 72 65 74 75 72 6e 20 6d 61 70 28 6f 62  )) return map(ob
d8b0: 6a 2c 20 69 64 65 6e 74 69 74 79 29 3b 0a 20 20  j, identity);.  
d8c0: 20 20 72 65 74 75 72 6e 20 76 61 6c 75 65 73 28    return values(
d8d0: 6f 62 6a 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20  obj);.  }..  // 
d8e0: 52 65 74 75 72 6e 20 74 68 65 20 6e 75 6d 62 65  Return the numbe
d8f0: 72 20 6f 66 20 65 6c 65 6d 65 6e 74 73 20 69 6e  r of elements in
d900: 20 61 20 63 6f 6c 6c 65 63 74 69 6f 6e 2e 0a 20   a collection.. 
d910: 20 66 75 6e 63 74 69 6f 6e 20 73 69 7a 65 28 6f   function size(o
d920: 62 6a 29 20 7b 0a 20 20 20 20 69 66 20 28 6f 62  bj) {.    if (ob
d930: 6a 20 3d 3d 20 6e 75 6c 6c 29 20 72 65 74 75 72  j == null) retur
d940: 6e 20 30 3b 0a 20 20 20 20 72 65 74 75 72 6e 20  n 0;.    return 
d950: 69 73 41 72 72 61 79 4c 69 6b 65 28 6f 62 6a 29  isArrayLike(obj)
d960: 20 3f 20 6f 62 6a 2e 6c 65 6e 67 74 68 20 3a 20   ? obj.length : 
d970: 6b 65 79 73 28 6f 62 6a 29 2e 6c 65 6e 67 74 68  keys(obj).length
d980: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 49 6e 74 65  ;.  }..  // Inte
d990: 72 6e 61 6c 20 60 5f 2e 70 69 63 6b 60 20 68 65  rnal `_.pick` he
d9a0: 6c 70 65 72 20 66 75 6e 63 74 69 6f 6e 20 74 6f  lper function to
d9b0: 20 64 65 74 65 72 6d 69 6e 65 20 77 68 65 74 68   determine wheth
d9c0: 65 72 20 60 6b 65 79 60 20 69 73 20 61 6e 20 65  er `key` is an e
d9d0: 6e 75 6d 65 72 61 62 6c 65 0a 20 20 2f 2f 20 70  numerable.  // p
d9e0: 72 6f 70 65 72 74 79 20 6e 61 6d 65 20 6f 66 20  roperty name of 
d9f0: 60 6f 62 6a 60 2e 0a 20 20 66 75 6e 63 74 69 6f  `obj`..  functio
da00: 6e 20 6b 65 79 49 6e 4f 62 6a 28 76 61 6c 75 65  n keyInObj(value
da10: 2c 20 6b 65 79 2c 20 6f 62 6a 29 20 7b 0a 20 20  , key, obj) {.  
da20: 20 20 72 65 74 75 72 6e 20 6b 65 79 20 69 6e 20    return key in 
da30: 6f 62 6a 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 52  obj;.  }..  // R
da40: 65 74 75 72 6e 20 61 20 63 6f 70 79 20 6f 66 20  eturn a copy of 
da50: 74 68 65 20 6f 62 6a 65 63 74 20 6f 6e 6c 79 20  the object only 
da60: 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 61  containing the a
da70: 6c 6c 6f 77 65 64 20 70 72 6f 70 65 72 74 69 65  llowed propertie
da80: 73 2e 0a 20 20 76 61 72 20 70 69 63 6b 20 3d 20  s..  var pick = 
da90: 72 65 73 74 41 72 67 75 6d 65 6e 74 73 28 66 75  restArguments(fu
daa0: 6e 63 74 69 6f 6e 28 6f 62 6a 2c 20 6b 65 79 73  nction(obj, keys
dab0: 29 20 7b 0a 20 20 20 20 76 61 72 20 72 65 73 75  ) {.    var resu
dac0: 6c 74 20 3d 20 7b 7d 2c 20 69 74 65 72 61 74 65  lt = {}, iterate
dad0: 65 20 3d 20 6b 65 79 73 5b 30 5d 3b 0a 20 20 20  e = keys[0];.   
dae0: 20 69 66 20 28 6f 62 6a 20 3d 3d 20 6e 75 6c 6c   if (obj == null
daf0: 29 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74 3b  ) return result;
db00: 0a 20 20 20 20 69 66 20 28 69 73 46 75 6e 63 74  .    if (isFunct
db10: 69 6f 6e 24 31 28 69 74 65 72 61 74 65 65 29 29  ion$1(iteratee))
db20: 20 7b 0a 20 20 20 20 20 20 69 66 20 28 6b 65 79   {.      if (key
db30: 73 2e 6c 65 6e 67 74 68 20 3e 20 31 29 20 69 74  s.length > 1) it
db40: 65 72 61 74 65 65 20 3d 20 6f 70 74 69 6d 69 7a  eratee = optimiz
db50: 65 43 62 28 69 74 65 72 61 74 65 65 2c 20 6b 65  eCb(iteratee, ke
db60: 79 73 5b 31 5d 29 3b 0a 20 20 20 20 20 20 6b 65  ys[1]);.      ke
db70: 79 73 20 3d 20 61 6c 6c 4b 65 79 73 28 6f 62 6a  ys = allKeys(obj
db80: 29 3b 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a  );.    } else {.
db90: 20 20 20 20 20 20 69 74 65 72 61 74 65 65 20 3d        iteratee =
dba0: 20 6b 65 79 49 6e 4f 62 6a 3b 0a 20 20 20 20 20   keyInObj;.     
dbb0: 20 6b 65 79 73 20 3d 20 66 6c 61 74 74 65 6e 28   keys = flatten(
dbc0: 6b 65 79 73 2c 20 66 61 6c 73 65 2c 20 66 61 6c  keys, false, fal
dbd0: 73 65 29 3b 0a 20 20 20 20 20 20 6f 62 6a 20 3d  se);.      obj =
dbe0: 20 4f 62 6a 65 63 74 28 6f 62 6a 29 3b 0a 20 20   Object(obj);.  
dbf0: 20 20 7d 0a 20 20 20 20 66 6f 72 20 28 76 61 72    }.    for (var
dc00: 20 69 20 3d 20 30 2c 20 6c 65 6e 67 74 68 20 3d   i = 0, length =
dc10: 20 6b 65 79 73 2e 6c 65 6e 67 74 68 3b 20 69 20   keys.length; i 
dc20: 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20 7b  < length; i++) {
dc30: 0a 20 20 20 20 20 20 76 61 72 20 6b 65 79 20 3d  .      var key =
dc40: 20 6b 65 79 73 5b 69 5d 3b 0a 20 20 20 20 20 20   keys[i];.      
dc50: 76 61 72 20 76 61 6c 75 65 20 3d 20 6f 62 6a 5b  var value = obj[
dc60: 6b 65 79 5d 3b 0a 20 20 20 20 20 20 69 66 20 28  key];.      if (
dc70: 69 74 65 72 61 74 65 65 28 76 61 6c 75 65 2c 20  iteratee(value, 
dc80: 6b 65 79 2c 20 6f 62 6a 29 29 20 72 65 73 75 6c  key, obj)) resul
dc90: 74 5b 6b 65 79 5d 20 3d 20 76 61 6c 75 65 3b 0a  t[key] = value;.
dca0: 20 20 20 20 7d 0a 20 20 20 20 72 65 74 75 72 6e      }.    return
dcb0: 20 72 65 73 75 6c 74 3b 0a 20 20 7d 29 3b 0a 0a   result;.  });..
dcc0: 20 20 2f 2f 20 52 65 74 75 72 6e 20 61 20 63 6f    // Return a co
dcd0: 70 79 20 6f 66 20 74 68 65 20 6f 62 6a 65 63 74  py of the object
dce0: 20 77 69 74 68 6f 75 74 20 74 68 65 20 64 69 73   without the dis
dcf0: 61 6c 6c 6f 77 65 64 20 70 72 6f 70 65 72 74 69  allowed properti
dd00: 65 73 2e 0a 20 20 76 61 72 20 6f 6d 69 74 20 3d  es..  var omit =
dd10: 20 72 65 73 74 41 72 67 75 6d 65 6e 74 73 28 66   restArguments(f
dd20: 75 6e 63 74 69 6f 6e 28 6f 62 6a 2c 20 6b 65 79  unction(obj, key
dd30: 73 29 20 7b 0a 20 20 20 20 76 61 72 20 69 74 65  s) {.    var ite
dd40: 72 61 74 65 65 20 3d 20 6b 65 79 73 5b 30 5d 2c  ratee = keys[0],
dd50: 20 63 6f 6e 74 65 78 74 3b 0a 20 20 20 20 69 66   context;.    if
dd60: 20 28 69 73 46 75 6e 63 74 69 6f 6e 24 31 28 69   (isFunction$1(i
dd70: 74 65 72 61 74 65 65 29 29 20 7b 0a 20 20 20 20  teratee)) {.    
dd80: 20 20 69 74 65 72 61 74 65 65 20 3d 20 6e 65 67    iteratee = neg
dd90: 61 74 65 28 69 74 65 72 61 74 65 65 29 3b 0a 20  ate(iteratee);. 
dda0: 20 20 20 20 20 69 66 20 28 6b 65 79 73 2e 6c 65       if (keys.le
ddb0: 6e 67 74 68 20 3e 20 31 29 20 63 6f 6e 74 65 78  ngth > 1) contex
ddc0: 74 20 3d 20 6b 65 79 73 5b 31 5d 3b 0a 20 20 20  t = keys[1];.   
ddd0: 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 20   } else {.      
dde0: 6b 65 79 73 20 3d 20 6d 61 70 28 66 6c 61 74 74  keys = map(flatt
ddf0: 65 6e 28 6b 65 79 73 2c 20 66 61 6c 73 65 2c 20  en(keys, false, 
de00: 66 61 6c 73 65 29 2c 20 53 74 72 69 6e 67 29 3b  false), String);
de10: 0a 20 20 20 20 20 20 69 74 65 72 61 74 65 65 20  .      iteratee 
de20: 3d 20 66 75 6e 63 74 69 6f 6e 28 76 61 6c 75 65  = function(value
de30: 2c 20 6b 65 79 29 20 7b 0a 20 20 20 20 20 20 20  , key) {.       
de40: 20 72 65 74 75 72 6e 20 21 63 6f 6e 74 61 69 6e   return !contain
de50: 73 28 6b 65 79 73 2c 20 6b 65 79 29 3b 0a 20 20  s(keys, key);.  
de60: 20 20 20 20 7d 3b 0a 20 20 20 20 7d 0a 20 20 20      };.    }.   
de70: 20 72 65 74 75 72 6e 20 70 69 63 6b 28 6f 62 6a   return pick(obj
de80: 2c 20 69 74 65 72 61 74 65 65 2c 20 63 6f 6e 74  , iteratee, cont
de90: 65 78 74 29 3b 0a 20 20 7d 29 3b 0a 0a 20 20 2f  ext);.  });..  /
dea0: 2f 20 52 65 74 75 72 6e 73 20 65 76 65 72 79 74  / Returns everyt
deb0: 68 69 6e 67 20 62 75 74 20 74 68 65 20 6c 61 73  hing but the las
dec0: 74 20 65 6e 74 72 79 20 6f 66 20 74 68 65 20 61  t entry of the a
ded0: 72 72 61 79 2e 20 45 73 70 65 63 69 61 6c 6c 79  rray. Especially
dee0: 20 75 73 65 66 75 6c 20 6f 6e 0a 20 20 2f 2f 20   useful on.  // 
def0: 74 68 65 20 61 72 67 75 6d 65 6e 74 73 20 6f 62  the arguments ob
df00: 6a 65 63 74 2e 20 50 61 73 73 69 6e 67 20 2a 2a  ject. Passing **
df10: 6e 2a 2a 20 77 69 6c 6c 20 72 65 74 75 72 6e 20  n** will return 
df20: 61 6c 6c 20 74 68 65 20 76 61 6c 75 65 73 20 69  all the values i
df30: 6e 0a 20 20 2f 2f 20 74 68 65 20 61 72 72 61 79  n.  // the array
df40: 2c 20 65 78 63 6c 75 64 69 6e 67 20 74 68 65 20  , excluding the 
df50: 6c 61 73 74 20 4e 2e 0a 20 20 66 75 6e 63 74 69  last N..  functi
df60: 6f 6e 20 69 6e 69 74 69 61 6c 28 61 72 72 61 79  on initial(array
df70: 2c 20 6e 2c 20 67 75 61 72 64 29 20 7b 0a 20 20  , n, guard) {.  
df80: 20 20 72 65 74 75 72 6e 20 73 6c 69 63 65 2e 63    return slice.c
df90: 61 6c 6c 28 61 72 72 61 79 2c 20 30 2c 20 4d 61  all(array, 0, Ma
dfa0: 74 68 2e 6d 61 78 28 30 2c 20 61 72 72 61 79 2e  th.max(0, array.
dfb0: 6c 65 6e 67 74 68 20 2d 20 28 6e 20 3d 3d 20 6e  length - (n == n
dfc0: 75 6c 6c 20 7c 7c 20 67 75 61 72 64 20 3f 20 31  ull || guard ? 1
dfd0: 20 3a 20 6e 29 29 29 3b 0a 20 20 7d 0a 0a 20 20   : n)));.  }..  
dfe0: 2f 2f 20 47 65 74 20 74 68 65 20 66 69 72 73 74  // Get the first
dff0: 20 65 6c 65 6d 65 6e 74 20 6f 66 20 61 6e 20 61   element of an a
e000: 72 72 61 79 2e 20 50 61 73 73 69 6e 67 20 2a 2a  rray. Passing **
e010: 6e 2a 2a 20 77 69 6c 6c 20 72 65 74 75 72 6e 20  n** will return 
e020: 74 68 65 20 66 69 72 73 74 20 4e 0a 20 20 2f 2f  the first N.  //
e030: 20 76 61 6c 75 65 73 20 69 6e 20 74 68 65 20 61   values in the a
e040: 72 72 61 79 2e 20 54 68 65 20 2a 2a 67 75 61 72  rray. The **guar
e050: 64 2a 2a 20 63 68 65 63 6b 20 61 6c 6c 6f 77 73  d** check allows
e060: 20 69 74 20 74 6f 20 77 6f 72 6b 20 77 69 74 68   it to work with
e070: 20 60 5f 2e 6d 61 70 60 2e 0a 20 20 66 75 6e 63   `_.map`..  func
e080: 74 69 6f 6e 20 66 69 72 73 74 28 61 72 72 61 79  tion first(array
e090: 2c 20 6e 2c 20 67 75 61 72 64 29 20 7b 0a 20 20  , n, guard) {.  
e0a0: 20 20 69 66 20 28 61 72 72 61 79 20 3d 3d 20 6e    if (array == n
e0b0: 75 6c 6c 20 7c 7c 20 61 72 72 61 79 2e 6c 65 6e  ull || array.len
e0c0: 67 74 68 20 3c 20 31 29 20 72 65 74 75 72 6e 20  gth < 1) return 
e0d0: 6e 20 3d 3d 20 6e 75 6c 6c 20 7c 7c 20 67 75 61  n == null || gua
e0e0: 72 64 20 3f 20 76 6f 69 64 20 30 20 3a 20 5b 5d  rd ? void 0 : []
e0f0: 3b 0a 20 20 20 20 69 66 20 28 6e 20 3d 3d 20 6e  ;.    if (n == n
e100: 75 6c 6c 20 7c 7c 20 67 75 61 72 64 29 20 72 65  ull || guard) re
e110: 74 75 72 6e 20 61 72 72 61 79 5b 30 5d 3b 0a 20  turn array[0];. 
e120: 20 20 20 72 65 74 75 72 6e 20 69 6e 69 74 69 61     return initia
e130: 6c 28 61 72 72 61 79 2c 20 61 72 72 61 79 2e 6c  l(array, array.l
e140: 65 6e 67 74 68 20 2d 20 6e 29 3b 0a 20 20 7d 0a  ength - n);.  }.
e150: 0a 20 20 2f 2f 20 52 65 74 75 72 6e 73 20 65 76  .  // Returns ev
e160: 65 72 79 74 68 69 6e 67 20 62 75 74 20 74 68 65  erything but the
e170: 20 66 69 72 73 74 20 65 6e 74 72 79 20 6f 66 20   first entry of 
e180: 74 68 65 20 60 61 72 72 61 79 60 2e 20 45 73 70  the `array`. Esp
e190: 65 63 69 61 6c 6c 79 20 75 73 65 66 75 6c 20 6f  ecially useful o
e1a0: 6e 0a 20 20 2f 2f 20 74 68 65 20 60 61 72 67 75  n.  // the `argu
e1b0: 6d 65 6e 74 73 60 20 6f 62 6a 65 63 74 2e 20 50  ments` object. P
e1c0: 61 73 73 69 6e 67 20 61 6e 20 2a 2a 6e 2a 2a 20  assing an **n** 
e1d0: 77 69 6c 6c 20 72 65 74 75 72 6e 20 74 68 65 20  will return the 
e1e0: 72 65 73 74 20 4e 20 76 61 6c 75 65 73 20 69 6e  rest N values in
e1f0: 20 74 68 65 0a 20 20 2f 2f 20 60 61 72 72 61 79   the.  // `array
e200: 60 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 72 65  `..  function re
e210: 73 74 28 61 72 72 61 79 2c 20 6e 2c 20 67 75 61  st(array, n, gua
e220: 72 64 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e  rd) {.    return
e230: 20 73 6c 69 63 65 2e 63 61 6c 6c 28 61 72 72 61   slice.call(arra
e240: 79 2c 20 6e 20 3d 3d 20 6e 75 6c 6c 20 7c 7c 20  y, n == null || 
e250: 67 75 61 72 64 20 3f 20 31 20 3a 20 6e 29 3b 0a  guard ? 1 : n);.
e260: 20 20 7d 0a 0a 20 20 2f 2f 20 47 65 74 20 74 68    }..  // Get th
e270: 65 20 6c 61 73 74 20 65 6c 65 6d 65 6e 74 20 6f  e last element o
e280: 66 20 61 6e 20 61 72 72 61 79 2e 20 50 61 73 73  f an array. Pass
e290: 69 6e 67 20 2a 2a 6e 2a 2a 20 77 69 6c 6c 20 72  ing **n** will r
e2a0: 65 74 75 72 6e 20 74 68 65 20 6c 61 73 74 20 4e  eturn the last N
e2b0: 0a 20 20 2f 2f 20 76 61 6c 75 65 73 20 69 6e 20  .  // values in 
e2c0: 74 68 65 20 61 72 72 61 79 2e 0a 20 20 66 75 6e  the array..  fun
e2d0: 63 74 69 6f 6e 20 6c 61 73 74 28 61 72 72 61 79  ction last(array
e2e0: 2c 20 6e 2c 20 67 75 61 72 64 29 20 7b 0a 20 20  , n, guard) {.  
e2f0: 20 20 69 66 20 28 61 72 72 61 79 20 3d 3d 20 6e    if (array == n
e300: 75 6c 6c 20 7c 7c 20 61 72 72 61 79 2e 6c 65 6e  ull || array.len
e310: 67 74 68 20 3c 20 31 29 20 72 65 74 75 72 6e 20  gth < 1) return 
e320: 6e 20 3d 3d 20 6e 75 6c 6c 20 7c 7c 20 67 75 61  n == null || gua
e330: 72 64 20 3f 20 76 6f 69 64 20 30 20 3a 20 5b 5d  rd ? void 0 : []
e340: 3b 0a 20 20 20 20 69 66 20 28 6e 20 3d 3d 20 6e  ;.    if (n == n
e350: 75 6c 6c 20 7c 7c 20 67 75 61 72 64 29 20 72 65  ull || guard) re
e360: 74 75 72 6e 20 61 72 72 61 79 5b 61 72 72 61 79  turn array[array
e370: 2e 6c 65 6e 67 74 68 20 2d 20 31 5d 3b 0a 20 20  .length - 1];.  
e380: 20 20 72 65 74 75 72 6e 20 72 65 73 74 28 61 72    return rest(ar
e390: 72 61 79 2c 20 4d 61 74 68 2e 6d 61 78 28 30 2c  ray, Math.max(0,
e3a0: 20 61 72 72 61 79 2e 6c 65 6e 67 74 68 20 2d 20   array.length - 
e3b0: 6e 29 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 54  n));.  }..  // T
e3c0: 72 69 6d 20 6f 75 74 20 61 6c 6c 20 66 61 6c 73  rim out all fals
e3d0: 79 20 76 61 6c 75 65 73 20 66 72 6f 6d 20 61 6e  y values from an
e3e0: 20 61 72 72 61 79 2e 0a 20 20 66 75 6e 63 74 69   array..  functi
e3f0: 6f 6e 20 63 6f 6d 70 61 63 74 28 61 72 72 61 79  on compact(array
e400: 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 66  ) {.    return f
e410: 69 6c 74 65 72 28 61 72 72 61 79 2c 20 42 6f 6f  ilter(array, Boo
e420: 6c 65 61 6e 29 3b 0a 20 20 7d 0a 0a 20 20 2f 2f  lean);.  }..  //
e430: 20 46 6c 61 74 74 65 6e 20 6f 75 74 20 61 6e 20   Flatten out an 
e440: 61 72 72 61 79 2c 20 65 69 74 68 65 72 20 72 65  array, either re
e450: 63 75 72 73 69 76 65 6c 79 20 28 62 79 20 64 65  cursively (by de
e460: 66 61 75 6c 74 29 2c 20 6f 72 20 75 70 20 74 6f  fault), or up to
e470: 20 60 64 65 70 74 68 60 2e 0a 20 20 2f 2f 20 50   `depth`..  // P
e480: 61 73 73 69 6e 67 20 60 74 72 75 65 60 20 6f 72  assing `true` or
e490: 20 60 66 61 6c 73 65 60 20 61 73 20 60 64 65 70   `false` as `dep
e4a0: 74 68 60 20 6d 65 61 6e 73 20 60 31 60 20 6f 72  th` means `1` or
e4b0: 20 60 49 6e 66 69 6e 69 74 79 60 2c 20 72 65 73   `Infinity`, res
e4c0: 70 65 63 74 69 76 65 6c 79 2e 0a 20 20 66 75 6e  pectively..  fun
e4d0: 63 74 69 6f 6e 20 66 6c 61 74 74 65 6e 24 31 28  ction flatten$1(
e4e0: 61 72 72 61 79 2c 20 64 65 70 74 68 29 20 7b 0a  array, depth) {.
e4f0: 20 20 20 20 72 65 74 75 72 6e 20 66 6c 61 74 74      return flatt
e500: 65 6e 28 61 72 72 61 79 2c 20 64 65 70 74 68 2c  en(array, depth,
e510: 20 66 61 6c 73 65 29 3b 0a 20 20 7d 0a 0a 20 20   false);.  }..  
e520: 2f 2f 20 54 61 6b 65 20 74 68 65 20 64 69 66 66  // Take the diff
e530: 65 72 65 6e 63 65 20 62 65 74 77 65 65 6e 20 6f  erence between o
e540: 6e 65 20 61 72 72 61 79 20 61 6e 64 20 61 20 6e  ne array and a n
e550: 75 6d 62 65 72 20 6f 66 20 6f 74 68 65 72 20 61  umber of other a
e560: 72 72 61 79 73 2e 0a 20 20 2f 2f 20 4f 6e 6c 79  rrays..  // Only
e570: 20 74 68 65 20 65 6c 65 6d 65 6e 74 73 20 70 72   the elements pr
e580: 65 73 65 6e 74 20 69 6e 20 6a 75 73 74 20 74 68  esent in just th
e590: 65 20 66 69 72 73 74 20 61 72 72 61 79 20 77 69  e first array wi
e5a0: 6c 6c 20 72 65 6d 61 69 6e 2e 0a 20 20 76 61 72  ll remain..  var
e5b0: 20 64 69 66 66 65 72 65 6e 63 65 20 3d 20 72 65   difference = re
e5c0: 73 74 41 72 67 75 6d 65 6e 74 73 28 66 75 6e 63  stArguments(func
e5d0: 74 69 6f 6e 28 61 72 72 61 79 2c 20 72 65 73 74  tion(array, rest
e5e0: 29 20 7b 0a 20 20 20 20 72 65 73 74 20 3d 20 66  ) {.    rest = f
e5f0: 6c 61 74 74 65 6e 28 72 65 73 74 2c 20 74 72 75  latten(rest, tru
e600: 65 2c 20 74 72 75 65 29 3b 0a 20 20 20 20 72 65  e, true);.    re
e610: 74 75 72 6e 20 66 69 6c 74 65 72 28 61 72 72 61  turn filter(arra
e620: 79 2c 20 66 75 6e 63 74 69 6f 6e 28 76 61 6c 75  y, function(valu
e630: 65 29 7b 0a 20 20 20 20 20 20 72 65 74 75 72 6e  e){.      return
e640: 20 21 63 6f 6e 74 61 69 6e 73 28 72 65 73 74 2c   !contains(rest,
e650: 20 76 61 6c 75 65 29 3b 0a 20 20 20 20 7d 29 3b   value);.    });
e660: 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 52 65 74  .  });..  // Ret
e670: 75 72 6e 20 61 20 76 65 72 73 69 6f 6e 20 6f 66  urn a version of
e680: 20 74 68 65 20 61 72 72 61 79 20 74 68 61 74 20   the array that 
e690: 64 6f 65 73 20 6e 6f 74 20 63 6f 6e 74 61 69 6e  does not contain
e6a0: 20 74 68 65 20 73 70 65 63 69 66 69 65 64 20 76   the specified v
e6b0: 61 6c 75 65 28 73 29 2e 0a 20 20 76 61 72 20 77  alue(s)..  var w
e6c0: 69 74 68 6f 75 74 20 3d 20 72 65 73 74 41 72 67  ithout = restArg
e6d0: 75 6d 65 6e 74 73 28 66 75 6e 63 74 69 6f 6e 28  uments(function(
e6e0: 61 72 72 61 79 2c 20 6f 74 68 65 72 41 72 72 61  array, otherArra
e6f0: 79 73 29 20 7b 0a 20 20 20 20 72 65 74 75 72 6e  ys) {.    return
e700: 20 64 69 66 66 65 72 65 6e 63 65 28 61 72 72 61   difference(arra
e710: 79 2c 20 6f 74 68 65 72 41 72 72 61 79 73 29 3b  y, otherArrays);
e720: 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 50 72 6f  .  });..  // Pro
e730: 64 75 63 65 20 61 20 64 75 70 6c 69 63 61 74 65  duce a duplicate
e740: 2d 66 72 65 65 20 76 65 72 73 69 6f 6e 20 6f 66  -free version of
e750: 20 74 68 65 20 61 72 72 61 79 2e 20 49 66 20 74   the array. If t
e760: 68 65 20 61 72 72 61 79 20 68 61 73 20 61 6c 72  he array has alr
e770: 65 61 64 79 0a 20 20 2f 2f 20 62 65 65 6e 20 73  eady.  // been s
e780: 6f 72 74 65 64 2c 20 79 6f 75 20 68 61 76 65 20  orted, you have 
e790: 74 68 65 20 6f 70 74 69 6f 6e 20 6f 66 20 75 73  the option of us
e7a0: 69 6e 67 20 61 20 66 61 73 74 65 72 20 61 6c 67  ing a faster alg
e7b0: 6f 72 69 74 68 6d 2e 0a 20 20 2f 2f 20 54 68 65  orithm..  // The
e7c0: 20 66 61 73 74 65 72 20 61 6c 67 6f 72 69 74 68   faster algorith
e7d0: 6d 20 77 69 6c 6c 20 6e 6f 74 20 77 6f 72 6b 20  m will not work 
e7e0: 77 69 74 68 20 61 6e 20 69 74 65 72 61 74 65 65  with an iteratee
e7f0: 20 69 66 20 74 68 65 20 69 74 65 72 61 74 65 65   if the iteratee
e800: 0a 20 20 2f 2f 20 69 73 20 6e 6f 74 20 61 20 6f  .  // is not a o
e810: 6e 65 2d 74 6f 2d 6f 6e 65 20 66 75 6e 63 74 69  ne-to-one functi
e820: 6f 6e 2c 20 73 6f 20 70 72 6f 76 69 64 69 6e 67  on, so providing
e830: 20 61 6e 20 69 74 65 72 61 74 65 65 20 77 69 6c   an iteratee wil
e840: 6c 20 64 69 73 61 62 6c 65 0a 20 20 2f 2f 20 74  l disable.  // t
e850: 68 65 20 66 61 73 74 65 72 20 61 6c 67 6f 72 69  he faster algori
e860: 74 68 6d 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20  thm..  function 
e870: 75 6e 69 71 28 61 72 72 61 79 2c 20 69 73 53 6f  uniq(array, isSo
e880: 72 74 65 64 2c 20 69 74 65 72 61 74 65 65 2c 20  rted, iteratee, 
e890: 63 6f 6e 74 65 78 74 29 20 7b 0a 20 20 20 20 69  context) {.    i
e8a0: 66 20 28 21 69 73 42 6f 6f 6c 65 61 6e 28 69 73  f (!isBoolean(is
e8b0: 53 6f 72 74 65 64 29 29 20 7b 0a 20 20 20 20 20  Sorted)) {.     
e8c0: 20 63 6f 6e 74 65 78 74 20 3d 20 69 74 65 72 61   context = itera
e8d0: 74 65 65 3b 0a 20 20 20 20 20 20 69 74 65 72 61  tee;.      itera
e8e0: 74 65 65 20 3d 20 69 73 53 6f 72 74 65 64 3b 0a  tee = isSorted;.
e8f0: 20 20 20 20 20 20 69 73 53 6f 72 74 65 64 20 3d        isSorted =
e900: 20 66 61 6c 73 65 3b 0a 20 20 20 20 7d 0a 20 20   false;.    }.  
e910: 20 20 69 66 20 28 69 74 65 72 61 74 65 65 20 21    if (iteratee !
e920: 3d 20 6e 75 6c 6c 29 20 69 74 65 72 61 74 65 65  = null) iteratee
e930: 20 3d 20 63 62 28 69 74 65 72 61 74 65 65 2c 20   = cb(iteratee, 
e940: 63 6f 6e 74 65 78 74 29 3b 0a 20 20 20 20 76 61  context);.    va
e950: 72 20 72 65 73 75 6c 74 20 3d 20 5b 5d 3b 0a 20  r result = [];. 
e960: 20 20 20 76 61 72 20 73 65 65 6e 20 3d 20 5b 5d     var seen = []
e970: 3b 0a 20 20 20 20 66 6f 72 20 28 76 61 72 20 69  ;.    for (var i
e980: 20 3d 20 30 2c 20 6c 65 6e 67 74 68 20 3d 20 67   = 0, length = g
e990: 65 74 4c 65 6e 67 74 68 28 61 72 72 61 79 29 3b  etLength(array);
e9a0: 20 69 20 3c 20 6c 65 6e 67 74 68 3b 20 69 2b 2b   i < length; i++
e9b0: 29 20 7b 0a 20 20 20 20 20 20 76 61 72 20 76 61  ) {.      var va
e9c0: 6c 75 65 20 3d 20 61 72 72 61 79 5b 69 5d 2c 0a  lue = array[i],.
e9d0: 20 20 20 20 20 20 20 20 20 20 63 6f 6d 70 75 74            comput
e9e0: 65 64 20 3d 20 69 74 65 72 61 74 65 65 20 3f 20  ed = iteratee ? 
e9f0: 69 74 65 72 61 74 65 65 28 76 61 6c 75 65 2c 20  iteratee(value, 
ea00: 69 2c 20 61 72 72 61 79 29 20 3a 20 76 61 6c 75  i, array) : valu
ea10: 65 3b 0a 20 20 20 20 20 20 69 66 20 28 69 73 53  e;.      if (isS
ea20: 6f 72 74 65 64 20 26 26 20 21 69 74 65 72 61 74  orted && !iterat
ea30: 65 65 29 20 7b 0a 20 20 20 20 20 20 20 20 69 66  ee) {.        if
ea40: 20 28 21 69 20 7c 7c 20 73 65 65 6e 20 21 3d 3d   (!i || seen !==
ea50: 20 63 6f 6d 70 75 74 65 64 29 20 72 65 73 75 6c   computed) resul
ea60: 74 2e 70 75 73 68 28 76 61 6c 75 65 29 3b 0a 20  t.push(value);. 
ea70: 20 20 20 20 20 20 20 73 65 65 6e 20 3d 20 63 6f         seen = co
ea80: 6d 70 75 74 65 64 3b 0a 20 20 20 20 20 20 7d 20  mputed;.      } 
ea90: 65 6c 73 65 20 69 66 20 28 69 74 65 72 61 74 65  else if (iterate
eaa0: 65 29 20 7b 0a 20 20 20 20 20 20 20 20 69 66 20  e) {.        if 
eab0: 28 21 63 6f 6e 74 61 69 6e 73 28 73 65 65 6e 2c  (!contains(seen,
eac0: 20 63 6f 6d 70 75 74 65 64 29 29 20 7b 0a 20 20   computed)) {.  
ead0: 20 20 20 20 20 20 20 20 73 65 65 6e 2e 70 75 73          seen.pus
eae0: 68 28 63 6f 6d 70 75 74 65 64 29 3b 0a 20 20 20  h(computed);.   
eaf0: 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 70 75         result.pu
eb00: 73 68 28 76 61 6c 75 65 29 3b 0a 20 20 20 20 20  sh(value);.     
eb10: 20 20 20 7d 0a 20 20 20 20 20 20 7d 20 65 6c 73     }.      } els
eb20: 65 20 69 66 20 28 21 63 6f 6e 74 61 69 6e 73 28  e if (!contains(
eb30: 72 65 73 75 6c 74 2c 20 76 61 6c 75 65 29 29 20  result, value)) 
eb40: 7b 0a 20 20 20 20 20 20 20 20 72 65 73 75 6c 74  {.        result
eb50: 2e 70 75 73 68 28 76 61 6c 75 65 29 3b 0a 20 20  .push(value);.  
eb60: 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20 20 20      }.    }.    
eb70: 72 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a 20  return result;. 
eb80: 20 7d 0a 0a 20 20 2f 2f 20 50 72 6f 64 75 63 65   }..  // Produce
eb90: 20 61 6e 20 61 72 72 61 79 20 74 68 61 74 20 63   an array that c
eba0: 6f 6e 74 61 69 6e 73 20 74 68 65 20 75 6e 69 6f  ontains the unio
ebb0: 6e 3a 20 65 61 63 68 20 64 69 73 74 69 6e 63 74  n: each distinct
ebc0: 20 65 6c 65 6d 65 6e 74 20 66 72 6f 6d 20 61 6c   element from al
ebd0: 6c 20 6f 66 0a 20 20 2f 2f 20 74 68 65 20 70 61  l of.  // the pa
ebe0: 73 73 65 64 2d 69 6e 20 61 72 72 61 79 73 2e 0a  ssed-in arrays..
ebf0: 20 20 76 61 72 20 75 6e 69 6f 6e 20 3d 20 72 65    var union = re
ec00: 73 74 41 72 67 75 6d 65 6e 74 73 28 66 75 6e 63  stArguments(func
ec10: 74 69 6f 6e 28 61 72 72 61 79 73 29 20 7b 0a 20  tion(arrays) {. 
ec20: 20 20 20 72 65 74 75 72 6e 20 75 6e 69 71 28 66     return uniq(f
ec30: 6c 61 74 74 65 6e 28 61 72 72 61 79 73 2c 20 74  latten(arrays, t
ec40: 72 75 65 2c 20 74 72 75 65 29 29 3b 0a 20 20 7d  rue, true));.  }
ec50: 29 3b 0a 0a 20 20 2f 2f 20 50 72 6f 64 75 63 65  );..  // Produce
ec60: 20 61 6e 20 61 72 72 61 79 20 74 68 61 74 20 63   an array that c
ec70: 6f 6e 74 61 69 6e 73 20 65 76 65 72 79 20 69 74  ontains every it
ec80: 65 6d 20 73 68 61 72 65 64 20 62 65 74 77 65 65  em shared betwee
ec90: 6e 20 61 6c 6c 20 74 68 65 0a 20 20 2f 2f 20 70  n all the.  // p
eca0: 61 73 73 65 64 2d 69 6e 20 61 72 72 61 79 73 2e  assed-in arrays.
ecb0: 0a 20 20 66 75 6e 63 74 69 6f 6e 20 69 6e 74 65  .  function inte
ecc0: 72 73 65 63 74 69 6f 6e 28 61 72 72 61 79 29 20  rsection(array) 
ecd0: 7b 0a 20 20 20 20 76 61 72 20 72 65 73 75 6c 74  {.    var result
ece0: 20 3d 20 5b 5d 3b 0a 20 20 20 20 76 61 72 20 61   = [];.    var a
ecf0: 72 67 73 4c 65 6e 67 74 68 20 3d 20 61 72 67 75  rgsLength = argu
ed00: 6d 65 6e 74 73 2e 6c 65 6e 67 74 68 3b 0a 20 20  ments.length;.  
ed10: 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30    for (var i = 0
ed20: 2c 20 6c 65 6e 67 74 68 20 3d 20 67 65 74 4c 65  , length = getLe
ed30: 6e 67 74 68 28 61 72 72 61 79 29 3b 20 69 20 3c  ngth(array); i <
ed40: 20 6c 65 6e 67 74 68 3b 20 69 2b 2b 29 20 7b 0a   length; i++) {.
ed50: 20 20 20 20 20 20 76 61 72 20 69 74 65 6d 20 3d        var item =
ed60: 20 61 72 72 61 79 5b 69 5d 3b 0a 20 20 20 20 20   array[i];.     
ed70: 20 69 66 20 28 63 6f 6e 74 61 69 6e 73 28 72 65   if (contains(re
ed80: 73 75 6c 74 2c 20 69 74 65 6d 29 29 20 63 6f 6e  sult, item)) con
ed90: 74 69 6e 75 65 3b 0a 20 20 20 20 20 20 76 61 72  tinue;.      var
eda0: 20 6a 3b 0a 20 20 20 20 20 20 66 6f 72 20 28 6a   j;.      for (j
edb0: 20 3d 20 31 3b 20 6a 20 3c 20 61 72 67 73 4c 65   = 1; j < argsLe
edc0: 6e 67 74 68 3b 20 6a 2b 2b 29 20 7b 0a 20 20 20  ngth; j++) {.   
edd0: 20 20 20 20 20 69 66 20 28 21 63 6f 6e 74 61 69       if (!contai
ede0: 6e 73 28 61 72 67 75 6d 65 6e 74 73 5b 6a 5d 2c  ns(arguments[j],
edf0: 20 69 74 65 6d 29 29 20 62 72 65 61 6b 3b 0a 20   item)) break;. 
ee00: 20 20 20 20 20 7d 0a 20 20 20 20 20 20 69 66 20       }.      if 
ee10: 28 6a 20 3d 3d 3d 20 61 72 67 73 4c 65 6e 67 74  (j === argsLengt
ee20: 68 29 20 72 65 73 75 6c 74 2e 70 75 73 68 28 69  h) result.push(i
ee30: 74 65 6d 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20  tem);.    }.    
ee40: 72 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a 20  return result;. 
ee50: 20 7d 0a 0a 20 20 2f 2f 20 43 6f 6d 70 6c 65 6d   }..  // Complem
ee60: 65 6e 74 20 6f 66 20 7a 69 70 2e 20 55 6e 7a 69  ent of zip. Unzi
ee70: 70 20 61 63 63 65 70 74 73 20 61 6e 20 61 72 72  p accepts an arr
ee80: 61 79 20 6f 66 20 61 72 72 61 79 73 20 61 6e 64  ay of arrays and
ee90: 20 67 72 6f 75 70 73 0a 20 20 2f 2f 20 65 61 63   groups.  // eac
eea0: 68 20 61 72 72 61 79 27 73 20 65 6c 65 6d 65 6e  h array's elemen
eeb0: 74 73 20 6f 6e 20 73 68 61 72 65 64 20 69 6e 64  ts on shared ind
eec0: 69 63 65 73 2e 0a 20 20 66 75 6e 63 74 69 6f 6e  ices..  function
eed0: 20 75 6e 7a 69 70 28 61 72 72 61 79 29 20 7b 0a   unzip(array) {.
eee0: 20 20 20 20 76 61 72 20 6c 65 6e 67 74 68 20 3d      var length =
eef0: 20 61 72 72 61 79 20 26 26 20 6d 61 78 28 61 72   array && max(ar
ef00: 72 61 79 2c 20 67 65 74 4c 65 6e 67 74 68 29 2e  ray, getLength).
ef10: 6c 65 6e 67 74 68 20 7c 7c 20 30 3b 0a 20 20 20  length || 0;.   
ef20: 20 76 61 72 20 72 65 73 75 6c 74 20 3d 20 41 72   var result = Ar
ef30: 72 61 79 28 6c 65 6e 67 74 68 29 3b 0a 0a 20 20  ray(length);..  
ef40: 20 20 66 6f 72 20 28 76 61 72 20 69 6e 64 65 78    for (var index
ef50: 20 3d 20 30 3b 20 69 6e 64 65 78 20 3c 20 6c 65   = 0; index < le
ef60: 6e 67 74 68 3b 20 69 6e 64 65 78 2b 2b 29 20 7b  ngth; index++) {
ef70: 0a 20 20 20 20 20 20 72 65 73 75 6c 74 5b 69 6e  .      result[in
ef80: 64 65 78 5d 20 3d 20 70 6c 75 63 6b 28 61 72 72  dex] = pluck(arr
ef90: 61 79 2c 20 69 6e 64 65 78 29 3b 0a 20 20 20 20  ay, index);.    
efa0: 7d 0a 20 20 20 20 72 65 74 75 72 6e 20 72 65 73  }.    return res
efb0: 75 6c 74 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 5a  ult;.  }..  // Z
efc0: 69 70 20 74 6f 67 65 74 68 65 72 20 6d 75 6c 74  ip together mult
efd0: 69 70 6c 65 20 6c 69 73 74 73 20 69 6e 74 6f 20  iple lists into 
efe0: 61 20 73 69 6e 67 6c 65 20 61 72 72 61 79 20 2d  a single array -
eff0: 2d 20 65 6c 65 6d 65 6e 74 73 20 74 68 61 74 20  - elements that 
f000: 73 68 61 72 65 0a 20 20 2f 2f 20 61 6e 20 69 6e  share.  // an in
f010: 64 65 78 20 67 6f 20 74 6f 67 65 74 68 65 72 2e  dex go together.
f020: 0a 20 20 76 61 72 20 7a 69 70 20 3d 20 72 65 73  .  var zip = res
f030: 74 41 72 67 75 6d 65 6e 74 73 28 75 6e 7a 69 70  tArguments(unzip
f040: 29 3b 0a 0a 20 20 2f 2f 20 43 6f 6e 76 65 72 74  );..  // Convert
f050: 73 20 6c 69 73 74 73 20 69 6e 74 6f 20 6f 62 6a  s lists into obj
f060: 65 63 74 73 2e 20 50 61 73 73 20 65 69 74 68 65  ects. Pass eithe
f070: 72 20 61 20 73 69 6e 67 6c 65 20 61 72 72 61 79  r a single array
f080: 20 6f 66 20 60 5b 6b 65 79 2c 20 76 61 6c 75 65   of `[key, value
f090: 5d 60 0a 20 20 2f 2f 20 70 61 69 72 73 2c 20 6f  ]`.  // pairs, o
f0a0: 72 20 74 77 6f 20 70 61 72 61 6c 6c 65 6c 20 61  r two parallel a
f0b0: 72 72 61 79 73 20 6f 66 20 74 68 65 20 73 61 6d  rrays of the sam
f0c0: 65 20 6c 65 6e 67 74 68 20 2d 2d 20 6f 6e 65 20  e length -- one 
f0d0: 6f 66 20 6b 65 79 73 2c 20 61 6e 64 20 6f 6e 65  of keys, and one
f0e0: 20 6f 66 0a 20 20 2f 2f 20 74 68 65 20 63 6f 72   of.  // the cor
f0f0: 72 65 73 70 6f 6e 64 69 6e 67 20 76 61 6c 75 65  responding value
f100: 73 2e 20 50 61 73 73 69 6e 67 20 62 79 20 70 61  s. Passing by pa
f110: 69 72 73 20 69 73 20 74 68 65 20 72 65 76 65 72  irs is the rever
f120: 73 65 20 6f 66 20 60 5f 2e 70 61 69 72 73 60 2e  se of `_.pairs`.
f130: 0a 20 20 66 75 6e 63 74 69 6f 6e 20 6f 62 6a 65  .  function obje
f140: 63 74 28 6c 69 73 74 2c 20 76 61 6c 75 65 73 29  ct(list, values)
f150: 20 7b 0a 20 20 20 20 76 61 72 20 72 65 73 75 6c   {.    var resul
f160: 74 20 3d 20 7b 7d 3b 0a 20 20 20 20 66 6f 72 20  t = {};.    for 
f170: 28 76 61 72 20 69 20 3d 20 30 2c 20 6c 65 6e 67  (var i = 0, leng
f180: 74 68 20 3d 20 67 65 74 4c 65 6e 67 74 68 28 6c  th = getLength(l
f190: 69 73 74 29 3b 20 69 20 3c 20 6c 65 6e 67 74 68  ist); i < length
f1a0: 3b 20 69 2b 2b 29 20 7b 0a 20 20 20 20 20 20 69  ; i++) {.      i
f1b0: 66 20 28 76 61 6c 75 65 73 29 20 7b 0a 20 20 20  f (values) {.   
f1c0: 20 20 20 20 20 72 65 73 75 6c 74 5b 6c 69 73 74       result[list
f1d0: 5b 69 5d 5d 20 3d 20 76 61 6c 75 65 73 5b 69 5d  [i]] = values[i]
f1e0: 3b 0a 20 20 20 20 20 20 7d 20 65 6c 73 65 20 7b  ;.      } else {
f1f0: 0a 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 5b  .        result[
f200: 6c 69 73 74 5b 69 5d 5b 30 5d 5d 20 3d 20 6c 69  list[i][0]] = li
f210: 73 74 5b 69 5d 5b 31 5d 3b 0a 20 20 20 20 20 20  st[i][1];.      
f220: 7d 0a 20 20 20 20 7d 0a 20 20 20 20 72 65 74 75  }.    }.    retu
f230: 72 6e 20 72 65 73 75 6c 74 3b 0a 20 20 7d 0a 0a  rn result;.  }..
f240: 20 20 2f 2f 20 47 65 6e 65 72 61 74 65 20 61 6e    // Generate an
f250: 20 69 6e 74 65 67 65 72 20 41 72 72 61 79 20 63   integer Array c
f260: 6f 6e 74 61 69 6e 69 6e 67 20 61 6e 20 61 72 69  ontaining an ari
f270: 74 68 6d 65 74 69 63 20 70 72 6f 67 72 65 73 73  thmetic progress
f280: 69 6f 6e 2e 20 41 20 70 6f 72 74 20 6f 66 0a 20  ion. A port of. 
f290: 20 2f 2f 20 74 68 65 20 6e 61 74 69 76 65 20 50   // the native P
f2a0: 79 74 68 6f 6e 20 60 72 61 6e 67 65 28 29 60 20  ython `range()` 
f2b0: 66 75 6e 63 74 69 6f 6e 2e 20 53 65 65 0a 20 20  function. See.  
f2c0: 2f 2f 20 5b 74 68 65 20 50 79 74 68 6f 6e 20 64  // [the Python d
f2d0: 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 5d 28 68 74  ocumentation](ht
f2e0: 74 70 73 3a 2f 2f 64 6f 63 73 2e 70 79 74 68 6f  tps://docs.pytho
f2f0: 6e 2e 6f 72 67 2f 6c 69 62 72 61 72 79 2f 66 75  n.org/library/fu
f300: 6e 63 74 69 6f 6e 73 2e 68 74 6d 6c 23 72 61 6e  nctions.html#ran
f310: 67 65 29 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20  ge)..  function 
f320: 72 61 6e 67 65 28 73 74 61 72 74 2c 20 73 74 6f  range(start, sto
f330: 70 2c 20 73 74 65 70 29 20 7b 0a 20 20 20 20 69  p, step) {.    i
f340: 66 20 28 73 74 6f 70 20 3d 3d 20 6e 75 6c 6c 29  f (stop == null)
f350: 20 7b 0a 20 20 20 20 20 20 73 74 6f 70 20 3d 20   {.      stop = 
f360: 73 74 61 72 74 20 7c 7c 20 30 3b 0a 20 20 20 20  start || 0;.    
f370: 20 20 73 74 61 72 74 20 3d 20 30 3b 0a 20 20 20    start = 0;.   
f380: 20 7d 0a 20 20 20 20 69 66 20 28 21 73 74 65 70   }.    if (!step
f390: 29 20 7b 0a 20 20 20 20 20 20 73 74 65 70 20 3d  ) {.      step =
f3a0: 20 73 74 6f 70 20 3c 20 73 74 61 72 74 20 3f 20   stop < start ? 
f3b0: 2d 31 20 3a 20 31 3b 0a 20 20 20 20 7d 0a 0a 20  -1 : 1;.    }.. 
f3c0: 20 20 20 76 61 72 20 6c 65 6e 67 74 68 20 3d 20     var length = 
f3d0: 4d 61 74 68 2e 6d 61 78 28 4d 61 74 68 2e 63 65  Math.max(Math.ce
f3e0: 69 6c 28 28 73 74 6f 70 20 2d 20 73 74 61 72 74  il((stop - start
f3f0: 29 20 2f 20 73 74 65 70 29 2c 20 30 29 3b 0a 20  ) / step), 0);. 
f400: 20 20 20 76 61 72 20 72 61 6e 67 65 20 3d 20 41     var range = A
f410: 72 72 61 79 28 6c 65 6e 67 74 68 29 3b 0a 0a 20  rray(length);.. 
f420: 20 20 20 66 6f 72 20 28 76 61 72 20 69 64 78 20     for (var idx 
f430: 3d 20 30 3b 20 69 64 78 20 3c 20 6c 65 6e 67 74  = 0; idx < lengt
f440: 68 3b 20 69 64 78 2b 2b 2c 20 73 74 61 72 74 20  h; idx++, start 
f450: 2b 3d 20 73 74 65 70 29 20 7b 0a 20 20 20 20 20  += step) {.     
f460: 20 72 61 6e 67 65 5b 69 64 78 5d 20 3d 20 73 74   range[idx] = st
f470: 61 72 74 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20  art;.    }..    
f480: 72 65 74 75 72 6e 20 72 61 6e 67 65 3b 0a 20 20  return range;.  
f490: 7d 0a 0a 20 20 2f 2f 20 43 68 75 6e 6b 20 61 20  }..  // Chunk a 
f4a0: 73 69 6e 67 6c 65 20 61 72 72 61 79 20 69 6e 74  single array int
f4b0: 6f 20 6d 75 6c 74 69 70 6c 65 20 61 72 72 61 79  o multiple array
f4c0: 73 2c 20 65 61 63 68 20 63 6f 6e 74 61 69 6e 69  s, each containi
f4d0: 6e 67 20 60 63 6f 75 6e 74 60 20 6f 72 20 66 65  ng `count` or fe
f4e0: 77 65 72 0a 20 20 2f 2f 20 69 74 65 6d 73 2e 0a  wer.  // items..
f4f0: 20 20 66 75 6e 63 74 69 6f 6e 20 63 68 75 6e 6b    function chunk
f500: 28 61 72 72 61 79 2c 20 63 6f 75 6e 74 29 20 7b  (array, count) {
f510: 0a 20 20 20 20 69 66 20 28 63 6f 75 6e 74 20 3d  .    if (count =
f520: 3d 20 6e 75 6c 6c 20 7c 7c 20 63 6f 75 6e 74 20  = null || count 
f530: 3c 20 31 29 20 72 65 74 75 72 6e 20 5b 5d 3b 0a  < 1) return [];.
f540: 20 20 20 20 76 61 72 20 72 65 73 75 6c 74 20 3d      var result =
f550: 20 5b 5d 3b 0a 20 20 20 20 76 61 72 20 69 20 3d   [];.    var i =
f560: 20 30 2c 20 6c 65 6e 67 74 68 20 3d 20 61 72 72   0, length = arr
f570: 61 79 2e 6c 65 6e 67 74 68 3b 0a 20 20 20 20 77  ay.length;.    w
f580: 68 69 6c 65 20 28 69 20 3c 20 6c 65 6e 67 74 68  hile (i < length
f590: 29 20 7b 0a 20 20 20 20 20 20 72 65 73 75 6c 74  ) {.      result
f5a0: 2e 70 75 73 68 28 73 6c 69 63 65 2e 63 61 6c 6c  .push(slice.call
f5b0: 28 61 72 72 61 79 2c 20 69 2c 20 69 20 2b 3d 20  (array, i, i += 
f5c0: 63 6f 75 6e 74 29 29 3b 0a 20 20 20 20 7d 0a 20  count));.    }. 
f5d0: 20 20 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74     return result
f5e0: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 48 65 6c 70  ;.  }..  // Help
f5f0: 65 72 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 63  er function to c
f600: 6f 6e 74 69 6e 75 65 20 63 68 61 69 6e 69 6e 67  ontinue chaining
f610: 20 69 6e 74 65 72 6d 65 64 69 61 74 65 20 72 65   intermediate re
f620: 73 75 6c 74 73 2e 0a 20 20 66 75 6e 63 74 69 6f  sults..  functio
f630: 6e 20 63 68 61 69 6e 52 65 73 75 6c 74 28 69 6e  n chainResult(in
f640: 73 74 61 6e 63 65 2c 20 6f 62 6a 29 20 7b 0a 20  stance, obj) {. 
f650: 20 20 20 72 65 74 75 72 6e 20 69 6e 73 74 61 6e     return instan
f660: 63 65 2e 5f 63 68 61 69 6e 20 3f 20 5f 28 6f 62  ce._chain ? _(ob
f670: 6a 29 2e 63 68 61 69 6e 28 29 20 3a 20 6f 62 6a  j).chain() : obj
f680: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 41 64 64 20  ;.  }..  // Add 
f690: 79 6f 75 72 20 6f 77 6e 20 63 75 73 74 6f 6d 20  your own custom 
f6a0: 66 75 6e 63 74 69 6f 6e 73 20 74 6f 20 74 68 65  functions to the
f6b0: 20 55 6e 64 65 72 73 63 6f 72 65 20 6f 62 6a 65   Underscore obje
f6c0: 63 74 2e 0a 20 20 66 75 6e 63 74 69 6f 6e 20 6d  ct..  function m
f6d0: 69 78 69 6e 28 6f 62 6a 29 20 7b 0a 20 20 20 20  ixin(obj) {.    
f6e0: 65 61 63 68 28 66 75 6e 63 74 69 6f 6e 73 28 6f  each(functions(o
f6f0: 62 6a 29 2c 20 66 75 6e 63 74 69 6f 6e 28 6e 61  bj), function(na
f700: 6d 65 29 20 7b 0a 20 20 20 20 20 20 76 61 72 20  me) {.      var 
f710: 66 75 6e 63 20 3d 20 5f 5b 6e 61 6d 65 5d 20 3d  func = _[name] =
f720: 20 6f 62 6a 5b 6e 61 6d 65 5d 3b 0a 20 20 20 20   obj[name];.    
f730: 20 20 5f 2e 70 72 6f 74 6f 74 79 70 65 5b 6e 61    _.prototype[na
f740: 6d 65 5d 20 3d 20 66 75 6e 63 74 69 6f 6e 28 29  me] = function()
f750: 20 7b 0a 20 20 20 20 20 20 20 20 76 61 72 20 61   {.        var a
f760: 72 67 73 20 3d 20 5b 74 68 69 73 2e 5f 77 72 61  rgs = [this._wra
f770: 70 70 65 64 5d 3b 0a 20 20 20 20 20 20 20 20 70  pped];.        p
f780: 75 73 68 2e 61 70 70 6c 79 28 61 72 67 73 2c 20  ush.apply(args, 
f790: 61 72 67 75 6d 65 6e 74 73 29 3b 0a 20 20 20 20  arguments);.    
f7a0: 20 20 20 20 72 65 74 75 72 6e 20 63 68 61 69 6e      return chain
f7b0: 52 65 73 75 6c 74 28 74 68 69 73 2c 20 66 75 6e  Result(this, fun
f7c0: 63 2e 61 70 70 6c 79 28 5f 2c 20 61 72 67 73 29  c.apply(_, args)
f7d0: 29 3b 0a 20 20 20 20 20 20 7d 3b 0a 20 20 20 20  );.      };.    
f7e0: 7d 29 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 5f  });.    return _
f7f0: 3b 0a 20 20 7d 0a 0a 20 20 2f 2f 20 41 64 64 20  ;.  }..  // Add 
f800: 61 6c 6c 20 6d 75 74 61 74 6f 72 20 60 41 72 72  all mutator `Arr
f810: 61 79 60 20 66 75 6e 63 74 69 6f 6e 73 20 74 6f  ay` functions to
f820: 20 74 68 65 20 77 72 61 70 70 65 72 2e 0a 20 20   the wrapper..  
f830: 65 61 63 68 28 5b 27 70 6f 70 27 2c 20 27 70 75  each(['pop', 'pu
f840: 73 68 27 2c 20 27 72 65 76 65 72 73 65 27 2c 20  sh', 'reverse', 
f850: 27 73 68 69 66 74 27 2c 20 27 73 6f 72 74 27 2c  'shift', 'sort',
f860: 20 27 73 70 6c 69 63 65 27 2c 20 27 75 6e 73 68   'splice', 'unsh
f870: 69 66 74 27 5d 2c 20 66 75 6e 63 74 69 6f 6e 28  ift'], function(
f880: 6e 61 6d 65 29 20 7b 0a 20 20 20 20 76 61 72 20  name) {.    var 
f890: 6d 65 74 68 6f 64 20 3d 20 41 72 72 61 79 50 72  method = ArrayPr
f8a0: 6f 74 6f 5b 6e 61 6d 65 5d 3b 0a 20 20 20 20 5f  oto[name];.    _
f8b0: 2e 70 72 6f 74 6f 74 79 70 65 5b 6e 61 6d 65 5d  .prototype[name]
f8c0: 20 3d 20 66 75 6e 63 74 69 6f 6e 28 29 20 7b 0a   = function() {.
f8d0: 20 20 20 20 20 20 76 61 72 20 6f 62 6a 20 3d 20        var obj = 
f8e0: 74 68 69 73 2e 5f 77 72 61 70 70 65 64 3b 0a 20  this._wrapped;. 
f8f0: 20 20 20 20 20 69 66 20 28 6f 62 6a 20 21 3d 20       if (obj != 
f900: 6e 75 6c 6c 29 20 7b 0a 20 20 20 20 20 20 20 20  null) {.        
f910: 6d 65 74 68 6f 64 2e 61 70 70 6c 79 28 6f 62 6a  method.apply(obj
f920: 2c 20 61 72 67 75 6d 65 6e 74 73 29 3b 0a 20 20  , arguments);.  
f930: 20 20 20 20 20 20 69 66 20 28 28 6e 61 6d 65 20        if ((name 
f940: 3d 3d 3d 20 27 73 68 69 66 74 27 20 7c 7c 20 6e  === 'shift' || n
f950: 61 6d 65 20 3d 3d 3d 20 27 73 70 6c 69 63 65 27  ame === 'splice'
f960: 29 20 26 26 20 6f 62 6a 2e 6c 65 6e 67 74 68 20  ) && obj.length 
f970: 3d 3d 3d 20 30 29 20 7b 0a 20 20 20 20 20 20 20  === 0) {.       
f980: 20 20 20 64 65 6c 65 74 65 20 6f 62 6a 5b 30 5d     delete obj[0]
f990: 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20  ;.        }.    
f9a0: 20 20 7d 0a 20 20 20 20 20 20 72 65 74 75 72 6e    }.      return
f9b0: 20 63 68 61 69 6e 52 65 73 75 6c 74 28 74 68 69   chainResult(thi
f9c0: 73 2c 20 6f 62 6a 29 3b 0a 20 20 20 20 7d 3b 0a  s, obj);.    };.
f9d0: 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 41 64 64 20    });..  // Add 
f9e0: 61 6c 6c 20 61 63 63 65 73 73 6f 72 20 60 41 72  all accessor `Ar
f9f0: 72 61 79 60 20 66 75 6e 63 74 69 6f 6e 73 20 74  ray` functions t
fa00: 6f 20 74 68 65 20 77 72 61 70 70 65 72 2e 0a 20  o the wrapper.. 
fa10: 20 65 61 63 68 28 5b 27 63 6f 6e 63 61 74 27 2c   each(['concat',
fa20: 20 27 6a 6f 69 6e 27 2c 20 27 73 6c 69 63 65 27   'join', 'slice'
fa30: 5d 2c 20 66 75 6e 63 74 69 6f 6e 28 6e 61 6d 65  ], function(name
fa40: 29 20 7b 0a 20 20 20 20 76 61 72 20 6d 65 74 68  ) {.    var meth
fa50: 6f 64 20 3d 20 41 72 72 61 79 50 72 6f 74 6f 5b  od = ArrayProto[
fa60: 6e 61 6d 65 5d 3b 0a 20 20 20 20 5f 2e 70 72 6f  name];.    _.pro
fa70: 74 6f 74 79 70 65 5b 6e 61 6d 65 5d 20 3d 20 66  totype[name] = f
fa80: 75 6e 63 74 69 6f 6e 28 29 20 7b 0a 20 20 20 20  unction() {.    
fa90: 20 20 76 61 72 20 6f 62 6a 20 3d 20 74 68 69 73    var obj = this
faa0: 2e 5f 77 72 61 70 70 65 64 3b 0a 20 20 20 20 20  ._wrapped;.     
fab0: 20 69 66 20 28 6f 62 6a 20 21 3d 20 6e 75 6c 6c   if (obj != null
fac0: 29 20 6f 62 6a 20 3d 20 6d 65 74 68 6f 64 2e 61  ) obj = method.a
fad0: 70 70 6c 79 28 6f 62 6a 2c 20 61 72 67 75 6d 65  pply(obj, argume
fae0: 6e 74 73 29 3b 0a 20 20 20 20 20 20 72 65 74 75  nts);.      retu
faf0: 72 6e 20 63 68 61 69 6e 52 65 73 75 6c 74 28 74  rn chainResult(t
fb00: 68 69 73 2c 20 6f 62 6a 29 3b 0a 20 20 20 20 7d  his, obj);.    }
fb10: 3b 0a 20 20 7d 29 3b 0a 0a 20 20 2f 2f 20 4e 61  ;.  });..  // Na
fb20: 6d 65 64 20 45 78 70 6f 72 74 73 0a 0a 20 20 76  med Exports..  v
fb30: 61 72 20 61 6c 6c 45 78 70 6f 72 74 73 20 3d 20  ar allExports = 
fb40: 7b 0a 20 20 20 20 5f 5f 70 72 6f 74 6f 5f 5f 3a  {.    __proto__:
fb50: 20 6e 75 6c 6c 2c 0a 20 20 20 20 56 45 52 53 49   null,.    VERSI
fb60: 4f 4e 3a 20 56 45 52 53 49 4f 4e 2c 0a 20 20 20  ON: VERSION,.   
fb70: 20 72 65 73 74 41 72 67 75 6d 65 6e 74 73 3a 20   restArguments: 
fb80: 72 65 73 74 41 72 67 75 6d 65 6e 74 73 2c 0a 20  restArguments,. 
fb90: 20 20 20 69 73 4f 62 6a 65 63 74 3a 20 69 73 4f     isObject: isO
fba0: 62 6a 65 63 74 2c 0a 20 20 20 20 69 73 4e 75 6c  bject,.    isNul
fbb0: 6c 3a 20 69 73 4e 75 6c 6c 2c 0a 20 20 20 20 69  l: isNull,.    i
fbc0: 73 55 6e 64 65 66 69 6e 65 64 3a 20 69 73 55 6e  sUndefined: isUn
fbd0: 64 65 66 69 6e 65 64 2c 0a 20 20 20 20 69 73 42  defined,.    isB
fbe0: 6f 6f 6c 65 61 6e 3a 20 69 73 42 6f 6f 6c 65 61  oolean: isBoolea
fbf0: 6e 2c 0a 20 20 20 20 69 73 45 6c 65 6d 65 6e 74  n,.    isElement
fc00: 3a 20 69 73 45 6c 65 6d 65 6e 74 2c 0a 20 20 20  : isElement,.   
fc10: 20 69 73 53 74 72 69 6e 67 3a 20 69 73 53 74 72   isString: isStr
fc20: 69 6e 67 2c 0a 20 20 20 20 69 73 4e 75 6d 62 65  ing,.    isNumbe
fc30: 72 3a 20 69 73 4e 75 6d 62 65 72 2c 0a 20 20 20  r: isNumber,.   
fc40: 20 69 73 44 61 74 65 3a 20 69 73 44 61 74 65 2c   isDate: isDate,
fc50: 0a 20 20 20 20 69 73 52 65 67 45 78 70 3a 20 69  .    isRegExp: i
fc60: 73 52 65 67 45 78 70 2c 0a 20 20 20 20 69 73 45  sRegExp,.    isE
fc70: 72 72 6f 72 3a 20 69 73 45 72 72 6f 72 2c 0a 20  rror: isError,. 
fc80: 20 20 20 69 73 53 79 6d 62 6f 6c 3a 20 69 73 53     isSymbol: isS
fc90: 79 6d 62 6f 6c 2c 0a 20 20 20 20 69 73 41 72 72  ymbol,.    isArr
fca0: 61 79 42 75 66 66 65 72 3a 20 69 73 41 72 72 61  ayBuffer: isArra
fcb0: 79 42 75 66 66 65 72 2c 0a 20 20 20 20 69 73 44  yBuffer,.    isD
fcc0: 61 74 61 56 69 65 77 3a 20 69 73 44 61 74 61 56  ataView: isDataV
fcd0: 69 65 77 24 31 2c 0a 20 20 20 20 69 73 41 72 72  iew$1,.    isArr
fce0: 61 79 3a 20 69 73 41 72 72 61 79 2c 0a 20 20 20  ay: isArray,.   
fcf0: 20 69 73 46 75 6e 63 74 69 6f 6e 3a 20 69 73 46   isFunction: isF
fd00: 75 6e 63 74 69 6f 6e 24 31 2c 0a 20 20 20 20 69  unction$1,.    i
fd10: 73 41 72 67 75 6d 65 6e 74 73 3a 20 69 73 41 72  sArguments: isAr
fd20: 67 75 6d 65 6e 74 73 24 31 2c 0a 20 20 20 20 69  guments$1,.    i
fd30: 73 46 69 6e 69 74 65 3a 20 69 73 46 69 6e 69 74  sFinite: isFinit
fd40: 65 24 31 2c 0a 20 20 20 20 69 73 4e 61 4e 3a 20  e$1,.    isNaN: 
fd50: 69 73 4e 61 4e 24 31 2c 0a 20 20 20 20 69 73 54  isNaN$1,.    isT
fd60: 79 70 65 64 41 72 72 61 79 3a 20 69 73 54 79 70  ypedArray: isTyp
fd70: 65 64 41 72 72 61 79 24 31 2c 0a 20 20 20 20 69  edArray$1,.    i
fd80: 73 45 6d 70 74 79 3a 20 69 73 45 6d 70 74 79 2c  sEmpty: isEmpty,
fd90: 0a 20 20 20 20 69 73 4d 61 74 63 68 3a 20 69 73  .    isMatch: is
fda0: 4d 61 74 63 68 2c 0a 20 20 20 20 69 73 45 71 75  Match,.    isEqu
fdb0: 61 6c 3a 20 69 73 45 71 75 61 6c 2c 0a 20 20 20  al: isEqual,.   
fdc0: 20 69 73 4d 61 70 3a 20 69 73 4d 61 70 2c 0a 20   isMap: isMap,. 
fdd0: 20 20 20 69 73 57 65 61 6b 4d 61 70 3a 20 69 73     isWeakMap: is
fde0: 57 65 61 6b 4d 61 70 2c 0a 20 20 20 20 69 73 53  WeakMap,.    isS
fdf0: 65 74 3a 20 69 73 53 65 74 2c 0a 20 20 20 20 69  et: isSet,.    i
fe00: 73 57 65 61 6b 53 65 74 3a 20 69 73 57 65 61 6b  sWeakSet: isWeak
fe10: 53 65 74 2c 0a 20 20 20 20 6b 65 79 73 3a 20 6b  Set,.    keys: k
fe20: 65 79 73 2c 0a 20 20 20 20 61 6c 6c 4b 65 79 73  eys,.    allKeys
fe30: 3a 20 61 6c 6c 4b 65 79 73 2c 0a 20 20 20 20 76  : allKeys,.    v
fe40: 61 6c 75 65 73 3a 20 76 61 6c 75 65 73 2c 0a 20  alues: values,. 
fe50: 20 20 20 70 61 69 72 73 3a 20 70 61 69 72 73 2c     pairs: pairs,
fe60: 0a 20 20 20 20 69 6e 76 65 72 74 3a 20 69 6e 76  .    invert: inv
fe70: 65 72 74 2c 0a 20 20 20 20 66 75 6e 63 74 69 6f  ert,.    functio
fe80: 6e 73 3a 20 66 75 6e 63 74 69 6f 6e 73 2c 0a 20  ns: functions,. 
fe90: 20 20 20 6d 65 74 68 6f 64 73 3a 20 66 75 6e 63     methods: func
fea0: 74 69 6f 6e 73 2c 0a 20 20 20 20 65 78 74 65 6e  tions,.    exten
feb0: 64 3a 20 65 78 74 65 6e 64 2c 0a 20 20 20 20 65  d: extend,.    e
fec0: 78 74 65 6e 64 4f 77 6e 3a 20 65 78 74 65 6e 64  xtendOwn: extend
fed0: 4f 77 6e 2c 0a 20 20 20 20 61 73 73 69 67 6e 3a  Own,.    assign:
fee0: 20 65 78 74 65 6e 64 4f 77 6e 2c 0a 20 20 20 20   extendOwn,.    
fef0: 64 65 66 61 75 6c 74 73 3a 20 64 65 66 61 75 6c  defaults: defaul
ff00: 74 73 2c 0a 20 20 20 20 63 72 65 61 74 65 3a 20  ts,.    create: 
ff10: 63 72 65 61 74 65 2c 0a 20 20 20 20 63 6c 6f 6e  create,.    clon
ff20: 65 3a 20 63 6c 6f 6e 65 2c 0a 20 20 20 20 74 61  e: clone,.    ta
ff30: 70 3a 20 74 61 70 2c 0a 20 20 20 20 67 65 74 3a  p: tap,.    get:
ff40: 20 67 65 74 2c 0a 20 20 20 20 68 61 73 3a 20 68   get,.    has: h
ff50: 61 73 24 31 2c 0a 20 20 20 20 6d 61 70 4f 62 6a  as$1,.    mapObj
ff60: 65 63 74 3a 20 6d 61 70 4f 62 6a 65 63 74 2c 0a  ect: mapObject,.
ff70: 20 20 20 20 69 64 65 6e 74 69 74 79 3a 20 69 64      identity: id
ff80: 65 6e 74 69 74 79 2c 0a 20 20 20 20 63 6f 6e 73  entity,.    cons
ff90: 74 61 6e 74 3a 20 63 6f 6e 73 74 61 6e 74 2c 0a  tant: constant,.
ffa0: 20 20 20 20 6e 6f 6f 70 3a 20 6e 6f 6f 70 2c 0a      noop: noop,.
ffb0: 20 20 20 20 74 6f 50 61 74 68 3a 20 74 6f 50 61      toPath: toPa
ffc0: 74 68 2c 0a 20 20 20 20 70 72 6f 70 65 72 74 79  th,.    property
ffd0: 3a 20 70 72 6f 70 65 72 74 79 2c 0a 20 20 20 20  : property,.    
ffe0: 70 72 6f 70 65 72 74 79 4f 66 3a 20 70 72 6f 70  propertyOf: prop
fff0: 65 72 74 79 4f 66 2c 0a 20 20 20 20 6d 61 74 63  ertyOf,.    matc
10000 68 65 72 3a 20 6d 61 74 63 68 65 72 2c 0a 20 20  her: matcher,.  
10010 20 20 6d 61 74 63 68 65 73 3a 20 6d 61 74 63 68    matches: match
10020 65 72 2c 0a 20 20 20 20 74 69 6d 65 73 3a 20 74  er,.    times: t
10030 69 6d 65 73 2c 0a 20 20 20 20 72 61 6e 64 6f 6d  imes,.    random
10040 3a 20 72 61 6e 64 6f 6d 2c 0a 20 20 20 20 6e 6f  : random,.    no
10050 77 3a 20 6e 6f 77 2c 0a 20 20 20 20 65 73 63 61  w: now,.    esca
10060 70 65 3a 20 5f 65 73 63 61 70 65 2c 0a 20 20 20  pe: _escape,.   
10070 20 75 6e 65 73 63 61 70 65 3a 20 5f 75 6e 65 73   unescape: _unes
10080 63 61 70 65 2c 0a 20 20 20 20 74 65 6d 70 6c 61  cape,.    templa
10090 74 65 53 65 74 74 69 6e 67 73 3a 20 74 65 6d 70  teSettings: temp
100a0 6c 61 74 65 53 65 74 74 69 6e 67 73 2c 0a 20 20  lateSettings,.  
100b0 20 20 74 65 6d 70 6c 61 74 65 3a 20 74 65 6d 70    template: temp
100c0 6c 61 74 65 2c 0a 20 20 20 20 72 65 73 75 6c 74  late,.    result
100d0 3a 20 72 65 73 75 6c 74 2c 0a 20 20 20 20 75 6e  : result,.    un
100e0 69 71 75 65 49 64 3a 20 75 6e 69 71 75 65 49 64  iqueId: uniqueId
100f0 2c 0a 20 20 20 20 63 68 61 69 6e 3a 20 63 68 61  ,.    chain: cha
10100 69 6e 2c 0a 20 20 20 20 69 74 65 72 61 74 65 65  in,.    iteratee
10110 3a 20 69 74 65 72 61 74 65 65 2c 0a 20 20 20 20  : iteratee,.    
10120 70 61 72 74 69 61 6c 3a 20 70 61 72 74 69 61 6c  partial: partial
10130 2c 0a 20 20 20 20 62 69 6e 64 3a 20 62 69 6e 64  ,.    bind: bind
10140 2c 0a 20 20 20 20 62 69 6e 64 41 6c 6c 3a 20 62  ,.    bindAll: b
10150 69 6e 64 41 6c 6c 2c 0a 20 20 20 20 6d 65 6d 6f  indAll,.    memo
10160 69 7a 65 3a 20 6d 65 6d 6f 69 7a 65 2c 0a 20 20  ize: memoize,.  
10170 20 20 64 65 6c 61 79 3a 20 64 65 6c 61 79 2c 0a    delay: delay,.
10180 20 20 20 20 64 65 66 65 72 3a 20 64 65 66 65 72      defer: defer
10190 2c 0a 20 20 20 20 74 68 72 6f 74 74 6c 65 3a 20  ,.    throttle: 
101a0 74 68 72 6f 74 74 6c 65 2c 0a 20 20 20 20 64 65  throttle,.    de
101b0 62 6f 75 6e 63 65 3a 20 64 65 62 6f 75 6e 63 65  bounce: debounce
101c0 2c 0a 20 20 20 20 77 72 61 70 3a 20 77 72 61 70  ,.    wrap: wrap
101d0 2c 0a 20 20 20 20 6e 65 67 61 74 65 3a 20 6e 65  ,.    negate: ne
101e0 67 61 74 65 2c 0a 20 20 20 20 63 6f 6d 70 6f 73  gate,.    compos
101f0 65 3a 20 63 6f 6d 70 6f 73 65 2c 0a 20 20 20 20  e: compose,.    
10200 61 66 74 65 72 3a 20 61 66 74 65 72 2c 0a 20 20  after: after,.  
10210 20 20 62 65 66 6f 72 65 3a 20 62 65 66 6f 72 65    before: before
10220 2c 0a 20 20 20 20 6f 6e 63 65 3a 20 6f 6e 63 65  ,.    once: once
10230 2c 0a 20 20 20 20 66 69 6e 64 4b 65 79 3a 20 66  ,.    findKey: f
10240 69 6e 64 4b 65 79 2c 0a 20 20 20 20 66 69 6e 64  indKey,.    find
10250 49 6e 64 65 78 3a 20 66 69 6e 64 49 6e 64 65 78  Index: findIndex
10260 2c 0a 20 20 20 20 66 69 6e 64 4c 61 73 74 49 6e  ,.    findLastIn
10270 64 65 78 3a 20 66 69 6e 64 4c 61 73 74 49 6e 64  dex: findLastInd
10280 65 78 2c 0a 20 20 20 20 73 6f 72 74 65 64 49 6e  ex,.    sortedIn
10290 64 65 78 3a 20 73 6f 72 74 65 64 49 6e 64 65 78  dex: sortedIndex
102a0 2c 0a 20 20 20 20 69 6e 64 65 78 4f 66 3a 20 69  ,.    indexOf: i
102b0 6e 64 65 78 4f 66 2c 0a 20 20 20 20 6c 61 73 74  ndexOf,.    last
102c0 49 6e 64 65 78 4f 66 3a 20 6c 61 73 74 49 6e 64  IndexOf: lastInd
102d0 65 78 4f 66 2c 0a 20 20 20 20 66 69 6e 64 3a 20  exOf,.    find: 
102e0 66 69 6e 64 2c 0a 20 20 20 20 64 65 74 65 63 74  find,.    detect
102f0 3a 20 66 69 6e 64 2c 0a 20 20 20 20 66 69 6e 64  : find,.    find
10300 57 68 65 72 65 3a 20 66 69 6e 64 57 68 65 72 65  Where: findWhere
10310 2c 0a 20 20 20 20 65 61 63 68 3a 20 65 61 63 68  ,.    each: each
10320 2c 0a 20 20 20 20 66 6f 72 45 61 63 68 3a 20 65  ,.    forEach: e
10330 61 63 68 2c 0a 20 20 20 20 6d 61 70 3a 20 6d 61  ach,.    map: ma
10340 70 2c 0a 20 20 20 20 63 6f 6c 6c 65 63 74 3a 20  p,.    collect: 
10350 6d 61 70 2c 0a 20 20 20 20 72 65 64 75 63 65 3a  map,.    reduce:
10360 20 72 65 64 75 63 65 2c 0a 20 20 20 20 66 6f 6c   reduce,.    fol
10370 64 6c 3a 20 72 65 64 75 63 65 2c 0a 20 20 20 20  dl: reduce,.    
10380 69 6e 6a 65 63 74 3a 20 72 65 64 75 63 65 2c 0a  inject: reduce,.
10390 20 20 20 20 72 65 64 75 63 65 52 69 67 68 74 3a      reduceRight:
103a0 20 72 65 64 75 63 65 52 69 67 68 74 2c 0a 20 20   reduceRight,.  
103b0 20 20 66 6f 6c 64 72 3a 20 72 65 64 75 63 65 52    foldr: reduceR
103c0 69 67 68 74 2c 0a 20 20 20 20 66 69 6c 74 65 72  ight,.    filter
103d0 3a 20 66 69 6c 74 65 72 2c 0a 20 20 20 20 73 65  : filter,.    se
103e0 6c 65 63 74 3a 20 66 69 6c 74 65 72 2c 0a 20 20  lect: filter,.  
103f0 20 20 72 65 6a 65 63 74 3a 20 72 65 6a 65 63 74    reject: reject
10400 2c 0a 20 20 20 20 65 76 65 72 79 3a 20 65 76 65  ,.    every: eve
10410 72 79 2c 0a 20 20 20 20 61 6c 6c 3a 20 65 76 65  ry,.    all: eve
10420 72 79 2c 0a 20 20 20 20 73 6f 6d 65 3a 20 73 6f  ry,.    some: so
10430 6d 65 2c 0a 20 20 20 20 61 6e 79 3a 20 73 6f 6d  me,.    any: som
10440 65 2c 0a 20 20 20 20 63 6f 6e 74 61 69 6e 73 3a  e,.    contains:
10450 20 63 6f 6e 74 61 69 6e 73 2c 0a 20 20 20 20 69   contains,.    i
10460 6e 63 6c 75 64 65 73 3a 20 63 6f 6e 74 61 69 6e  ncludes: contain
10470 73 2c 0a 20 20 20 20 69 6e 63 6c 75 64 65 3a 20  s,.    include: 
10480 63 6f 6e 74 61 69 6e 73 2c 0a 20 20 20 20 69 6e  contains,.    in
10490 76 6f 6b 65 3a 20 69 6e 76 6f 6b 65 2c 0a 20 20  voke: invoke,.  
104a0 20 20 70 6c 75 63 6b 3a 20 70 6c 75 63 6b 2c 0a    pluck: pluck,.
104b0 20 20 20 20 77 68 65 72 65 3a 20 77 68 65 72 65      where: where
104c0 2c 0a 20 20 20 20 6d 61 78 3a 20 6d 61 78 2c 0a  ,.    max: max,.
104d0 20 20 20 20 6d 69 6e 3a 20 6d 69 6e 2c 0a 20 20      min: min,.  
104e0 20 20 73 68 75 66 66 6c 65 3a 20 73 68 75 66 66    shuffle: shuff
104f0 6c 65 2c 0a 20 20 20 20 73 61 6d 70 6c 65 3a 20  le,.    sample: 
10500 73 61 6d 70 6c 65 2c 0a 20 20 20 20 73 6f 72 74  sample,.    sort
10510 42 79 3a 20 73 6f 72 74 42 79 2c 0a 20 20 20 20  By: sortBy,.    
10520 67 72 6f 75 70 42 79 3a 20 67 72 6f 75 70 42 79  groupBy: groupBy
10530 2c 0a 20 20 20 20 69 6e 64 65 78 42 79 3a 20 69  ,.    indexBy: i
10540 6e 64 65 78 42 79 2c 0a 20 20 20 20 63 6f 75 6e  ndexBy,.    coun
10550 74 42 79 3a 20 63 6f 75 6e 74 42 79 2c 0a 20 20  tBy: countBy,.  
10560 20 20 70 61 72 74 69 74 69 6f 6e 3a 20 70 61 72    partition: par
10570 74 69 74 69 6f 6e 2c 0a 20 20 20 20 74 6f 41 72  tition,.    toAr
10580 72 61 79 3a 20 74 6f 41 72 72 61 79 2c 0a 20 20  ray: toArray,.  
10590 20 20 73 69 7a 65 3a 20 73 69 7a 65 2c 0a 20 20    size: size,.  
105a0 20 20 70 69 63 6b 3a 20 70 69 63 6b 2c 0a 20 20    pick: pick,.  
105b0 20 20 6f 6d 69 74 3a 20 6f 6d 69 74 2c 0a 20 20    omit: omit,.  
105c0 20 20 66 69 72 73 74 3a 20 66 69 72 73 74 2c 0a    first: first,.
105d0 20 20 20 20 68 65 61 64 3a 20 66 69 72 73 74 2c      head: first,
105e0 0a 20 20 20 20 74 61 6b 65 3a 20 66 69 72 73 74  .    take: first
105f0 2c 0a 20 20 20 20 69 6e 69 74 69 61 6c 3a 20 69  ,.    initial: i
10600 6e 69 74 69 61 6c 2c 0a 20 20 20 20 6c 61 73 74  nitial,.    last
10610 3a 20 6c 61 73 74 2c 0a 20 20 20 20 72 65 73 74  : last,.    rest
10620 3a 20 72 65 73 74 2c 0a 20 20 20 20 74 61 69 6c  : rest,.    tail
10630 3a 20 72 65 73 74 2c 0a 20 20 20 20 64 72 6f 70  : rest,.    drop
10640 3a 20 72 65 73 74 2c 0a 20 20 20 20 63 6f 6d 70  : rest,.    comp
10650 61 63 74 3a 20 63 6f 6d 70 61 63 74 2c 0a 20 20  act: compact,.  
10660 20 20 66 6c 61 74 74 65 6e 3a 20 66 6c 61 74 74    flatten: flatt
10670 65 6e 24 31 2c 0a 20 20 20 20 77 69 74 68 6f 75  en$1,.    withou
10680 74 3a 20 77 69 74 68 6f 75 74 2c 0a 20 20 20 20  t: without,.    
10690 75 6e 69 71 3a 20 75 6e 69 71 2c 0a 20 20 20 20  uniq: uniq,.    
106a0 75 6e 69 71 75 65 3a 20 75 6e 69 71 2c 0a 20 20  unique: uniq,.  
106b0 20 20 75 6e 69 6f 6e 3a 20 75 6e 69 6f 6e 2c 0a    union: union,.
106c0 20 20 20 20 69 6e 74 65 72 73 65 63 74 69 6f 6e      intersection
106d0 3a 20 69 6e 74 65 72 73 65 63 74 69 6f 6e 2c 0a  : intersection,.
106e0 20 20 20 20 64 69 66 66 65 72 65 6e 63 65 3a 20      difference: 
106f0 64 69 66 66 65 72 65 6e 63 65 2c 0a 20 20 20 20  difference,.    
10700 75 6e 7a 69 70 3a 20 75 6e 7a 69 70 2c 0a 20 20  unzip: unzip,.  
10710 20 20 74 72 61 6e 73 70 6f 73 65 3a 20 75 6e 7a    transpose: unz
10720 69 70 2c 0a 20 20 20 20 7a 69 70 3a 20 7a 69 70  ip,.    zip: zip
10730 2c 0a 20 20 20 20 6f 62 6a 65 63 74 3a 20 6f 62  ,.    object: ob
10740 6a 65 63 74 2c 0a 20 20 20 20 72 61 6e 67 65 3a  ject,.    range:
10750 20 72 61 6e 67 65 2c 0a 20 20 20 20 63 68 75 6e   range,.    chun
10760 6b 3a 20 63 68 75 6e 6b 2c 0a 20 20 20 20 6d 69  k: chunk,.    mi
10770 78 69 6e 3a 20 6d 69 78 69 6e 2c 0a 20 20 20 20  xin: mixin,.    
10780 27 64 65 66 61 75 6c 74 27 3a 20 5f 0a 20 20 7d  'default': _.  }
10790 3b 0a 0a 20 20 2f 2f 20 44 65 66 61 75 6c 74 20  ;..  // Default 
107a0 45 78 70 6f 72 74 0a 0a 20 20 2f 2f 20 41 64 64  Export..  // Add
107b0 20 61 6c 6c 20 6f 66 20 74 68 65 20 55 6e 64 65   all of the Unde
107c0 72 73 63 6f 72 65 20 66 75 6e 63 74 69 6f 6e 73  rscore functions
107d0 20 74 6f 20 74 68 65 20 77 72 61 70 70 65 72 20   to the wrapper 
107e0 6f 62 6a 65 63 74 2e 0a 20 20 76 61 72 20 5f 24  object..  var _$
107f0 31 20 3d 20 6d 69 78 69 6e 28 61 6c 6c 45 78 70  1 = mixin(allExp
10800 6f 72 74 73 29 3b 0a 20 20 2f 2f 20 4c 65 67 61  orts);.  // Lega
10810 63 79 20 4e 6f 64 65 2e 6a 73 20 41 50 49 2e 0a  cy Node.js API..
10820 20 20 5f 24 31 2e 5f 20 3d 20 5f 24 31 3b 0a 0a    _$1._ = _$1;..
10830 20 20 72 65 74 75 72 6e 20 5f 24 31 3b 0a 0a 7d    return _$1;..}
10840 29 29 29 3b 0a 2f 2f 23 20 73 6f 75 72 63 65 4d  )));.//# sourceM
10850 61 70 70 69 6e 67 55 52 4c 3d 75 6e 64 65 72 73  appingURL=unders
10860 63 6f 72 65 2e 6a 73 2e 6d 61 70 0a              core.js.map.