UNPKG

903 kBJavaScriptView Raw
1/* eslint-disable */
2import crypto from 'crypto';
3import { emptyDirSync, readJsonSync, writeJsonSync, ensureFileSync, removeSync, pathExistsSync, readdirSync as readdirSync$1, statSync } from 'fs-extra';
4import fs, { existsSync, readdirSync, renameSync, readFileSync } from 'fs';
5import require$$0 from 'util';
6import os from 'os';
7import path, { normalize as normalize$1, join, dirname, resolve, relative } from 'path';
8import { sync as sync$4 } from 'resolve';
9import { createFilter as createFilter$1 } from '@rollup/pluginutils';
10
11var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
13function createCommonjsModule(fn) {
14 var module = { exports: {} };
15 return fn(module, module.exports), module.exports;
16}
17
18function commonjsRequire (target) {
19 throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.');
20}
21
22/**
23 * @license
24 * Lodash <https://lodash.com/>
25 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
26 * Released under MIT license <https://lodash.com/license>
27 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
28 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
29 */
30
31var lodash = createCommonjsModule(function (module, exports) {
32(function() {
33
34 /** Used as a safe reference for `undefined` in pre-ES5 environments. */
35 var undefined$1;
36
37 /** Used as the semantic version number. */
38 var VERSION = '4.17.20';
39
40 /** Used as the size to enable large array optimizations. */
41 var LARGE_ARRAY_SIZE = 200;
42
43 /** Error message constants. */
44 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
45 FUNC_ERROR_TEXT = 'Expected a function';
46
47 /** Used to stand-in for `undefined` hash values. */
48 var HASH_UNDEFINED = '__lodash_hash_undefined__';
49
50 /** Used as the maximum memoize cache size. */
51 var MAX_MEMOIZE_SIZE = 500;
52
53 /** Used as the internal argument placeholder. */
54 var PLACEHOLDER = '__lodash_placeholder__';
55
56 /** Used to compose bitmasks for cloning. */
57 var CLONE_DEEP_FLAG = 1,
58 CLONE_FLAT_FLAG = 2,
59 CLONE_SYMBOLS_FLAG = 4;
60
61 /** Used to compose bitmasks for value comparisons. */
62 var COMPARE_PARTIAL_FLAG = 1,
63 COMPARE_UNORDERED_FLAG = 2;
64
65 /** Used to compose bitmasks for function metadata. */
66 var WRAP_BIND_FLAG = 1,
67 WRAP_BIND_KEY_FLAG = 2,
68 WRAP_CURRY_BOUND_FLAG = 4,
69 WRAP_CURRY_FLAG = 8,
70 WRAP_CURRY_RIGHT_FLAG = 16,
71 WRAP_PARTIAL_FLAG = 32,
72 WRAP_PARTIAL_RIGHT_FLAG = 64,
73 WRAP_ARY_FLAG = 128,
74 WRAP_REARG_FLAG = 256,
75 WRAP_FLIP_FLAG = 512;
76
77 /** Used as default options for `_.truncate`. */
78 var DEFAULT_TRUNC_LENGTH = 30,
79 DEFAULT_TRUNC_OMISSION = '...';
80
81 /** Used to detect hot functions by number of calls within a span of milliseconds. */
82 var HOT_COUNT = 800,
83 HOT_SPAN = 16;
84
85 /** Used to indicate the type of lazy iteratees. */
86 var LAZY_FILTER_FLAG = 1,
87 LAZY_MAP_FLAG = 2,
88 LAZY_WHILE_FLAG = 3;
89
90 /** Used as references for various `Number` constants. */
91 var INFINITY = 1 / 0,
92 MAX_SAFE_INTEGER = 9007199254740991,
93 MAX_INTEGER = 1.7976931348623157e+308,
94 NAN = 0 / 0;
95
96 /** Used as references for the maximum length and index of an array. */
97 var MAX_ARRAY_LENGTH = 4294967295,
98 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
99 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
100
101 /** Used to associate wrap methods with their bit flags. */
102 var wrapFlags = [
103 ['ary', WRAP_ARY_FLAG],
104 ['bind', WRAP_BIND_FLAG],
105 ['bindKey', WRAP_BIND_KEY_FLAG],
106 ['curry', WRAP_CURRY_FLAG],
107 ['curryRight', WRAP_CURRY_RIGHT_FLAG],
108 ['flip', WRAP_FLIP_FLAG],
109 ['partial', WRAP_PARTIAL_FLAG],
110 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
111 ['rearg', WRAP_REARG_FLAG]
112 ];
113
114 /** `Object#toString` result references. */
115 var argsTag = '[object Arguments]',
116 arrayTag = '[object Array]',
117 asyncTag = '[object AsyncFunction]',
118 boolTag = '[object Boolean]',
119 dateTag = '[object Date]',
120 domExcTag = '[object DOMException]',
121 errorTag = '[object Error]',
122 funcTag = '[object Function]',
123 genTag = '[object GeneratorFunction]',
124 mapTag = '[object Map]',
125 numberTag = '[object Number]',
126 nullTag = '[object Null]',
127 objectTag = '[object Object]',
128 promiseTag = '[object Promise]',
129 proxyTag = '[object Proxy]',
130 regexpTag = '[object RegExp]',
131 setTag = '[object Set]',
132 stringTag = '[object String]',
133 symbolTag = '[object Symbol]',
134 undefinedTag = '[object Undefined]',
135 weakMapTag = '[object WeakMap]',
136 weakSetTag = '[object WeakSet]';
137
138 var arrayBufferTag = '[object ArrayBuffer]',
139 dataViewTag = '[object DataView]',
140 float32Tag = '[object Float32Array]',
141 float64Tag = '[object Float64Array]',
142 int8Tag = '[object Int8Array]',
143 int16Tag = '[object Int16Array]',
144 int32Tag = '[object Int32Array]',
145 uint8Tag = '[object Uint8Array]',
146 uint8ClampedTag = '[object Uint8ClampedArray]',
147 uint16Tag = '[object Uint16Array]',
148 uint32Tag = '[object Uint32Array]';
149
150 /** Used to match empty string literals in compiled template source. */
151 var reEmptyStringLeading = /\b__p \+= '';/g,
152 reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
153 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
154
155 /** Used to match HTML entities and HTML characters. */
156 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
157 reUnescapedHtml = /[&<>"']/g,
158 reHasEscapedHtml = RegExp(reEscapedHtml.source),
159 reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
160
161 /** Used to match template delimiters. */
162 var reEscape = /<%-([\s\S]+?)%>/g,
163 reEvaluate = /<%([\s\S]+?)%>/g,
164 reInterpolate = /<%=([\s\S]+?)%>/g;
165
166 /** Used to match property names within property paths. */
167 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
168 reIsPlainProp = /^\w*$/,
169 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
170
171 /**
172 * Used to match `RegExp`
173 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
174 */
175 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
176 reHasRegExpChar = RegExp(reRegExpChar.source);
177
178 /** Used to match leading and trailing whitespace. */
179 var reTrim = /^\s+|\s+$/g,
180 reTrimStart = /^\s+/,
181 reTrimEnd = /\s+$/;
182
183 /** Used to match wrap detail comments. */
184 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
185 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
186 reSplitDetails = /,? & /;
187
188 /** Used to match words composed of alphanumeric characters. */
189 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
190
191 /** Used to match backslashes in property paths. */
192 var reEscapeChar = /\\(\\)?/g;
193
194 /**
195 * Used to match
196 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
197 */
198 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
199
200 /** Used to match `RegExp` flags from their coerced string values. */
201 var reFlags = /\w*$/;
202
203 /** Used to detect bad signed hexadecimal string values. */
204 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
205
206 /** Used to detect binary string values. */
207 var reIsBinary = /^0b[01]+$/i;
208
209 /** Used to detect host constructors (Safari). */
210 var reIsHostCtor = /^\[object .+?Constructor\]$/;
211
212 /** Used to detect octal string values. */
213 var reIsOctal = /^0o[0-7]+$/i;
214
215 /** Used to detect unsigned integer values. */
216 var reIsUint = /^(?:0|[1-9]\d*)$/;
217
218 /** Used to match Latin Unicode letters (excluding mathematical operators). */
219 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
220
221 /** Used to ensure capturing order of template delimiters. */
222 var reNoMatch = /($^)/;
223
224 /** Used to match unescaped characters in compiled string literals. */
225 var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
226
227 /** Used to compose unicode character classes. */
228 var rsAstralRange = '\\ud800-\\udfff',
229 rsComboMarksRange = '\\u0300-\\u036f',
230 reComboHalfMarksRange = '\\ufe20-\\ufe2f',
231 rsComboSymbolsRange = '\\u20d0-\\u20ff',
232 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
233 rsDingbatRange = '\\u2700-\\u27bf',
234 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
235 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
236 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
237 rsPunctuationRange = '\\u2000-\\u206f',
238 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
239 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
240 rsVarRange = '\\ufe0e\\ufe0f',
241 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
242
243 /** Used to compose unicode capture groups. */
244 var rsApos = "['\u2019]",
245 rsAstral = '[' + rsAstralRange + ']',
246 rsBreak = '[' + rsBreakRange + ']',
247 rsCombo = '[' + rsComboRange + ']',
248 rsDigits = '\\d+',
249 rsDingbat = '[' + rsDingbatRange + ']',
250 rsLower = '[' + rsLowerRange + ']',
251 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
252 rsFitz = '\\ud83c[\\udffb-\\udfff]',
253 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
254 rsNonAstral = '[^' + rsAstralRange + ']',
255 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
256 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
257 rsUpper = '[' + rsUpperRange + ']',
258 rsZWJ = '\\u200d';
259
260 /** Used to compose unicode regexes. */
261 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
262 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
263 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
264 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
265 reOptMod = rsModifier + '?',
266 rsOptVar = '[' + rsVarRange + ']?',
267 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
268 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
269 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
270 rsSeq = rsOptVar + reOptMod + rsOptJoin,
271 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
272 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
273
274 /** Used to match apostrophes. */
275 var reApos = RegExp(rsApos, 'g');
276
277 /**
278 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
279 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
280 */
281 var reComboMark = RegExp(rsCombo, 'g');
282
283 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
284 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
285
286 /** Used to match complex or compound words. */
287 var reUnicodeWord = RegExp([
288 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
289 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
290 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
291 rsUpper + '+' + rsOptContrUpper,
292 rsOrdUpper,
293 rsOrdLower,
294 rsDigits,
295 rsEmoji
296 ].join('|'), 'g');
297
298 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
299 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
300
301 /** Used to detect strings that need a more robust regexp to match words. */
302 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
303
304 /** Used to assign default `context` object properties. */
305 var contextProps = [
306 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
307 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
308 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
309 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
310 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
311 ];
312
313 /** Used to make template sourceURLs easier to identify. */
314 var templateCounter = -1;
315
316 /** Used to identify `toStringTag` values of typed arrays. */
317 var typedArrayTags = {};
318 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
319 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
320 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
321 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
322 typedArrayTags[uint32Tag] = true;
323 typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
324 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
325 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
326 typedArrayTags[errorTag] = typedArrayTags[funcTag] =
327 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
328 typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
329 typedArrayTags[setTag] = typedArrayTags[stringTag] =
330 typedArrayTags[weakMapTag] = false;
331
332 /** Used to identify `toStringTag` values supported by `_.clone`. */
333 var cloneableTags = {};
334 cloneableTags[argsTag] = cloneableTags[arrayTag] =
335 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
336 cloneableTags[boolTag] = cloneableTags[dateTag] =
337 cloneableTags[float32Tag] = cloneableTags[float64Tag] =
338 cloneableTags[int8Tag] = cloneableTags[int16Tag] =
339 cloneableTags[int32Tag] = cloneableTags[mapTag] =
340 cloneableTags[numberTag] = cloneableTags[objectTag] =
341 cloneableTags[regexpTag] = cloneableTags[setTag] =
342 cloneableTags[stringTag] = cloneableTags[symbolTag] =
343 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
344 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
345 cloneableTags[errorTag] = cloneableTags[funcTag] =
346 cloneableTags[weakMapTag] = false;
347
348 /** Used to map Latin Unicode letters to basic Latin letters. */
349 var deburredLetters = {
350 // Latin-1 Supplement block.
351 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
352 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
353 '\xc7': 'C', '\xe7': 'c',
354 '\xd0': 'D', '\xf0': 'd',
355 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
356 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
357 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
358 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
359 '\xd1': 'N', '\xf1': 'n',
360 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
361 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
362 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
363 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
364 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
365 '\xc6': 'Ae', '\xe6': 'ae',
366 '\xde': 'Th', '\xfe': 'th',
367 '\xdf': 'ss',
368 // Latin Extended-A block.
369 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
370 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
371 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
372 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
373 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
374 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
375 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
376 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
377 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
378 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
379 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
380 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
381 '\u0134': 'J', '\u0135': 'j',
382 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
383 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
384 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
385 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
386 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
387 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
388 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
389 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
390 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
391 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
392 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
393 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
394 '\u0163': 't', '\u0165': 't', '\u0167': 't',
395 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
396 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
397 '\u0174': 'W', '\u0175': 'w',
398 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
399 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
400 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
401 '\u0132': 'IJ', '\u0133': 'ij',
402 '\u0152': 'Oe', '\u0153': 'oe',
403 '\u0149': "'n", '\u017f': 's'
404 };
405
406 /** Used to map characters to HTML entities. */
407 var htmlEscapes = {
408 '&': '&amp;',
409 '<': '&lt;',
410 '>': '&gt;',
411 '"': '&quot;',
412 "'": '&#39;'
413 };
414
415 /** Used to map HTML entities to characters. */
416 var htmlUnescapes = {
417 '&amp;': '&',
418 '&lt;': '<',
419 '&gt;': '>',
420 '&quot;': '"',
421 '&#39;': "'"
422 };
423
424 /** Used to escape characters for inclusion in compiled string literals. */
425 var stringEscapes = {
426 '\\': '\\',
427 "'": "'",
428 '\n': 'n',
429 '\r': 'r',
430 '\u2028': 'u2028',
431 '\u2029': 'u2029'
432 };
433
434 /** Built-in method references without a dependency on `root`. */
435 var freeParseFloat = parseFloat,
436 freeParseInt = parseInt;
437
438 /** Detect free variable `global` from Node.js. */
439 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
440
441 /** Detect free variable `self`. */
442 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
443
444 /** Used as a reference to the global object. */
445 var root = freeGlobal || freeSelf || Function('return this')();
446
447 /** Detect free variable `exports`. */
448 var freeExports = exports && !exports.nodeType && exports;
449
450 /** Detect free variable `module`. */
451 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
452
453 /** Detect the popular CommonJS extension `module.exports`. */
454 var moduleExports = freeModule && freeModule.exports === freeExports;
455
456 /** Detect free variable `process` from Node.js. */
457 var freeProcess = moduleExports && freeGlobal.process;
458
459 /** Used to access faster Node.js helpers. */
460 var nodeUtil = (function() {
461 try {
462 // Use `util.types` for Node.js 10+.
463 var types = freeModule && freeModule.require && freeModule.require('util').types;
464
465 if (types) {
466 return types;
467 }
468
469 // Legacy `process.binding('util')` for Node.js < 10.
470 return freeProcess && freeProcess.binding && freeProcess.binding('util');
471 } catch (e) {}
472 }());
473
474 /* Node.js helper references. */
475 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
476 nodeIsDate = nodeUtil && nodeUtil.isDate,
477 nodeIsMap = nodeUtil && nodeUtil.isMap,
478 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
479 nodeIsSet = nodeUtil && nodeUtil.isSet,
480 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
481
482 /*--------------------------------------------------------------------------*/
483
484 /**
485 * A faster alternative to `Function#apply`, this function invokes `func`
486 * with the `this` binding of `thisArg` and the arguments of `args`.
487 *
488 * @private
489 * @param {Function} func The function to invoke.
490 * @param {*} thisArg The `this` binding of `func`.
491 * @param {Array} args The arguments to invoke `func` with.
492 * @returns {*} Returns the result of `func`.
493 */
494 function apply(func, thisArg, args) {
495 switch (args.length) {
496 case 0: return func.call(thisArg);
497 case 1: return func.call(thisArg, args[0]);
498 case 2: return func.call(thisArg, args[0], args[1]);
499 case 3: return func.call(thisArg, args[0], args[1], args[2]);
500 }
501 return func.apply(thisArg, args);
502 }
503
504 /**
505 * A specialized version of `baseAggregator` for arrays.
506 *
507 * @private
508 * @param {Array} [array] The array to iterate over.
509 * @param {Function} setter The function to set `accumulator` values.
510 * @param {Function} iteratee The iteratee to transform keys.
511 * @param {Object} accumulator The initial aggregated object.
512 * @returns {Function} Returns `accumulator`.
513 */
514 function arrayAggregator(array, setter, iteratee, accumulator) {
515 var index = -1,
516 length = array == null ? 0 : array.length;
517
518 while (++index < length) {
519 var value = array[index];
520 setter(accumulator, value, iteratee(value), array);
521 }
522 return accumulator;
523 }
524
525 /**
526 * A specialized version of `_.forEach` for arrays without support for
527 * iteratee shorthands.
528 *
529 * @private
530 * @param {Array} [array] The array to iterate over.
531 * @param {Function} iteratee The function invoked per iteration.
532 * @returns {Array} Returns `array`.
533 */
534 function arrayEach(array, iteratee) {
535 var index = -1,
536 length = array == null ? 0 : array.length;
537
538 while (++index < length) {
539 if (iteratee(array[index], index, array) === false) {
540 break;
541 }
542 }
543 return array;
544 }
545
546 /**
547 * A specialized version of `_.forEachRight` for arrays without support for
548 * iteratee shorthands.
549 *
550 * @private
551 * @param {Array} [array] The array to iterate over.
552 * @param {Function} iteratee The function invoked per iteration.
553 * @returns {Array} Returns `array`.
554 */
555 function arrayEachRight(array, iteratee) {
556 var length = array == null ? 0 : array.length;
557
558 while (length--) {
559 if (iteratee(array[length], length, array) === false) {
560 break;
561 }
562 }
563 return array;
564 }
565
566 /**
567 * A specialized version of `_.every` for arrays without support for
568 * iteratee shorthands.
569 *
570 * @private
571 * @param {Array} [array] The array to iterate over.
572 * @param {Function} predicate The function invoked per iteration.
573 * @returns {boolean} Returns `true` if all elements pass the predicate check,
574 * else `false`.
575 */
576 function arrayEvery(array, predicate) {
577 var index = -1,
578 length = array == null ? 0 : array.length;
579
580 while (++index < length) {
581 if (!predicate(array[index], index, array)) {
582 return false;
583 }
584 }
585 return true;
586 }
587
588 /**
589 * A specialized version of `_.filter` for arrays without support for
590 * iteratee shorthands.
591 *
592 * @private
593 * @param {Array} [array] The array to iterate over.
594 * @param {Function} predicate The function invoked per iteration.
595 * @returns {Array} Returns the new filtered array.
596 */
597 function arrayFilter(array, predicate) {
598 var index = -1,
599 length = array == null ? 0 : array.length,
600 resIndex = 0,
601 result = [];
602
603 while (++index < length) {
604 var value = array[index];
605 if (predicate(value, index, array)) {
606 result[resIndex++] = value;
607 }
608 }
609 return result;
610 }
611
612 /**
613 * A specialized version of `_.includes` for arrays without support for
614 * specifying an index to search from.
615 *
616 * @private
617 * @param {Array} [array] The array to inspect.
618 * @param {*} target The value to search for.
619 * @returns {boolean} Returns `true` if `target` is found, else `false`.
620 */
621 function arrayIncludes(array, value) {
622 var length = array == null ? 0 : array.length;
623 return !!length && baseIndexOf(array, value, 0) > -1;
624 }
625
626 /**
627 * This function is like `arrayIncludes` except that it accepts a comparator.
628 *
629 * @private
630 * @param {Array} [array] The array to inspect.
631 * @param {*} target The value to search for.
632 * @param {Function} comparator The comparator invoked per element.
633 * @returns {boolean} Returns `true` if `target` is found, else `false`.
634 */
635 function arrayIncludesWith(array, value, comparator) {
636 var index = -1,
637 length = array == null ? 0 : array.length;
638
639 while (++index < length) {
640 if (comparator(value, array[index])) {
641 return true;
642 }
643 }
644 return false;
645 }
646
647 /**
648 * A specialized version of `_.map` for arrays without support for iteratee
649 * shorthands.
650 *
651 * @private
652 * @param {Array} [array] The array to iterate over.
653 * @param {Function} iteratee The function invoked per iteration.
654 * @returns {Array} Returns the new mapped array.
655 */
656 function arrayMap(array, iteratee) {
657 var index = -1,
658 length = array == null ? 0 : array.length,
659 result = Array(length);
660
661 while (++index < length) {
662 result[index] = iteratee(array[index], index, array);
663 }
664 return result;
665 }
666
667 /**
668 * Appends the elements of `values` to `array`.
669 *
670 * @private
671 * @param {Array} array The array to modify.
672 * @param {Array} values The values to append.
673 * @returns {Array} Returns `array`.
674 */
675 function arrayPush(array, values) {
676 var index = -1,
677 length = values.length,
678 offset = array.length;
679
680 while (++index < length) {
681 array[offset + index] = values[index];
682 }
683 return array;
684 }
685
686 /**
687 * A specialized version of `_.reduce` for arrays without support for
688 * iteratee shorthands.
689 *
690 * @private
691 * @param {Array} [array] The array to iterate over.
692 * @param {Function} iteratee The function invoked per iteration.
693 * @param {*} [accumulator] The initial value.
694 * @param {boolean} [initAccum] Specify using the first element of `array` as
695 * the initial value.
696 * @returns {*} Returns the accumulated value.
697 */
698 function arrayReduce(array, iteratee, accumulator, initAccum) {
699 var index = -1,
700 length = array == null ? 0 : array.length;
701
702 if (initAccum && length) {
703 accumulator = array[++index];
704 }
705 while (++index < length) {
706 accumulator = iteratee(accumulator, array[index], index, array);
707 }
708 return accumulator;
709 }
710
711 /**
712 * A specialized version of `_.reduceRight` for arrays without support for
713 * iteratee shorthands.
714 *
715 * @private
716 * @param {Array} [array] The array to iterate over.
717 * @param {Function} iteratee The function invoked per iteration.
718 * @param {*} [accumulator] The initial value.
719 * @param {boolean} [initAccum] Specify using the last element of `array` as
720 * the initial value.
721 * @returns {*} Returns the accumulated value.
722 */
723 function arrayReduceRight(array, iteratee, accumulator, initAccum) {
724 var length = array == null ? 0 : array.length;
725 if (initAccum && length) {
726 accumulator = array[--length];
727 }
728 while (length--) {
729 accumulator = iteratee(accumulator, array[length], length, array);
730 }
731 return accumulator;
732 }
733
734 /**
735 * A specialized version of `_.some` for arrays without support for iteratee
736 * shorthands.
737 *
738 * @private
739 * @param {Array} [array] The array to iterate over.
740 * @param {Function} predicate The function invoked per iteration.
741 * @returns {boolean} Returns `true` if any element passes the predicate check,
742 * else `false`.
743 */
744 function arraySome(array, predicate) {
745 var index = -1,
746 length = array == null ? 0 : array.length;
747
748 while (++index < length) {
749 if (predicate(array[index], index, array)) {
750 return true;
751 }
752 }
753 return false;
754 }
755
756 /**
757 * Gets the size of an ASCII `string`.
758 *
759 * @private
760 * @param {string} string The string inspect.
761 * @returns {number} Returns the string size.
762 */
763 var asciiSize = baseProperty('length');
764
765 /**
766 * Converts an ASCII `string` to an array.
767 *
768 * @private
769 * @param {string} string The string to convert.
770 * @returns {Array} Returns the converted array.
771 */
772 function asciiToArray(string) {
773 return string.split('');
774 }
775
776 /**
777 * Splits an ASCII `string` into an array of its words.
778 *
779 * @private
780 * @param {string} The string to inspect.
781 * @returns {Array} Returns the words of `string`.
782 */
783 function asciiWords(string) {
784 return string.match(reAsciiWord) || [];
785 }
786
787 /**
788 * The base implementation of methods like `_.findKey` and `_.findLastKey`,
789 * without support for iteratee shorthands, which iterates over `collection`
790 * using `eachFunc`.
791 *
792 * @private
793 * @param {Array|Object} collection The collection to inspect.
794 * @param {Function} predicate The function invoked per iteration.
795 * @param {Function} eachFunc The function to iterate over `collection`.
796 * @returns {*} Returns the found element or its key, else `undefined`.
797 */
798 function baseFindKey(collection, predicate, eachFunc) {
799 var result;
800 eachFunc(collection, function(value, key, collection) {
801 if (predicate(value, key, collection)) {
802 result = key;
803 return false;
804 }
805 });
806 return result;
807 }
808
809 /**
810 * The base implementation of `_.findIndex` and `_.findLastIndex` without
811 * support for iteratee shorthands.
812 *
813 * @private
814 * @param {Array} array The array to inspect.
815 * @param {Function} predicate The function invoked per iteration.
816 * @param {number} fromIndex The index to search from.
817 * @param {boolean} [fromRight] Specify iterating from right to left.
818 * @returns {number} Returns the index of the matched value, else `-1`.
819 */
820 function baseFindIndex(array, predicate, fromIndex, fromRight) {
821 var length = array.length,
822 index = fromIndex + (fromRight ? 1 : -1);
823
824 while ((fromRight ? index-- : ++index < length)) {
825 if (predicate(array[index], index, array)) {
826 return index;
827 }
828 }
829 return -1;
830 }
831
832 /**
833 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
834 *
835 * @private
836 * @param {Array} array The array to inspect.
837 * @param {*} value The value to search for.
838 * @param {number} fromIndex The index to search from.
839 * @returns {number} Returns the index of the matched value, else `-1`.
840 */
841 function baseIndexOf(array, value, fromIndex) {
842 return value === value
843 ? strictIndexOf(array, value, fromIndex)
844 : baseFindIndex(array, baseIsNaN, fromIndex);
845 }
846
847 /**
848 * This function is like `baseIndexOf` except that it accepts a comparator.
849 *
850 * @private
851 * @param {Array} array The array to inspect.
852 * @param {*} value The value to search for.
853 * @param {number} fromIndex The index to search from.
854 * @param {Function} comparator The comparator invoked per element.
855 * @returns {number} Returns the index of the matched value, else `-1`.
856 */
857 function baseIndexOfWith(array, value, fromIndex, comparator) {
858 var index = fromIndex - 1,
859 length = array.length;
860
861 while (++index < length) {
862 if (comparator(array[index], value)) {
863 return index;
864 }
865 }
866 return -1;
867 }
868
869 /**
870 * The base implementation of `_.isNaN` without support for number objects.
871 *
872 * @private
873 * @param {*} value The value to check.
874 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
875 */
876 function baseIsNaN(value) {
877 return value !== value;
878 }
879
880 /**
881 * The base implementation of `_.mean` and `_.meanBy` without support for
882 * iteratee shorthands.
883 *
884 * @private
885 * @param {Array} array The array to iterate over.
886 * @param {Function} iteratee The function invoked per iteration.
887 * @returns {number} Returns the mean.
888 */
889 function baseMean(array, iteratee) {
890 var length = array == null ? 0 : array.length;
891 return length ? (baseSum(array, iteratee) / length) : NAN;
892 }
893
894 /**
895 * The base implementation of `_.property` without support for deep paths.
896 *
897 * @private
898 * @param {string} key The key of the property to get.
899 * @returns {Function} Returns the new accessor function.
900 */
901 function baseProperty(key) {
902 return function(object) {
903 return object == null ? undefined$1 : object[key];
904 };
905 }
906
907 /**
908 * The base implementation of `_.propertyOf` without support for deep paths.
909 *
910 * @private
911 * @param {Object} object The object to query.
912 * @returns {Function} Returns the new accessor function.
913 */
914 function basePropertyOf(object) {
915 return function(key) {
916 return object == null ? undefined$1 : object[key];
917 };
918 }
919
920 /**
921 * The base implementation of `_.reduce` and `_.reduceRight`, without support
922 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
923 *
924 * @private
925 * @param {Array|Object} collection The collection to iterate over.
926 * @param {Function} iteratee The function invoked per iteration.
927 * @param {*} accumulator The initial value.
928 * @param {boolean} initAccum Specify using the first or last element of
929 * `collection` as the initial value.
930 * @param {Function} eachFunc The function to iterate over `collection`.
931 * @returns {*} Returns the accumulated value.
932 */
933 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
934 eachFunc(collection, function(value, index, collection) {
935 accumulator = initAccum
936 ? (initAccum = false, value)
937 : iteratee(accumulator, value, index, collection);
938 });
939 return accumulator;
940 }
941
942 /**
943 * The base implementation of `_.sortBy` which uses `comparer` to define the
944 * sort order of `array` and replaces criteria objects with their corresponding
945 * values.
946 *
947 * @private
948 * @param {Array} array The array to sort.
949 * @param {Function} comparer The function to define sort order.
950 * @returns {Array} Returns `array`.
951 */
952 function baseSortBy(array, comparer) {
953 var length = array.length;
954
955 array.sort(comparer);
956 while (length--) {
957 array[length] = array[length].value;
958 }
959 return array;
960 }
961
962 /**
963 * The base implementation of `_.sum` and `_.sumBy` without support for
964 * iteratee shorthands.
965 *
966 * @private
967 * @param {Array} array The array to iterate over.
968 * @param {Function} iteratee The function invoked per iteration.
969 * @returns {number} Returns the sum.
970 */
971 function baseSum(array, iteratee) {
972 var result,
973 index = -1,
974 length = array.length;
975
976 while (++index < length) {
977 var current = iteratee(array[index]);
978 if (current !== undefined$1) {
979 result = result === undefined$1 ? current : (result + current);
980 }
981 }
982 return result;
983 }
984
985 /**
986 * The base implementation of `_.times` without support for iteratee shorthands
987 * or max array length checks.
988 *
989 * @private
990 * @param {number} n The number of times to invoke `iteratee`.
991 * @param {Function} iteratee The function invoked per iteration.
992 * @returns {Array} Returns the array of results.
993 */
994 function baseTimes(n, iteratee) {
995 var index = -1,
996 result = Array(n);
997
998 while (++index < n) {
999 result[index] = iteratee(index);
1000 }
1001 return result;
1002 }
1003
1004 /**
1005 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
1006 * of key-value pairs for `object` corresponding to the property names of `props`.
1007 *
1008 * @private
1009 * @param {Object} object The object to query.
1010 * @param {Array} props The property names to get values for.
1011 * @returns {Object} Returns the key-value pairs.
1012 */
1013 function baseToPairs(object, props) {
1014 return arrayMap(props, function(key) {
1015 return [key, object[key]];
1016 });
1017 }
1018
1019 /**
1020 * The base implementation of `_.unary` without support for storing metadata.
1021 *
1022 * @private
1023 * @param {Function} func The function to cap arguments for.
1024 * @returns {Function} Returns the new capped function.
1025 */
1026 function baseUnary(func) {
1027 return function(value) {
1028 return func(value);
1029 };
1030 }
1031
1032 /**
1033 * The base implementation of `_.values` and `_.valuesIn` which creates an
1034 * array of `object` property values corresponding to the property names
1035 * of `props`.
1036 *
1037 * @private
1038 * @param {Object} object The object to query.
1039 * @param {Array} props The property names to get values for.
1040 * @returns {Object} Returns the array of property values.
1041 */
1042 function baseValues(object, props) {
1043 return arrayMap(props, function(key) {
1044 return object[key];
1045 });
1046 }
1047
1048 /**
1049 * Checks if a `cache` value for `key` exists.
1050 *
1051 * @private
1052 * @param {Object} cache The cache to query.
1053 * @param {string} key The key of the entry to check.
1054 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1055 */
1056 function cacheHas(cache, key) {
1057 return cache.has(key);
1058 }
1059
1060 /**
1061 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
1062 * that is not found in the character symbols.
1063 *
1064 * @private
1065 * @param {Array} strSymbols The string symbols to inspect.
1066 * @param {Array} chrSymbols The character symbols to find.
1067 * @returns {number} Returns the index of the first unmatched string symbol.
1068 */
1069 function charsStartIndex(strSymbols, chrSymbols) {
1070 var index = -1,
1071 length = strSymbols.length;
1072
1073 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1074 return index;
1075 }
1076
1077 /**
1078 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
1079 * that is not found in the character symbols.
1080 *
1081 * @private
1082 * @param {Array} strSymbols The string symbols to inspect.
1083 * @param {Array} chrSymbols The character symbols to find.
1084 * @returns {number} Returns the index of the last unmatched string symbol.
1085 */
1086 function charsEndIndex(strSymbols, chrSymbols) {
1087 var index = strSymbols.length;
1088
1089 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
1090 return index;
1091 }
1092
1093 /**
1094 * Gets the number of `placeholder` occurrences in `array`.
1095 *
1096 * @private
1097 * @param {Array} array The array to inspect.
1098 * @param {*} placeholder The placeholder to search for.
1099 * @returns {number} Returns the placeholder count.
1100 */
1101 function countHolders(array, placeholder) {
1102 var length = array.length,
1103 result = 0;
1104
1105 while (length--) {
1106 if (array[length] === placeholder) {
1107 ++result;
1108 }
1109 }
1110 return result;
1111 }
1112
1113 /**
1114 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
1115 * letters to basic Latin letters.
1116 *
1117 * @private
1118 * @param {string} letter The matched letter to deburr.
1119 * @returns {string} Returns the deburred letter.
1120 */
1121 var deburrLetter = basePropertyOf(deburredLetters);
1122
1123 /**
1124 * Used by `_.escape` to convert characters to HTML entities.
1125 *
1126 * @private
1127 * @param {string} chr The matched character to escape.
1128 * @returns {string} Returns the escaped character.
1129 */
1130 var escapeHtmlChar = basePropertyOf(htmlEscapes);
1131
1132 /**
1133 * Used by `_.template` to escape characters for inclusion in compiled string literals.
1134 *
1135 * @private
1136 * @param {string} chr The matched character to escape.
1137 * @returns {string} Returns the escaped character.
1138 */
1139 function escapeStringChar(chr) {
1140 return '\\' + stringEscapes[chr];
1141 }
1142
1143 /**
1144 * Gets the value at `key` of `object`.
1145 *
1146 * @private
1147 * @param {Object} [object] The object to query.
1148 * @param {string} key The key of the property to get.
1149 * @returns {*} Returns the property value.
1150 */
1151 function getValue(object, key) {
1152 return object == null ? undefined$1 : object[key];
1153 }
1154
1155 /**
1156 * Checks if `string` contains Unicode symbols.
1157 *
1158 * @private
1159 * @param {string} string The string to inspect.
1160 * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1161 */
1162 function hasUnicode(string) {
1163 return reHasUnicode.test(string);
1164 }
1165
1166 /**
1167 * Checks if `string` contains a word composed of Unicode symbols.
1168 *
1169 * @private
1170 * @param {string} string The string to inspect.
1171 * @returns {boolean} Returns `true` if a word is found, else `false`.
1172 */
1173 function hasUnicodeWord(string) {
1174 return reHasUnicodeWord.test(string);
1175 }
1176
1177 /**
1178 * Converts `iterator` to an array.
1179 *
1180 * @private
1181 * @param {Object} iterator The iterator to convert.
1182 * @returns {Array} Returns the converted array.
1183 */
1184 function iteratorToArray(iterator) {
1185 var data,
1186 result = [];
1187
1188 while (!(data = iterator.next()).done) {
1189 result.push(data.value);
1190 }
1191 return result;
1192 }
1193
1194 /**
1195 * Converts `map` to its key-value pairs.
1196 *
1197 * @private
1198 * @param {Object} map The map to convert.
1199 * @returns {Array} Returns the key-value pairs.
1200 */
1201 function mapToArray(map) {
1202 var index = -1,
1203 result = Array(map.size);
1204
1205 map.forEach(function(value, key) {
1206 result[++index] = [key, value];
1207 });
1208 return result;
1209 }
1210
1211 /**
1212 * Creates a unary function that invokes `func` with its argument transformed.
1213 *
1214 * @private
1215 * @param {Function} func The function to wrap.
1216 * @param {Function} transform The argument transform.
1217 * @returns {Function} Returns the new function.
1218 */
1219 function overArg(func, transform) {
1220 return function(arg) {
1221 return func(transform(arg));
1222 };
1223 }
1224
1225 /**
1226 * Replaces all `placeholder` elements in `array` with an internal placeholder
1227 * and returns an array of their indexes.
1228 *
1229 * @private
1230 * @param {Array} array The array to modify.
1231 * @param {*} placeholder The placeholder to replace.
1232 * @returns {Array} Returns the new array of placeholder indexes.
1233 */
1234 function replaceHolders(array, placeholder) {
1235 var index = -1,
1236 length = array.length,
1237 resIndex = 0,
1238 result = [];
1239
1240 while (++index < length) {
1241 var value = array[index];
1242 if (value === placeholder || value === PLACEHOLDER) {
1243 array[index] = PLACEHOLDER;
1244 result[resIndex++] = index;
1245 }
1246 }
1247 return result;
1248 }
1249
1250 /**
1251 * Converts `set` to an array of its values.
1252 *
1253 * @private
1254 * @param {Object} set The set to convert.
1255 * @returns {Array} Returns the values.
1256 */
1257 function setToArray(set) {
1258 var index = -1,
1259 result = Array(set.size);
1260
1261 set.forEach(function(value) {
1262 result[++index] = value;
1263 });
1264 return result;
1265 }
1266
1267 /**
1268 * Converts `set` to its value-value pairs.
1269 *
1270 * @private
1271 * @param {Object} set The set to convert.
1272 * @returns {Array} Returns the value-value pairs.
1273 */
1274 function setToPairs(set) {
1275 var index = -1,
1276 result = Array(set.size);
1277
1278 set.forEach(function(value) {
1279 result[++index] = [value, value];
1280 });
1281 return result;
1282 }
1283
1284 /**
1285 * A specialized version of `_.indexOf` which performs strict equality
1286 * comparisons of values, i.e. `===`.
1287 *
1288 * @private
1289 * @param {Array} array The array to inspect.
1290 * @param {*} value The value to search for.
1291 * @param {number} fromIndex The index to search from.
1292 * @returns {number} Returns the index of the matched value, else `-1`.
1293 */
1294 function strictIndexOf(array, value, fromIndex) {
1295 var index = fromIndex - 1,
1296 length = array.length;
1297
1298 while (++index < length) {
1299 if (array[index] === value) {
1300 return index;
1301 }
1302 }
1303 return -1;
1304 }
1305
1306 /**
1307 * A specialized version of `_.lastIndexOf` which performs strict equality
1308 * comparisons of values, i.e. `===`.
1309 *
1310 * @private
1311 * @param {Array} array The array to inspect.
1312 * @param {*} value The value to search for.
1313 * @param {number} fromIndex The index to search from.
1314 * @returns {number} Returns the index of the matched value, else `-1`.
1315 */
1316 function strictLastIndexOf(array, value, fromIndex) {
1317 var index = fromIndex + 1;
1318 while (index--) {
1319 if (array[index] === value) {
1320 return index;
1321 }
1322 }
1323 return index;
1324 }
1325
1326 /**
1327 * Gets the number of symbols in `string`.
1328 *
1329 * @private
1330 * @param {string} string The string to inspect.
1331 * @returns {number} Returns the string size.
1332 */
1333 function stringSize(string) {
1334 return hasUnicode(string)
1335 ? unicodeSize(string)
1336 : asciiSize(string);
1337 }
1338
1339 /**
1340 * Converts `string` to an array.
1341 *
1342 * @private
1343 * @param {string} string The string to convert.
1344 * @returns {Array} Returns the converted array.
1345 */
1346 function stringToArray(string) {
1347 return hasUnicode(string)
1348 ? unicodeToArray(string)
1349 : asciiToArray(string);
1350 }
1351
1352 /**
1353 * Used by `_.unescape` to convert HTML entities to characters.
1354 *
1355 * @private
1356 * @param {string} chr The matched character to unescape.
1357 * @returns {string} Returns the unescaped character.
1358 */
1359 var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
1360
1361 /**
1362 * Gets the size of a Unicode `string`.
1363 *
1364 * @private
1365 * @param {string} string The string inspect.
1366 * @returns {number} Returns the string size.
1367 */
1368 function unicodeSize(string) {
1369 var result = reUnicode.lastIndex = 0;
1370 while (reUnicode.test(string)) {
1371 ++result;
1372 }
1373 return result;
1374 }
1375
1376 /**
1377 * Converts a Unicode `string` to an array.
1378 *
1379 * @private
1380 * @param {string} string The string to convert.
1381 * @returns {Array} Returns the converted array.
1382 */
1383 function unicodeToArray(string) {
1384 return string.match(reUnicode) || [];
1385 }
1386
1387 /**
1388 * Splits a Unicode `string` into an array of its words.
1389 *
1390 * @private
1391 * @param {string} The string to inspect.
1392 * @returns {Array} Returns the words of `string`.
1393 */
1394 function unicodeWords(string) {
1395 return string.match(reUnicodeWord) || [];
1396 }
1397
1398 /*--------------------------------------------------------------------------*/
1399
1400 /**
1401 * Create a new pristine `lodash` function using the `context` object.
1402 *
1403 * @static
1404 * @memberOf _
1405 * @since 1.1.0
1406 * @category Util
1407 * @param {Object} [context=root] The context object.
1408 * @returns {Function} Returns a new `lodash` function.
1409 * @example
1410 *
1411 * _.mixin({ 'foo': _.constant('foo') });
1412 *
1413 * var lodash = _.runInContext();
1414 * lodash.mixin({ 'bar': lodash.constant('bar') });
1415 *
1416 * _.isFunction(_.foo);
1417 * // => true
1418 * _.isFunction(_.bar);
1419 * // => false
1420 *
1421 * lodash.isFunction(lodash.foo);
1422 * // => false
1423 * lodash.isFunction(lodash.bar);
1424 * // => true
1425 *
1426 * // Create a suped-up `defer` in Node.js.
1427 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
1428 */
1429 var runInContext = (function runInContext(context) {
1430 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
1431
1432 /** Built-in constructor references. */
1433 var Array = context.Array,
1434 Date = context.Date,
1435 Error = context.Error,
1436 Function = context.Function,
1437 Math = context.Math,
1438 Object = context.Object,
1439 RegExp = context.RegExp,
1440 String = context.String,
1441 TypeError = context.TypeError;
1442
1443 /** Used for built-in method references. */
1444 var arrayProto = Array.prototype,
1445 funcProto = Function.prototype,
1446 objectProto = Object.prototype;
1447
1448 /** Used to detect overreaching core-js shims. */
1449 var coreJsData = context['__core-js_shared__'];
1450
1451 /** Used to resolve the decompiled source of functions. */
1452 var funcToString = funcProto.toString;
1453
1454 /** Used to check objects for own properties. */
1455 var hasOwnProperty = objectProto.hasOwnProperty;
1456
1457 /** Used to generate unique IDs. */
1458 var idCounter = 0;
1459
1460 /** Used to detect methods masquerading as native. */
1461 var maskSrcKey = (function() {
1462 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1463 return uid ? ('Symbol(src)_1.' + uid) : '';
1464 }());
1465
1466 /**
1467 * Used to resolve the
1468 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1469 * of values.
1470 */
1471 var nativeObjectToString = objectProto.toString;
1472
1473 /** Used to infer the `Object` constructor. */
1474 var objectCtorString = funcToString.call(Object);
1475
1476 /** Used to restore the original `_` reference in `_.noConflict`. */
1477 var oldDash = root._;
1478
1479 /** Used to detect if a method is native. */
1480 var reIsNative = RegExp('^' +
1481 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1482 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1483 );
1484
1485 /** Built-in value references. */
1486 var Buffer = moduleExports ? context.Buffer : undefined$1,
1487 Symbol = context.Symbol,
1488 Uint8Array = context.Uint8Array,
1489 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined$1,
1490 getPrototype = overArg(Object.getPrototypeOf, Object),
1491 objectCreate = Object.create,
1492 propertyIsEnumerable = objectProto.propertyIsEnumerable,
1493 splice = arrayProto.splice,
1494 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined$1,
1495 symIterator = Symbol ? Symbol.iterator : undefined$1,
1496 symToStringTag = Symbol ? Symbol.toStringTag : undefined$1;
1497
1498 var defineProperty = (function() {
1499 try {
1500 var func = getNative(Object, 'defineProperty');
1501 func({}, '', {});
1502 return func;
1503 } catch (e) {}
1504 }());
1505
1506 /** Mocked built-ins. */
1507 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
1508 ctxNow = Date && Date.now !== root.Date.now && Date.now,
1509 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1510
1511 /* Built-in method references for those with the same name as other `lodash` methods. */
1512 var nativeCeil = Math.ceil,
1513 nativeFloor = Math.floor,
1514 nativeGetSymbols = Object.getOwnPropertySymbols,
1515 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1,
1516 nativeIsFinite = context.isFinite,
1517 nativeJoin = arrayProto.join,
1518 nativeKeys = overArg(Object.keys, Object),
1519 nativeMax = Math.max,
1520 nativeMin = Math.min,
1521 nativeNow = Date.now,
1522 nativeParseInt = context.parseInt,
1523 nativeRandom = Math.random,
1524 nativeReverse = arrayProto.reverse;
1525
1526 /* Built-in method references that are verified to be native. */
1527 var DataView = getNative(context, 'DataView'),
1528 Map = getNative(context, 'Map'),
1529 Promise = getNative(context, 'Promise'),
1530 Set = getNative(context, 'Set'),
1531 WeakMap = getNative(context, 'WeakMap'),
1532 nativeCreate = getNative(Object, 'create');
1533
1534 /** Used to store function metadata. */
1535 var metaMap = WeakMap && new WeakMap;
1536
1537 /** Used to lookup unminified function names. */
1538 var realNames = {};
1539
1540 /** Used to detect maps, sets, and weakmaps. */
1541 var dataViewCtorString = toSource(DataView),
1542 mapCtorString = toSource(Map),
1543 promiseCtorString = toSource(Promise),
1544 setCtorString = toSource(Set),
1545 weakMapCtorString = toSource(WeakMap);
1546
1547 /** Used to convert symbols to primitives and strings. */
1548 var symbolProto = Symbol ? Symbol.prototype : undefined$1,
1549 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined$1,
1550 symbolToString = symbolProto ? symbolProto.toString : undefined$1;
1551
1552 /*------------------------------------------------------------------------*/
1553
1554 /**
1555 * Creates a `lodash` object which wraps `value` to enable implicit method
1556 * chain sequences. Methods that operate on and return arrays, collections,
1557 * and functions can be chained together. Methods that retrieve a single value
1558 * or may return a primitive value will automatically end the chain sequence
1559 * and return the unwrapped value. Otherwise, the value must be unwrapped
1560 * with `_#value`.
1561 *
1562 * Explicit chain sequences, which must be unwrapped with `_#value`, may be
1563 * enabled using `_.chain`.
1564 *
1565 * The execution of chained methods is lazy, that is, it's deferred until
1566 * `_#value` is implicitly or explicitly called.
1567 *
1568 * Lazy evaluation allows several methods to support shortcut fusion.
1569 * Shortcut fusion is an optimization to merge iteratee calls; this avoids
1570 * the creation of intermediate arrays and can greatly reduce the number of
1571 * iteratee executions. Sections of a chain sequence qualify for shortcut
1572 * fusion if the section is applied to an array and iteratees accept only
1573 * one argument. The heuristic for whether a section qualifies for shortcut
1574 * fusion is subject to change.
1575 *
1576 * Chaining is supported in custom builds as long as the `_#value` method is
1577 * directly or indirectly included in the build.
1578 *
1579 * In addition to lodash methods, wrappers have `Array` and `String` methods.
1580 *
1581 * The wrapper `Array` methods are:
1582 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
1583 *
1584 * The wrapper `String` methods are:
1585 * `replace` and `split`
1586 *
1587 * The wrapper methods that support shortcut fusion are:
1588 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
1589 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
1590 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
1591 *
1592 * The chainable wrapper methods are:
1593 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
1594 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
1595 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
1596 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
1597 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
1598 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
1599 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
1600 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
1601 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
1602 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
1603 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
1604 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
1605 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
1606 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
1607 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
1608 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
1609 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
1610 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
1611 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
1612 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
1613 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
1614 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
1615 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
1616 * `zipObject`, `zipObjectDeep`, and `zipWith`
1617 *
1618 * The wrapper methods that are **not** chainable by default are:
1619 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
1620 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
1621 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
1622 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
1623 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
1624 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
1625 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
1626 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
1627 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
1628 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
1629 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
1630 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
1631 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
1632 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
1633 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
1634 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
1635 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
1636 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
1637 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
1638 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
1639 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
1640 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
1641 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
1642 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
1643 * `upperFirst`, `value`, and `words`
1644 *
1645 * @name _
1646 * @constructor
1647 * @category Seq
1648 * @param {*} value The value to wrap in a `lodash` instance.
1649 * @returns {Object} Returns the new `lodash` wrapper instance.
1650 * @example
1651 *
1652 * function square(n) {
1653 * return n * n;
1654 * }
1655 *
1656 * var wrapped = _([1, 2, 3]);
1657 *
1658 * // Returns an unwrapped value.
1659 * wrapped.reduce(_.add);
1660 * // => 6
1661 *
1662 * // Returns a wrapped value.
1663 * var squares = wrapped.map(square);
1664 *
1665 * _.isArray(squares);
1666 * // => false
1667 *
1668 * _.isArray(squares.value());
1669 * // => true
1670 */
1671 function lodash(value) {
1672 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
1673 if (value instanceof LodashWrapper) {
1674 return value;
1675 }
1676 if (hasOwnProperty.call(value, '__wrapped__')) {
1677 return wrapperClone(value);
1678 }
1679 }
1680 return new LodashWrapper(value);
1681 }
1682
1683 /**
1684 * The base implementation of `_.create` without support for assigning
1685 * properties to the created object.
1686 *
1687 * @private
1688 * @param {Object} proto The object to inherit from.
1689 * @returns {Object} Returns the new object.
1690 */
1691 var baseCreate = (function() {
1692 function object() {}
1693 return function(proto) {
1694 if (!isObject(proto)) {
1695 return {};
1696 }
1697 if (objectCreate) {
1698 return objectCreate(proto);
1699 }
1700 object.prototype = proto;
1701 var result = new object;
1702 object.prototype = undefined$1;
1703 return result;
1704 };
1705 }());
1706
1707 /**
1708 * The function whose prototype chain sequence wrappers inherit from.
1709 *
1710 * @private
1711 */
1712 function baseLodash() {
1713 // No operation performed.
1714 }
1715
1716 /**
1717 * The base constructor for creating `lodash` wrapper objects.
1718 *
1719 * @private
1720 * @param {*} value The value to wrap.
1721 * @param {boolean} [chainAll] Enable explicit method chain sequences.
1722 */
1723 function LodashWrapper(value, chainAll) {
1724 this.__wrapped__ = value;
1725 this.__actions__ = [];
1726 this.__chain__ = !!chainAll;
1727 this.__index__ = 0;
1728 this.__values__ = undefined$1;
1729 }
1730
1731 /**
1732 * By default, the template delimiters used by lodash are like those in
1733 * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1734 * following template settings to use alternative delimiters.
1735 *
1736 * @static
1737 * @memberOf _
1738 * @type {Object}
1739 */
1740 lodash.templateSettings = {
1741
1742 /**
1743 * Used to detect `data` property values to be HTML-escaped.
1744 *
1745 * @memberOf _.templateSettings
1746 * @type {RegExp}
1747 */
1748 'escape': reEscape,
1749
1750 /**
1751 * Used to detect code to be evaluated.
1752 *
1753 * @memberOf _.templateSettings
1754 * @type {RegExp}
1755 */
1756 'evaluate': reEvaluate,
1757
1758 /**
1759 * Used to detect `data` property values to inject.
1760 *
1761 * @memberOf _.templateSettings
1762 * @type {RegExp}
1763 */
1764 'interpolate': reInterpolate,
1765
1766 /**
1767 * Used to reference the data object in the template text.
1768 *
1769 * @memberOf _.templateSettings
1770 * @type {string}
1771 */
1772 'variable': '',
1773
1774 /**
1775 * Used to import variables into the compiled template.
1776 *
1777 * @memberOf _.templateSettings
1778 * @type {Object}
1779 */
1780 'imports': {
1781
1782 /**
1783 * A reference to the `lodash` function.
1784 *
1785 * @memberOf _.templateSettings.imports
1786 * @type {Function}
1787 */
1788 '_': lodash
1789 }
1790 };
1791
1792 // Ensure wrappers are instances of `baseLodash`.
1793 lodash.prototype = baseLodash.prototype;
1794 lodash.prototype.constructor = lodash;
1795
1796 LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1797 LodashWrapper.prototype.constructor = LodashWrapper;
1798
1799 /*------------------------------------------------------------------------*/
1800
1801 /**
1802 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1803 *
1804 * @private
1805 * @constructor
1806 * @param {*} value The value to wrap.
1807 */
1808 function LazyWrapper(value) {
1809 this.__wrapped__ = value;
1810 this.__actions__ = [];
1811 this.__dir__ = 1;
1812 this.__filtered__ = false;
1813 this.__iteratees__ = [];
1814 this.__takeCount__ = MAX_ARRAY_LENGTH;
1815 this.__views__ = [];
1816 }
1817
1818 /**
1819 * Creates a clone of the lazy wrapper object.
1820 *
1821 * @private
1822 * @name clone
1823 * @memberOf LazyWrapper
1824 * @returns {Object} Returns the cloned `LazyWrapper` object.
1825 */
1826 function lazyClone() {
1827 var result = new LazyWrapper(this.__wrapped__);
1828 result.__actions__ = copyArray(this.__actions__);
1829 result.__dir__ = this.__dir__;
1830 result.__filtered__ = this.__filtered__;
1831 result.__iteratees__ = copyArray(this.__iteratees__);
1832 result.__takeCount__ = this.__takeCount__;
1833 result.__views__ = copyArray(this.__views__);
1834 return result;
1835 }
1836
1837 /**
1838 * Reverses the direction of lazy iteration.
1839 *
1840 * @private
1841 * @name reverse
1842 * @memberOf LazyWrapper
1843 * @returns {Object} Returns the new reversed `LazyWrapper` object.
1844 */
1845 function lazyReverse() {
1846 if (this.__filtered__) {
1847 var result = new LazyWrapper(this);
1848 result.__dir__ = -1;
1849 result.__filtered__ = true;
1850 } else {
1851 result = this.clone();
1852 result.__dir__ *= -1;
1853 }
1854 return result;
1855 }
1856
1857 /**
1858 * Extracts the unwrapped value from its lazy wrapper.
1859 *
1860 * @private
1861 * @name value
1862 * @memberOf LazyWrapper
1863 * @returns {*} Returns the unwrapped value.
1864 */
1865 function lazyValue() {
1866 var array = this.__wrapped__.value(),
1867 dir = this.__dir__,
1868 isArr = isArray(array),
1869 isRight = dir < 0,
1870 arrLength = isArr ? array.length : 0,
1871 view = getView(0, arrLength, this.__views__),
1872 start = view.start,
1873 end = view.end,
1874 length = end - start,
1875 index = isRight ? end : (start - 1),
1876 iteratees = this.__iteratees__,
1877 iterLength = iteratees.length,
1878 resIndex = 0,
1879 takeCount = nativeMin(length, this.__takeCount__);
1880
1881 if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
1882 return baseWrapperValue(array, this.__actions__);
1883 }
1884 var result = [];
1885
1886 outer:
1887 while (length-- && resIndex < takeCount) {
1888 index += dir;
1889
1890 var iterIndex = -1,
1891 value = array[index];
1892
1893 while (++iterIndex < iterLength) {
1894 var data = iteratees[iterIndex],
1895 iteratee = data.iteratee,
1896 type = data.type,
1897 computed = iteratee(value);
1898
1899 if (type == LAZY_MAP_FLAG) {
1900 value = computed;
1901 } else if (!computed) {
1902 if (type == LAZY_FILTER_FLAG) {
1903 continue outer;
1904 } else {
1905 break outer;
1906 }
1907 }
1908 }
1909 result[resIndex++] = value;
1910 }
1911 return result;
1912 }
1913
1914 // Ensure `LazyWrapper` is an instance of `baseLodash`.
1915 LazyWrapper.prototype = baseCreate(baseLodash.prototype);
1916 LazyWrapper.prototype.constructor = LazyWrapper;
1917
1918 /*------------------------------------------------------------------------*/
1919
1920 /**
1921 * Creates a hash object.
1922 *
1923 * @private
1924 * @constructor
1925 * @param {Array} [entries] The key-value pairs to cache.
1926 */
1927 function Hash(entries) {
1928 var index = -1,
1929 length = entries == null ? 0 : entries.length;
1930
1931 this.clear();
1932 while (++index < length) {
1933 var entry = entries[index];
1934 this.set(entry[0], entry[1]);
1935 }
1936 }
1937
1938 /**
1939 * Removes all key-value entries from the hash.
1940 *
1941 * @private
1942 * @name clear
1943 * @memberOf Hash
1944 */
1945 function hashClear() {
1946 this.__data__ = nativeCreate ? nativeCreate(null) : {};
1947 this.size = 0;
1948 }
1949
1950 /**
1951 * Removes `key` and its value from the hash.
1952 *
1953 * @private
1954 * @name delete
1955 * @memberOf Hash
1956 * @param {Object} hash The hash to modify.
1957 * @param {string} key The key of the value to remove.
1958 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1959 */
1960 function hashDelete(key) {
1961 var result = this.has(key) && delete this.__data__[key];
1962 this.size -= result ? 1 : 0;
1963 return result;
1964 }
1965
1966 /**
1967 * Gets the hash value for `key`.
1968 *
1969 * @private
1970 * @name get
1971 * @memberOf Hash
1972 * @param {string} key The key of the value to get.
1973 * @returns {*} Returns the entry value.
1974 */
1975 function hashGet(key) {
1976 var data = this.__data__;
1977 if (nativeCreate) {
1978 var result = data[key];
1979 return result === HASH_UNDEFINED ? undefined$1 : result;
1980 }
1981 return hasOwnProperty.call(data, key) ? data[key] : undefined$1;
1982 }
1983
1984 /**
1985 * Checks if a hash value for `key` exists.
1986 *
1987 * @private
1988 * @name has
1989 * @memberOf Hash
1990 * @param {string} key The key of the entry to check.
1991 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1992 */
1993 function hashHas(key) {
1994 var data = this.__data__;
1995 return nativeCreate ? (data[key] !== undefined$1) : hasOwnProperty.call(data, key);
1996 }
1997
1998 /**
1999 * Sets the hash `key` to `value`.
2000 *
2001 * @private
2002 * @name set
2003 * @memberOf Hash
2004 * @param {string} key The key of the value to set.
2005 * @param {*} value The value to set.
2006 * @returns {Object} Returns the hash instance.
2007 */
2008 function hashSet(key, value) {
2009 var data = this.__data__;
2010 this.size += this.has(key) ? 0 : 1;
2011 data[key] = (nativeCreate && value === undefined$1) ? HASH_UNDEFINED : value;
2012 return this;
2013 }
2014
2015 // Add methods to `Hash`.
2016 Hash.prototype.clear = hashClear;
2017 Hash.prototype['delete'] = hashDelete;
2018 Hash.prototype.get = hashGet;
2019 Hash.prototype.has = hashHas;
2020 Hash.prototype.set = hashSet;
2021
2022 /*------------------------------------------------------------------------*/
2023
2024 /**
2025 * Creates an list cache object.
2026 *
2027 * @private
2028 * @constructor
2029 * @param {Array} [entries] The key-value pairs to cache.
2030 */
2031 function ListCache(entries) {
2032 var index = -1,
2033 length = entries == null ? 0 : entries.length;
2034
2035 this.clear();
2036 while (++index < length) {
2037 var entry = entries[index];
2038 this.set(entry[0], entry[1]);
2039 }
2040 }
2041
2042 /**
2043 * Removes all key-value entries from the list cache.
2044 *
2045 * @private
2046 * @name clear
2047 * @memberOf ListCache
2048 */
2049 function listCacheClear() {
2050 this.__data__ = [];
2051 this.size = 0;
2052 }
2053
2054 /**
2055 * Removes `key` and its value from the list cache.
2056 *
2057 * @private
2058 * @name delete
2059 * @memberOf ListCache
2060 * @param {string} key The key of the value to remove.
2061 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2062 */
2063 function listCacheDelete(key) {
2064 var data = this.__data__,
2065 index = assocIndexOf(data, key);
2066
2067 if (index < 0) {
2068 return false;
2069 }
2070 var lastIndex = data.length - 1;
2071 if (index == lastIndex) {
2072 data.pop();
2073 } else {
2074 splice.call(data, index, 1);
2075 }
2076 --this.size;
2077 return true;
2078 }
2079
2080 /**
2081 * Gets the list cache value for `key`.
2082 *
2083 * @private
2084 * @name get
2085 * @memberOf ListCache
2086 * @param {string} key The key of the value to get.
2087 * @returns {*} Returns the entry value.
2088 */
2089 function listCacheGet(key) {
2090 var data = this.__data__,
2091 index = assocIndexOf(data, key);
2092
2093 return index < 0 ? undefined$1 : data[index][1];
2094 }
2095
2096 /**
2097 * Checks if a list cache value for `key` exists.
2098 *
2099 * @private
2100 * @name has
2101 * @memberOf ListCache
2102 * @param {string} key The key of the entry to check.
2103 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2104 */
2105 function listCacheHas(key) {
2106 return assocIndexOf(this.__data__, key) > -1;
2107 }
2108
2109 /**
2110 * Sets the list cache `key` to `value`.
2111 *
2112 * @private
2113 * @name set
2114 * @memberOf ListCache
2115 * @param {string} key The key of the value to set.
2116 * @param {*} value The value to set.
2117 * @returns {Object} Returns the list cache instance.
2118 */
2119 function listCacheSet(key, value) {
2120 var data = this.__data__,
2121 index = assocIndexOf(data, key);
2122
2123 if (index < 0) {
2124 ++this.size;
2125 data.push([key, value]);
2126 } else {
2127 data[index][1] = value;
2128 }
2129 return this;
2130 }
2131
2132 // Add methods to `ListCache`.
2133 ListCache.prototype.clear = listCacheClear;
2134 ListCache.prototype['delete'] = listCacheDelete;
2135 ListCache.prototype.get = listCacheGet;
2136 ListCache.prototype.has = listCacheHas;
2137 ListCache.prototype.set = listCacheSet;
2138
2139 /*------------------------------------------------------------------------*/
2140
2141 /**
2142 * Creates a map cache object to store key-value pairs.
2143 *
2144 * @private
2145 * @constructor
2146 * @param {Array} [entries] The key-value pairs to cache.
2147 */
2148 function MapCache(entries) {
2149 var index = -1,
2150 length = entries == null ? 0 : entries.length;
2151
2152 this.clear();
2153 while (++index < length) {
2154 var entry = entries[index];
2155 this.set(entry[0], entry[1]);
2156 }
2157 }
2158
2159 /**
2160 * Removes all key-value entries from the map.
2161 *
2162 * @private
2163 * @name clear
2164 * @memberOf MapCache
2165 */
2166 function mapCacheClear() {
2167 this.size = 0;
2168 this.__data__ = {
2169 'hash': new Hash,
2170 'map': new (Map || ListCache),
2171 'string': new Hash
2172 };
2173 }
2174
2175 /**
2176 * Removes `key` and its value from the map.
2177 *
2178 * @private
2179 * @name delete
2180 * @memberOf MapCache
2181 * @param {string} key The key of the value to remove.
2182 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2183 */
2184 function mapCacheDelete(key) {
2185 var result = getMapData(this, key)['delete'](key);
2186 this.size -= result ? 1 : 0;
2187 return result;
2188 }
2189
2190 /**
2191 * Gets the map value for `key`.
2192 *
2193 * @private
2194 * @name get
2195 * @memberOf MapCache
2196 * @param {string} key The key of the value to get.
2197 * @returns {*} Returns the entry value.
2198 */
2199 function mapCacheGet(key) {
2200 return getMapData(this, key).get(key);
2201 }
2202
2203 /**
2204 * Checks if a map value for `key` exists.
2205 *
2206 * @private
2207 * @name has
2208 * @memberOf MapCache
2209 * @param {string} key The key of the entry to check.
2210 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2211 */
2212 function mapCacheHas(key) {
2213 return getMapData(this, key).has(key);
2214 }
2215
2216 /**
2217 * Sets the map `key` to `value`.
2218 *
2219 * @private
2220 * @name set
2221 * @memberOf MapCache
2222 * @param {string} key The key of the value to set.
2223 * @param {*} value The value to set.
2224 * @returns {Object} Returns the map cache instance.
2225 */
2226 function mapCacheSet(key, value) {
2227 var data = getMapData(this, key),
2228 size = data.size;
2229
2230 data.set(key, value);
2231 this.size += data.size == size ? 0 : 1;
2232 return this;
2233 }
2234
2235 // Add methods to `MapCache`.
2236 MapCache.prototype.clear = mapCacheClear;
2237 MapCache.prototype['delete'] = mapCacheDelete;
2238 MapCache.prototype.get = mapCacheGet;
2239 MapCache.prototype.has = mapCacheHas;
2240 MapCache.prototype.set = mapCacheSet;
2241
2242 /*------------------------------------------------------------------------*/
2243
2244 /**
2245 *
2246 * Creates an array cache object to store unique values.
2247 *
2248 * @private
2249 * @constructor
2250 * @param {Array} [values] The values to cache.
2251 */
2252 function SetCache(values) {
2253 var index = -1,
2254 length = values == null ? 0 : values.length;
2255
2256 this.__data__ = new MapCache;
2257 while (++index < length) {
2258 this.add(values[index]);
2259 }
2260 }
2261
2262 /**
2263 * Adds `value` to the array cache.
2264 *
2265 * @private
2266 * @name add
2267 * @memberOf SetCache
2268 * @alias push
2269 * @param {*} value The value to cache.
2270 * @returns {Object} Returns the cache instance.
2271 */
2272 function setCacheAdd(value) {
2273 this.__data__.set(value, HASH_UNDEFINED);
2274 return this;
2275 }
2276
2277 /**
2278 * Checks if `value` is in the array cache.
2279 *
2280 * @private
2281 * @name has
2282 * @memberOf SetCache
2283 * @param {*} value The value to search for.
2284 * @returns {number} Returns `true` if `value` is found, else `false`.
2285 */
2286 function setCacheHas(value) {
2287 return this.__data__.has(value);
2288 }
2289
2290 // Add methods to `SetCache`.
2291 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2292 SetCache.prototype.has = setCacheHas;
2293
2294 /*------------------------------------------------------------------------*/
2295
2296 /**
2297 * Creates a stack cache object to store key-value pairs.
2298 *
2299 * @private
2300 * @constructor
2301 * @param {Array} [entries] The key-value pairs to cache.
2302 */
2303 function Stack(entries) {
2304 var data = this.__data__ = new ListCache(entries);
2305 this.size = data.size;
2306 }
2307
2308 /**
2309 * Removes all key-value entries from the stack.
2310 *
2311 * @private
2312 * @name clear
2313 * @memberOf Stack
2314 */
2315 function stackClear() {
2316 this.__data__ = new ListCache;
2317 this.size = 0;
2318 }
2319
2320 /**
2321 * Removes `key` and its value from the stack.
2322 *
2323 * @private
2324 * @name delete
2325 * @memberOf Stack
2326 * @param {string} key The key of the value to remove.
2327 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2328 */
2329 function stackDelete(key) {
2330 var data = this.__data__,
2331 result = data['delete'](key);
2332
2333 this.size = data.size;
2334 return result;
2335 }
2336
2337 /**
2338 * Gets the stack value for `key`.
2339 *
2340 * @private
2341 * @name get
2342 * @memberOf Stack
2343 * @param {string} key The key of the value to get.
2344 * @returns {*} Returns the entry value.
2345 */
2346 function stackGet(key) {
2347 return this.__data__.get(key);
2348 }
2349
2350 /**
2351 * Checks if a stack value for `key` exists.
2352 *
2353 * @private
2354 * @name has
2355 * @memberOf Stack
2356 * @param {string} key The key of the entry to check.
2357 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2358 */
2359 function stackHas(key) {
2360 return this.__data__.has(key);
2361 }
2362
2363 /**
2364 * Sets the stack `key` to `value`.
2365 *
2366 * @private
2367 * @name set
2368 * @memberOf Stack
2369 * @param {string} key The key of the value to set.
2370 * @param {*} value The value to set.
2371 * @returns {Object} Returns the stack cache instance.
2372 */
2373 function stackSet(key, value) {
2374 var data = this.__data__;
2375 if (data instanceof ListCache) {
2376 var pairs = data.__data__;
2377 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2378 pairs.push([key, value]);
2379 this.size = ++data.size;
2380 return this;
2381 }
2382 data = this.__data__ = new MapCache(pairs);
2383 }
2384 data.set(key, value);
2385 this.size = data.size;
2386 return this;
2387 }
2388
2389 // Add methods to `Stack`.
2390 Stack.prototype.clear = stackClear;
2391 Stack.prototype['delete'] = stackDelete;
2392 Stack.prototype.get = stackGet;
2393 Stack.prototype.has = stackHas;
2394 Stack.prototype.set = stackSet;
2395
2396 /*------------------------------------------------------------------------*/
2397
2398 /**
2399 * Creates an array of the enumerable property names of the array-like `value`.
2400 *
2401 * @private
2402 * @param {*} value The value to query.
2403 * @param {boolean} inherited Specify returning inherited property names.
2404 * @returns {Array} Returns the array of property names.
2405 */
2406 function arrayLikeKeys(value, inherited) {
2407 var isArr = isArray(value),
2408 isArg = !isArr && isArguments(value),
2409 isBuff = !isArr && !isArg && isBuffer(value),
2410 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2411 skipIndexes = isArr || isArg || isBuff || isType,
2412 result = skipIndexes ? baseTimes(value.length, String) : [],
2413 length = result.length;
2414
2415 for (var key in value) {
2416 if ((inherited || hasOwnProperty.call(value, key)) &&
2417 !(skipIndexes && (
2418 // Safari 9 has enumerable `arguments.length` in strict mode.
2419 key == 'length' ||
2420 // Node.js 0.10 has enumerable non-index properties on buffers.
2421 (isBuff && (key == 'offset' || key == 'parent')) ||
2422 // PhantomJS 2 has enumerable non-index properties on typed arrays.
2423 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2424 // Skip index properties.
2425 isIndex(key, length)
2426 ))) {
2427 result.push(key);
2428 }
2429 }
2430 return result;
2431 }
2432
2433 /**
2434 * A specialized version of `_.sample` for arrays.
2435 *
2436 * @private
2437 * @param {Array} array The array to sample.
2438 * @returns {*} Returns the random element.
2439 */
2440 function arraySample(array) {
2441 var length = array.length;
2442 return length ? array[baseRandom(0, length - 1)] : undefined$1;
2443 }
2444
2445 /**
2446 * A specialized version of `_.sampleSize` for arrays.
2447 *
2448 * @private
2449 * @param {Array} array The array to sample.
2450 * @param {number} n The number of elements to sample.
2451 * @returns {Array} Returns the random elements.
2452 */
2453 function arraySampleSize(array, n) {
2454 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
2455 }
2456
2457 /**
2458 * A specialized version of `_.shuffle` for arrays.
2459 *
2460 * @private
2461 * @param {Array} array The array to shuffle.
2462 * @returns {Array} Returns the new shuffled array.
2463 */
2464 function arrayShuffle(array) {
2465 return shuffleSelf(copyArray(array));
2466 }
2467
2468 /**
2469 * This function is like `assignValue` except that it doesn't assign
2470 * `undefined` values.
2471 *
2472 * @private
2473 * @param {Object} object The object to modify.
2474 * @param {string} key The key of the property to assign.
2475 * @param {*} value The value to assign.
2476 */
2477 function assignMergeValue(object, key, value) {
2478 if ((value !== undefined$1 && !eq(object[key], value)) ||
2479 (value === undefined$1 && !(key in object))) {
2480 baseAssignValue(object, key, value);
2481 }
2482 }
2483
2484 /**
2485 * Assigns `value` to `key` of `object` if the existing value is not equivalent
2486 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2487 * for equality comparisons.
2488 *
2489 * @private
2490 * @param {Object} object The object to modify.
2491 * @param {string} key The key of the property to assign.
2492 * @param {*} value The value to assign.
2493 */
2494 function assignValue(object, key, value) {
2495 var objValue = object[key];
2496 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2497 (value === undefined$1 && !(key in object))) {
2498 baseAssignValue(object, key, value);
2499 }
2500 }
2501
2502 /**
2503 * Gets the index at which the `key` is found in `array` of key-value pairs.
2504 *
2505 * @private
2506 * @param {Array} array The array to inspect.
2507 * @param {*} key The key to search for.
2508 * @returns {number} Returns the index of the matched value, else `-1`.
2509 */
2510 function assocIndexOf(array, key) {
2511 var length = array.length;
2512 while (length--) {
2513 if (eq(array[length][0], key)) {
2514 return length;
2515 }
2516 }
2517 return -1;
2518 }
2519
2520 /**
2521 * Aggregates elements of `collection` on `accumulator` with keys transformed
2522 * by `iteratee` and values set by `setter`.
2523 *
2524 * @private
2525 * @param {Array|Object} collection The collection to iterate over.
2526 * @param {Function} setter The function to set `accumulator` values.
2527 * @param {Function} iteratee The iteratee to transform keys.
2528 * @param {Object} accumulator The initial aggregated object.
2529 * @returns {Function} Returns `accumulator`.
2530 */
2531 function baseAggregator(collection, setter, iteratee, accumulator) {
2532 baseEach(collection, function(value, key, collection) {
2533 setter(accumulator, value, iteratee(value), collection);
2534 });
2535 return accumulator;
2536 }
2537
2538 /**
2539 * The base implementation of `_.assign` without support for multiple sources
2540 * or `customizer` functions.
2541 *
2542 * @private
2543 * @param {Object} object The destination object.
2544 * @param {Object} source The source object.
2545 * @returns {Object} Returns `object`.
2546 */
2547 function baseAssign(object, source) {
2548 return object && copyObject(source, keys(source), object);
2549 }
2550
2551 /**
2552 * The base implementation of `_.assignIn` without support for multiple sources
2553 * or `customizer` functions.
2554 *
2555 * @private
2556 * @param {Object} object The destination object.
2557 * @param {Object} source The source object.
2558 * @returns {Object} Returns `object`.
2559 */
2560 function baseAssignIn(object, source) {
2561 return object && copyObject(source, keysIn(source), object);
2562 }
2563
2564 /**
2565 * The base implementation of `assignValue` and `assignMergeValue` without
2566 * value checks.
2567 *
2568 * @private
2569 * @param {Object} object The object to modify.
2570 * @param {string} key The key of the property to assign.
2571 * @param {*} value The value to assign.
2572 */
2573 function baseAssignValue(object, key, value) {
2574 if (key == '__proto__' && defineProperty) {
2575 defineProperty(object, key, {
2576 'configurable': true,
2577 'enumerable': true,
2578 'value': value,
2579 'writable': true
2580 });
2581 } else {
2582 object[key] = value;
2583 }
2584 }
2585
2586 /**
2587 * The base implementation of `_.at` without support for individual paths.
2588 *
2589 * @private
2590 * @param {Object} object The object to iterate over.
2591 * @param {string[]} paths The property paths to pick.
2592 * @returns {Array} Returns the picked elements.
2593 */
2594 function baseAt(object, paths) {
2595 var index = -1,
2596 length = paths.length,
2597 result = Array(length),
2598 skip = object == null;
2599
2600 while (++index < length) {
2601 result[index] = skip ? undefined$1 : get(object, paths[index]);
2602 }
2603 return result;
2604 }
2605
2606 /**
2607 * The base implementation of `_.clamp` which doesn't coerce arguments.
2608 *
2609 * @private
2610 * @param {number} number The number to clamp.
2611 * @param {number} [lower] The lower bound.
2612 * @param {number} upper The upper bound.
2613 * @returns {number} Returns the clamped number.
2614 */
2615 function baseClamp(number, lower, upper) {
2616 if (number === number) {
2617 if (upper !== undefined$1) {
2618 number = number <= upper ? number : upper;
2619 }
2620 if (lower !== undefined$1) {
2621 number = number >= lower ? number : lower;
2622 }
2623 }
2624 return number;
2625 }
2626
2627 /**
2628 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2629 * traversed objects.
2630 *
2631 * @private
2632 * @param {*} value The value to clone.
2633 * @param {boolean} bitmask The bitmask flags.
2634 * 1 - Deep clone
2635 * 2 - Flatten inherited properties
2636 * 4 - Clone symbols
2637 * @param {Function} [customizer] The function to customize cloning.
2638 * @param {string} [key] The key of `value`.
2639 * @param {Object} [object] The parent object of `value`.
2640 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2641 * @returns {*} Returns the cloned value.
2642 */
2643 function baseClone(value, bitmask, customizer, key, object, stack) {
2644 var result,
2645 isDeep = bitmask & CLONE_DEEP_FLAG,
2646 isFlat = bitmask & CLONE_FLAT_FLAG,
2647 isFull = bitmask & CLONE_SYMBOLS_FLAG;
2648
2649 if (customizer) {
2650 result = object ? customizer(value, key, object, stack) : customizer(value);
2651 }
2652 if (result !== undefined$1) {
2653 return result;
2654 }
2655 if (!isObject(value)) {
2656 return value;
2657 }
2658 var isArr = isArray(value);
2659 if (isArr) {
2660 result = initCloneArray(value);
2661 if (!isDeep) {
2662 return copyArray(value, result);
2663 }
2664 } else {
2665 var tag = getTag(value),
2666 isFunc = tag == funcTag || tag == genTag;
2667
2668 if (isBuffer(value)) {
2669 return cloneBuffer(value, isDeep);
2670 }
2671 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
2672 result = (isFlat || isFunc) ? {} : initCloneObject(value);
2673 if (!isDeep) {
2674 return isFlat
2675 ? copySymbolsIn(value, baseAssignIn(result, value))
2676 : copySymbols(value, baseAssign(result, value));
2677 }
2678 } else {
2679 if (!cloneableTags[tag]) {
2680 return object ? value : {};
2681 }
2682 result = initCloneByTag(value, tag, isDeep);
2683 }
2684 }
2685 // Check for circular references and return its corresponding clone.
2686 stack || (stack = new Stack);
2687 var stacked = stack.get(value);
2688 if (stacked) {
2689 return stacked;
2690 }
2691 stack.set(value, result);
2692
2693 if (isSet(value)) {
2694 value.forEach(function(subValue) {
2695 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2696 });
2697 } else if (isMap(value)) {
2698 value.forEach(function(subValue, key) {
2699 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
2700 });
2701 }
2702
2703 var keysFunc = isFull
2704 ? (isFlat ? getAllKeysIn : getAllKeys)
2705 : (isFlat ? keysIn : keys);
2706
2707 var props = isArr ? undefined$1 : keysFunc(value);
2708 arrayEach(props || value, function(subValue, key) {
2709 if (props) {
2710 key = subValue;
2711 subValue = value[key];
2712 }
2713 // Recursively populate clone (susceptible to call stack limits).
2714 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
2715 });
2716 return result;
2717 }
2718
2719 /**
2720 * The base implementation of `_.conforms` which doesn't clone `source`.
2721 *
2722 * @private
2723 * @param {Object} source The object of property predicates to conform to.
2724 * @returns {Function} Returns the new spec function.
2725 */
2726 function baseConforms(source) {
2727 var props = keys(source);
2728 return function(object) {
2729 return baseConformsTo(object, source, props);
2730 };
2731 }
2732
2733 /**
2734 * The base implementation of `_.conformsTo` which accepts `props` to check.
2735 *
2736 * @private
2737 * @param {Object} object The object to inspect.
2738 * @param {Object} source The object of property predicates to conform to.
2739 * @returns {boolean} Returns `true` if `object` conforms, else `false`.
2740 */
2741 function baseConformsTo(object, source, props) {
2742 var length = props.length;
2743 if (object == null) {
2744 return !length;
2745 }
2746 object = Object(object);
2747 while (length--) {
2748 var key = props[length],
2749 predicate = source[key],
2750 value = object[key];
2751
2752 if ((value === undefined$1 && !(key in object)) || !predicate(value)) {
2753 return false;
2754 }
2755 }
2756 return true;
2757 }
2758
2759 /**
2760 * The base implementation of `_.delay` and `_.defer` which accepts `args`
2761 * to provide to `func`.
2762 *
2763 * @private
2764 * @param {Function} func The function to delay.
2765 * @param {number} wait The number of milliseconds to delay invocation.
2766 * @param {Array} args The arguments to provide to `func`.
2767 * @returns {number|Object} Returns the timer id or timeout object.
2768 */
2769 function baseDelay(func, wait, args) {
2770 if (typeof func != 'function') {
2771 throw new TypeError(FUNC_ERROR_TEXT);
2772 }
2773 return setTimeout(function() { func.apply(undefined$1, args); }, wait);
2774 }
2775
2776 /**
2777 * The base implementation of methods like `_.difference` without support
2778 * for excluding multiple arrays or iteratee shorthands.
2779 *
2780 * @private
2781 * @param {Array} array The array to inspect.
2782 * @param {Array} values The values to exclude.
2783 * @param {Function} [iteratee] The iteratee invoked per element.
2784 * @param {Function} [comparator] The comparator invoked per element.
2785 * @returns {Array} Returns the new array of filtered values.
2786 */
2787 function baseDifference(array, values, iteratee, comparator) {
2788 var index = -1,
2789 includes = arrayIncludes,
2790 isCommon = true,
2791 length = array.length,
2792 result = [],
2793 valuesLength = values.length;
2794
2795 if (!length) {
2796 return result;
2797 }
2798 if (iteratee) {
2799 values = arrayMap(values, baseUnary(iteratee));
2800 }
2801 if (comparator) {
2802 includes = arrayIncludesWith;
2803 isCommon = false;
2804 }
2805 else if (values.length >= LARGE_ARRAY_SIZE) {
2806 includes = cacheHas;
2807 isCommon = false;
2808 values = new SetCache(values);
2809 }
2810 outer:
2811 while (++index < length) {
2812 var value = array[index],
2813 computed = iteratee == null ? value : iteratee(value);
2814
2815 value = (comparator || value !== 0) ? value : 0;
2816 if (isCommon && computed === computed) {
2817 var valuesIndex = valuesLength;
2818 while (valuesIndex--) {
2819 if (values[valuesIndex] === computed) {
2820 continue outer;
2821 }
2822 }
2823 result.push(value);
2824 }
2825 else if (!includes(values, computed, comparator)) {
2826 result.push(value);
2827 }
2828 }
2829 return result;
2830 }
2831
2832 /**
2833 * The base implementation of `_.forEach` without support for iteratee shorthands.
2834 *
2835 * @private
2836 * @param {Array|Object} collection The collection to iterate over.
2837 * @param {Function} iteratee The function invoked per iteration.
2838 * @returns {Array|Object} Returns `collection`.
2839 */
2840 var baseEach = createBaseEach(baseForOwn);
2841
2842 /**
2843 * The base implementation of `_.forEachRight` without support for iteratee shorthands.
2844 *
2845 * @private
2846 * @param {Array|Object} collection The collection to iterate over.
2847 * @param {Function} iteratee The function invoked per iteration.
2848 * @returns {Array|Object} Returns `collection`.
2849 */
2850 var baseEachRight = createBaseEach(baseForOwnRight, true);
2851
2852 /**
2853 * The base implementation of `_.every` without support for iteratee shorthands.
2854 *
2855 * @private
2856 * @param {Array|Object} collection The collection to iterate over.
2857 * @param {Function} predicate The function invoked per iteration.
2858 * @returns {boolean} Returns `true` if all elements pass the predicate check,
2859 * else `false`
2860 */
2861 function baseEvery(collection, predicate) {
2862 var result = true;
2863 baseEach(collection, function(value, index, collection) {
2864 result = !!predicate(value, index, collection);
2865 return result;
2866 });
2867 return result;
2868 }
2869
2870 /**
2871 * The base implementation of methods like `_.max` and `_.min` which accepts a
2872 * `comparator` to determine the extremum value.
2873 *
2874 * @private
2875 * @param {Array} array The array to iterate over.
2876 * @param {Function} iteratee The iteratee invoked per iteration.
2877 * @param {Function} comparator The comparator used to compare values.
2878 * @returns {*} Returns the extremum value.
2879 */
2880 function baseExtremum(array, iteratee, comparator) {
2881 var index = -1,
2882 length = array.length;
2883
2884 while (++index < length) {
2885 var value = array[index],
2886 current = iteratee(value);
2887
2888 if (current != null && (computed === undefined$1
2889 ? (current === current && !isSymbol(current))
2890 : comparator(current, computed)
2891 )) {
2892 var computed = current,
2893 result = value;
2894 }
2895 }
2896 return result;
2897 }
2898
2899 /**
2900 * The base implementation of `_.fill` without an iteratee call guard.
2901 *
2902 * @private
2903 * @param {Array} array The array to fill.
2904 * @param {*} value The value to fill `array` with.
2905 * @param {number} [start=0] The start position.
2906 * @param {number} [end=array.length] The end position.
2907 * @returns {Array} Returns `array`.
2908 */
2909 function baseFill(array, value, start, end) {
2910 var length = array.length;
2911
2912 start = toInteger(start);
2913 if (start < 0) {
2914 start = -start > length ? 0 : (length + start);
2915 }
2916 end = (end === undefined$1 || end > length) ? length : toInteger(end);
2917 if (end < 0) {
2918 end += length;
2919 }
2920 end = start > end ? 0 : toLength(end);
2921 while (start < end) {
2922 array[start++] = value;
2923 }
2924 return array;
2925 }
2926
2927 /**
2928 * The base implementation of `_.filter` without support for iteratee shorthands.
2929 *
2930 * @private
2931 * @param {Array|Object} collection The collection to iterate over.
2932 * @param {Function} predicate The function invoked per iteration.
2933 * @returns {Array} Returns the new filtered array.
2934 */
2935 function baseFilter(collection, predicate) {
2936 var result = [];
2937 baseEach(collection, function(value, index, collection) {
2938 if (predicate(value, index, collection)) {
2939 result.push(value);
2940 }
2941 });
2942 return result;
2943 }
2944
2945 /**
2946 * The base implementation of `_.flatten` with support for restricting flattening.
2947 *
2948 * @private
2949 * @param {Array} array The array to flatten.
2950 * @param {number} depth The maximum recursion depth.
2951 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
2952 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
2953 * @param {Array} [result=[]] The initial result value.
2954 * @returns {Array} Returns the new flattened array.
2955 */
2956 function baseFlatten(array, depth, predicate, isStrict, result) {
2957 var index = -1,
2958 length = array.length;
2959
2960 predicate || (predicate = isFlattenable);
2961 result || (result = []);
2962
2963 while (++index < length) {
2964 var value = array[index];
2965 if (depth > 0 && predicate(value)) {
2966 if (depth > 1) {
2967 // Recursively flatten arrays (susceptible to call stack limits).
2968 baseFlatten(value, depth - 1, predicate, isStrict, result);
2969 } else {
2970 arrayPush(result, value);
2971 }
2972 } else if (!isStrict) {
2973 result[result.length] = value;
2974 }
2975 }
2976 return result;
2977 }
2978
2979 /**
2980 * The base implementation of `baseForOwn` which iterates over `object`
2981 * properties returned by `keysFunc` and invokes `iteratee` for each property.
2982 * Iteratee functions may exit iteration early by explicitly returning `false`.
2983 *
2984 * @private
2985 * @param {Object} object The object to iterate over.
2986 * @param {Function} iteratee The function invoked per iteration.
2987 * @param {Function} keysFunc The function to get the keys of `object`.
2988 * @returns {Object} Returns `object`.
2989 */
2990 var baseFor = createBaseFor();
2991
2992 /**
2993 * This function is like `baseFor` except that it iterates over properties
2994 * in the opposite order.
2995 *
2996 * @private
2997 * @param {Object} object The object to iterate over.
2998 * @param {Function} iteratee The function invoked per iteration.
2999 * @param {Function} keysFunc The function to get the keys of `object`.
3000 * @returns {Object} Returns `object`.
3001 */
3002 var baseForRight = createBaseFor(true);
3003
3004 /**
3005 * The base implementation of `_.forOwn` without support for iteratee shorthands.
3006 *
3007 * @private
3008 * @param {Object} object The object to iterate over.
3009 * @param {Function} iteratee The function invoked per iteration.
3010 * @returns {Object} Returns `object`.
3011 */
3012 function baseForOwn(object, iteratee) {
3013 return object && baseFor(object, iteratee, keys);
3014 }
3015
3016 /**
3017 * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
3018 *
3019 * @private
3020 * @param {Object} object The object to iterate over.
3021 * @param {Function} iteratee The function invoked per iteration.
3022 * @returns {Object} Returns `object`.
3023 */
3024 function baseForOwnRight(object, iteratee) {
3025 return object && baseForRight(object, iteratee, keys);
3026 }
3027
3028 /**
3029 * The base implementation of `_.functions` which creates an array of
3030 * `object` function property names filtered from `props`.
3031 *
3032 * @private
3033 * @param {Object} object The object to inspect.
3034 * @param {Array} props The property names to filter.
3035 * @returns {Array} Returns the function names.
3036 */
3037 function baseFunctions(object, props) {
3038 return arrayFilter(props, function(key) {
3039 return isFunction(object[key]);
3040 });
3041 }
3042
3043 /**
3044 * The base implementation of `_.get` without support for default values.
3045 *
3046 * @private
3047 * @param {Object} object The object to query.
3048 * @param {Array|string} path The path of the property to get.
3049 * @returns {*} Returns the resolved value.
3050 */
3051 function baseGet(object, path) {
3052 path = castPath(path, object);
3053
3054 var index = 0,
3055 length = path.length;
3056
3057 while (object != null && index < length) {
3058 object = object[toKey(path[index++])];
3059 }
3060 return (index && index == length) ? object : undefined$1;
3061 }
3062
3063 /**
3064 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3065 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3066 * symbols of `object`.
3067 *
3068 * @private
3069 * @param {Object} object The object to query.
3070 * @param {Function} keysFunc The function to get the keys of `object`.
3071 * @param {Function} symbolsFunc The function to get the symbols of `object`.
3072 * @returns {Array} Returns the array of property names and symbols.
3073 */
3074 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3075 var result = keysFunc(object);
3076 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
3077 }
3078
3079 /**
3080 * The base implementation of `getTag` without fallbacks for buggy environments.
3081 *
3082 * @private
3083 * @param {*} value The value to query.
3084 * @returns {string} Returns the `toStringTag`.
3085 */
3086 function baseGetTag(value) {
3087 if (value == null) {
3088 return value === undefined$1 ? undefinedTag : nullTag;
3089 }
3090 return (symToStringTag && symToStringTag in Object(value))
3091 ? getRawTag(value)
3092 : objectToString(value);
3093 }
3094
3095 /**
3096 * The base implementation of `_.gt` which doesn't coerce arguments.
3097 *
3098 * @private
3099 * @param {*} value The value to compare.
3100 * @param {*} other The other value to compare.
3101 * @returns {boolean} Returns `true` if `value` is greater than `other`,
3102 * else `false`.
3103 */
3104 function baseGt(value, other) {
3105 return value > other;
3106 }
3107
3108 /**
3109 * The base implementation of `_.has` without support for deep paths.
3110 *
3111 * @private
3112 * @param {Object} [object] The object to query.
3113 * @param {Array|string} key The key to check.
3114 * @returns {boolean} Returns `true` if `key` exists, else `false`.
3115 */
3116 function baseHas(object, key) {
3117 return object != null && hasOwnProperty.call(object, key);
3118 }
3119
3120 /**
3121 * The base implementation of `_.hasIn` without support for deep paths.
3122 *
3123 * @private
3124 * @param {Object} [object] The object to query.
3125 * @param {Array|string} key The key to check.
3126 * @returns {boolean} Returns `true` if `key` exists, else `false`.
3127 */
3128 function baseHasIn(object, key) {
3129 return object != null && key in Object(object);
3130 }
3131
3132 /**
3133 * The base implementation of `_.inRange` which doesn't coerce arguments.
3134 *
3135 * @private
3136 * @param {number} number The number to check.
3137 * @param {number} start The start of the range.
3138 * @param {number} end The end of the range.
3139 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
3140 */
3141 function baseInRange(number, start, end) {
3142 return number >= nativeMin(start, end) && number < nativeMax(start, end);
3143 }
3144
3145 /**
3146 * The base implementation of methods like `_.intersection`, without support
3147 * for iteratee shorthands, that accepts an array of arrays to inspect.
3148 *
3149 * @private
3150 * @param {Array} arrays The arrays to inspect.
3151 * @param {Function} [iteratee] The iteratee invoked per element.
3152 * @param {Function} [comparator] The comparator invoked per element.
3153 * @returns {Array} Returns the new array of shared values.
3154 */
3155 function baseIntersection(arrays, iteratee, comparator) {
3156 var includes = comparator ? arrayIncludesWith : arrayIncludes,
3157 length = arrays[0].length,
3158 othLength = arrays.length,
3159 othIndex = othLength,
3160 caches = Array(othLength),
3161 maxLength = Infinity,
3162 result = [];
3163
3164 while (othIndex--) {
3165 var array = arrays[othIndex];
3166 if (othIndex && iteratee) {
3167 array = arrayMap(array, baseUnary(iteratee));
3168 }
3169 maxLength = nativeMin(array.length, maxLength);
3170 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
3171 ? new SetCache(othIndex && array)
3172 : undefined$1;
3173 }
3174 array = arrays[0];
3175
3176 var index = -1,
3177 seen = caches[0];
3178
3179 outer:
3180 while (++index < length && result.length < maxLength) {
3181 var value = array[index],
3182 computed = iteratee ? iteratee(value) : value;
3183
3184 value = (comparator || value !== 0) ? value : 0;
3185 if (!(seen
3186 ? cacheHas(seen, computed)
3187 : includes(result, computed, comparator)
3188 )) {
3189 othIndex = othLength;
3190 while (--othIndex) {
3191 var cache = caches[othIndex];
3192 if (!(cache
3193 ? cacheHas(cache, computed)
3194 : includes(arrays[othIndex], computed, comparator))
3195 ) {
3196 continue outer;
3197 }
3198 }
3199 if (seen) {
3200 seen.push(computed);
3201 }
3202 result.push(value);
3203 }
3204 }
3205 return result;
3206 }
3207
3208 /**
3209 * The base implementation of `_.invert` and `_.invertBy` which inverts
3210 * `object` with values transformed by `iteratee` and set by `setter`.
3211 *
3212 * @private
3213 * @param {Object} object The object to iterate over.
3214 * @param {Function} setter The function to set `accumulator` values.
3215 * @param {Function} iteratee The iteratee to transform values.
3216 * @param {Object} accumulator The initial inverted object.
3217 * @returns {Function} Returns `accumulator`.
3218 */
3219 function baseInverter(object, setter, iteratee, accumulator) {
3220 baseForOwn(object, function(value, key, object) {
3221 setter(accumulator, iteratee(value), key, object);
3222 });
3223 return accumulator;
3224 }
3225
3226 /**
3227 * The base implementation of `_.invoke` without support for individual
3228 * method arguments.
3229 *
3230 * @private
3231 * @param {Object} object The object to query.
3232 * @param {Array|string} path The path of the method to invoke.
3233 * @param {Array} args The arguments to invoke the method with.
3234 * @returns {*} Returns the result of the invoked method.
3235 */
3236 function baseInvoke(object, path, args) {
3237 path = castPath(path, object);
3238 object = parent(object, path);
3239 var func = object == null ? object : object[toKey(last(path))];
3240 return func == null ? undefined$1 : apply(func, object, args);
3241 }
3242
3243 /**
3244 * The base implementation of `_.isArguments`.
3245 *
3246 * @private
3247 * @param {*} value The value to check.
3248 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3249 */
3250 function baseIsArguments(value) {
3251 return isObjectLike(value) && baseGetTag(value) == argsTag;
3252 }
3253
3254 /**
3255 * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
3256 *
3257 * @private
3258 * @param {*} value The value to check.
3259 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3260 */
3261 function baseIsArrayBuffer(value) {
3262 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
3263 }
3264
3265 /**
3266 * The base implementation of `_.isDate` without Node.js optimizations.
3267 *
3268 * @private
3269 * @param {*} value The value to check.
3270 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
3271 */
3272 function baseIsDate(value) {
3273 return isObjectLike(value) && baseGetTag(value) == dateTag;
3274 }
3275
3276 /**
3277 * The base implementation of `_.isEqual` which supports partial comparisons
3278 * and tracks traversed objects.
3279 *
3280 * @private
3281 * @param {*} value The value to compare.
3282 * @param {*} other The other value to compare.
3283 * @param {boolean} bitmask The bitmask flags.
3284 * 1 - Unordered comparison
3285 * 2 - Partial comparison
3286 * @param {Function} [customizer] The function to customize comparisons.
3287 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
3288 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3289 */
3290 function baseIsEqual(value, other, bitmask, customizer, stack) {
3291 if (value === other) {
3292 return true;
3293 }
3294 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
3295 return value !== value && other !== other;
3296 }
3297 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
3298 }
3299
3300 /**
3301 * A specialized version of `baseIsEqual` for arrays and objects which performs
3302 * deep comparisons and tracks traversed objects enabling objects with circular
3303 * references to be compared.
3304 *
3305 * @private
3306 * @param {Object} object The object to compare.
3307 * @param {Object} other The other object to compare.
3308 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
3309 * @param {Function} customizer The function to customize comparisons.
3310 * @param {Function} equalFunc The function to determine equivalents of values.
3311 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
3312 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3313 */
3314 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3315 var objIsArr = isArray(object),
3316 othIsArr = isArray(other),
3317 objTag = objIsArr ? arrayTag : getTag(object),
3318 othTag = othIsArr ? arrayTag : getTag(other);
3319
3320 objTag = objTag == argsTag ? objectTag : objTag;
3321 othTag = othTag == argsTag ? objectTag : othTag;
3322
3323 var objIsObj = objTag == objectTag,
3324 othIsObj = othTag == objectTag,
3325 isSameTag = objTag == othTag;
3326
3327 if (isSameTag && isBuffer(object)) {
3328 if (!isBuffer(other)) {
3329 return false;
3330 }
3331 objIsArr = true;
3332 objIsObj = false;
3333 }
3334 if (isSameTag && !objIsObj) {
3335 stack || (stack = new Stack);
3336 return (objIsArr || isTypedArray(object))
3337 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
3338 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
3339 }
3340 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
3341 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
3342 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
3343
3344 if (objIsWrapped || othIsWrapped) {
3345 var objUnwrapped = objIsWrapped ? object.value() : object,
3346 othUnwrapped = othIsWrapped ? other.value() : other;
3347
3348 stack || (stack = new Stack);
3349 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
3350 }
3351 }
3352 if (!isSameTag) {
3353 return false;
3354 }
3355 stack || (stack = new Stack);
3356 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
3357 }
3358
3359 /**
3360 * The base implementation of `_.isMap` without Node.js optimizations.
3361 *
3362 * @private
3363 * @param {*} value The value to check.
3364 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3365 */
3366 function baseIsMap(value) {
3367 return isObjectLike(value) && getTag(value) == mapTag;
3368 }
3369
3370 /**
3371 * The base implementation of `_.isMatch` without support for iteratee shorthands.
3372 *
3373 * @private
3374 * @param {Object} object The object to inspect.
3375 * @param {Object} source The object of property values to match.
3376 * @param {Array} matchData The property names, values, and compare flags to match.
3377 * @param {Function} [customizer] The function to customize comparisons.
3378 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
3379 */
3380 function baseIsMatch(object, source, matchData, customizer) {
3381 var index = matchData.length,
3382 length = index,
3383 noCustomizer = !customizer;
3384
3385 if (object == null) {
3386 return !length;
3387 }
3388 object = Object(object);
3389 while (index--) {
3390 var data = matchData[index];
3391 if ((noCustomizer && data[2])
3392 ? data[1] !== object[data[0]]
3393 : !(data[0] in object)
3394 ) {
3395 return false;
3396 }
3397 }
3398 while (++index < length) {
3399 data = matchData[index];
3400 var key = data[0],
3401 objValue = object[key],
3402 srcValue = data[1];
3403
3404 if (noCustomizer && data[2]) {
3405 if (objValue === undefined$1 && !(key in object)) {
3406 return false;
3407 }
3408 } else {
3409 var stack = new Stack;
3410 if (customizer) {
3411 var result = customizer(objValue, srcValue, key, object, source, stack);
3412 }
3413 if (!(result === undefined$1
3414 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
3415 : result
3416 )) {
3417 return false;
3418 }
3419 }
3420 }
3421 return true;
3422 }
3423
3424 /**
3425 * The base implementation of `_.isNative` without bad shim checks.
3426 *
3427 * @private
3428 * @param {*} value The value to check.
3429 * @returns {boolean} Returns `true` if `value` is a native function,
3430 * else `false`.
3431 */
3432 function baseIsNative(value) {
3433 if (!isObject(value) || isMasked(value)) {
3434 return false;
3435 }
3436 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
3437 return pattern.test(toSource(value));
3438 }
3439
3440 /**
3441 * The base implementation of `_.isRegExp` without Node.js optimizations.
3442 *
3443 * @private
3444 * @param {*} value The value to check.
3445 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
3446 */
3447 function baseIsRegExp(value) {
3448 return isObjectLike(value) && baseGetTag(value) == regexpTag;
3449 }
3450
3451 /**
3452 * The base implementation of `_.isSet` without Node.js optimizations.
3453 *
3454 * @private
3455 * @param {*} value The value to check.
3456 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3457 */
3458 function baseIsSet(value) {
3459 return isObjectLike(value) && getTag(value) == setTag;
3460 }
3461
3462 /**
3463 * The base implementation of `_.isTypedArray` without Node.js optimizations.
3464 *
3465 * @private
3466 * @param {*} value The value to check.
3467 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3468 */
3469 function baseIsTypedArray(value) {
3470 return isObjectLike(value) &&
3471 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
3472 }
3473
3474 /**
3475 * The base implementation of `_.iteratee`.
3476 *
3477 * @private
3478 * @param {*} [value=_.identity] The value to convert to an iteratee.
3479 * @returns {Function} Returns the iteratee.
3480 */
3481 function baseIteratee(value) {
3482 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
3483 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
3484 if (typeof value == 'function') {
3485 return value;
3486 }
3487 if (value == null) {
3488 return identity;
3489 }
3490 if (typeof value == 'object') {
3491 return isArray(value)
3492 ? baseMatchesProperty(value[0], value[1])
3493 : baseMatches(value);
3494 }
3495 return property(value);
3496 }
3497
3498 /**
3499 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3500 *
3501 * @private
3502 * @param {Object} object The object to query.
3503 * @returns {Array} Returns the array of property names.
3504 */
3505 function baseKeys(object) {
3506 if (!isPrototype(object)) {
3507 return nativeKeys(object);
3508 }
3509 var result = [];
3510 for (var key in Object(object)) {
3511 if (hasOwnProperty.call(object, key) && key != 'constructor') {
3512 result.push(key);
3513 }
3514 }
3515 return result;
3516 }
3517
3518 /**
3519 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
3520 *
3521 * @private
3522 * @param {Object} object The object to query.
3523 * @returns {Array} Returns the array of property names.
3524 */
3525 function baseKeysIn(object) {
3526 if (!isObject(object)) {
3527 return nativeKeysIn(object);
3528 }
3529 var isProto = isPrototype(object),
3530 result = [];
3531
3532 for (var key in object) {
3533 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
3534 result.push(key);
3535 }
3536 }
3537 return result;
3538 }
3539
3540 /**
3541 * The base implementation of `_.lt` which doesn't coerce arguments.
3542 *
3543 * @private
3544 * @param {*} value The value to compare.
3545 * @param {*} other The other value to compare.
3546 * @returns {boolean} Returns `true` if `value` is less than `other`,
3547 * else `false`.
3548 */
3549 function baseLt(value, other) {
3550 return value < other;
3551 }
3552
3553 /**
3554 * The base implementation of `_.map` without support for iteratee shorthands.
3555 *
3556 * @private
3557 * @param {Array|Object} collection The collection to iterate over.
3558 * @param {Function} iteratee The function invoked per iteration.
3559 * @returns {Array} Returns the new mapped array.
3560 */
3561 function baseMap(collection, iteratee) {
3562 var index = -1,
3563 result = isArrayLike(collection) ? Array(collection.length) : [];
3564
3565 baseEach(collection, function(value, key, collection) {
3566 result[++index] = iteratee(value, key, collection);
3567 });
3568 return result;
3569 }
3570
3571 /**
3572 * The base implementation of `_.matches` which doesn't clone `source`.
3573 *
3574 * @private
3575 * @param {Object} source The object of property values to match.
3576 * @returns {Function} Returns the new spec function.
3577 */
3578 function baseMatches(source) {
3579 var matchData = getMatchData(source);
3580 if (matchData.length == 1 && matchData[0][2]) {
3581 return matchesStrictComparable(matchData[0][0], matchData[0][1]);
3582 }
3583 return function(object) {
3584 return object === source || baseIsMatch(object, source, matchData);
3585 };
3586 }
3587
3588 /**
3589 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
3590 *
3591 * @private
3592 * @param {string} path The path of the property to get.
3593 * @param {*} srcValue The value to match.
3594 * @returns {Function} Returns the new spec function.
3595 */
3596 function baseMatchesProperty(path, srcValue) {
3597 if (isKey(path) && isStrictComparable(srcValue)) {
3598 return matchesStrictComparable(toKey(path), srcValue);
3599 }
3600 return function(object) {
3601 var objValue = get(object, path);
3602 return (objValue === undefined$1 && objValue === srcValue)
3603 ? hasIn(object, path)
3604 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
3605 };
3606 }
3607
3608 /**
3609 * The base implementation of `_.merge` without support for multiple sources.
3610 *
3611 * @private
3612 * @param {Object} object The destination object.
3613 * @param {Object} source The source object.
3614 * @param {number} srcIndex The index of `source`.
3615 * @param {Function} [customizer] The function to customize merged values.
3616 * @param {Object} [stack] Tracks traversed source values and their merged
3617 * counterparts.
3618 */
3619 function baseMerge(object, source, srcIndex, customizer, stack) {
3620 if (object === source) {
3621 return;
3622 }
3623 baseFor(source, function(srcValue, key) {
3624 stack || (stack = new Stack);
3625 if (isObject(srcValue)) {
3626 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3627 }
3628 else {
3629 var newValue = customizer
3630 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
3631 : undefined$1;
3632
3633 if (newValue === undefined$1) {
3634 newValue = srcValue;
3635 }
3636 assignMergeValue(object, key, newValue);
3637 }
3638 }, keysIn);
3639 }
3640
3641 /**
3642 * A specialized version of `baseMerge` for arrays and objects which performs
3643 * deep merges and tracks traversed objects enabling objects with circular
3644 * references to be merged.
3645 *
3646 * @private
3647 * @param {Object} object The destination object.
3648 * @param {Object} source The source object.
3649 * @param {string} key The key of the value to merge.
3650 * @param {number} srcIndex The index of `source`.
3651 * @param {Function} mergeFunc The function to merge values.
3652 * @param {Function} [customizer] The function to customize assigned values.
3653 * @param {Object} [stack] Tracks traversed source values and their merged
3654 * counterparts.
3655 */
3656 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3657 var objValue = safeGet(object, key),
3658 srcValue = safeGet(source, key),
3659 stacked = stack.get(srcValue);
3660
3661 if (stacked) {
3662 assignMergeValue(object, key, stacked);
3663 return;
3664 }
3665 var newValue = customizer
3666 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
3667 : undefined$1;
3668
3669 var isCommon = newValue === undefined$1;
3670
3671 if (isCommon) {
3672 var isArr = isArray(srcValue),
3673 isBuff = !isArr && isBuffer(srcValue),
3674 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3675
3676 newValue = srcValue;
3677 if (isArr || isBuff || isTyped) {
3678 if (isArray(objValue)) {
3679 newValue = objValue;
3680 }
3681 else if (isArrayLikeObject(objValue)) {
3682 newValue = copyArray(objValue);
3683 }
3684 else if (isBuff) {
3685 isCommon = false;
3686 newValue = cloneBuffer(srcValue, true);
3687 }
3688 else if (isTyped) {
3689 isCommon = false;
3690 newValue = cloneTypedArray(srcValue, true);
3691 }
3692 else {
3693 newValue = [];
3694 }
3695 }
3696 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3697 newValue = objValue;
3698 if (isArguments(objValue)) {
3699 newValue = toPlainObject(objValue);
3700 }
3701 else if (!isObject(objValue) || isFunction(objValue)) {
3702 newValue = initCloneObject(srcValue);
3703 }
3704 }
3705 else {
3706 isCommon = false;
3707 }
3708 }
3709 if (isCommon) {
3710 // Recursively merge objects and arrays (susceptible to call stack limits).
3711 stack.set(srcValue, newValue);
3712 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3713 stack['delete'](srcValue);
3714 }
3715 assignMergeValue(object, key, newValue);
3716 }
3717
3718 /**
3719 * The base implementation of `_.nth` which doesn't coerce arguments.
3720 *
3721 * @private
3722 * @param {Array} array The array to query.
3723 * @param {number} n The index of the element to return.
3724 * @returns {*} Returns the nth element of `array`.
3725 */
3726 function baseNth(array, n) {
3727 var length = array.length;
3728 if (!length) {
3729 return;
3730 }
3731 n += n < 0 ? length : 0;
3732 return isIndex(n, length) ? array[n] : undefined$1;
3733 }
3734
3735 /**
3736 * The base implementation of `_.orderBy` without param guards.
3737 *
3738 * @private
3739 * @param {Array|Object} collection The collection to iterate over.
3740 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
3741 * @param {string[]} orders The sort orders of `iteratees`.
3742 * @returns {Array} Returns the new sorted array.
3743 */
3744 function baseOrderBy(collection, iteratees, orders) {
3745 if (iteratees.length) {
3746 iteratees = arrayMap(iteratees, function(iteratee) {
3747 if (isArray(iteratee)) {
3748 return function(value) {
3749 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
3750 }
3751 }
3752 return iteratee;
3753 });
3754 } else {
3755 iteratees = [identity];
3756 }
3757
3758 var index = -1;
3759 iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
3760
3761 var result = baseMap(collection, function(value, key, collection) {
3762 var criteria = arrayMap(iteratees, function(iteratee) {
3763 return iteratee(value);
3764 });
3765 return { 'criteria': criteria, 'index': ++index, 'value': value };
3766 });
3767
3768 return baseSortBy(result, function(object, other) {
3769 return compareMultiple(object, other, orders);
3770 });
3771 }
3772
3773 /**
3774 * The base implementation of `_.pick` without support for individual
3775 * property identifiers.
3776 *
3777 * @private
3778 * @param {Object} object The source object.
3779 * @param {string[]} paths The property paths to pick.
3780 * @returns {Object} Returns the new object.
3781 */
3782 function basePick(object, paths) {
3783 return basePickBy(object, paths, function(value, path) {
3784 return hasIn(object, path);
3785 });
3786 }
3787
3788 /**
3789 * The base implementation of `_.pickBy` without support for iteratee shorthands.
3790 *
3791 * @private
3792 * @param {Object} object The source object.
3793 * @param {string[]} paths The property paths to pick.
3794 * @param {Function} predicate The function invoked per property.
3795 * @returns {Object} Returns the new object.
3796 */
3797 function basePickBy(object, paths, predicate) {
3798 var index = -1,
3799 length = paths.length,
3800 result = {};
3801
3802 while (++index < length) {
3803 var path = paths[index],
3804 value = baseGet(object, path);
3805
3806 if (predicate(value, path)) {
3807 baseSet(result, castPath(path, object), value);
3808 }
3809 }
3810 return result;
3811 }
3812
3813 /**
3814 * A specialized version of `baseProperty` which supports deep paths.
3815 *
3816 * @private
3817 * @param {Array|string} path The path of the property to get.
3818 * @returns {Function} Returns the new accessor function.
3819 */
3820 function basePropertyDeep(path) {
3821 return function(object) {
3822 return baseGet(object, path);
3823 };
3824 }
3825
3826 /**
3827 * The base implementation of `_.pullAllBy` without support for iteratee
3828 * shorthands.
3829 *
3830 * @private
3831 * @param {Array} array The array to modify.
3832 * @param {Array} values The values to remove.
3833 * @param {Function} [iteratee] The iteratee invoked per element.
3834 * @param {Function} [comparator] The comparator invoked per element.
3835 * @returns {Array} Returns `array`.
3836 */
3837 function basePullAll(array, values, iteratee, comparator) {
3838 var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
3839 index = -1,
3840 length = values.length,
3841 seen = array;
3842
3843 if (array === values) {
3844 values = copyArray(values);
3845 }
3846 if (iteratee) {
3847 seen = arrayMap(array, baseUnary(iteratee));
3848 }
3849 while (++index < length) {
3850 var fromIndex = 0,
3851 value = values[index],
3852 computed = iteratee ? iteratee(value) : value;
3853
3854 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
3855 if (seen !== array) {
3856 splice.call(seen, fromIndex, 1);
3857 }
3858 splice.call(array, fromIndex, 1);
3859 }
3860 }
3861 return array;
3862 }
3863
3864 /**
3865 * The base implementation of `_.pullAt` without support for individual
3866 * indexes or capturing the removed elements.
3867 *
3868 * @private
3869 * @param {Array} array The array to modify.
3870 * @param {number[]} indexes The indexes of elements to remove.
3871 * @returns {Array} Returns `array`.
3872 */
3873 function basePullAt(array, indexes) {
3874 var length = array ? indexes.length : 0,
3875 lastIndex = length - 1;
3876
3877 while (length--) {
3878 var index = indexes[length];
3879 if (length == lastIndex || index !== previous) {
3880 var previous = index;
3881 if (isIndex(index)) {
3882 splice.call(array, index, 1);
3883 } else {
3884 baseUnset(array, index);
3885 }
3886 }
3887 }
3888 return array;
3889 }
3890
3891 /**
3892 * The base implementation of `_.random` without support for returning
3893 * floating-point numbers.
3894 *
3895 * @private
3896 * @param {number} lower The lower bound.
3897 * @param {number} upper The upper bound.
3898 * @returns {number} Returns the random number.
3899 */
3900 function baseRandom(lower, upper) {
3901 return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
3902 }
3903
3904 /**
3905 * The base implementation of `_.range` and `_.rangeRight` which doesn't
3906 * coerce arguments.
3907 *
3908 * @private
3909 * @param {number} start The start of the range.
3910 * @param {number} end The end of the range.
3911 * @param {number} step The value to increment or decrement by.
3912 * @param {boolean} [fromRight] Specify iterating from right to left.
3913 * @returns {Array} Returns the range of numbers.
3914 */
3915 function baseRange(start, end, step, fromRight) {
3916 var index = -1,
3917 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
3918 result = Array(length);
3919
3920 while (length--) {
3921 result[fromRight ? length : ++index] = start;
3922 start += step;
3923 }
3924 return result;
3925 }
3926
3927 /**
3928 * The base implementation of `_.repeat` which doesn't coerce arguments.
3929 *
3930 * @private
3931 * @param {string} string The string to repeat.
3932 * @param {number} n The number of times to repeat the string.
3933 * @returns {string} Returns the repeated string.
3934 */
3935 function baseRepeat(string, n) {
3936 var result = '';
3937 if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
3938 return result;
3939 }
3940 // Leverage the exponentiation by squaring algorithm for a faster repeat.
3941 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
3942 do {
3943 if (n % 2) {
3944 result += string;
3945 }
3946 n = nativeFloor(n / 2);
3947 if (n) {
3948 string += string;
3949 }
3950 } while (n);
3951
3952 return result;
3953 }
3954
3955 /**
3956 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
3957 *
3958 * @private
3959 * @param {Function} func The function to apply a rest parameter to.
3960 * @param {number} [start=func.length-1] The start position of the rest parameter.
3961 * @returns {Function} Returns the new function.
3962 */
3963 function baseRest(func, start) {
3964 return setToString(overRest(func, start, identity), func + '');
3965 }
3966
3967 /**
3968 * The base implementation of `_.sample`.
3969 *
3970 * @private
3971 * @param {Array|Object} collection The collection to sample.
3972 * @returns {*} Returns the random element.
3973 */
3974 function baseSample(collection) {
3975 return arraySample(values(collection));
3976 }
3977
3978 /**
3979 * The base implementation of `_.sampleSize` without param guards.
3980 *
3981 * @private
3982 * @param {Array|Object} collection The collection to sample.
3983 * @param {number} n The number of elements to sample.
3984 * @returns {Array} Returns the random elements.
3985 */
3986 function baseSampleSize(collection, n) {
3987 var array = values(collection);
3988 return shuffleSelf(array, baseClamp(n, 0, array.length));
3989 }
3990
3991 /**
3992 * The base implementation of `_.set`.
3993 *
3994 * @private
3995 * @param {Object} object The object to modify.
3996 * @param {Array|string} path The path of the property to set.
3997 * @param {*} value The value to set.
3998 * @param {Function} [customizer] The function to customize path creation.
3999 * @returns {Object} Returns `object`.
4000 */
4001 function baseSet(object, path, value, customizer) {
4002 if (!isObject(object)) {
4003 return object;
4004 }
4005 path = castPath(path, object);
4006
4007 var index = -1,
4008 length = path.length,
4009 lastIndex = length - 1,
4010 nested = object;
4011
4012 while (nested != null && ++index < length) {
4013 var key = toKey(path[index]),
4014 newValue = value;
4015
4016 if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
4017 return object;
4018 }
4019
4020 if (index != lastIndex) {
4021 var objValue = nested[key];
4022 newValue = customizer ? customizer(objValue, key, nested) : undefined$1;
4023 if (newValue === undefined$1) {
4024 newValue = isObject(objValue)
4025 ? objValue
4026 : (isIndex(path[index + 1]) ? [] : {});
4027 }
4028 }
4029 assignValue(nested, key, newValue);
4030 nested = nested[key];
4031 }
4032 return object;
4033 }
4034
4035 /**
4036 * The base implementation of `setData` without support for hot loop shorting.
4037 *
4038 * @private
4039 * @param {Function} func The function to associate metadata with.
4040 * @param {*} data The metadata.
4041 * @returns {Function} Returns `func`.
4042 */
4043 var baseSetData = !metaMap ? identity : function(func, data) {
4044 metaMap.set(func, data);
4045 return func;
4046 };
4047
4048 /**
4049 * The base implementation of `setToString` without support for hot loop shorting.
4050 *
4051 * @private
4052 * @param {Function} func The function to modify.
4053 * @param {Function} string The `toString` result.
4054 * @returns {Function} Returns `func`.
4055 */
4056 var baseSetToString = !defineProperty ? identity : function(func, string) {
4057 return defineProperty(func, 'toString', {
4058 'configurable': true,
4059 'enumerable': false,
4060 'value': constant(string),
4061 'writable': true
4062 });
4063 };
4064
4065 /**
4066 * The base implementation of `_.shuffle`.
4067 *
4068 * @private
4069 * @param {Array|Object} collection The collection to shuffle.
4070 * @returns {Array} Returns the new shuffled array.
4071 */
4072 function baseShuffle(collection) {
4073 return shuffleSelf(values(collection));
4074 }
4075
4076 /**
4077 * The base implementation of `_.slice` without an iteratee call guard.
4078 *
4079 * @private
4080 * @param {Array} array The array to slice.
4081 * @param {number} [start=0] The start position.
4082 * @param {number} [end=array.length] The end position.
4083 * @returns {Array} Returns the slice of `array`.
4084 */
4085 function baseSlice(array, start, end) {
4086 var index = -1,
4087 length = array.length;
4088
4089 if (start < 0) {
4090 start = -start > length ? 0 : (length + start);
4091 }
4092 end = end > length ? length : end;
4093 if (end < 0) {
4094 end += length;
4095 }
4096 length = start > end ? 0 : ((end - start) >>> 0);
4097 start >>>= 0;
4098
4099 var result = Array(length);
4100 while (++index < length) {
4101 result[index] = array[index + start];
4102 }
4103 return result;
4104 }
4105
4106 /**
4107 * The base implementation of `_.some` without support for iteratee shorthands.
4108 *
4109 * @private
4110 * @param {Array|Object} collection The collection to iterate over.
4111 * @param {Function} predicate The function invoked per iteration.
4112 * @returns {boolean} Returns `true` if any element passes the predicate check,
4113 * else `false`.
4114 */
4115 function baseSome(collection, predicate) {
4116 var result;
4117
4118 baseEach(collection, function(value, index, collection) {
4119 result = predicate(value, index, collection);
4120 return !result;
4121 });
4122 return !!result;
4123 }
4124
4125 /**
4126 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
4127 * performs a binary search of `array` to determine the index at which `value`
4128 * should be inserted into `array` in order to maintain its sort order.
4129 *
4130 * @private
4131 * @param {Array} array The sorted array to inspect.
4132 * @param {*} value The value to evaluate.
4133 * @param {boolean} [retHighest] Specify returning the highest qualified index.
4134 * @returns {number} Returns the index at which `value` should be inserted
4135 * into `array`.
4136 */
4137 function baseSortedIndex(array, value, retHighest) {
4138 var low = 0,
4139 high = array == null ? low : array.length;
4140
4141 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
4142 while (low < high) {
4143 var mid = (low + high) >>> 1,
4144 computed = array[mid];
4145
4146 if (computed !== null && !isSymbol(computed) &&
4147 (retHighest ? (computed <= value) : (computed < value))) {
4148 low = mid + 1;
4149 } else {
4150 high = mid;
4151 }
4152 }
4153 return high;
4154 }
4155 return baseSortedIndexBy(array, value, identity, retHighest);
4156 }
4157
4158 /**
4159 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
4160 * which invokes `iteratee` for `value` and each element of `array` to compute
4161 * their sort ranking. The iteratee is invoked with one argument; (value).
4162 *
4163 * @private
4164 * @param {Array} array The sorted array to inspect.
4165 * @param {*} value The value to evaluate.
4166 * @param {Function} iteratee The iteratee invoked per element.
4167 * @param {boolean} [retHighest] Specify returning the highest qualified index.
4168 * @returns {number} Returns the index at which `value` should be inserted
4169 * into `array`.
4170 */
4171 function baseSortedIndexBy(array, value, iteratee, retHighest) {
4172 var low = 0,
4173 high = array == null ? 0 : array.length;
4174 if (high === 0) {
4175 return 0;
4176 }
4177
4178 value = iteratee(value);
4179 var valIsNaN = value !== value,
4180 valIsNull = value === null,
4181 valIsSymbol = isSymbol(value),
4182 valIsUndefined = value === undefined$1;
4183
4184 while (low < high) {
4185 var mid = nativeFloor((low + high) / 2),
4186 computed = iteratee(array[mid]),
4187 othIsDefined = computed !== undefined$1,
4188 othIsNull = computed === null,
4189 othIsReflexive = computed === computed,
4190 othIsSymbol = isSymbol(computed);
4191
4192 if (valIsNaN) {
4193 var setLow = retHighest || othIsReflexive;
4194 } else if (valIsUndefined) {
4195 setLow = othIsReflexive && (retHighest || othIsDefined);
4196 } else if (valIsNull) {
4197 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
4198 } else if (valIsSymbol) {
4199 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
4200 } else if (othIsNull || othIsSymbol) {
4201 setLow = false;
4202 } else {
4203 setLow = retHighest ? (computed <= value) : (computed < value);
4204 }
4205 if (setLow) {
4206 low = mid + 1;
4207 } else {
4208 high = mid;
4209 }
4210 }
4211 return nativeMin(high, MAX_ARRAY_INDEX);
4212 }
4213
4214 /**
4215 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
4216 * support for iteratee shorthands.
4217 *
4218 * @private
4219 * @param {Array} array The array to inspect.
4220 * @param {Function} [iteratee] The iteratee invoked per element.
4221 * @returns {Array} Returns the new duplicate free array.
4222 */
4223 function baseSortedUniq(array, iteratee) {
4224 var index = -1,
4225 length = array.length,
4226 resIndex = 0,
4227 result = [];
4228
4229 while (++index < length) {
4230 var value = array[index],
4231 computed = iteratee ? iteratee(value) : value;
4232
4233 if (!index || !eq(computed, seen)) {
4234 var seen = computed;
4235 result[resIndex++] = value === 0 ? 0 : value;
4236 }
4237 }
4238 return result;
4239 }
4240
4241 /**
4242 * The base implementation of `_.toNumber` which doesn't ensure correct
4243 * conversions of binary, hexadecimal, or octal string values.
4244 *
4245 * @private
4246 * @param {*} value The value to process.
4247 * @returns {number} Returns the number.
4248 */
4249 function baseToNumber(value) {
4250 if (typeof value == 'number') {
4251 return value;
4252 }
4253 if (isSymbol(value)) {
4254 return NAN;
4255 }
4256 return +value;
4257 }
4258
4259 /**
4260 * The base implementation of `_.toString` which doesn't convert nullish
4261 * values to empty strings.
4262 *
4263 * @private
4264 * @param {*} value The value to process.
4265 * @returns {string} Returns the string.
4266 */
4267 function baseToString(value) {
4268 // Exit early for strings to avoid a performance hit in some environments.
4269 if (typeof value == 'string') {
4270 return value;
4271 }
4272 if (isArray(value)) {
4273 // Recursively convert values (susceptible to call stack limits).
4274 return arrayMap(value, baseToString) + '';
4275 }
4276 if (isSymbol(value)) {
4277 return symbolToString ? symbolToString.call(value) : '';
4278 }
4279 var result = (value + '');
4280 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
4281 }
4282
4283 /**
4284 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
4285 *
4286 * @private
4287 * @param {Array} array The array to inspect.
4288 * @param {Function} [iteratee] The iteratee invoked per element.
4289 * @param {Function} [comparator] The comparator invoked per element.
4290 * @returns {Array} Returns the new duplicate free array.
4291 */
4292 function baseUniq(array, iteratee, comparator) {
4293 var index = -1,
4294 includes = arrayIncludes,
4295 length = array.length,
4296 isCommon = true,
4297 result = [],
4298 seen = result;
4299
4300 if (comparator) {
4301 isCommon = false;
4302 includes = arrayIncludesWith;
4303 }
4304 else if (length >= LARGE_ARRAY_SIZE) {
4305 var set = iteratee ? null : createSet(array);
4306 if (set) {
4307 return setToArray(set);
4308 }
4309 isCommon = false;
4310 includes = cacheHas;
4311 seen = new SetCache;
4312 }
4313 else {
4314 seen = iteratee ? [] : result;
4315 }
4316 outer:
4317 while (++index < length) {
4318 var value = array[index],
4319 computed = iteratee ? iteratee(value) : value;
4320
4321 value = (comparator || value !== 0) ? value : 0;
4322 if (isCommon && computed === computed) {
4323 var seenIndex = seen.length;
4324 while (seenIndex--) {
4325 if (seen[seenIndex] === computed) {
4326 continue outer;
4327 }
4328 }
4329 if (iteratee) {
4330 seen.push(computed);
4331 }
4332 result.push(value);
4333 }
4334 else if (!includes(seen, computed, comparator)) {
4335 if (seen !== result) {
4336 seen.push(computed);
4337 }
4338 result.push(value);
4339 }
4340 }
4341 return result;
4342 }
4343
4344 /**
4345 * The base implementation of `_.unset`.
4346 *
4347 * @private
4348 * @param {Object} object The object to modify.
4349 * @param {Array|string} path The property path to unset.
4350 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
4351 */
4352 function baseUnset(object, path) {
4353 path = castPath(path, object);
4354 object = parent(object, path);
4355 return object == null || delete object[toKey(last(path))];
4356 }
4357
4358 /**
4359 * The base implementation of `_.update`.
4360 *
4361 * @private
4362 * @param {Object} object The object to modify.
4363 * @param {Array|string} path The path of the property to update.
4364 * @param {Function} updater The function to produce the updated value.
4365 * @param {Function} [customizer] The function to customize path creation.
4366 * @returns {Object} Returns `object`.
4367 */
4368 function baseUpdate(object, path, updater, customizer) {
4369 return baseSet(object, path, updater(baseGet(object, path)), customizer);
4370 }
4371
4372 /**
4373 * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
4374 * without support for iteratee shorthands.
4375 *
4376 * @private
4377 * @param {Array} array The array to query.
4378 * @param {Function} predicate The function invoked per iteration.
4379 * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
4380 * @param {boolean} [fromRight] Specify iterating from right to left.
4381 * @returns {Array} Returns the slice of `array`.
4382 */
4383 function baseWhile(array, predicate, isDrop, fromRight) {
4384 var length = array.length,
4385 index = fromRight ? length : -1;
4386
4387 while ((fromRight ? index-- : ++index < length) &&
4388 predicate(array[index], index, array)) {}
4389
4390 return isDrop
4391 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
4392 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
4393 }
4394
4395 /**
4396 * The base implementation of `wrapperValue` which returns the result of
4397 * performing a sequence of actions on the unwrapped `value`, where each
4398 * successive action is supplied the return value of the previous.
4399 *
4400 * @private
4401 * @param {*} value The unwrapped value.
4402 * @param {Array} actions Actions to perform to resolve the unwrapped value.
4403 * @returns {*} Returns the resolved value.
4404 */
4405 function baseWrapperValue(value, actions) {
4406 var result = value;
4407 if (result instanceof LazyWrapper) {
4408 result = result.value();
4409 }
4410 return arrayReduce(actions, function(result, action) {
4411 return action.func.apply(action.thisArg, arrayPush([result], action.args));
4412 }, result);
4413 }
4414
4415 /**
4416 * The base implementation of methods like `_.xor`, without support for
4417 * iteratee shorthands, that accepts an array of arrays to inspect.
4418 *
4419 * @private
4420 * @param {Array} arrays The arrays to inspect.
4421 * @param {Function} [iteratee] The iteratee invoked per element.
4422 * @param {Function} [comparator] The comparator invoked per element.
4423 * @returns {Array} Returns the new array of values.
4424 */
4425 function baseXor(arrays, iteratee, comparator) {
4426 var length = arrays.length;
4427 if (length < 2) {
4428 return length ? baseUniq(arrays[0]) : [];
4429 }
4430 var index = -1,
4431 result = Array(length);
4432
4433 while (++index < length) {
4434 var array = arrays[index],
4435 othIndex = -1;
4436
4437 while (++othIndex < length) {
4438 if (othIndex != index) {
4439 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
4440 }
4441 }
4442 }
4443 return baseUniq(baseFlatten(result, 1), iteratee, comparator);
4444 }
4445
4446 /**
4447 * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
4448 *
4449 * @private
4450 * @param {Array} props The property identifiers.
4451 * @param {Array} values The property values.
4452 * @param {Function} assignFunc The function to assign values.
4453 * @returns {Object} Returns the new object.
4454 */
4455 function baseZipObject(props, values, assignFunc) {
4456 var index = -1,
4457 length = props.length,
4458 valsLength = values.length,
4459 result = {};
4460
4461 while (++index < length) {
4462 var value = index < valsLength ? values[index] : undefined$1;
4463 assignFunc(result, props[index], value);
4464 }
4465 return result;
4466 }
4467
4468 /**
4469 * Casts `value` to an empty array if it's not an array like object.
4470 *
4471 * @private
4472 * @param {*} value The value to inspect.
4473 * @returns {Array|Object} Returns the cast array-like object.
4474 */
4475 function castArrayLikeObject(value) {
4476 return isArrayLikeObject(value) ? value : [];
4477 }
4478
4479 /**
4480 * Casts `value` to `identity` if it's not a function.
4481 *
4482 * @private
4483 * @param {*} value The value to inspect.
4484 * @returns {Function} Returns cast function.
4485 */
4486 function castFunction(value) {
4487 return typeof value == 'function' ? value : identity;
4488 }
4489
4490 /**
4491 * Casts `value` to a path array if it's not one.
4492 *
4493 * @private
4494 * @param {*} value The value to inspect.
4495 * @param {Object} [object] The object to query keys on.
4496 * @returns {Array} Returns the cast property path array.
4497 */
4498 function castPath(value, object) {
4499 if (isArray(value)) {
4500 return value;
4501 }
4502 return isKey(value, object) ? [value] : stringToPath(toString(value));
4503 }
4504
4505 /**
4506 * A `baseRest` alias which can be replaced with `identity` by module
4507 * replacement plugins.
4508 *
4509 * @private
4510 * @type {Function}
4511 * @param {Function} func The function to apply a rest parameter to.
4512 * @returns {Function} Returns the new function.
4513 */
4514 var castRest = baseRest;
4515
4516 /**
4517 * Casts `array` to a slice if it's needed.
4518 *
4519 * @private
4520 * @param {Array} array The array to inspect.
4521 * @param {number} start The start position.
4522 * @param {number} [end=array.length] The end position.
4523 * @returns {Array} Returns the cast slice.
4524 */
4525 function castSlice(array, start, end) {
4526 var length = array.length;
4527 end = end === undefined$1 ? length : end;
4528 return (!start && end >= length) ? array : baseSlice(array, start, end);
4529 }
4530
4531 /**
4532 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
4533 *
4534 * @private
4535 * @param {number|Object} id The timer id or timeout object of the timer to clear.
4536 */
4537 var clearTimeout = ctxClearTimeout || function(id) {
4538 return root.clearTimeout(id);
4539 };
4540
4541 /**
4542 * Creates a clone of `buffer`.
4543 *
4544 * @private
4545 * @param {Buffer} buffer The buffer to clone.
4546 * @param {boolean} [isDeep] Specify a deep clone.
4547 * @returns {Buffer} Returns the cloned buffer.
4548 */
4549 function cloneBuffer(buffer, isDeep) {
4550 if (isDeep) {
4551 return buffer.slice();
4552 }
4553 var length = buffer.length,
4554 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
4555
4556 buffer.copy(result);
4557 return result;
4558 }
4559
4560 /**
4561 * Creates a clone of `arrayBuffer`.
4562 *
4563 * @private
4564 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
4565 * @returns {ArrayBuffer} Returns the cloned array buffer.
4566 */
4567 function cloneArrayBuffer(arrayBuffer) {
4568 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
4569 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
4570 return result;
4571 }
4572
4573 /**
4574 * Creates a clone of `dataView`.
4575 *
4576 * @private
4577 * @param {Object} dataView The data view to clone.
4578 * @param {boolean} [isDeep] Specify a deep clone.
4579 * @returns {Object} Returns the cloned data view.
4580 */
4581 function cloneDataView(dataView, isDeep) {
4582 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
4583 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
4584 }
4585
4586 /**
4587 * Creates a clone of `regexp`.
4588 *
4589 * @private
4590 * @param {Object} regexp The regexp to clone.
4591 * @returns {Object} Returns the cloned regexp.
4592 */
4593 function cloneRegExp(regexp) {
4594 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
4595 result.lastIndex = regexp.lastIndex;
4596 return result;
4597 }
4598
4599 /**
4600 * Creates a clone of the `symbol` object.
4601 *
4602 * @private
4603 * @param {Object} symbol The symbol object to clone.
4604 * @returns {Object} Returns the cloned symbol object.
4605 */
4606 function cloneSymbol(symbol) {
4607 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
4608 }
4609
4610 /**
4611 * Creates a clone of `typedArray`.
4612 *
4613 * @private
4614 * @param {Object} typedArray The typed array to clone.
4615 * @param {boolean} [isDeep] Specify a deep clone.
4616 * @returns {Object} Returns the cloned typed array.
4617 */
4618 function cloneTypedArray(typedArray, isDeep) {
4619 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
4620 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
4621 }
4622
4623 /**
4624 * Compares values to sort them in ascending order.
4625 *
4626 * @private
4627 * @param {*} value The value to compare.
4628 * @param {*} other The other value to compare.
4629 * @returns {number} Returns the sort order indicator for `value`.
4630 */
4631 function compareAscending(value, other) {
4632 if (value !== other) {
4633 var valIsDefined = value !== undefined$1,
4634 valIsNull = value === null,
4635 valIsReflexive = value === value,
4636 valIsSymbol = isSymbol(value);
4637
4638 var othIsDefined = other !== undefined$1,
4639 othIsNull = other === null,
4640 othIsReflexive = other === other,
4641 othIsSymbol = isSymbol(other);
4642
4643 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
4644 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
4645 (valIsNull && othIsDefined && othIsReflexive) ||
4646 (!valIsDefined && othIsReflexive) ||
4647 !valIsReflexive) {
4648 return 1;
4649 }
4650 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
4651 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
4652 (othIsNull && valIsDefined && valIsReflexive) ||
4653 (!othIsDefined && valIsReflexive) ||
4654 !othIsReflexive) {
4655 return -1;
4656 }
4657 }
4658 return 0;
4659 }
4660
4661 /**
4662 * Used by `_.orderBy` to compare multiple properties of a value to another
4663 * and stable sort them.
4664 *
4665 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
4666 * specify an order of "desc" for descending or "asc" for ascending sort order
4667 * of corresponding values.
4668 *
4669 * @private
4670 * @param {Object} object The object to compare.
4671 * @param {Object} other The other object to compare.
4672 * @param {boolean[]|string[]} orders The order to sort by for each property.
4673 * @returns {number} Returns the sort order indicator for `object`.
4674 */
4675 function compareMultiple(object, other, orders) {
4676 var index = -1,
4677 objCriteria = object.criteria,
4678 othCriteria = other.criteria,
4679 length = objCriteria.length,
4680 ordersLength = orders.length;
4681
4682 while (++index < length) {
4683 var result = compareAscending(objCriteria[index], othCriteria[index]);
4684 if (result) {
4685 if (index >= ordersLength) {
4686 return result;
4687 }
4688 var order = orders[index];
4689 return result * (order == 'desc' ? -1 : 1);
4690 }
4691 }
4692 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
4693 // that causes it, under certain circumstances, to provide the same value for
4694 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
4695 // for more details.
4696 //
4697 // This also ensures a stable sort in V8 and other engines.
4698 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
4699 return object.index - other.index;
4700 }
4701
4702 /**
4703 * Creates an array that is the composition of partially applied arguments,
4704 * placeholders, and provided arguments into a single array of arguments.
4705 *
4706 * @private
4707 * @param {Array} args The provided arguments.
4708 * @param {Array} partials The arguments to prepend to those provided.
4709 * @param {Array} holders The `partials` placeholder indexes.
4710 * @params {boolean} [isCurried] Specify composing for a curried function.
4711 * @returns {Array} Returns the new array of composed arguments.
4712 */
4713 function composeArgs(args, partials, holders, isCurried) {
4714 var argsIndex = -1,
4715 argsLength = args.length,
4716 holdersLength = holders.length,
4717 leftIndex = -1,
4718 leftLength = partials.length,
4719 rangeLength = nativeMax(argsLength - holdersLength, 0),
4720 result = Array(leftLength + rangeLength),
4721 isUncurried = !isCurried;
4722
4723 while (++leftIndex < leftLength) {
4724 result[leftIndex] = partials[leftIndex];
4725 }
4726 while (++argsIndex < holdersLength) {
4727 if (isUncurried || argsIndex < argsLength) {
4728 result[holders[argsIndex]] = args[argsIndex];
4729 }
4730 }
4731 while (rangeLength--) {
4732 result[leftIndex++] = args[argsIndex++];
4733 }
4734 return result;
4735 }
4736
4737 /**
4738 * This function is like `composeArgs` except that the arguments composition
4739 * is tailored for `_.partialRight`.
4740 *
4741 * @private
4742 * @param {Array} args The provided arguments.
4743 * @param {Array} partials The arguments to append to those provided.
4744 * @param {Array} holders The `partials` placeholder indexes.
4745 * @params {boolean} [isCurried] Specify composing for a curried function.
4746 * @returns {Array} Returns the new array of composed arguments.
4747 */
4748 function composeArgsRight(args, partials, holders, isCurried) {
4749 var argsIndex = -1,
4750 argsLength = args.length,
4751 holdersIndex = -1,
4752 holdersLength = holders.length,
4753 rightIndex = -1,
4754 rightLength = partials.length,
4755 rangeLength = nativeMax(argsLength - holdersLength, 0),
4756 result = Array(rangeLength + rightLength),
4757 isUncurried = !isCurried;
4758
4759 while (++argsIndex < rangeLength) {
4760 result[argsIndex] = args[argsIndex];
4761 }
4762 var offset = argsIndex;
4763 while (++rightIndex < rightLength) {
4764 result[offset + rightIndex] = partials[rightIndex];
4765 }
4766 while (++holdersIndex < holdersLength) {
4767 if (isUncurried || argsIndex < argsLength) {
4768 result[offset + holders[holdersIndex]] = args[argsIndex++];
4769 }
4770 }
4771 return result;
4772 }
4773
4774 /**
4775 * Copies the values of `source` to `array`.
4776 *
4777 * @private
4778 * @param {Array} source The array to copy values from.
4779 * @param {Array} [array=[]] The array to copy values to.
4780 * @returns {Array} Returns `array`.
4781 */
4782 function copyArray(source, array) {
4783 var index = -1,
4784 length = source.length;
4785
4786 array || (array = Array(length));
4787 while (++index < length) {
4788 array[index] = source[index];
4789 }
4790 return array;
4791 }
4792
4793 /**
4794 * Copies properties of `source` to `object`.
4795 *
4796 * @private
4797 * @param {Object} source The object to copy properties from.
4798 * @param {Array} props The property identifiers to copy.
4799 * @param {Object} [object={}] The object to copy properties to.
4800 * @param {Function} [customizer] The function to customize copied values.
4801 * @returns {Object} Returns `object`.
4802 */
4803 function copyObject(source, props, object, customizer) {
4804 var isNew = !object;
4805 object || (object = {});
4806
4807 var index = -1,
4808 length = props.length;
4809
4810 while (++index < length) {
4811 var key = props[index];
4812
4813 var newValue = customizer
4814 ? customizer(object[key], source[key], key, object, source)
4815 : undefined$1;
4816
4817 if (newValue === undefined$1) {
4818 newValue = source[key];
4819 }
4820 if (isNew) {
4821 baseAssignValue(object, key, newValue);
4822 } else {
4823 assignValue(object, key, newValue);
4824 }
4825 }
4826 return object;
4827 }
4828
4829 /**
4830 * Copies own symbols of `source` to `object`.
4831 *
4832 * @private
4833 * @param {Object} source The object to copy symbols from.
4834 * @param {Object} [object={}] The object to copy symbols to.
4835 * @returns {Object} Returns `object`.
4836 */
4837 function copySymbols(source, object) {
4838 return copyObject(source, getSymbols(source), object);
4839 }
4840
4841 /**
4842 * Copies own and inherited symbols of `source` to `object`.
4843 *
4844 * @private
4845 * @param {Object} source The object to copy symbols from.
4846 * @param {Object} [object={}] The object to copy symbols to.
4847 * @returns {Object} Returns `object`.
4848 */
4849 function copySymbolsIn(source, object) {
4850 return copyObject(source, getSymbolsIn(source), object);
4851 }
4852
4853 /**
4854 * Creates a function like `_.groupBy`.
4855 *
4856 * @private
4857 * @param {Function} setter The function to set accumulator values.
4858 * @param {Function} [initializer] The accumulator object initializer.
4859 * @returns {Function} Returns the new aggregator function.
4860 */
4861 function createAggregator(setter, initializer) {
4862 return function(collection, iteratee) {
4863 var func = isArray(collection) ? arrayAggregator : baseAggregator,
4864 accumulator = initializer ? initializer() : {};
4865
4866 return func(collection, setter, getIteratee(iteratee, 2), accumulator);
4867 };
4868 }
4869
4870 /**
4871 * Creates a function like `_.assign`.
4872 *
4873 * @private
4874 * @param {Function} assigner The function to assign values.
4875 * @returns {Function} Returns the new assigner function.
4876 */
4877 function createAssigner(assigner) {
4878 return baseRest(function(object, sources) {
4879 var index = -1,
4880 length = sources.length,
4881 customizer = length > 1 ? sources[length - 1] : undefined$1,
4882 guard = length > 2 ? sources[2] : undefined$1;
4883
4884 customizer = (assigner.length > 3 && typeof customizer == 'function')
4885 ? (length--, customizer)
4886 : undefined$1;
4887
4888 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
4889 customizer = length < 3 ? undefined$1 : customizer;
4890 length = 1;
4891 }
4892 object = Object(object);
4893 while (++index < length) {
4894 var source = sources[index];
4895 if (source) {
4896 assigner(object, source, index, customizer);
4897 }
4898 }
4899 return object;
4900 });
4901 }
4902
4903 /**
4904 * Creates a `baseEach` or `baseEachRight` function.
4905 *
4906 * @private
4907 * @param {Function} eachFunc The function to iterate over a collection.
4908 * @param {boolean} [fromRight] Specify iterating from right to left.
4909 * @returns {Function} Returns the new base function.
4910 */
4911 function createBaseEach(eachFunc, fromRight) {
4912 return function(collection, iteratee) {
4913 if (collection == null) {
4914 return collection;
4915 }
4916 if (!isArrayLike(collection)) {
4917 return eachFunc(collection, iteratee);
4918 }
4919 var length = collection.length,
4920 index = fromRight ? length : -1,
4921 iterable = Object(collection);
4922
4923 while ((fromRight ? index-- : ++index < length)) {
4924 if (iteratee(iterable[index], index, iterable) === false) {
4925 break;
4926 }
4927 }
4928 return collection;
4929 };
4930 }
4931
4932 /**
4933 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
4934 *
4935 * @private
4936 * @param {boolean} [fromRight] Specify iterating from right to left.
4937 * @returns {Function} Returns the new base function.
4938 */
4939 function createBaseFor(fromRight) {
4940 return function(object, iteratee, keysFunc) {
4941 var index = -1,
4942 iterable = Object(object),
4943 props = keysFunc(object),
4944 length = props.length;
4945
4946 while (length--) {
4947 var key = props[fromRight ? length : ++index];
4948 if (iteratee(iterable[key], key, iterable) === false) {
4949 break;
4950 }
4951 }
4952 return object;
4953 };
4954 }
4955
4956 /**
4957 * Creates a function that wraps `func` to invoke it with the optional `this`
4958 * binding of `thisArg`.
4959 *
4960 * @private
4961 * @param {Function} func The function to wrap.
4962 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
4963 * @param {*} [thisArg] The `this` binding of `func`.
4964 * @returns {Function} Returns the new wrapped function.
4965 */
4966 function createBind(func, bitmask, thisArg) {
4967 var isBind = bitmask & WRAP_BIND_FLAG,
4968 Ctor = createCtor(func);
4969
4970 function wrapper() {
4971 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
4972 return fn.apply(isBind ? thisArg : this, arguments);
4973 }
4974 return wrapper;
4975 }
4976
4977 /**
4978 * Creates a function like `_.lowerFirst`.
4979 *
4980 * @private
4981 * @param {string} methodName The name of the `String` case method to use.
4982 * @returns {Function} Returns the new case function.
4983 */
4984 function createCaseFirst(methodName) {
4985 return function(string) {
4986 string = toString(string);
4987
4988 var strSymbols = hasUnicode(string)
4989 ? stringToArray(string)
4990 : undefined$1;
4991
4992 var chr = strSymbols
4993 ? strSymbols[0]
4994 : string.charAt(0);
4995
4996 var trailing = strSymbols
4997 ? castSlice(strSymbols, 1).join('')
4998 : string.slice(1);
4999
5000 return chr[methodName]() + trailing;
5001 };
5002 }
5003
5004 /**
5005 * Creates a function like `_.camelCase`.
5006 *
5007 * @private
5008 * @param {Function} callback The function to combine each word.
5009 * @returns {Function} Returns the new compounder function.
5010 */
5011 function createCompounder(callback) {
5012 return function(string) {
5013 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
5014 };
5015 }
5016
5017 /**
5018 * Creates a function that produces an instance of `Ctor` regardless of
5019 * whether it was invoked as part of a `new` expression or by `call` or `apply`.
5020 *
5021 * @private
5022 * @param {Function} Ctor The constructor to wrap.
5023 * @returns {Function} Returns the new wrapped function.
5024 */
5025 function createCtor(Ctor) {
5026 return function() {
5027 // Use a `switch` statement to work with class constructors. See
5028 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
5029 // for more details.
5030 var args = arguments;
5031 switch (args.length) {
5032 case 0: return new Ctor;
5033 case 1: return new Ctor(args[0]);
5034 case 2: return new Ctor(args[0], args[1]);
5035 case 3: return new Ctor(args[0], args[1], args[2]);
5036 case 4: return new Ctor(args[0], args[1], args[2], args[3]);
5037 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
5038 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
5039 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
5040 }
5041 var thisBinding = baseCreate(Ctor.prototype),
5042 result = Ctor.apply(thisBinding, args);
5043
5044 // Mimic the constructor's `return` behavior.
5045 // See https://es5.github.io/#x13.2.2 for more details.
5046 return isObject(result) ? result : thisBinding;
5047 };
5048 }
5049
5050 /**
5051 * Creates a function that wraps `func` to enable currying.
5052 *
5053 * @private
5054 * @param {Function} func The function to wrap.
5055 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5056 * @param {number} arity The arity of `func`.
5057 * @returns {Function} Returns the new wrapped function.
5058 */
5059 function createCurry(func, bitmask, arity) {
5060 var Ctor = createCtor(func);
5061
5062 function wrapper() {
5063 var length = arguments.length,
5064 args = Array(length),
5065 index = length,
5066 placeholder = getHolder(wrapper);
5067
5068 while (index--) {
5069 args[index] = arguments[index];
5070 }
5071 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
5072 ? []
5073 : replaceHolders(args, placeholder);
5074
5075 length -= holders.length;
5076 if (length < arity) {
5077 return createRecurry(
5078 func, bitmask, createHybrid, wrapper.placeholder, undefined$1,
5079 args, holders, undefined$1, undefined$1, arity - length);
5080 }
5081 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5082 return apply(fn, this, args);
5083 }
5084 return wrapper;
5085 }
5086
5087 /**
5088 * Creates a `_.find` or `_.findLast` function.
5089 *
5090 * @private
5091 * @param {Function} findIndexFunc The function to find the collection index.
5092 * @returns {Function} Returns the new find function.
5093 */
5094 function createFind(findIndexFunc) {
5095 return function(collection, predicate, fromIndex) {
5096 var iterable = Object(collection);
5097 if (!isArrayLike(collection)) {
5098 var iteratee = getIteratee(predicate, 3);
5099 collection = keys(collection);
5100 predicate = function(key) { return iteratee(iterable[key], key, iterable); };
5101 }
5102 var index = findIndexFunc(collection, predicate, fromIndex);
5103 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined$1;
5104 };
5105 }
5106
5107 /**
5108 * Creates a `_.flow` or `_.flowRight` function.
5109 *
5110 * @private
5111 * @param {boolean} [fromRight] Specify iterating from right to left.
5112 * @returns {Function} Returns the new flow function.
5113 */
5114 function createFlow(fromRight) {
5115 return flatRest(function(funcs) {
5116 var length = funcs.length,
5117 index = length,
5118 prereq = LodashWrapper.prototype.thru;
5119
5120 if (fromRight) {
5121 funcs.reverse();
5122 }
5123 while (index--) {
5124 var func = funcs[index];
5125 if (typeof func != 'function') {
5126 throw new TypeError(FUNC_ERROR_TEXT);
5127 }
5128 if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
5129 var wrapper = new LodashWrapper([], true);
5130 }
5131 }
5132 index = wrapper ? index : length;
5133 while (++index < length) {
5134 func = funcs[index];
5135
5136 var funcName = getFuncName(func),
5137 data = funcName == 'wrapper' ? getData(func) : undefined$1;
5138
5139 if (data && isLaziable(data[0]) &&
5140 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
5141 !data[4].length && data[9] == 1
5142 ) {
5143 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
5144 } else {
5145 wrapper = (func.length == 1 && isLaziable(func))
5146 ? wrapper[funcName]()
5147 : wrapper.thru(func);
5148 }
5149 }
5150 return function() {
5151 var args = arguments,
5152 value = args[0];
5153
5154 if (wrapper && args.length == 1 && isArray(value)) {
5155 return wrapper.plant(value).value();
5156 }
5157 var index = 0,
5158 result = length ? funcs[index].apply(this, args) : value;
5159
5160 while (++index < length) {
5161 result = funcs[index].call(this, result);
5162 }
5163 return result;
5164 };
5165 });
5166 }
5167
5168 /**
5169 * Creates a function that wraps `func` to invoke it with optional `this`
5170 * binding of `thisArg`, partial application, and currying.
5171 *
5172 * @private
5173 * @param {Function|string} func The function or method name to wrap.
5174 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5175 * @param {*} [thisArg] The `this` binding of `func`.
5176 * @param {Array} [partials] The arguments to prepend to those provided to
5177 * the new function.
5178 * @param {Array} [holders] The `partials` placeholder indexes.
5179 * @param {Array} [partialsRight] The arguments to append to those provided
5180 * to the new function.
5181 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
5182 * @param {Array} [argPos] The argument positions of the new function.
5183 * @param {number} [ary] The arity cap of `func`.
5184 * @param {number} [arity] The arity of `func`.
5185 * @returns {Function} Returns the new wrapped function.
5186 */
5187 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
5188 var isAry = bitmask & WRAP_ARY_FLAG,
5189 isBind = bitmask & WRAP_BIND_FLAG,
5190 isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
5191 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
5192 isFlip = bitmask & WRAP_FLIP_FLAG,
5193 Ctor = isBindKey ? undefined$1 : createCtor(func);
5194
5195 function wrapper() {
5196 var length = arguments.length,
5197 args = Array(length),
5198 index = length;
5199
5200 while (index--) {
5201 args[index] = arguments[index];
5202 }
5203 if (isCurried) {
5204 var placeholder = getHolder(wrapper),
5205 holdersCount = countHolders(args, placeholder);
5206 }
5207 if (partials) {
5208 args = composeArgs(args, partials, holders, isCurried);
5209 }
5210 if (partialsRight) {
5211 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
5212 }
5213 length -= holdersCount;
5214 if (isCurried && length < arity) {
5215 var newHolders = replaceHolders(args, placeholder);
5216 return createRecurry(
5217 func, bitmask, createHybrid, wrapper.placeholder, thisArg,
5218 args, newHolders, argPos, ary, arity - length
5219 );
5220 }
5221 var thisBinding = isBind ? thisArg : this,
5222 fn = isBindKey ? thisBinding[func] : func;
5223
5224 length = args.length;
5225 if (argPos) {
5226 args = reorder(args, argPos);
5227 } else if (isFlip && length > 1) {
5228 args.reverse();
5229 }
5230 if (isAry && ary < length) {
5231 args.length = ary;
5232 }
5233 if (this && this !== root && this instanceof wrapper) {
5234 fn = Ctor || createCtor(fn);
5235 }
5236 return fn.apply(thisBinding, args);
5237 }
5238 return wrapper;
5239 }
5240
5241 /**
5242 * Creates a function like `_.invertBy`.
5243 *
5244 * @private
5245 * @param {Function} setter The function to set accumulator values.
5246 * @param {Function} toIteratee The function to resolve iteratees.
5247 * @returns {Function} Returns the new inverter function.
5248 */
5249 function createInverter(setter, toIteratee) {
5250 return function(object, iteratee) {
5251 return baseInverter(object, setter, toIteratee(iteratee), {});
5252 };
5253 }
5254
5255 /**
5256 * Creates a function that performs a mathematical operation on two values.
5257 *
5258 * @private
5259 * @param {Function} operator The function to perform the operation.
5260 * @param {number} [defaultValue] The value used for `undefined` arguments.
5261 * @returns {Function} Returns the new mathematical operation function.
5262 */
5263 function createMathOperation(operator, defaultValue) {
5264 return function(value, other) {
5265 var result;
5266 if (value === undefined$1 && other === undefined$1) {
5267 return defaultValue;
5268 }
5269 if (value !== undefined$1) {
5270 result = value;
5271 }
5272 if (other !== undefined$1) {
5273 if (result === undefined$1) {
5274 return other;
5275 }
5276 if (typeof value == 'string' || typeof other == 'string') {
5277 value = baseToString(value);
5278 other = baseToString(other);
5279 } else {
5280 value = baseToNumber(value);
5281 other = baseToNumber(other);
5282 }
5283 result = operator(value, other);
5284 }
5285 return result;
5286 };
5287 }
5288
5289 /**
5290 * Creates a function like `_.over`.
5291 *
5292 * @private
5293 * @param {Function} arrayFunc The function to iterate over iteratees.
5294 * @returns {Function} Returns the new over function.
5295 */
5296 function createOver(arrayFunc) {
5297 return flatRest(function(iteratees) {
5298 iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
5299 return baseRest(function(args) {
5300 var thisArg = this;
5301 return arrayFunc(iteratees, function(iteratee) {
5302 return apply(iteratee, thisArg, args);
5303 });
5304 });
5305 });
5306 }
5307
5308 /**
5309 * Creates the padding for `string` based on `length`. The `chars` string
5310 * is truncated if the number of characters exceeds `length`.
5311 *
5312 * @private
5313 * @param {number} length The padding length.
5314 * @param {string} [chars=' '] The string used as padding.
5315 * @returns {string} Returns the padding for `string`.
5316 */
5317 function createPadding(length, chars) {
5318 chars = chars === undefined$1 ? ' ' : baseToString(chars);
5319
5320 var charsLength = chars.length;
5321 if (charsLength < 2) {
5322 return charsLength ? baseRepeat(chars, length) : chars;
5323 }
5324 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
5325 return hasUnicode(chars)
5326 ? castSlice(stringToArray(result), 0, length).join('')
5327 : result.slice(0, length);
5328 }
5329
5330 /**
5331 * Creates a function that wraps `func` to invoke it with the `this` binding
5332 * of `thisArg` and `partials` prepended to the arguments it receives.
5333 *
5334 * @private
5335 * @param {Function} func The function to wrap.
5336 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5337 * @param {*} thisArg The `this` binding of `func`.
5338 * @param {Array} partials The arguments to prepend to those provided to
5339 * the new function.
5340 * @returns {Function} Returns the new wrapped function.
5341 */
5342 function createPartial(func, bitmask, thisArg, partials) {
5343 var isBind = bitmask & WRAP_BIND_FLAG,
5344 Ctor = createCtor(func);
5345
5346 function wrapper() {
5347 var argsIndex = -1,
5348 argsLength = arguments.length,
5349 leftIndex = -1,
5350 leftLength = partials.length,
5351 args = Array(leftLength + argsLength),
5352 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
5353
5354 while (++leftIndex < leftLength) {
5355 args[leftIndex] = partials[leftIndex];
5356 }
5357 while (argsLength--) {
5358 args[leftIndex++] = arguments[++argsIndex];
5359 }
5360 return apply(fn, isBind ? thisArg : this, args);
5361 }
5362 return wrapper;
5363 }
5364
5365 /**
5366 * Creates a `_.range` or `_.rangeRight` function.
5367 *
5368 * @private
5369 * @param {boolean} [fromRight] Specify iterating from right to left.
5370 * @returns {Function} Returns the new range function.
5371 */
5372 function createRange(fromRight) {
5373 return function(start, end, step) {
5374 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
5375 end = step = undefined$1;
5376 }
5377 // Ensure the sign of `-0` is preserved.
5378 start = toFinite(start);
5379 if (end === undefined$1) {
5380 end = start;
5381 start = 0;
5382 } else {
5383 end = toFinite(end);
5384 }
5385 step = step === undefined$1 ? (start < end ? 1 : -1) : toFinite(step);
5386 return baseRange(start, end, step, fromRight);
5387 };
5388 }
5389
5390 /**
5391 * Creates a function that performs a relational operation on two values.
5392 *
5393 * @private
5394 * @param {Function} operator The function to perform the operation.
5395 * @returns {Function} Returns the new relational operation function.
5396 */
5397 function createRelationalOperation(operator) {
5398 return function(value, other) {
5399 if (!(typeof value == 'string' && typeof other == 'string')) {
5400 value = toNumber(value);
5401 other = toNumber(other);
5402 }
5403 return operator(value, other);
5404 };
5405 }
5406
5407 /**
5408 * Creates a function that wraps `func` to continue currying.
5409 *
5410 * @private
5411 * @param {Function} func The function to wrap.
5412 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
5413 * @param {Function} wrapFunc The function to create the `func` wrapper.
5414 * @param {*} placeholder The placeholder value.
5415 * @param {*} [thisArg] The `this` binding of `func`.
5416 * @param {Array} [partials] The arguments to prepend to those provided to
5417 * the new function.
5418 * @param {Array} [holders] The `partials` placeholder indexes.
5419 * @param {Array} [argPos] The argument positions of the new function.
5420 * @param {number} [ary] The arity cap of `func`.
5421 * @param {number} [arity] The arity of `func`.
5422 * @returns {Function} Returns the new wrapped function.
5423 */
5424 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
5425 var isCurry = bitmask & WRAP_CURRY_FLAG,
5426 newHolders = isCurry ? holders : undefined$1,
5427 newHoldersRight = isCurry ? undefined$1 : holders,
5428 newPartials = isCurry ? partials : undefined$1,
5429 newPartialsRight = isCurry ? undefined$1 : partials;
5430
5431 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
5432 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
5433
5434 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
5435 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
5436 }
5437 var newData = [
5438 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
5439 newHoldersRight, argPos, ary, arity
5440 ];
5441
5442 var result = wrapFunc.apply(undefined$1, newData);
5443 if (isLaziable(func)) {
5444 setData(result, newData);
5445 }
5446 result.placeholder = placeholder;
5447 return setWrapToString(result, func, bitmask);
5448 }
5449
5450 /**
5451 * Creates a function like `_.round`.
5452 *
5453 * @private
5454 * @param {string} methodName The name of the `Math` method to use when rounding.
5455 * @returns {Function} Returns the new round function.
5456 */
5457 function createRound(methodName) {
5458 var func = Math[methodName];
5459 return function(number, precision) {
5460 number = toNumber(number);
5461 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
5462 if (precision && nativeIsFinite(number)) {
5463 // Shift with exponential notation to avoid floating-point issues.
5464 // See [MDN](https://mdn.io/round#Examples) for more details.
5465 var pair = (toString(number) + 'e').split('e'),
5466 value = func(pair[0] + 'e' + (+pair[1] + precision));
5467
5468 pair = (toString(value) + 'e').split('e');
5469 return +(pair[0] + 'e' + (+pair[1] - precision));
5470 }
5471 return func(number);
5472 };
5473 }
5474
5475 /**
5476 * Creates a set object of `values`.
5477 *
5478 * @private
5479 * @param {Array} values The values to add to the set.
5480 * @returns {Object} Returns the new set.
5481 */
5482 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
5483 return new Set(values);
5484 };
5485
5486 /**
5487 * Creates a `_.toPairs` or `_.toPairsIn` function.
5488 *
5489 * @private
5490 * @param {Function} keysFunc The function to get the keys of a given object.
5491 * @returns {Function} Returns the new pairs function.
5492 */
5493 function createToPairs(keysFunc) {
5494 return function(object) {
5495 var tag = getTag(object);
5496 if (tag == mapTag) {
5497 return mapToArray(object);
5498 }
5499 if (tag == setTag) {
5500 return setToPairs(object);
5501 }
5502 return baseToPairs(object, keysFunc(object));
5503 };
5504 }
5505
5506 /**
5507 * Creates a function that either curries or invokes `func` with optional
5508 * `this` binding and partially applied arguments.
5509 *
5510 * @private
5511 * @param {Function|string} func The function or method name to wrap.
5512 * @param {number} bitmask The bitmask flags.
5513 * 1 - `_.bind`
5514 * 2 - `_.bindKey`
5515 * 4 - `_.curry` or `_.curryRight` of a bound function
5516 * 8 - `_.curry`
5517 * 16 - `_.curryRight`
5518 * 32 - `_.partial`
5519 * 64 - `_.partialRight`
5520 * 128 - `_.rearg`
5521 * 256 - `_.ary`
5522 * 512 - `_.flip`
5523 * @param {*} [thisArg] The `this` binding of `func`.
5524 * @param {Array} [partials] The arguments to be partially applied.
5525 * @param {Array} [holders] The `partials` placeholder indexes.
5526 * @param {Array} [argPos] The argument positions of the new function.
5527 * @param {number} [ary] The arity cap of `func`.
5528 * @param {number} [arity] The arity of `func`.
5529 * @returns {Function} Returns the new wrapped function.
5530 */
5531 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
5532 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
5533 if (!isBindKey && typeof func != 'function') {
5534 throw new TypeError(FUNC_ERROR_TEXT);
5535 }
5536 var length = partials ? partials.length : 0;
5537 if (!length) {
5538 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
5539 partials = holders = undefined$1;
5540 }
5541 ary = ary === undefined$1 ? ary : nativeMax(toInteger(ary), 0);
5542 arity = arity === undefined$1 ? arity : toInteger(arity);
5543 length -= holders ? holders.length : 0;
5544
5545 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
5546 var partialsRight = partials,
5547 holdersRight = holders;
5548
5549 partials = holders = undefined$1;
5550 }
5551 var data = isBindKey ? undefined$1 : getData(func);
5552
5553 var newData = [
5554 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
5555 argPos, ary, arity
5556 ];
5557
5558 if (data) {
5559 mergeData(newData, data);
5560 }
5561 func = newData[0];
5562 bitmask = newData[1];
5563 thisArg = newData[2];
5564 partials = newData[3];
5565 holders = newData[4];
5566 arity = newData[9] = newData[9] === undefined$1
5567 ? (isBindKey ? 0 : func.length)
5568 : nativeMax(newData[9] - length, 0);
5569
5570 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
5571 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
5572 }
5573 if (!bitmask || bitmask == WRAP_BIND_FLAG) {
5574 var result = createBind(func, bitmask, thisArg);
5575 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
5576 result = createCurry(func, bitmask, arity);
5577 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
5578 result = createPartial(func, bitmask, thisArg, partials);
5579 } else {
5580 result = createHybrid.apply(undefined$1, newData);
5581 }
5582 var setter = data ? baseSetData : setData;
5583 return setWrapToString(setter(result, newData), func, bitmask);
5584 }
5585
5586 /**
5587 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
5588 * of source objects to the destination object for all destination properties
5589 * that resolve to `undefined`.
5590 *
5591 * @private
5592 * @param {*} objValue The destination value.
5593 * @param {*} srcValue The source value.
5594 * @param {string} key The key of the property to assign.
5595 * @param {Object} object The parent object of `objValue`.
5596 * @returns {*} Returns the value to assign.
5597 */
5598 function customDefaultsAssignIn(objValue, srcValue, key, object) {
5599 if (objValue === undefined$1 ||
5600 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
5601 return srcValue;
5602 }
5603 return objValue;
5604 }
5605
5606 /**
5607 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
5608 * objects into destination objects that are passed thru.
5609 *
5610 * @private
5611 * @param {*} objValue The destination value.
5612 * @param {*} srcValue The source value.
5613 * @param {string} key The key of the property to merge.
5614 * @param {Object} object The parent object of `objValue`.
5615 * @param {Object} source The parent object of `srcValue`.
5616 * @param {Object} [stack] Tracks traversed source values and their merged
5617 * counterparts.
5618 * @returns {*} Returns the value to assign.
5619 */
5620 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
5621 if (isObject(objValue) && isObject(srcValue)) {
5622 // Recursively merge objects and arrays (susceptible to call stack limits).
5623 stack.set(srcValue, objValue);
5624 baseMerge(objValue, srcValue, undefined$1, customDefaultsMerge, stack);
5625 stack['delete'](srcValue);
5626 }
5627 return objValue;
5628 }
5629
5630 /**
5631 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
5632 * objects.
5633 *
5634 * @private
5635 * @param {*} value The value to inspect.
5636 * @param {string} key The key of the property to inspect.
5637 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
5638 */
5639 function customOmitClone(value) {
5640 return isPlainObject(value) ? undefined$1 : value;
5641 }
5642
5643 /**
5644 * A specialized version of `baseIsEqualDeep` for arrays with support for
5645 * partial deep comparisons.
5646 *
5647 * @private
5648 * @param {Array} array The array to compare.
5649 * @param {Array} other The other array to compare.
5650 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5651 * @param {Function} customizer The function to customize comparisons.
5652 * @param {Function} equalFunc The function to determine equivalents of values.
5653 * @param {Object} stack Tracks traversed `array` and `other` objects.
5654 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
5655 */
5656 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
5657 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5658 arrLength = array.length,
5659 othLength = other.length;
5660
5661 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
5662 return false;
5663 }
5664 // Check that cyclic values are equal.
5665 var arrStacked = stack.get(array);
5666 var othStacked = stack.get(other);
5667 if (arrStacked && othStacked) {
5668 return arrStacked == other && othStacked == array;
5669 }
5670 var index = -1,
5671 result = true,
5672 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined$1;
5673
5674 stack.set(array, other);
5675 stack.set(other, array);
5676
5677 // Ignore non-index properties.
5678 while (++index < arrLength) {
5679 var arrValue = array[index],
5680 othValue = other[index];
5681
5682 if (customizer) {
5683 var compared = isPartial
5684 ? customizer(othValue, arrValue, index, other, array, stack)
5685 : customizer(arrValue, othValue, index, array, other, stack);
5686 }
5687 if (compared !== undefined$1) {
5688 if (compared) {
5689 continue;
5690 }
5691 result = false;
5692 break;
5693 }
5694 // Recursively compare arrays (susceptible to call stack limits).
5695 if (seen) {
5696 if (!arraySome(other, function(othValue, othIndex) {
5697 if (!cacheHas(seen, othIndex) &&
5698 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
5699 return seen.push(othIndex);
5700 }
5701 })) {
5702 result = false;
5703 break;
5704 }
5705 } else if (!(
5706 arrValue === othValue ||
5707 equalFunc(arrValue, othValue, bitmask, customizer, stack)
5708 )) {
5709 result = false;
5710 break;
5711 }
5712 }
5713 stack['delete'](array);
5714 stack['delete'](other);
5715 return result;
5716 }
5717
5718 /**
5719 * A specialized version of `baseIsEqualDeep` for comparing objects of
5720 * the same `toStringTag`.
5721 *
5722 * **Note:** This function only supports comparing values with tags of
5723 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
5724 *
5725 * @private
5726 * @param {Object} object The object to compare.
5727 * @param {Object} other The other object to compare.
5728 * @param {string} tag The `toStringTag` of the objects to compare.
5729 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5730 * @param {Function} customizer The function to customize comparisons.
5731 * @param {Function} equalFunc The function to determine equivalents of values.
5732 * @param {Object} stack Tracks traversed `object` and `other` objects.
5733 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5734 */
5735 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
5736 switch (tag) {
5737 case dataViewTag:
5738 if ((object.byteLength != other.byteLength) ||
5739 (object.byteOffset != other.byteOffset)) {
5740 return false;
5741 }
5742 object = object.buffer;
5743 other = other.buffer;
5744
5745 case arrayBufferTag:
5746 if ((object.byteLength != other.byteLength) ||
5747 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
5748 return false;
5749 }
5750 return true;
5751
5752 case boolTag:
5753 case dateTag:
5754 case numberTag:
5755 // Coerce booleans to `1` or `0` and dates to milliseconds.
5756 // Invalid dates are coerced to `NaN`.
5757 return eq(+object, +other);
5758
5759 case errorTag:
5760 return object.name == other.name && object.message == other.message;
5761
5762 case regexpTag:
5763 case stringTag:
5764 // Coerce regexes to strings and treat strings, primitives and objects,
5765 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
5766 // for more details.
5767 return object == (other + '');
5768
5769 case mapTag:
5770 var convert = mapToArray;
5771
5772 case setTag:
5773 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
5774 convert || (convert = setToArray);
5775
5776 if (object.size != other.size && !isPartial) {
5777 return false;
5778 }
5779 // Assume cyclic values are equal.
5780 var stacked = stack.get(object);
5781 if (stacked) {
5782 return stacked == other;
5783 }
5784 bitmask |= COMPARE_UNORDERED_FLAG;
5785
5786 // Recursively compare objects (susceptible to call stack limits).
5787 stack.set(object, other);
5788 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
5789 stack['delete'](object);
5790 return result;
5791
5792 case symbolTag:
5793 if (symbolValueOf) {
5794 return symbolValueOf.call(object) == symbolValueOf.call(other);
5795 }
5796 }
5797 return false;
5798 }
5799
5800 /**
5801 * A specialized version of `baseIsEqualDeep` for objects with support for
5802 * partial deep comparisons.
5803 *
5804 * @private
5805 * @param {Object} object The object to compare.
5806 * @param {Object} other The other object to compare.
5807 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
5808 * @param {Function} customizer The function to customize comparisons.
5809 * @param {Function} equalFunc The function to determine equivalents of values.
5810 * @param {Object} stack Tracks traversed `object` and `other` objects.
5811 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
5812 */
5813 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
5814 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
5815 objProps = getAllKeys(object),
5816 objLength = objProps.length,
5817 othProps = getAllKeys(other),
5818 othLength = othProps.length;
5819
5820 if (objLength != othLength && !isPartial) {
5821 return false;
5822 }
5823 var index = objLength;
5824 while (index--) {
5825 var key = objProps[index];
5826 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
5827 return false;
5828 }
5829 }
5830 // Check that cyclic values are equal.
5831 var objStacked = stack.get(object);
5832 var othStacked = stack.get(other);
5833 if (objStacked && othStacked) {
5834 return objStacked == other && othStacked == object;
5835 }
5836 var result = true;
5837 stack.set(object, other);
5838 stack.set(other, object);
5839
5840 var skipCtor = isPartial;
5841 while (++index < objLength) {
5842 key = objProps[index];
5843 var objValue = object[key],
5844 othValue = other[key];
5845
5846 if (customizer) {
5847 var compared = isPartial
5848 ? customizer(othValue, objValue, key, other, object, stack)
5849 : customizer(objValue, othValue, key, object, other, stack);
5850 }
5851 // Recursively compare objects (susceptible to call stack limits).
5852 if (!(compared === undefined$1
5853 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
5854 : compared
5855 )) {
5856 result = false;
5857 break;
5858 }
5859 skipCtor || (skipCtor = key == 'constructor');
5860 }
5861 if (result && !skipCtor) {
5862 var objCtor = object.constructor,
5863 othCtor = other.constructor;
5864
5865 // Non `Object` object instances with different constructors are not equal.
5866 if (objCtor != othCtor &&
5867 ('constructor' in object && 'constructor' in other) &&
5868 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
5869 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
5870 result = false;
5871 }
5872 }
5873 stack['delete'](object);
5874 stack['delete'](other);
5875 return result;
5876 }
5877
5878 /**
5879 * A specialized version of `baseRest` which flattens the rest array.
5880 *
5881 * @private
5882 * @param {Function} func The function to apply a rest parameter to.
5883 * @returns {Function} Returns the new function.
5884 */
5885 function flatRest(func) {
5886 return setToString(overRest(func, undefined$1, flatten), func + '');
5887 }
5888
5889 /**
5890 * Creates an array of own enumerable property names and symbols of `object`.
5891 *
5892 * @private
5893 * @param {Object} object The object to query.
5894 * @returns {Array} Returns the array of property names and symbols.
5895 */
5896 function getAllKeys(object) {
5897 return baseGetAllKeys(object, keys, getSymbols);
5898 }
5899
5900 /**
5901 * Creates an array of own and inherited enumerable property names and
5902 * symbols of `object`.
5903 *
5904 * @private
5905 * @param {Object} object The object to query.
5906 * @returns {Array} Returns the array of property names and symbols.
5907 */
5908 function getAllKeysIn(object) {
5909 return baseGetAllKeys(object, keysIn, getSymbolsIn);
5910 }
5911
5912 /**
5913 * Gets metadata for `func`.
5914 *
5915 * @private
5916 * @param {Function} func The function to query.
5917 * @returns {*} Returns the metadata for `func`.
5918 */
5919 var getData = !metaMap ? noop : function(func) {
5920 return metaMap.get(func);
5921 };
5922
5923 /**
5924 * Gets the name of `func`.
5925 *
5926 * @private
5927 * @param {Function} func The function to query.
5928 * @returns {string} Returns the function name.
5929 */
5930 function getFuncName(func) {
5931 var result = (func.name + ''),
5932 array = realNames[result],
5933 length = hasOwnProperty.call(realNames, result) ? array.length : 0;
5934
5935 while (length--) {
5936 var data = array[length],
5937 otherFunc = data.func;
5938 if (otherFunc == null || otherFunc == func) {
5939 return data.name;
5940 }
5941 }
5942 return result;
5943 }
5944
5945 /**
5946 * Gets the argument placeholder value for `func`.
5947 *
5948 * @private
5949 * @param {Function} func The function to inspect.
5950 * @returns {*} Returns the placeholder value.
5951 */
5952 function getHolder(func) {
5953 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
5954 return object.placeholder;
5955 }
5956
5957 /**
5958 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
5959 * this function returns the custom method, otherwise it returns `baseIteratee`.
5960 * If arguments are provided, the chosen function is invoked with them and
5961 * its result is returned.
5962 *
5963 * @private
5964 * @param {*} [value] The value to convert to an iteratee.
5965 * @param {number} [arity] The arity of the created iteratee.
5966 * @returns {Function} Returns the chosen function or its result.
5967 */
5968 function getIteratee() {
5969 var result = lodash.iteratee || iteratee;
5970 result = result === iteratee ? baseIteratee : result;
5971 return arguments.length ? result(arguments[0], arguments[1]) : result;
5972 }
5973
5974 /**
5975 * Gets the data for `map`.
5976 *
5977 * @private
5978 * @param {Object} map The map to query.
5979 * @param {string} key The reference key.
5980 * @returns {*} Returns the map data.
5981 */
5982 function getMapData(map, key) {
5983 var data = map.__data__;
5984 return isKeyable(key)
5985 ? data[typeof key == 'string' ? 'string' : 'hash']
5986 : data.map;
5987 }
5988
5989 /**
5990 * Gets the property names, values, and compare flags of `object`.
5991 *
5992 * @private
5993 * @param {Object} object The object to query.
5994 * @returns {Array} Returns the match data of `object`.
5995 */
5996 function getMatchData(object) {
5997 var result = keys(object),
5998 length = result.length;
5999
6000 while (length--) {
6001 var key = result[length],
6002 value = object[key];
6003
6004 result[length] = [key, value, isStrictComparable(value)];
6005 }
6006 return result;
6007 }
6008
6009 /**
6010 * Gets the native function at `key` of `object`.
6011 *
6012 * @private
6013 * @param {Object} object The object to query.
6014 * @param {string} key The key of the method to get.
6015 * @returns {*} Returns the function if it's native, else `undefined`.
6016 */
6017 function getNative(object, key) {
6018 var value = getValue(object, key);
6019 return baseIsNative(value) ? value : undefined$1;
6020 }
6021
6022 /**
6023 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
6024 *
6025 * @private
6026 * @param {*} value The value to query.
6027 * @returns {string} Returns the raw `toStringTag`.
6028 */
6029 function getRawTag(value) {
6030 var isOwn = hasOwnProperty.call(value, symToStringTag),
6031 tag = value[symToStringTag];
6032
6033 try {
6034 value[symToStringTag] = undefined$1;
6035 var unmasked = true;
6036 } catch (e) {}
6037
6038 var result = nativeObjectToString.call(value);
6039 if (unmasked) {
6040 if (isOwn) {
6041 value[symToStringTag] = tag;
6042 } else {
6043 delete value[symToStringTag];
6044 }
6045 }
6046 return result;
6047 }
6048
6049 /**
6050 * Creates an array of the own enumerable symbols of `object`.
6051 *
6052 * @private
6053 * @param {Object} object The object to query.
6054 * @returns {Array} Returns the array of symbols.
6055 */
6056 var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
6057 if (object == null) {
6058 return [];
6059 }
6060 object = Object(object);
6061 return arrayFilter(nativeGetSymbols(object), function(symbol) {
6062 return propertyIsEnumerable.call(object, symbol);
6063 });
6064 };
6065
6066 /**
6067 * Creates an array of the own and inherited enumerable symbols of `object`.
6068 *
6069 * @private
6070 * @param {Object} object The object to query.
6071 * @returns {Array} Returns the array of symbols.
6072 */
6073 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
6074 var result = [];
6075 while (object) {
6076 arrayPush(result, getSymbols(object));
6077 object = getPrototype(object);
6078 }
6079 return result;
6080 };
6081
6082 /**
6083 * Gets the `toStringTag` of `value`.
6084 *
6085 * @private
6086 * @param {*} value The value to query.
6087 * @returns {string} Returns the `toStringTag`.
6088 */
6089 var getTag = baseGetTag;
6090
6091 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
6092 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
6093 (Map && getTag(new Map) != mapTag) ||
6094 (Promise && getTag(Promise.resolve()) != promiseTag) ||
6095 (Set && getTag(new Set) != setTag) ||
6096 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
6097 getTag = function(value) {
6098 var result = baseGetTag(value),
6099 Ctor = result == objectTag ? value.constructor : undefined$1,
6100 ctorString = Ctor ? toSource(Ctor) : '';
6101
6102 if (ctorString) {
6103 switch (ctorString) {
6104 case dataViewCtorString: return dataViewTag;
6105 case mapCtorString: return mapTag;
6106 case promiseCtorString: return promiseTag;
6107 case setCtorString: return setTag;
6108 case weakMapCtorString: return weakMapTag;
6109 }
6110 }
6111 return result;
6112 };
6113 }
6114
6115 /**
6116 * Gets the view, applying any `transforms` to the `start` and `end` positions.
6117 *
6118 * @private
6119 * @param {number} start The start of the view.
6120 * @param {number} end The end of the view.
6121 * @param {Array} transforms The transformations to apply to the view.
6122 * @returns {Object} Returns an object containing the `start` and `end`
6123 * positions of the view.
6124 */
6125 function getView(start, end, transforms) {
6126 var index = -1,
6127 length = transforms.length;
6128
6129 while (++index < length) {
6130 var data = transforms[index],
6131 size = data.size;
6132
6133 switch (data.type) {
6134 case 'drop': start += size; break;
6135 case 'dropRight': end -= size; break;
6136 case 'take': end = nativeMin(end, start + size); break;
6137 case 'takeRight': start = nativeMax(start, end - size); break;
6138 }
6139 }
6140 return { 'start': start, 'end': end };
6141 }
6142
6143 /**
6144 * Extracts wrapper details from the `source` body comment.
6145 *
6146 * @private
6147 * @param {string} source The source to inspect.
6148 * @returns {Array} Returns the wrapper details.
6149 */
6150 function getWrapDetails(source) {
6151 var match = source.match(reWrapDetails);
6152 return match ? match[1].split(reSplitDetails) : [];
6153 }
6154
6155 /**
6156 * Checks if `path` exists on `object`.
6157 *
6158 * @private
6159 * @param {Object} object The object to query.
6160 * @param {Array|string} path The path to check.
6161 * @param {Function} hasFunc The function to check properties.
6162 * @returns {boolean} Returns `true` if `path` exists, else `false`.
6163 */
6164 function hasPath(object, path, hasFunc) {
6165 path = castPath(path, object);
6166
6167 var index = -1,
6168 length = path.length,
6169 result = false;
6170
6171 while (++index < length) {
6172 var key = toKey(path[index]);
6173 if (!(result = object != null && hasFunc(object, key))) {
6174 break;
6175 }
6176 object = object[key];
6177 }
6178 if (result || ++index != length) {
6179 return result;
6180 }
6181 length = object == null ? 0 : object.length;
6182 return !!length && isLength(length) && isIndex(key, length) &&
6183 (isArray(object) || isArguments(object));
6184 }
6185
6186 /**
6187 * Initializes an array clone.
6188 *
6189 * @private
6190 * @param {Array} array The array to clone.
6191 * @returns {Array} Returns the initialized clone.
6192 */
6193 function initCloneArray(array) {
6194 var length = array.length,
6195 result = new array.constructor(length);
6196
6197 // Add properties assigned by `RegExp#exec`.
6198 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
6199 result.index = array.index;
6200 result.input = array.input;
6201 }
6202 return result;
6203 }
6204
6205 /**
6206 * Initializes an object clone.
6207 *
6208 * @private
6209 * @param {Object} object The object to clone.
6210 * @returns {Object} Returns the initialized clone.
6211 */
6212 function initCloneObject(object) {
6213 return (typeof object.constructor == 'function' && !isPrototype(object))
6214 ? baseCreate(getPrototype(object))
6215 : {};
6216 }
6217
6218 /**
6219 * Initializes an object clone based on its `toStringTag`.
6220 *
6221 * **Note:** This function only supports cloning values with tags of
6222 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
6223 *
6224 * @private
6225 * @param {Object} object The object to clone.
6226 * @param {string} tag The `toStringTag` of the object to clone.
6227 * @param {boolean} [isDeep] Specify a deep clone.
6228 * @returns {Object} Returns the initialized clone.
6229 */
6230 function initCloneByTag(object, tag, isDeep) {
6231 var Ctor = object.constructor;
6232 switch (tag) {
6233 case arrayBufferTag:
6234 return cloneArrayBuffer(object);
6235
6236 case boolTag:
6237 case dateTag:
6238 return new Ctor(+object);
6239
6240 case dataViewTag:
6241 return cloneDataView(object, isDeep);
6242
6243 case float32Tag: case float64Tag:
6244 case int8Tag: case int16Tag: case int32Tag:
6245 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
6246 return cloneTypedArray(object, isDeep);
6247
6248 case mapTag:
6249 return new Ctor;
6250
6251 case numberTag:
6252 case stringTag:
6253 return new Ctor(object);
6254
6255 case regexpTag:
6256 return cloneRegExp(object);
6257
6258 case setTag:
6259 return new Ctor;
6260
6261 case symbolTag:
6262 return cloneSymbol(object);
6263 }
6264 }
6265
6266 /**
6267 * Inserts wrapper `details` in a comment at the top of the `source` body.
6268 *
6269 * @private
6270 * @param {string} source The source to modify.
6271 * @returns {Array} details The details to insert.
6272 * @returns {string} Returns the modified source.
6273 */
6274 function insertWrapDetails(source, details) {
6275 var length = details.length;
6276 if (!length) {
6277 return source;
6278 }
6279 var lastIndex = length - 1;
6280 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
6281 details = details.join(length > 2 ? ', ' : ' ');
6282 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
6283 }
6284
6285 /**
6286 * Checks if `value` is a flattenable `arguments` object or array.
6287 *
6288 * @private
6289 * @param {*} value The value to check.
6290 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
6291 */
6292 function isFlattenable(value) {
6293 return isArray(value) || isArguments(value) ||
6294 !!(spreadableSymbol && value && value[spreadableSymbol]);
6295 }
6296
6297 /**
6298 * Checks if `value` is a valid array-like index.
6299 *
6300 * @private
6301 * @param {*} value The value to check.
6302 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
6303 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
6304 */
6305 function isIndex(value, length) {
6306 var type = typeof value;
6307 length = length == null ? MAX_SAFE_INTEGER : length;
6308
6309 return !!length &&
6310 (type == 'number' ||
6311 (type != 'symbol' && reIsUint.test(value))) &&
6312 (value > -1 && value % 1 == 0 && value < length);
6313 }
6314
6315 /**
6316 * Checks if the given arguments are from an iteratee call.
6317 *
6318 * @private
6319 * @param {*} value The potential iteratee value argument.
6320 * @param {*} index The potential iteratee index or key argument.
6321 * @param {*} object The potential iteratee object argument.
6322 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
6323 * else `false`.
6324 */
6325 function isIterateeCall(value, index, object) {
6326 if (!isObject(object)) {
6327 return false;
6328 }
6329 var type = typeof index;
6330 if (type == 'number'
6331 ? (isArrayLike(object) && isIndex(index, object.length))
6332 : (type == 'string' && index in object)
6333 ) {
6334 return eq(object[index], value);
6335 }
6336 return false;
6337 }
6338
6339 /**
6340 * Checks if `value` is a property name and not a property path.
6341 *
6342 * @private
6343 * @param {*} value The value to check.
6344 * @param {Object} [object] The object to query keys on.
6345 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
6346 */
6347 function isKey(value, object) {
6348 if (isArray(value)) {
6349 return false;
6350 }
6351 var type = typeof value;
6352 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
6353 value == null || isSymbol(value)) {
6354 return true;
6355 }
6356 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
6357 (object != null && value in Object(object));
6358 }
6359
6360 /**
6361 * Checks if `value` is suitable for use as unique object key.
6362 *
6363 * @private
6364 * @param {*} value The value to check.
6365 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
6366 */
6367 function isKeyable(value) {
6368 var type = typeof value;
6369 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
6370 ? (value !== '__proto__')
6371 : (value === null);
6372 }
6373
6374 /**
6375 * Checks if `func` has a lazy counterpart.
6376 *
6377 * @private
6378 * @param {Function} func The function to check.
6379 * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
6380 * else `false`.
6381 */
6382 function isLaziable(func) {
6383 var funcName = getFuncName(func),
6384 other = lodash[funcName];
6385
6386 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
6387 return false;
6388 }
6389 if (func === other) {
6390 return true;
6391 }
6392 var data = getData(other);
6393 return !!data && func === data[0];
6394 }
6395
6396 /**
6397 * Checks if `func` has its source masked.
6398 *
6399 * @private
6400 * @param {Function} func The function to check.
6401 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
6402 */
6403 function isMasked(func) {
6404 return !!maskSrcKey && (maskSrcKey in func);
6405 }
6406
6407 /**
6408 * Checks if `func` is capable of being masked.
6409 *
6410 * @private
6411 * @param {*} value The value to check.
6412 * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
6413 */
6414 var isMaskable = coreJsData ? isFunction : stubFalse;
6415
6416 /**
6417 * Checks if `value` is likely a prototype object.
6418 *
6419 * @private
6420 * @param {*} value The value to check.
6421 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
6422 */
6423 function isPrototype(value) {
6424 var Ctor = value && value.constructor,
6425 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
6426
6427 return value === proto;
6428 }
6429
6430 /**
6431 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
6432 *
6433 * @private
6434 * @param {*} value The value to check.
6435 * @returns {boolean} Returns `true` if `value` if suitable for strict
6436 * equality comparisons, else `false`.
6437 */
6438 function isStrictComparable(value) {
6439 return value === value && !isObject(value);
6440 }
6441
6442 /**
6443 * A specialized version of `matchesProperty` for source values suitable
6444 * for strict equality comparisons, i.e. `===`.
6445 *
6446 * @private
6447 * @param {string} key The key of the property to get.
6448 * @param {*} srcValue The value to match.
6449 * @returns {Function} Returns the new spec function.
6450 */
6451 function matchesStrictComparable(key, srcValue) {
6452 return function(object) {
6453 if (object == null) {
6454 return false;
6455 }
6456 return object[key] === srcValue &&
6457 (srcValue !== undefined$1 || (key in Object(object)));
6458 };
6459 }
6460
6461 /**
6462 * A specialized version of `_.memoize` which clears the memoized function's
6463 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
6464 *
6465 * @private
6466 * @param {Function} func The function to have its output memoized.
6467 * @returns {Function} Returns the new memoized function.
6468 */
6469 function memoizeCapped(func) {
6470 var result = memoize(func, function(key) {
6471 if (cache.size === MAX_MEMOIZE_SIZE) {
6472 cache.clear();
6473 }
6474 return key;
6475 });
6476
6477 var cache = result.cache;
6478 return result;
6479 }
6480
6481 /**
6482 * Merges the function metadata of `source` into `data`.
6483 *
6484 * Merging metadata reduces the number of wrappers used to invoke a function.
6485 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
6486 * may be applied regardless of execution order. Methods like `_.ary` and
6487 * `_.rearg` modify function arguments, making the order in which they are
6488 * executed important, preventing the merging of metadata. However, we make
6489 * an exception for a safe combined case where curried functions have `_.ary`
6490 * and or `_.rearg` applied.
6491 *
6492 * @private
6493 * @param {Array} data The destination metadata.
6494 * @param {Array} source The source metadata.
6495 * @returns {Array} Returns `data`.
6496 */
6497 function mergeData(data, source) {
6498 var bitmask = data[1],
6499 srcBitmask = source[1],
6500 newBitmask = bitmask | srcBitmask,
6501 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
6502
6503 var isCombo =
6504 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
6505 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
6506 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
6507
6508 // Exit early if metadata can't be merged.
6509 if (!(isCommon || isCombo)) {
6510 return data;
6511 }
6512 // Use source `thisArg` if available.
6513 if (srcBitmask & WRAP_BIND_FLAG) {
6514 data[2] = source[2];
6515 // Set when currying a bound function.
6516 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
6517 }
6518 // Compose partial arguments.
6519 var value = source[3];
6520 if (value) {
6521 var partials = data[3];
6522 data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6523 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6524 }
6525 // Compose partial right arguments.
6526 value = source[5];
6527 if (value) {
6528 partials = data[5];
6529 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6530 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6531 }
6532 // Use source `argPos` if available.
6533 value = source[7];
6534 if (value) {
6535 data[7] = value;
6536 }
6537 // Use source `ary` if it's smaller.
6538 if (srcBitmask & WRAP_ARY_FLAG) {
6539 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
6540 }
6541 // Use source `arity` if one is not provided.
6542 if (data[9] == null) {
6543 data[9] = source[9];
6544 }
6545 // Use source `func` and merge bitmasks.
6546 data[0] = source[0];
6547 data[1] = newBitmask;
6548
6549 return data;
6550 }
6551
6552 /**
6553 * This function is like
6554 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
6555 * except that it includes inherited enumerable properties.
6556 *
6557 * @private
6558 * @param {Object} object The object to query.
6559 * @returns {Array} Returns the array of property names.
6560 */
6561 function nativeKeysIn(object) {
6562 var result = [];
6563 if (object != null) {
6564 for (var key in Object(object)) {
6565 result.push(key);
6566 }
6567 }
6568 return result;
6569 }
6570
6571 /**
6572 * Converts `value` to a string using `Object.prototype.toString`.
6573 *
6574 * @private
6575 * @param {*} value The value to convert.
6576 * @returns {string} Returns the converted string.
6577 */
6578 function objectToString(value) {
6579 return nativeObjectToString.call(value);
6580 }
6581
6582 /**
6583 * A specialized version of `baseRest` which transforms the rest array.
6584 *
6585 * @private
6586 * @param {Function} func The function to apply a rest parameter to.
6587 * @param {number} [start=func.length-1] The start position of the rest parameter.
6588 * @param {Function} transform The rest array transform.
6589 * @returns {Function} Returns the new function.
6590 */
6591 function overRest(func, start, transform) {
6592 start = nativeMax(start === undefined$1 ? (func.length - 1) : start, 0);
6593 return function() {
6594 var args = arguments,
6595 index = -1,
6596 length = nativeMax(args.length - start, 0),
6597 array = Array(length);
6598
6599 while (++index < length) {
6600 array[index] = args[start + index];
6601 }
6602 index = -1;
6603 var otherArgs = Array(start + 1);
6604 while (++index < start) {
6605 otherArgs[index] = args[index];
6606 }
6607 otherArgs[start] = transform(array);
6608 return apply(func, this, otherArgs);
6609 };
6610 }
6611
6612 /**
6613 * Gets the parent value at `path` of `object`.
6614 *
6615 * @private
6616 * @param {Object} object The object to query.
6617 * @param {Array} path The path to get the parent value of.
6618 * @returns {*} Returns the parent value.
6619 */
6620 function parent(object, path) {
6621 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
6622 }
6623
6624 /**
6625 * Reorder `array` according to the specified indexes where the element at
6626 * the first index is assigned as the first element, the element at
6627 * the second index is assigned as the second element, and so on.
6628 *
6629 * @private
6630 * @param {Array} array The array to reorder.
6631 * @param {Array} indexes The arranged array indexes.
6632 * @returns {Array} Returns `array`.
6633 */
6634 function reorder(array, indexes) {
6635 var arrLength = array.length,
6636 length = nativeMin(indexes.length, arrLength),
6637 oldArray = copyArray(array);
6638
6639 while (length--) {
6640 var index = indexes[length];
6641 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined$1;
6642 }
6643 return array;
6644 }
6645
6646 /**
6647 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
6648 *
6649 * @private
6650 * @param {Object} object The object to query.
6651 * @param {string} key The key of the property to get.
6652 * @returns {*} Returns the property value.
6653 */
6654 function safeGet(object, key) {
6655 if (key === 'constructor' && typeof object[key] === 'function') {
6656 return;
6657 }
6658
6659 if (key == '__proto__') {
6660 return;
6661 }
6662
6663 return object[key];
6664 }
6665
6666 /**
6667 * Sets metadata for `func`.
6668 *
6669 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
6670 * period of time, it will trip its breaker and transition to an identity
6671 * function to avoid garbage collection pauses in V8. See
6672 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
6673 * for more details.
6674 *
6675 * @private
6676 * @param {Function} func The function to associate metadata with.
6677 * @param {*} data The metadata.
6678 * @returns {Function} Returns `func`.
6679 */
6680 var setData = shortOut(baseSetData);
6681
6682 /**
6683 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
6684 *
6685 * @private
6686 * @param {Function} func The function to delay.
6687 * @param {number} wait The number of milliseconds to delay invocation.
6688 * @returns {number|Object} Returns the timer id or timeout object.
6689 */
6690 var setTimeout = ctxSetTimeout || function(func, wait) {
6691 return root.setTimeout(func, wait);
6692 };
6693
6694 /**
6695 * Sets the `toString` method of `func` to return `string`.
6696 *
6697 * @private
6698 * @param {Function} func The function to modify.
6699 * @param {Function} string The `toString` result.
6700 * @returns {Function} Returns `func`.
6701 */
6702 var setToString = shortOut(baseSetToString);
6703
6704 /**
6705 * Sets the `toString` method of `wrapper` to mimic the source of `reference`
6706 * with wrapper details in a comment at the top of the source body.
6707 *
6708 * @private
6709 * @param {Function} wrapper The function to modify.
6710 * @param {Function} reference The reference function.
6711 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6712 * @returns {Function} Returns `wrapper`.
6713 */
6714 function setWrapToString(wrapper, reference, bitmask) {
6715 var source = (reference + '');
6716 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
6717 }
6718
6719 /**
6720 * Creates a function that'll short out and invoke `identity` instead
6721 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
6722 * milliseconds.
6723 *
6724 * @private
6725 * @param {Function} func The function to restrict.
6726 * @returns {Function} Returns the new shortable function.
6727 */
6728 function shortOut(func) {
6729 var count = 0,
6730 lastCalled = 0;
6731
6732 return function() {
6733 var stamp = nativeNow(),
6734 remaining = HOT_SPAN - (stamp - lastCalled);
6735
6736 lastCalled = stamp;
6737 if (remaining > 0) {
6738 if (++count >= HOT_COUNT) {
6739 return arguments[0];
6740 }
6741 } else {
6742 count = 0;
6743 }
6744 return func.apply(undefined$1, arguments);
6745 };
6746 }
6747
6748 /**
6749 * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
6750 *
6751 * @private
6752 * @param {Array} array The array to shuffle.
6753 * @param {number} [size=array.length] The size of `array`.
6754 * @returns {Array} Returns `array`.
6755 */
6756 function shuffleSelf(array, size) {
6757 var index = -1,
6758 length = array.length,
6759 lastIndex = length - 1;
6760
6761 size = size === undefined$1 ? length : size;
6762 while (++index < size) {
6763 var rand = baseRandom(index, lastIndex),
6764 value = array[rand];
6765
6766 array[rand] = array[index];
6767 array[index] = value;
6768 }
6769 array.length = size;
6770 return array;
6771 }
6772
6773 /**
6774 * Converts `string` to a property path array.
6775 *
6776 * @private
6777 * @param {string} string The string to convert.
6778 * @returns {Array} Returns the property path array.
6779 */
6780 var stringToPath = memoizeCapped(function(string) {
6781 var result = [];
6782 if (string.charCodeAt(0) === 46 /* . */) {
6783 result.push('');
6784 }
6785 string.replace(rePropName, function(match, number, quote, subString) {
6786 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
6787 });
6788 return result;
6789 });
6790
6791 /**
6792 * Converts `value` to a string key if it's not a string or symbol.
6793 *
6794 * @private
6795 * @param {*} value The value to inspect.
6796 * @returns {string|symbol} Returns the key.
6797 */
6798 function toKey(value) {
6799 if (typeof value == 'string' || isSymbol(value)) {
6800 return value;
6801 }
6802 var result = (value + '');
6803 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
6804 }
6805
6806 /**
6807 * Converts `func` to its source code.
6808 *
6809 * @private
6810 * @param {Function} func The function to convert.
6811 * @returns {string} Returns the source code.
6812 */
6813 function toSource(func) {
6814 if (func != null) {
6815 try {
6816 return funcToString.call(func);
6817 } catch (e) {}
6818 try {
6819 return (func + '');
6820 } catch (e) {}
6821 }
6822 return '';
6823 }
6824
6825 /**
6826 * Updates wrapper `details` based on `bitmask` flags.
6827 *
6828 * @private
6829 * @returns {Array} details The details to modify.
6830 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
6831 * @returns {Array} Returns `details`.
6832 */
6833 function updateWrapDetails(details, bitmask) {
6834 arrayEach(wrapFlags, function(pair) {
6835 var value = '_.' + pair[0];
6836 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
6837 details.push(value);
6838 }
6839 });
6840 return details.sort();
6841 }
6842
6843 /**
6844 * Creates a clone of `wrapper`.
6845 *
6846 * @private
6847 * @param {Object} wrapper The wrapper to clone.
6848 * @returns {Object} Returns the cloned wrapper.
6849 */
6850 function wrapperClone(wrapper) {
6851 if (wrapper instanceof LazyWrapper) {
6852 return wrapper.clone();
6853 }
6854 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
6855 result.__actions__ = copyArray(wrapper.__actions__);
6856 result.__index__ = wrapper.__index__;
6857 result.__values__ = wrapper.__values__;
6858 return result;
6859 }
6860
6861 /*------------------------------------------------------------------------*/
6862
6863 /**
6864 * Creates an array of elements split into groups the length of `size`.
6865 * If `array` can't be split evenly, the final chunk will be the remaining
6866 * elements.
6867 *
6868 * @static
6869 * @memberOf _
6870 * @since 3.0.0
6871 * @category Array
6872 * @param {Array} array The array to process.
6873 * @param {number} [size=1] The length of each chunk
6874 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
6875 * @returns {Array} Returns the new array of chunks.
6876 * @example
6877 *
6878 * _.chunk(['a', 'b', 'c', 'd'], 2);
6879 * // => [['a', 'b'], ['c', 'd']]
6880 *
6881 * _.chunk(['a', 'b', 'c', 'd'], 3);
6882 * // => [['a', 'b', 'c'], ['d']]
6883 */
6884 function chunk(array, size, guard) {
6885 if ((guard ? isIterateeCall(array, size, guard) : size === undefined$1)) {
6886 size = 1;
6887 } else {
6888 size = nativeMax(toInteger(size), 0);
6889 }
6890 var length = array == null ? 0 : array.length;
6891 if (!length || size < 1) {
6892 return [];
6893 }
6894 var index = 0,
6895 resIndex = 0,
6896 result = Array(nativeCeil(length / size));
6897
6898 while (index < length) {
6899 result[resIndex++] = baseSlice(array, index, (index += size));
6900 }
6901 return result;
6902 }
6903
6904 /**
6905 * Creates an array with all falsey values removed. The values `false`, `null`,
6906 * `0`, `""`, `undefined`, and `NaN` are falsey.
6907 *
6908 * @static
6909 * @memberOf _
6910 * @since 0.1.0
6911 * @category Array
6912 * @param {Array} array The array to compact.
6913 * @returns {Array} Returns the new array of filtered values.
6914 * @example
6915 *
6916 * _.compact([0, 1, false, 2, '', 3]);
6917 * // => [1, 2, 3]
6918 */
6919 function compact(array) {
6920 var index = -1,
6921 length = array == null ? 0 : array.length,
6922 resIndex = 0,
6923 result = [];
6924
6925 while (++index < length) {
6926 var value = array[index];
6927 if (value) {
6928 result[resIndex++] = value;
6929 }
6930 }
6931 return result;
6932 }
6933
6934 /**
6935 * Creates a new array concatenating `array` with any additional arrays
6936 * and/or values.
6937 *
6938 * @static
6939 * @memberOf _
6940 * @since 4.0.0
6941 * @category Array
6942 * @param {Array} array The array to concatenate.
6943 * @param {...*} [values] The values to concatenate.
6944 * @returns {Array} Returns the new concatenated array.
6945 * @example
6946 *
6947 * var array = [1];
6948 * var other = _.concat(array, 2, [3], [[4]]);
6949 *
6950 * console.log(other);
6951 * // => [1, 2, 3, [4]]
6952 *
6953 * console.log(array);
6954 * // => [1]
6955 */
6956 function concat() {
6957 var length = arguments.length;
6958 if (!length) {
6959 return [];
6960 }
6961 var args = Array(length - 1),
6962 array = arguments[0],
6963 index = length;
6964
6965 while (index--) {
6966 args[index - 1] = arguments[index];
6967 }
6968 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
6969 }
6970
6971 /**
6972 * Creates an array of `array` values not included in the other given arrays
6973 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
6974 * for equality comparisons. The order and references of result values are
6975 * determined by the first array.
6976 *
6977 * **Note:** Unlike `_.pullAll`, this method returns a new array.
6978 *
6979 * @static
6980 * @memberOf _
6981 * @since 0.1.0
6982 * @category Array
6983 * @param {Array} array The array to inspect.
6984 * @param {...Array} [values] The values to exclude.
6985 * @returns {Array} Returns the new array of filtered values.
6986 * @see _.without, _.xor
6987 * @example
6988 *
6989 * _.difference([2, 1], [2, 3]);
6990 * // => [1]
6991 */
6992 var difference = baseRest(function(array, values) {
6993 return isArrayLikeObject(array)
6994 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
6995 : [];
6996 });
6997
6998 /**
6999 * This method is like `_.difference` except that it accepts `iteratee` which
7000 * is invoked for each element of `array` and `values` to generate the criterion
7001 * by which they're compared. The order and references of result values are
7002 * determined by the first array. The iteratee is invoked with one argument:
7003 * (value).
7004 *
7005 * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
7006 *
7007 * @static
7008 * @memberOf _
7009 * @since 4.0.0
7010 * @category Array
7011 * @param {Array} array The array to inspect.
7012 * @param {...Array} [values] The values to exclude.
7013 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7014 * @returns {Array} Returns the new array of filtered values.
7015 * @example
7016 *
7017 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7018 * // => [1.2]
7019 *
7020 * // The `_.property` iteratee shorthand.
7021 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
7022 * // => [{ 'x': 2 }]
7023 */
7024 var differenceBy = baseRest(function(array, values) {
7025 var iteratee = last(values);
7026 if (isArrayLikeObject(iteratee)) {
7027 iteratee = undefined$1;
7028 }
7029 return isArrayLikeObject(array)
7030 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
7031 : [];
7032 });
7033
7034 /**
7035 * This method is like `_.difference` except that it accepts `comparator`
7036 * which is invoked to compare elements of `array` to `values`. The order and
7037 * references of result values are determined by the first array. The comparator
7038 * is invoked with two arguments: (arrVal, othVal).
7039 *
7040 * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
7041 *
7042 * @static
7043 * @memberOf _
7044 * @since 4.0.0
7045 * @category Array
7046 * @param {Array} array The array to inspect.
7047 * @param {...Array} [values] The values to exclude.
7048 * @param {Function} [comparator] The comparator invoked per element.
7049 * @returns {Array} Returns the new array of filtered values.
7050 * @example
7051 *
7052 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7053 *
7054 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
7055 * // => [{ 'x': 2, 'y': 1 }]
7056 */
7057 var differenceWith = baseRest(function(array, values) {
7058 var comparator = last(values);
7059 if (isArrayLikeObject(comparator)) {
7060 comparator = undefined$1;
7061 }
7062 return isArrayLikeObject(array)
7063 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined$1, comparator)
7064 : [];
7065 });
7066
7067 /**
7068 * Creates a slice of `array` with `n` elements dropped from the beginning.
7069 *
7070 * @static
7071 * @memberOf _
7072 * @since 0.5.0
7073 * @category Array
7074 * @param {Array} array The array to query.
7075 * @param {number} [n=1] The number of elements to drop.
7076 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7077 * @returns {Array} Returns the slice of `array`.
7078 * @example
7079 *
7080 * _.drop([1, 2, 3]);
7081 * // => [2, 3]
7082 *
7083 * _.drop([1, 2, 3], 2);
7084 * // => [3]
7085 *
7086 * _.drop([1, 2, 3], 5);
7087 * // => []
7088 *
7089 * _.drop([1, 2, 3], 0);
7090 * // => [1, 2, 3]
7091 */
7092 function drop(array, n, guard) {
7093 var length = array == null ? 0 : array.length;
7094 if (!length) {
7095 return [];
7096 }
7097 n = (guard || n === undefined$1) ? 1 : toInteger(n);
7098 return baseSlice(array, n < 0 ? 0 : n, length);
7099 }
7100
7101 /**
7102 * Creates a slice of `array` with `n` elements dropped from the end.
7103 *
7104 * @static
7105 * @memberOf _
7106 * @since 3.0.0
7107 * @category Array
7108 * @param {Array} array The array to query.
7109 * @param {number} [n=1] The number of elements to drop.
7110 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
7111 * @returns {Array} Returns the slice of `array`.
7112 * @example
7113 *
7114 * _.dropRight([1, 2, 3]);
7115 * // => [1, 2]
7116 *
7117 * _.dropRight([1, 2, 3], 2);
7118 * // => [1]
7119 *
7120 * _.dropRight([1, 2, 3], 5);
7121 * // => []
7122 *
7123 * _.dropRight([1, 2, 3], 0);
7124 * // => [1, 2, 3]
7125 */
7126 function dropRight(array, n, guard) {
7127 var length = array == null ? 0 : array.length;
7128 if (!length) {
7129 return [];
7130 }
7131 n = (guard || n === undefined$1) ? 1 : toInteger(n);
7132 n = length - n;
7133 return baseSlice(array, 0, n < 0 ? 0 : n);
7134 }
7135
7136 /**
7137 * Creates a slice of `array` excluding elements dropped from the end.
7138 * Elements are dropped until `predicate` returns falsey. The predicate is
7139 * invoked with three arguments: (value, index, array).
7140 *
7141 * @static
7142 * @memberOf _
7143 * @since 3.0.0
7144 * @category Array
7145 * @param {Array} array The array to query.
7146 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7147 * @returns {Array} Returns the slice of `array`.
7148 * @example
7149 *
7150 * var users = [
7151 * { 'user': 'barney', 'active': true },
7152 * { 'user': 'fred', 'active': false },
7153 * { 'user': 'pebbles', 'active': false }
7154 * ];
7155 *
7156 * _.dropRightWhile(users, function(o) { return !o.active; });
7157 * // => objects for ['barney']
7158 *
7159 * // The `_.matches` iteratee shorthand.
7160 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
7161 * // => objects for ['barney', 'fred']
7162 *
7163 * // The `_.matchesProperty` iteratee shorthand.
7164 * _.dropRightWhile(users, ['active', false]);
7165 * // => objects for ['barney']
7166 *
7167 * // The `_.property` iteratee shorthand.
7168 * _.dropRightWhile(users, 'active');
7169 * // => objects for ['barney', 'fred', 'pebbles']
7170 */
7171 function dropRightWhile(array, predicate) {
7172 return (array && array.length)
7173 ? baseWhile(array, getIteratee(predicate, 3), true, true)
7174 : [];
7175 }
7176
7177 /**
7178 * Creates a slice of `array` excluding elements dropped from the beginning.
7179 * Elements are dropped until `predicate` returns falsey. The predicate is
7180 * invoked with three arguments: (value, index, array).
7181 *
7182 * @static
7183 * @memberOf _
7184 * @since 3.0.0
7185 * @category Array
7186 * @param {Array} array The array to query.
7187 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7188 * @returns {Array} Returns the slice of `array`.
7189 * @example
7190 *
7191 * var users = [
7192 * { 'user': 'barney', 'active': false },
7193 * { 'user': 'fred', 'active': false },
7194 * { 'user': 'pebbles', 'active': true }
7195 * ];
7196 *
7197 * _.dropWhile(users, function(o) { return !o.active; });
7198 * // => objects for ['pebbles']
7199 *
7200 * // The `_.matches` iteratee shorthand.
7201 * _.dropWhile(users, { 'user': 'barney', 'active': false });
7202 * // => objects for ['fred', 'pebbles']
7203 *
7204 * // The `_.matchesProperty` iteratee shorthand.
7205 * _.dropWhile(users, ['active', false]);
7206 * // => objects for ['pebbles']
7207 *
7208 * // The `_.property` iteratee shorthand.
7209 * _.dropWhile(users, 'active');
7210 * // => objects for ['barney', 'fred', 'pebbles']
7211 */
7212 function dropWhile(array, predicate) {
7213 return (array && array.length)
7214 ? baseWhile(array, getIteratee(predicate, 3), true)
7215 : [];
7216 }
7217
7218 /**
7219 * Fills elements of `array` with `value` from `start` up to, but not
7220 * including, `end`.
7221 *
7222 * **Note:** This method mutates `array`.
7223 *
7224 * @static
7225 * @memberOf _
7226 * @since 3.2.0
7227 * @category Array
7228 * @param {Array} array The array to fill.
7229 * @param {*} value The value to fill `array` with.
7230 * @param {number} [start=0] The start position.
7231 * @param {number} [end=array.length] The end position.
7232 * @returns {Array} Returns `array`.
7233 * @example
7234 *
7235 * var array = [1, 2, 3];
7236 *
7237 * _.fill(array, 'a');
7238 * console.log(array);
7239 * // => ['a', 'a', 'a']
7240 *
7241 * _.fill(Array(3), 2);
7242 * // => [2, 2, 2]
7243 *
7244 * _.fill([4, 6, 8, 10], '*', 1, 3);
7245 * // => [4, '*', '*', 10]
7246 */
7247 function fill(array, value, start, end) {
7248 var length = array == null ? 0 : array.length;
7249 if (!length) {
7250 return [];
7251 }
7252 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
7253 start = 0;
7254 end = length;
7255 }
7256 return baseFill(array, value, start, end);
7257 }
7258
7259 /**
7260 * This method is like `_.find` except that it returns the index of the first
7261 * element `predicate` returns truthy for instead of the element itself.
7262 *
7263 * @static
7264 * @memberOf _
7265 * @since 1.1.0
7266 * @category Array
7267 * @param {Array} array The array to inspect.
7268 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7269 * @param {number} [fromIndex=0] The index to search from.
7270 * @returns {number} Returns the index of the found element, else `-1`.
7271 * @example
7272 *
7273 * var users = [
7274 * { 'user': 'barney', 'active': false },
7275 * { 'user': 'fred', 'active': false },
7276 * { 'user': 'pebbles', 'active': true }
7277 * ];
7278 *
7279 * _.findIndex(users, function(o) { return o.user == 'barney'; });
7280 * // => 0
7281 *
7282 * // The `_.matches` iteratee shorthand.
7283 * _.findIndex(users, { 'user': 'fred', 'active': false });
7284 * // => 1
7285 *
7286 * // The `_.matchesProperty` iteratee shorthand.
7287 * _.findIndex(users, ['active', false]);
7288 * // => 0
7289 *
7290 * // The `_.property` iteratee shorthand.
7291 * _.findIndex(users, 'active');
7292 * // => 2
7293 */
7294 function findIndex(array, predicate, fromIndex) {
7295 var length = array == null ? 0 : array.length;
7296 if (!length) {
7297 return -1;
7298 }
7299 var index = fromIndex == null ? 0 : toInteger(fromIndex);
7300 if (index < 0) {
7301 index = nativeMax(length + index, 0);
7302 }
7303 return baseFindIndex(array, getIteratee(predicate, 3), index);
7304 }
7305
7306 /**
7307 * This method is like `_.findIndex` except that it iterates over elements
7308 * of `collection` from right to left.
7309 *
7310 * @static
7311 * @memberOf _
7312 * @since 2.0.0
7313 * @category Array
7314 * @param {Array} array The array to inspect.
7315 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7316 * @param {number} [fromIndex=array.length-1] The index to search from.
7317 * @returns {number} Returns the index of the found element, else `-1`.
7318 * @example
7319 *
7320 * var users = [
7321 * { 'user': 'barney', 'active': true },
7322 * { 'user': 'fred', 'active': false },
7323 * { 'user': 'pebbles', 'active': false }
7324 * ];
7325 *
7326 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
7327 * // => 2
7328 *
7329 * // The `_.matches` iteratee shorthand.
7330 * _.findLastIndex(users, { 'user': 'barney', 'active': true });
7331 * // => 0
7332 *
7333 * // The `_.matchesProperty` iteratee shorthand.
7334 * _.findLastIndex(users, ['active', false]);
7335 * // => 2
7336 *
7337 * // The `_.property` iteratee shorthand.
7338 * _.findLastIndex(users, 'active');
7339 * // => 0
7340 */
7341 function findLastIndex(array, predicate, fromIndex) {
7342 var length = array == null ? 0 : array.length;
7343 if (!length) {
7344 return -1;
7345 }
7346 var index = length - 1;
7347 if (fromIndex !== undefined$1) {
7348 index = toInteger(fromIndex);
7349 index = fromIndex < 0
7350 ? nativeMax(length + index, 0)
7351 : nativeMin(index, length - 1);
7352 }
7353 return baseFindIndex(array, getIteratee(predicate, 3), index, true);
7354 }
7355
7356 /**
7357 * Flattens `array` a single level deep.
7358 *
7359 * @static
7360 * @memberOf _
7361 * @since 0.1.0
7362 * @category Array
7363 * @param {Array} array The array to flatten.
7364 * @returns {Array} Returns the new flattened array.
7365 * @example
7366 *
7367 * _.flatten([1, [2, [3, [4]], 5]]);
7368 * // => [1, 2, [3, [4]], 5]
7369 */
7370 function flatten(array) {
7371 var length = array == null ? 0 : array.length;
7372 return length ? baseFlatten(array, 1) : [];
7373 }
7374
7375 /**
7376 * Recursively flattens `array`.
7377 *
7378 * @static
7379 * @memberOf _
7380 * @since 3.0.0
7381 * @category Array
7382 * @param {Array} array The array to flatten.
7383 * @returns {Array} Returns the new flattened array.
7384 * @example
7385 *
7386 * _.flattenDeep([1, [2, [3, [4]], 5]]);
7387 * // => [1, 2, 3, 4, 5]
7388 */
7389 function flattenDeep(array) {
7390 var length = array == null ? 0 : array.length;
7391 return length ? baseFlatten(array, INFINITY) : [];
7392 }
7393
7394 /**
7395 * Recursively flatten `array` up to `depth` times.
7396 *
7397 * @static
7398 * @memberOf _
7399 * @since 4.4.0
7400 * @category Array
7401 * @param {Array} array The array to flatten.
7402 * @param {number} [depth=1] The maximum recursion depth.
7403 * @returns {Array} Returns the new flattened array.
7404 * @example
7405 *
7406 * var array = [1, [2, [3, [4]], 5]];
7407 *
7408 * _.flattenDepth(array, 1);
7409 * // => [1, 2, [3, [4]], 5]
7410 *
7411 * _.flattenDepth(array, 2);
7412 * // => [1, 2, 3, [4], 5]
7413 */
7414 function flattenDepth(array, depth) {
7415 var length = array == null ? 0 : array.length;
7416 if (!length) {
7417 return [];
7418 }
7419 depth = depth === undefined$1 ? 1 : toInteger(depth);
7420 return baseFlatten(array, depth);
7421 }
7422
7423 /**
7424 * The inverse of `_.toPairs`; this method returns an object composed
7425 * from key-value `pairs`.
7426 *
7427 * @static
7428 * @memberOf _
7429 * @since 4.0.0
7430 * @category Array
7431 * @param {Array} pairs The key-value pairs.
7432 * @returns {Object} Returns the new object.
7433 * @example
7434 *
7435 * _.fromPairs([['a', 1], ['b', 2]]);
7436 * // => { 'a': 1, 'b': 2 }
7437 */
7438 function fromPairs(pairs) {
7439 var index = -1,
7440 length = pairs == null ? 0 : pairs.length,
7441 result = {};
7442
7443 while (++index < length) {
7444 var pair = pairs[index];
7445 result[pair[0]] = pair[1];
7446 }
7447 return result;
7448 }
7449
7450 /**
7451 * Gets the first element of `array`.
7452 *
7453 * @static
7454 * @memberOf _
7455 * @since 0.1.0
7456 * @alias first
7457 * @category Array
7458 * @param {Array} array The array to query.
7459 * @returns {*} Returns the first element of `array`.
7460 * @example
7461 *
7462 * _.head([1, 2, 3]);
7463 * // => 1
7464 *
7465 * _.head([]);
7466 * // => undefined
7467 */
7468 function head(array) {
7469 return (array && array.length) ? array[0] : undefined$1;
7470 }
7471
7472 /**
7473 * Gets the index at which the first occurrence of `value` is found in `array`
7474 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7475 * for equality comparisons. If `fromIndex` is negative, it's used as the
7476 * offset from the end of `array`.
7477 *
7478 * @static
7479 * @memberOf _
7480 * @since 0.1.0
7481 * @category Array
7482 * @param {Array} array The array to inspect.
7483 * @param {*} value The value to search for.
7484 * @param {number} [fromIndex=0] The index to search from.
7485 * @returns {number} Returns the index of the matched value, else `-1`.
7486 * @example
7487 *
7488 * _.indexOf([1, 2, 1, 2], 2);
7489 * // => 1
7490 *
7491 * // Search from the `fromIndex`.
7492 * _.indexOf([1, 2, 1, 2], 2, 2);
7493 * // => 3
7494 */
7495 function indexOf(array, value, fromIndex) {
7496 var length = array == null ? 0 : array.length;
7497 if (!length) {
7498 return -1;
7499 }
7500 var index = fromIndex == null ? 0 : toInteger(fromIndex);
7501 if (index < 0) {
7502 index = nativeMax(length + index, 0);
7503 }
7504 return baseIndexOf(array, value, index);
7505 }
7506
7507 /**
7508 * Gets all but the last element of `array`.
7509 *
7510 * @static
7511 * @memberOf _
7512 * @since 0.1.0
7513 * @category Array
7514 * @param {Array} array The array to query.
7515 * @returns {Array} Returns the slice of `array`.
7516 * @example
7517 *
7518 * _.initial([1, 2, 3]);
7519 * // => [1, 2]
7520 */
7521 function initial(array) {
7522 var length = array == null ? 0 : array.length;
7523 return length ? baseSlice(array, 0, -1) : [];
7524 }
7525
7526 /**
7527 * Creates an array of unique values that are included in all given arrays
7528 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7529 * for equality comparisons. The order and references of result values are
7530 * determined by the first array.
7531 *
7532 * @static
7533 * @memberOf _
7534 * @since 0.1.0
7535 * @category Array
7536 * @param {...Array} [arrays] The arrays to inspect.
7537 * @returns {Array} Returns the new array of intersecting values.
7538 * @example
7539 *
7540 * _.intersection([2, 1], [2, 3]);
7541 * // => [2]
7542 */
7543 var intersection = baseRest(function(arrays) {
7544 var mapped = arrayMap(arrays, castArrayLikeObject);
7545 return (mapped.length && mapped[0] === arrays[0])
7546 ? baseIntersection(mapped)
7547 : [];
7548 });
7549
7550 /**
7551 * This method is like `_.intersection` except that it accepts `iteratee`
7552 * which is invoked for each element of each `arrays` to generate the criterion
7553 * by which they're compared. The order and references of result values are
7554 * determined by the first array. The iteratee is invoked with one argument:
7555 * (value).
7556 *
7557 * @static
7558 * @memberOf _
7559 * @since 4.0.0
7560 * @category Array
7561 * @param {...Array} [arrays] The arrays to inspect.
7562 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7563 * @returns {Array} Returns the new array of intersecting values.
7564 * @example
7565 *
7566 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
7567 * // => [2.1]
7568 *
7569 * // The `_.property` iteratee shorthand.
7570 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
7571 * // => [{ 'x': 1 }]
7572 */
7573 var intersectionBy = baseRest(function(arrays) {
7574 var iteratee = last(arrays),
7575 mapped = arrayMap(arrays, castArrayLikeObject);
7576
7577 if (iteratee === last(mapped)) {
7578 iteratee = undefined$1;
7579 } else {
7580 mapped.pop();
7581 }
7582 return (mapped.length && mapped[0] === arrays[0])
7583 ? baseIntersection(mapped, getIteratee(iteratee, 2))
7584 : [];
7585 });
7586
7587 /**
7588 * This method is like `_.intersection` except that it accepts `comparator`
7589 * which is invoked to compare elements of `arrays`. The order and references
7590 * of result values are determined by the first array. The comparator is
7591 * invoked with two arguments: (arrVal, othVal).
7592 *
7593 * @static
7594 * @memberOf _
7595 * @since 4.0.0
7596 * @category Array
7597 * @param {...Array} [arrays] The arrays to inspect.
7598 * @param {Function} [comparator] The comparator invoked per element.
7599 * @returns {Array} Returns the new array of intersecting values.
7600 * @example
7601 *
7602 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
7603 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
7604 *
7605 * _.intersectionWith(objects, others, _.isEqual);
7606 * // => [{ 'x': 1, 'y': 2 }]
7607 */
7608 var intersectionWith = baseRest(function(arrays) {
7609 var comparator = last(arrays),
7610 mapped = arrayMap(arrays, castArrayLikeObject);
7611
7612 comparator = typeof comparator == 'function' ? comparator : undefined$1;
7613 if (comparator) {
7614 mapped.pop();
7615 }
7616 return (mapped.length && mapped[0] === arrays[0])
7617 ? baseIntersection(mapped, undefined$1, comparator)
7618 : [];
7619 });
7620
7621 /**
7622 * Converts all elements in `array` into a string separated by `separator`.
7623 *
7624 * @static
7625 * @memberOf _
7626 * @since 4.0.0
7627 * @category Array
7628 * @param {Array} array The array to convert.
7629 * @param {string} [separator=','] The element separator.
7630 * @returns {string} Returns the joined string.
7631 * @example
7632 *
7633 * _.join(['a', 'b', 'c'], '~');
7634 * // => 'a~b~c'
7635 */
7636 function join(array, separator) {
7637 return array == null ? '' : nativeJoin.call(array, separator);
7638 }
7639
7640 /**
7641 * Gets the last element of `array`.
7642 *
7643 * @static
7644 * @memberOf _
7645 * @since 0.1.0
7646 * @category Array
7647 * @param {Array} array The array to query.
7648 * @returns {*} Returns the last element of `array`.
7649 * @example
7650 *
7651 * _.last([1, 2, 3]);
7652 * // => 3
7653 */
7654 function last(array) {
7655 var length = array == null ? 0 : array.length;
7656 return length ? array[length - 1] : undefined$1;
7657 }
7658
7659 /**
7660 * This method is like `_.indexOf` except that it iterates over elements of
7661 * `array` from right to left.
7662 *
7663 * @static
7664 * @memberOf _
7665 * @since 0.1.0
7666 * @category Array
7667 * @param {Array} array The array to inspect.
7668 * @param {*} value The value to search for.
7669 * @param {number} [fromIndex=array.length-1] The index to search from.
7670 * @returns {number} Returns the index of the matched value, else `-1`.
7671 * @example
7672 *
7673 * _.lastIndexOf([1, 2, 1, 2], 2);
7674 * // => 3
7675 *
7676 * // Search from the `fromIndex`.
7677 * _.lastIndexOf([1, 2, 1, 2], 2, 2);
7678 * // => 1
7679 */
7680 function lastIndexOf(array, value, fromIndex) {
7681 var length = array == null ? 0 : array.length;
7682 if (!length) {
7683 return -1;
7684 }
7685 var index = length;
7686 if (fromIndex !== undefined$1) {
7687 index = toInteger(fromIndex);
7688 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
7689 }
7690 return value === value
7691 ? strictLastIndexOf(array, value, index)
7692 : baseFindIndex(array, baseIsNaN, index, true);
7693 }
7694
7695 /**
7696 * Gets the element at index `n` of `array`. If `n` is negative, the nth
7697 * element from the end is returned.
7698 *
7699 * @static
7700 * @memberOf _
7701 * @since 4.11.0
7702 * @category Array
7703 * @param {Array} array The array to query.
7704 * @param {number} [n=0] The index of the element to return.
7705 * @returns {*} Returns the nth element of `array`.
7706 * @example
7707 *
7708 * var array = ['a', 'b', 'c', 'd'];
7709 *
7710 * _.nth(array, 1);
7711 * // => 'b'
7712 *
7713 * _.nth(array, -2);
7714 * // => 'c';
7715 */
7716 function nth(array, n) {
7717 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined$1;
7718 }
7719
7720 /**
7721 * Removes all given values from `array` using
7722 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
7723 * for equality comparisons.
7724 *
7725 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
7726 * to remove elements from an array by predicate.
7727 *
7728 * @static
7729 * @memberOf _
7730 * @since 2.0.0
7731 * @category Array
7732 * @param {Array} array The array to modify.
7733 * @param {...*} [values] The values to remove.
7734 * @returns {Array} Returns `array`.
7735 * @example
7736 *
7737 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7738 *
7739 * _.pull(array, 'a', 'c');
7740 * console.log(array);
7741 * // => ['b', 'b']
7742 */
7743 var pull = baseRest(pullAll);
7744
7745 /**
7746 * This method is like `_.pull` except that it accepts an array of values to remove.
7747 *
7748 * **Note:** Unlike `_.difference`, this method mutates `array`.
7749 *
7750 * @static
7751 * @memberOf _
7752 * @since 4.0.0
7753 * @category Array
7754 * @param {Array} array The array to modify.
7755 * @param {Array} values The values to remove.
7756 * @returns {Array} Returns `array`.
7757 * @example
7758 *
7759 * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
7760 *
7761 * _.pullAll(array, ['a', 'c']);
7762 * console.log(array);
7763 * // => ['b', 'b']
7764 */
7765 function pullAll(array, values) {
7766 return (array && array.length && values && values.length)
7767 ? basePullAll(array, values)
7768 : array;
7769 }
7770
7771 /**
7772 * This method is like `_.pullAll` except that it accepts `iteratee` which is
7773 * invoked for each element of `array` and `values` to generate the criterion
7774 * by which they're compared. The iteratee is invoked with one argument: (value).
7775 *
7776 * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
7777 *
7778 * @static
7779 * @memberOf _
7780 * @since 4.0.0
7781 * @category Array
7782 * @param {Array} array The array to modify.
7783 * @param {Array} values The values to remove.
7784 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
7785 * @returns {Array} Returns `array`.
7786 * @example
7787 *
7788 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
7789 *
7790 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
7791 * console.log(array);
7792 * // => [{ 'x': 2 }]
7793 */
7794 function pullAllBy(array, values, iteratee) {
7795 return (array && array.length && values && values.length)
7796 ? basePullAll(array, values, getIteratee(iteratee, 2))
7797 : array;
7798 }
7799
7800 /**
7801 * This method is like `_.pullAll` except that it accepts `comparator` which
7802 * is invoked to compare elements of `array` to `values`. The comparator is
7803 * invoked with two arguments: (arrVal, othVal).
7804 *
7805 * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
7806 *
7807 * @static
7808 * @memberOf _
7809 * @since 4.6.0
7810 * @category Array
7811 * @param {Array} array The array to modify.
7812 * @param {Array} values The values to remove.
7813 * @param {Function} [comparator] The comparator invoked per element.
7814 * @returns {Array} Returns `array`.
7815 * @example
7816 *
7817 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
7818 *
7819 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
7820 * console.log(array);
7821 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
7822 */
7823 function pullAllWith(array, values, comparator) {
7824 return (array && array.length && values && values.length)
7825 ? basePullAll(array, values, undefined$1, comparator)
7826 : array;
7827 }
7828
7829 /**
7830 * Removes elements from `array` corresponding to `indexes` and returns an
7831 * array of removed elements.
7832 *
7833 * **Note:** Unlike `_.at`, this method mutates `array`.
7834 *
7835 * @static
7836 * @memberOf _
7837 * @since 3.0.0
7838 * @category Array
7839 * @param {Array} array The array to modify.
7840 * @param {...(number|number[])} [indexes] The indexes of elements to remove.
7841 * @returns {Array} Returns the new array of removed elements.
7842 * @example
7843 *
7844 * var array = ['a', 'b', 'c', 'd'];
7845 * var pulled = _.pullAt(array, [1, 3]);
7846 *
7847 * console.log(array);
7848 * // => ['a', 'c']
7849 *
7850 * console.log(pulled);
7851 * // => ['b', 'd']
7852 */
7853 var pullAt = flatRest(function(array, indexes) {
7854 var length = array == null ? 0 : array.length,
7855 result = baseAt(array, indexes);
7856
7857 basePullAt(array, arrayMap(indexes, function(index) {
7858 return isIndex(index, length) ? +index : index;
7859 }).sort(compareAscending));
7860
7861 return result;
7862 });
7863
7864 /**
7865 * Removes all elements from `array` that `predicate` returns truthy for
7866 * and returns an array of the removed elements. The predicate is invoked
7867 * with three arguments: (value, index, array).
7868 *
7869 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
7870 * to pull elements from an array by value.
7871 *
7872 * @static
7873 * @memberOf _
7874 * @since 2.0.0
7875 * @category Array
7876 * @param {Array} array The array to modify.
7877 * @param {Function} [predicate=_.identity] The function invoked per iteration.
7878 * @returns {Array} Returns the new array of removed elements.
7879 * @example
7880 *
7881 * var array = [1, 2, 3, 4];
7882 * var evens = _.remove(array, function(n) {
7883 * return n % 2 == 0;
7884 * });
7885 *
7886 * console.log(array);
7887 * // => [1, 3]
7888 *
7889 * console.log(evens);
7890 * // => [2, 4]
7891 */
7892 function remove(array, predicate) {
7893 var result = [];
7894 if (!(array && array.length)) {
7895 return result;
7896 }
7897 var index = -1,
7898 indexes = [],
7899 length = array.length;
7900
7901 predicate = getIteratee(predicate, 3);
7902 while (++index < length) {
7903 var value = array[index];
7904 if (predicate(value, index, array)) {
7905 result.push(value);
7906 indexes.push(index);
7907 }
7908 }
7909 basePullAt(array, indexes);
7910 return result;
7911 }
7912
7913 /**
7914 * Reverses `array` so that the first element becomes the last, the second
7915 * element becomes the second to last, and so on.
7916 *
7917 * **Note:** This method mutates `array` and is based on
7918 * [`Array#reverse`](https://mdn.io/Array/reverse).
7919 *
7920 * @static
7921 * @memberOf _
7922 * @since 4.0.0
7923 * @category Array
7924 * @param {Array} array The array to modify.
7925 * @returns {Array} Returns `array`.
7926 * @example
7927 *
7928 * var array = [1, 2, 3];
7929 *
7930 * _.reverse(array);
7931 * // => [3, 2, 1]
7932 *
7933 * console.log(array);
7934 * // => [3, 2, 1]
7935 */
7936 function reverse(array) {
7937 return array == null ? array : nativeReverse.call(array);
7938 }
7939
7940 /**
7941 * Creates a slice of `array` from `start` up to, but not including, `end`.
7942 *
7943 * **Note:** This method is used instead of
7944 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
7945 * returned.
7946 *
7947 * @static
7948 * @memberOf _
7949 * @since 3.0.0
7950 * @category Array
7951 * @param {Array} array The array to slice.
7952 * @param {number} [start=0] The start position.
7953 * @param {number} [end=array.length] The end position.
7954 * @returns {Array} Returns the slice of `array`.
7955 */
7956 function slice(array, start, end) {
7957 var length = array == null ? 0 : array.length;
7958 if (!length) {
7959 return [];
7960 }
7961 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
7962 start = 0;
7963 end = length;
7964 }
7965 else {
7966 start = start == null ? 0 : toInteger(start);
7967 end = end === undefined$1 ? length : toInteger(end);
7968 }
7969 return baseSlice(array, start, end);
7970 }
7971
7972 /**
7973 * Uses a binary search to determine the lowest index at which `value`
7974 * should be inserted into `array` in order to maintain its sort order.
7975 *
7976 * @static
7977 * @memberOf _
7978 * @since 0.1.0
7979 * @category Array
7980 * @param {Array} array The sorted array to inspect.
7981 * @param {*} value The value to evaluate.
7982 * @returns {number} Returns the index at which `value` should be inserted
7983 * into `array`.
7984 * @example
7985 *
7986 * _.sortedIndex([30, 50], 40);
7987 * // => 1
7988 */
7989 function sortedIndex(array, value) {
7990 return baseSortedIndex(array, value);
7991 }
7992
7993 /**
7994 * This method is like `_.sortedIndex` except that it accepts `iteratee`
7995 * which is invoked for `value` and each element of `array` to compute their
7996 * sort ranking. The iteratee is invoked with one argument: (value).
7997 *
7998 * @static
7999 * @memberOf _
8000 * @since 4.0.0
8001 * @category Array
8002 * @param {Array} array The sorted array to inspect.
8003 * @param {*} value The value to evaluate.
8004 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8005 * @returns {number} Returns the index at which `value` should be inserted
8006 * into `array`.
8007 * @example
8008 *
8009 * var objects = [{ 'x': 4 }, { 'x': 5 }];
8010 *
8011 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8012 * // => 0
8013 *
8014 * // The `_.property` iteratee shorthand.
8015 * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
8016 * // => 0
8017 */
8018 function sortedIndexBy(array, value, iteratee) {
8019 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
8020 }
8021
8022 /**
8023 * This method is like `_.indexOf` except that it performs a binary
8024 * search on a sorted `array`.
8025 *
8026 * @static
8027 * @memberOf _
8028 * @since 4.0.0
8029 * @category Array
8030 * @param {Array} array The array to inspect.
8031 * @param {*} value The value to search for.
8032 * @returns {number} Returns the index of the matched value, else `-1`.
8033 * @example
8034 *
8035 * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
8036 * // => 1
8037 */
8038 function sortedIndexOf(array, value) {
8039 var length = array == null ? 0 : array.length;
8040 if (length) {
8041 var index = baseSortedIndex(array, value);
8042 if (index < length && eq(array[index], value)) {
8043 return index;
8044 }
8045 }
8046 return -1;
8047 }
8048
8049 /**
8050 * This method is like `_.sortedIndex` except that it returns the highest
8051 * index at which `value` should be inserted into `array` in order to
8052 * maintain its sort order.
8053 *
8054 * @static
8055 * @memberOf _
8056 * @since 3.0.0
8057 * @category Array
8058 * @param {Array} array The sorted array to inspect.
8059 * @param {*} value The value to evaluate.
8060 * @returns {number} Returns the index at which `value` should be inserted
8061 * into `array`.
8062 * @example
8063 *
8064 * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
8065 * // => 4
8066 */
8067 function sortedLastIndex(array, value) {
8068 return baseSortedIndex(array, value, true);
8069 }
8070
8071 /**
8072 * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
8073 * which is invoked for `value` and each element of `array` to compute their
8074 * sort ranking. The iteratee is invoked with one argument: (value).
8075 *
8076 * @static
8077 * @memberOf _
8078 * @since 4.0.0
8079 * @category Array
8080 * @param {Array} array The sorted array to inspect.
8081 * @param {*} value The value to evaluate.
8082 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8083 * @returns {number} Returns the index at which `value` should be inserted
8084 * into `array`.
8085 * @example
8086 *
8087 * var objects = [{ 'x': 4 }, { 'x': 5 }];
8088 *
8089 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
8090 * // => 1
8091 *
8092 * // The `_.property` iteratee shorthand.
8093 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
8094 * // => 1
8095 */
8096 function sortedLastIndexBy(array, value, iteratee) {
8097 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
8098 }
8099
8100 /**
8101 * This method is like `_.lastIndexOf` except that it performs a binary
8102 * search on a sorted `array`.
8103 *
8104 * @static
8105 * @memberOf _
8106 * @since 4.0.0
8107 * @category Array
8108 * @param {Array} array The array to inspect.
8109 * @param {*} value The value to search for.
8110 * @returns {number} Returns the index of the matched value, else `-1`.
8111 * @example
8112 *
8113 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
8114 * // => 3
8115 */
8116 function sortedLastIndexOf(array, value) {
8117 var length = array == null ? 0 : array.length;
8118 if (length) {
8119 var index = baseSortedIndex(array, value, true) - 1;
8120 if (eq(array[index], value)) {
8121 return index;
8122 }
8123 }
8124 return -1;
8125 }
8126
8127 /**
8128 * This method is like `_.uniq` except that it's designed and optimized
8129 * for sorted arrays.
8130 *
8131 * @static
8132 * @memberOf _
8133 * @since 4.0.0
8134 * @category Array
8135 * @param {Array} array The array to inspect.
8136 * @returns {Array} Returns the new duplicate free array.
8137 * @example
8138 *
8139 * _.sortedUniq([1, 1, 2]);
8140 * // => [1, 2]
8141 */
8142 function sortedUniq(array) {
8143 return (array && array.length)
8144 ? baseSortedUniq(array)
8145 : [];
8146 }
8147
8148 /**
8149 * This method is like `_.uniqBy` except that it's designed and optimized
8150 * for sorted arrays.
8151 *
8152 * @static
8153 * @memberOf _
8154 * @since 4.0.0
8155 * @category Array
8156 * @param {Array} array The array to inspect.
8157 * @param {Function} [iteratee] The iteratee invoked per element.
8158 * @returns {Array} Returns the new duplicate free array.
8159 * @example
8160 *
8161 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
8162 * // => [1.1, 2.3]
8163 */
8164 function sortedUniqBy(array, iteratee) {
8165 return (array && array.length)
8166 ? baseSortedUniq(array, getIteratee(iteratee, 2))
8167 : [];
8168 }
8169
8170 /**
8171 * Gets all but the first element of `array`.
8172 *
8173 * @static
8174 * @memberOf _
8175 * @since 4.0.0
8176 * @category Array
8177 * @param {Array} array The array to query.
8178 * @returns {Array} Returns the slice of `array`.
8179 * @example
8180 *
8181 * _.tail([1, 2, 3]);
8182 * // => [2, 3]
8183 */
8184 function tail(array) {
8185 var length = array == null ? 0 : array.length;
8186 return length ? baseSlice(array, 1, length) : [];
8187 }
8188
8189 /**
8190 * Creates a slice of `array` with `n` elements taken from the beginning.
8191 *
8192 * @static
8193 * @memberOf _
8194 * @since 0.1.0
8195 * @category Array
8196 * @param {Array} array The array to query.
8197 * @param {number} [n=1] The number of elements to take.
8198 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8199 * @returns {Array} Returns the slice of `array`.
8200 * @example
8201 *
8202 * _.take([1, 2, 3]);
8203 * // => [1]
8204 *
8205 * _.take([1, 2, 3], 2);
8206 * // => [1, 2]
8207 *
8208 * _.take([1, 2, 3], 5);
8209 * // => [1, 2, 3]
8210 *
8211 * _.take([1, 2, 3], 0);
8212 * // => []
8213 */
8214 function take(array, n, guard) {
8215 if (!(array && array.length)) {
8216 return [];
8217 }
8218 n = (guard || n === undefined$1) ? 1 : toInteger(n);
8219 return baseSlice(array, 0, n < 0 ? 0 : n);
8220 }
8221
8222 /**
8223 * Creates a slice of `array` with `n` elements taken from the end.
8224 *
8225 * @static
8226 * @memberOf _
8227 * @since 3.0.0
8228 * @category Array
8229 * @param {Array} array The array to query.
8230 * @param {number} [n=1] The number of elements to take.
8231 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
8232 * @returns {Array} Returns the slice of `array`.
8233 * @example
8234 *
8235 * _.takeRight([1, 2, 3]);
8236 * // => [3]
8237 *
8238 * _.takeRight([1, 2, 3], 2);
8239 * // => [2, 3]
8240 *
8241 * _.takeRight([1, 2, 3], 5);
8242 * // => [1, 2, 3]
8243 *
8244 * _.takeRight([1, 2, 3], 0);
8245 * // => []
8246 */
8247 function takeRight(array, n, guard) {
8248 var length = array == null ? 0 : array.length;
8249 if (!length) {
8250 return [];
8251 }
8252 n = (guard || n === undefined$1) ? 1 : toInteger(n);
8253 n = length - n;
8254 return baseSlice(array, n < 0 ? 0 : n, length);
8255 }
8256
8257 /**
8258 * Creates a slice of `array` with elements taken from the end. Elements are
8259 * taken until `predicate` returns falsey. The predicate is invoked with
8260 * three arguments: (value, index, array).
8261 *
8262 * @static
8263 * @memberOf _
8264 * @since 3.0.0
8265 * @category Array
8266 * @param {Array} array The array to query.
8267 * @param {Function} [predicate=_.identity] The function invoked per iteration.
8268 * @returns {Array} Returns the slice of `array`.
8269 * @example
8270 *
8271 * var users = [
8272 * { 'user': 'barney', 'active': true },
8273 * { 'user': 'fred', 'active': false },
8274 * { 'user': 'pebbles', 'active': false }
8275 * ];
8276 *
8277 * _.takeRightWhile(users, function(o) { return !o.active; });
8278 * // => objects for ['fred', 'pebbles']
8279 *
8280 * // The `_.matches` iteratee shorthand.
8281 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
8282 * // => objects for ['pebbles']
8283 *
8284 * // The `_.matchesProperty` iteratee shorthand.
8285 * _.takeRightWhile(users, ['active', false]);
8286 * // => objects for ['fred', 'pebbles']
8287 *
8288 * // The `_.property` iteratee shorthand.
8289 * _.takeRightWhile(users, 'active');
8290 * // => []
8291 */
8292 function takeRightWhile(array, predicate) {
8293 return (array && array.length)
8294 ? baseWhile(array, getIteratee(predicate, 3), false, true)
8295 : [];
8296 }
8297
8298 /**
8299 * Creates a slice of `array` with elements taken from the beginning. Elements
8300 * are taken until `predicate` returns falsey. The predicate is invoked with
8301 * three arguments: (value, index, array).
8302 *
8303 * @static
8304 * @memberOf _
8305 * @since 3.0.0
8306 * @category Array
8307 * @param {Array} array The array to query.
8308 * @param {Function} [predicate=_.identity] The function invoked per iteration.
8309 * @returns {Array} Returns the slice of `array`.
8310 * @example
8311 *
8312 * var users = [
8313 * { 'user': 'barney', 'active': false },
8314 * { 'user': 'fred', 'active': false },
8315 * { 'user': 'pebbles', 'active': true }
8316 * ];
8317 *
8318 * _.takeWhile(users, function(o) { return !o.active; });
8319 * // => objects for ['barney', 'fred']
8320 *
8321 * // The `_.matches` iteratee shorthand.
8322 * _.takeWhile(users, { 'user': 'barney', 'active': false });
8323 * // => objects for ['barney']
8324 *
8325 * // The `_.matchesProperty` iteratee shorthand.
8326 * _.takeWhile(users, ['active', false]);
8327 * // => objects for ['barney', 'fred']
8328 *
8329 * // The `_.property` iteratee shorthand.
8330 * _.takeWhile(users, 'active');
8331 * // => []
8332 */
8333 function takeWhile(array, predicate) {
8334 return (array && array.length)
8335 ? baseWhile(array, getIteratee(predicate, 3))
8336 : [];
8337 }
8338
8339 /**
8340 * Creates an array of unique values, in order, from all given arrays using
8341 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8342 * for equality comparisons.
8343 *
8344 * @static
8345 * @memberOf _
8346 * @since 0.1.0
8347 * @category Array
8348 * @param {...Array} [arrays] The arrays to inspect.
8349 * @returns {Array} Returns the new array of combined values.
8350 * @example
8351 *
8352 * _.union([2], [1, 2]);
8353 * // => [2, 1]
8354 */
8355 var union = baseRest(function(arrays) {
8356 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8357 });
8358
8359 /**
8360 * This method is like `_.union` except that it accepts `iteratee` which is
8361 * invoked for each element of each `arrays` to generate the criterion by
8362 * which uniqueness is computed. Result values are chosen from the first
8363 * array in which the value occurs. The iteratee is invoked with one argument:
8364 * (value).
8365 *
8366 * @static
8367 * @memberOf _
8368 * @since 4.0.0
8369 * @category Array
8370 * @param {...Array} [arrays] The arrays to inspect.
8371 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8372 * @returns {Array} Returns the new array of combined values.
8373 * @example
8374 *
8375 * _.unionBy([2.1], [1.2, 2.3], Math.floor);
8376 * // => [2.1, 1.2]
8377 *
8378 * // The `_.property` iteratee shorthand.
8379 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8380 * // => [{ 'x': 1 }, { 'x': 2 }]
8381 */
8382 var unionBy = baseRest(function(arrays) {
8383 var iteratee = last(arrays);
8384 if (isArrayLikeObject(iteratee)) {
8385 iteratee = undefined$1;
8386 }
8387 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
8388 });
8389
8390 /**
8391 * This method is like `_.union` except that it accepts `comparator` which
8392 * is invoked to compare elements of `arrays`. Result values are chosen from
8393 * the first array in which the value occurs. The comparator is invoked
8394 * with two arguments: (arrVal, othVal).
8395 *
8396 * @static
8397 * @memberOf _
8398 * @since 4.0.0
8399 * @category Array
8400 * @param {...Array} [arrays] The arrays to inspect.
8401 * @param {Function} [comparator] The comparator invoked per element.
8402 * @returns {Array} Returns the new array of combined values.
8403 * @example
8404 *
8405 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8406 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8407 *
8408 * _.unionWith(objects, others, _.isEqual);
8409 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8410 */
8411 var unionWith = baseRest(function(arrays) {
8412 var comparator = last(arrays);
8413 comparator = typeof comparator == 'function' ? comparator : undefined$1;
8414 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined$1, comparator);
8415 });
8416
8417 /**
8418 * Creates a duplicate-free version of an array, using
8419 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8420 * for equality comparisons, in which only the first occurrence of each element
8421 * is kept. The order of result values is determined by the order they occur
8422 * in the array.
8423 *
8424 * @static
8425 * @memberOf _
8426 * @since 0.1.0
8427 * @category Array
8428 * @param {Array} array The array to inspect.
8429 * @returns {Array} Returns the new duplicate free array.
8430 * @example
8431 *
8432 * _.uniq([2, 1, 2]);
8433 * // => [2, 1]
8434 */
8435 function uniq(array) {
8436 return (array && array.length) ? baseUniq(array) : [];
8437 }
8438
8439 /**
8440 * This method is like `_.uniq` except that it accepts `iteratee` which is
8441 * invoked for each element in `array` to generate the criterion by which
8442 * uniqueness is computed. The order of result values is determined by the
8443 * order they occur in the array. The iteratee is invoked with one argument:
8444 * (value).
8445 *
8446 * @static
8447 * @memberOf _
8448 * @since 4.0.0
8449 * @category Array
8450 * @param {Array} array The array to inspect.
8451 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8452 * @returns {Array} Returns the new duplicate free array.
8453 * @example
8454 *
8455 * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
8456 * // => [2.1, 1.2]
8457 *
8458 * // The `_.property` iteratee shorthand.
8459 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
8460 * // => [{ 'x': 1 }, { 'x': 2 }]
8461 */
8462 function uniqBy(array, iteratee) {
8463 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
8464 }
8465
8466 /**
8467 * This method is like `_.uniq` except that it accepts `comparator` which
8468 * is invoked to compare elements of `array`. The order of result values is
8469 * determined by the order they occur in the array.The comparator is invoked
8470 * with two arguments: (arrVal, othVal).
8471 *
8472 * @static
8473 * @memberOf _
8474 * @since 4.0.0
8475 * @category Array
8476 * @param {Array} array The array to inspect.
8477 * @param {Function} [comparator] The comparator invoked per element.
8478 * @returns {Array} Returns the new duplicate free array.
8479 * @example
8480 *
8481 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
8482 *
8483 * _.uniqWith(objects, _.isEqual);
8484 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
8485 */
8486 function uniqWith(array, comparator) {
8487 comparator = typeof comparator == 'function' ? comparator : undefined$1;
8488 return (array && array.length) ? baseUniq(array, undefined$1, comparator) : [];
8489 }
8490
8491 /**
8492 * This method is like `_.zip` except that it accepts an array of grouped
8493 * elements and creates an array regrouping the elements to their pre-zip
8494 * configuration.
8495 *
8496 * @static
8497 * @memberOf _
8498 * @since 1.2.0
8499 * @category Array
8500 * @param {Array} array The array of grouped elements to process.
8501 * @returns {Array} Returns the new array of regrouped elements.
8502 * @example
8503 *
8504 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
8505 * // => [['a', 1, true], ['b', 2, false]]
8506 *
8507 * _.unzip(zipped);
8508 * // => [['a', 'b'], [1, 2], [true, false]]
8509 */
8510 function unzip(array) {
8511 if (!(array && array.length)) {
8512 return [];
8513 }
8514 var length = 0;
8515 array = arrayFilter(array, function(group) {
8516 if (isArrayLikeObject(group)) {
8517 length = nativeMax(group.length, length);
8518 return true;
8519 }
8520 });
8521 return baseTimes(length, function(index) {
8522 return arrayMap(array, baseProperty(index));
8523 });
8524 }
8525
8526 /**
8527 * This method is like `_.unzip` except that it accepts `iteratee` to specify
8528 * how regrouped values should be combined. The iteratee is invoked with the
8529 * elements of each group: (...group).
8530 *
8531 * @static
8532 * @memberOf _
8533 * @since 3.8.0
8534 * @category Array
8535 * @param {Array} array The array of grouped elements to process.
8536 * @param {Function} [iteratee=_.identity] The function to combine
8537 * regrouped values.
8538 * @returns {Array} Returns the new array of regrouped elements.
8539 * @example
8540 *
8541 * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
8542 * // => [[1, 10, 100], [2, 20, 200]]
8543 *
8544 * _.unzipWith(zipped, _.add);
8545 * // => [3, 30, 300]
8546 */
8547 function unzipWith(array, iteratee) {
8548 if (!(array && array.length)) {
8549 return [];
8550 }
8551 var result = unzip(array);
8552 if (iteratee == null) {
8553 return result;
8554 }
8555 return arrayMap(result, function(group) {
8556 return apply(iteratee, undefined$1, group);
8557 });
8558 }
8559
8560 /**
8561 * Creates an array excluding all given values using
8562 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
8563 * for equality comparisons.
8564 *
8565 * **Note:** Unlike `_.pull`, this method returns a new array.
8566 *
8567 * @static
8568 * @memberOf _
8569 * @since 0.1.0
8570 * @category Array
8571 * @param {Array} array The array to inspect.
8572 * @param {...*} [values] The values to exclude.
8573 * @returns {Array} Returns the new array of filtered values.
8574 * @see _.difference, _.xor
8575 * @example
8576 *
8577 * _.without([2, 1, 2, 3], 1, 2);
8578 * // => [3]
8579 */
8580 var without = baseRest(function(array, values) {
8581 return isArrayLikeObject(array)
8582 ? baseDifference(array, values)
8583 : [];
8584 });
8585
8586 /**
8587 * Creates an array of unique values that is the
8588 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
8589 * of the given arrays. The order of result values is determined by the order
8590 * they occur in the arrays.
8591 *
8592 * @static
8593 * @memberOf _
8594 * @since 2.4.0
8595 * @category Array
8596 * @param {...Array} [arrays] The arrays to inspect.
8597 * @returns {Array} Returns the new array of filtered values.
8598 * @see _.difference, _.without
8599 * @example
8600 *
8601 * _.xor([2, 1], [2, 3]);
8602 * // => [1, 3]
8603 */
8604 var xor = baseRest(function(arrays) {
8605 return baseXor(arrayFilter(arrays, isArrayLikeObject));
8606 });
8607
8608 /**
8609 * This method is like `_.xor` except that it accepts `iteratee` which is
8610 * invoked for each element of each `arrays` to generate the criterion by
8611 * which by which they're compared. The order of result values is determined
8612 * by the order they occur in the arrays. The iteratee is invoked with one
8613 * argument: (value).
8614 *
8615 * @static
8616 * @memberOf _
8617 * @since 4.0.0
8618 * @category Array
8619 * @param {...Array} [arrays] The arrays to inspect.
8620 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
8621 * @returns {Array} Returns the new array of filtered values.
8622 * @example
8623 *
8624 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
8625 * // => [1.2, 3.4]
8626 *
8627 * // The `_.property` iteratee shorthand.
8628 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
8629 * // => [{ 'x': 2 }]
8630 */
8631 var xorBy = baseRest(function(arrays) {
8632 var iteratee = last(arrays);
8633 if (isArrayLikeObject(iteratee)) {
8634 iteratee = undefined$1;
8635 }
8636 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
8637 });
8638
8639 /**
8640 * This method is like `_.xor` except that it accepts `comparator` which is
8641 * invoked to compare elements of `arrays`. The order of result values is
8642 * determined by the order they occur in the arrays. The comparator is invoked
8643 * with two arguments: (arrVal, othVal).
8644 *
8645 * @static
8646 * @memberOf _
8647 * @since 4.0.0
8648 * @category Array
8649 * @param {...Array} [arrays] The arrays to inspect.
8650 * @param {Function} [comparator] The comparator invoked per element.
8651 * @returns {Array} Returns the new array of filtered values.
8652 * @example
8653 *
8654 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
8655 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
8656 *
8657 * _.xorWith(objects, others, _.isEqual);
8658 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
8659 */
8660 var xorWith = baseRest(function(arrays) {
8661 var comparator = last(arrays);
8662 comparator = typeof comparator == 'function' ? comparator : undefined$1;
8663 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined$1, comparator);
8664 });
8665
8666 /**
8667 * Creates an array of grouped elements, the first of which contains the
8668 * first elements of the given arrays, the second of which contains the
8669 * second elements of the given arrays, and so on.
8670 *
8671 * @static
8672 * @memberOf _
8673 * @since 0.1.0
8674 * @category Array
8675 * @param {...Array} [arrays] The arrays to process.
8676 * @returns {Array} Returns the new array of grouped elements.
8677 * @example
8678 *
8679 * _.zip(['a', 'b'], [1, 2], [true, false]);
8680 * // => [['a', 1, true], ['b', 2, false]]
8681 */
8682 var zip = baseRest(unzip);
8683
8684 /**
8685 * This method is like `_.fromPairs` except that it accepts two arrays,
8686 * one of property identifiers and one of corresponding values.
8687 *
8688 * @static
8689 * @memberOf _
8690 * @since 0.4.0
8691 * @category Array
8692 * @param {Array} [props=[]] The property identifiers.
8693 * @param {Array} [values=[]] The property values.
8694 * @returns {Object} Returns the new object.
8695 * @example
8696 *
8697 * _.zipObject(['a', 'b'], [1, 2]);
8698 * // => { 'a': 1, 'b': 2 }
8699 */
8700 function zipObject(props, values) {
8701 return baseZipObject(props || [], values || [], assignValue);
8702 }
8703
8704 /**
8705 * This method is like `_.zipObject` except that it supports property paths.
8706 *
8707 * @static
8708 * @memberOf _
8709 * @since 4.1.0
8710 * @category Array
8711 * @param {Array} [props=[]] The property identifiers.
8712 * @param {Array} [values=[]] The property values.
8713 * @returns {Object} Returns the new object.
8714 * @example
8715 *
8716 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
8717 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
8718 */
8719 function zipObjectDeep(props, values) {
8720 return baseZipObject(props || [], values || [], baseSet);
8721 }
8722
8723 /**
8724 * This method is like `_.zip` except that it accepts `iteratee` to specify
8725 * how grouped values should be combined. The iteratee is invoked with the
8726 * elements of each group: (...group).
8727 *
8728 * @static
8729 * @memberOf _
8730 * @since 3.8.0
8731 * @category Array
8732 * @param {...Array} [arrays] The arrays to process.
8733 * @param {Function} [iteratee=_.identity] The function to combine
8734 * grouped values.
8735 * @returns {Array} Returns the new array of grouped elements.
8736 * @example
8737 *
8738 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
8739 * return a + b + c;
8740 * });
8741 * // => [111, 222]
8742 */
8743 var zipWith = baseRest(function(arrays) {
8744 var length = arrays.length,
8745 iteratee = length > 1 ? arrays[length - 1] : undefined$1;
8746
8747 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined$1;
8748 return unzipWith(arrays, iteratee);
8749 });
8750
8751 /*------------------------------------------------------------------------*/
8752
8753 /**
8754 * Creates a `lodash` wrapper instance that wraps `value` with explicit method
8755 * chain sequences enabled. The result of such sequences must be unwrapped
8756 * with `_#value`.
8757 *
8758 * @static
8759 * @memberOf _
8760 * @since 1.3.0
8761 * @category Seq
8762 * @param {*} value The value to wrap.
8763 * @returns {Object} Returns the new `lodash` wrapper instance.
8764 * @example
8765 *
8766 * var users = [
8767 * { 'user': 'barney', 'age': 36 },
8768 * { 'user': 'fred', 'age': 40 },
8769 * { 'user': 'pebbles', 'age': 1 }
8770 * ];
8771 *
8772 * var youngest = _
8773 * .chain(users)
8774 * .sortBy('age')
8775 * .map(function(o) {
8776 * return o.user + ' is ' + o.age;
8777 * })
8778 * .head()
8779 * .value();
8780 * // => 'pebbles is 1'
8781 */
8782 function chain(value) {
8783 var result = lodash(value);
8784 result.__chain__ = true;
8785 return result;
8786 }
8787
8788 /**
8789 * This method invokes `interceptor` and returns `value`. The interceptor
8790 * is invoked with one argument; (value). The purpose of this method is to
8791 * "tap into" a method chain sequence in order to modify intermediate results.
8792 *
8793 * @static
8794 * @memberOf _
8795 * @since 0.1.0
8796 * @category Seq
8797 * @param {*} value The value to provide to `interceptor`.
8798 * @param {Function} interceptor The function to invoke.
8799 * @returns {*} Returns `value`.
8800 * @example
8801 *
8802 * _([1, 2, 3])
8803 * .tap(function(array) {
8804 * // Mutate input array.
8805 * array.pop();
8806 * })
8807 * .reverse()
8808 * .value();
8809 * // => [2, 1]
8810 */
8811 function tap(value, interceptor) {
8812 interceptor(value);
8813 return value;
8814 }
8815
8816 /**
8817 * This method is like `_.tap` except that it returns the result of `interceptor`.
8818 * The purpose of this method is to "pass thru" values replacing intermediate
8819 * results in a method chain sequence.
8820 *
8821 * @static
8822 * @memberOf _
8823 * @since 3.0.0
8824 * @category Seq
8825 * @param {*} value The value to provide to `interceptor`.
8826 * @param {Function} interceptor The function to invoke.
8827 * @returns {*} Returns the result of `interceptor`.
8828 * @example
8829 *
8830 * _(' abc ')
8831 * .chain()
8832 * .trim()
8833 * .thru(function(value) {
8834 * return [value];
8835 * })
8836 * .value();
8837 * // => ['abc']
8838 */
8839 function thru(value, interceptor) {
8840 return interceptor(value);
8841 }
8842
8843 /**
8844 * This method is the wrapper version of `_.at`.
8845 *
8846 * @name at
8847 * @memberOf _
8848 * @since 1.0.0
8849 * @category Seq
8850 * @param {...(string|string[])} [paths] The property paths to pick.
8851 * @returns {Object} Returns the new `lodash` wrapper instance.
8852 * @example
8853 *
8854 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
8855 *
8856 * _(object).at(['a[0].b.c', 'a[1]']).value();
8857 * // => [3, 4]
8858 */
8859 var wrapperAt = flatRest(function(paths) {
8860 var length = paths.length,
8861 start = length ? paths[0] : 0,
8862 value = this.__wrapped__,
8863 interceptor = function(object) { return baseAt(object, paths); };
8864
8865 if (length > 1 || this.__actions__.length ||
8866 !(value instanceof LazyWrapper) || !isIndex(start)) {
8867 return this.thru(interceptor);
8868 }
8869 value = value.slice(start, +start + (length ? 1 : 0));
8870 value.__actions__.push({
8871 'func': thru,
8872 'args': [interceptor],
8873 'thisArg': undefined$1
8874 });
8875 return new LodashWrapper(value, this.__chain__).thru(function(array) {
8876 if (length && !array.length) {
8877 array.push(undefined$1);
8878 }
8879 return array;
8880 });
8881 });
8882
8883 /**
8884 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
8885 *
8886 * @name chain
8887 * @memberOf _
8888 * @since 0.1.0
8889 * @category Seq
8890 * @returns {Object} Returns the new `lodash` wrapper instance.
8891 * @example
8892 *
8893 * var users = [
8894 * { 'user': 'barney', 'age': 36 },
8895 * { 'user': 'fred', 'age': 40 }
8896 * ];
8897 *
8898 * // A sequence without explicit chaining.
8899 * _(users).head();
8900 * // => { 'user': 'barney', 'age': 36 }
8901 *
8902 * // A sequence with explicit chaining.
8903 * _(users)
8904 * .chain()
8905 * .head()
8906 * .pick('user')
8907 * .value();
8908 * // => { 'user': 'barney' }
8909 */
8910 function wrapperChain() {
8911 return chain(this);
8912 }
8913
8914 /**
8915 * Executes the chain sequence and returns the wrapped result.
8916 *
8917 * @name commit
8918 * @memberOf _
8919 * @since 3.2.0
8920 * @category Seq
8921 * @returns {Object} Returns the new `lodash` wrapper instance.
8922 * @example
8923 *
8924 * var array = [1, 2];
8925 * var wrapped = _(array).push(3);
8926 *
8927 * console.log(array);
8928 * // => [1, 2]
8929 *
8930 * wrapped = wrapped.commit();
8931 * console.log(array);
8932 * // => [1, 2, 3]
8933 *
8934 * wrapped.last();
8935 * // => 3
8936 *
8937 * console.log(array);
8938 * // => [1, 2, 3]
8939 */
8940 function wrapperCommit() {
8941 return new LodashWrapper(this.value(), this.__chain__);
8942 }
8943
8944 /**
8945 * Gets the next value on a wrapped object following the
8946 * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
8947 *
8948 * @name next
8949 * @memberOf _
8950 * @since 4.0.0
8951 * @category Seq
8952 * @returns {Object} Returns the next iterator value.
8953 * @example
8954 *
8955 * var wrapped = _([1, 2]);
8956 *
8957 * wrapped.next();
8958 * // => { 'done': false, 'value': 1 }
8959 *
8960 * wrapped.next();
8961 * // => { 'done': false, 'value': 2 }
8962 *
8963 * wrapped.next();
8964 * // => { 'done': true, 'value': undefined }
8965 */
8966 function wrapperNext() {
8967 if (this.__values__ === undefined$1) {
8968 this.__values__ = toArray(this.value());
8969 }
8970 var done = this.__index__ >= this.__values__.length,
8971 value = done ? undefined$1 : this.__values__[this.__index__++];
8972
8973 return { 'done': done, 'value': value };
8974 }
8975
8976 /**
8977 * Enables the wrapper to be iterable.
8978 *
8979 * @name Symbol.iterator
8980 * @memberOf _
8981 * @since 4.0.0
8982 * @category Seq
8983 * @returns {Object} Returns the wrapper object.
8984 * @example
8985 *
8986 * var wrapped = _([1, 2]);
8987 *
8988 * wrapped[Symbol.iterator]() === wrapped;
8989 * // => true
8990 *
8991 * Array.from(wrapped);
8992 * // => [1, 2]
8993 */
8994 function wrapperToIterator() {
8995 return this;
8996 }
8997
8998 /**
8999 * Creates a clone of the chain sequence planting `value` as the wrapped value.
9000 *
9001 * @name plant
9002 * @memberOf _
9003 * @since 3.2.0
9004 * @category Seq
9005 * @param {*} value The value to plant.
9006 * @returns {Object} Returns the new `lodash` wrapper instance.
9007 * @example
9008 *
9009 * function square(n) {
9010 * return n * n;
9011 * }
9012 *
9013 * var wrapped = _([1, 2]).map(square);
9014 * var other = wrapped.plant([3, 4]);
9015 *
9016 * other.value();
9017 * // => [9, 16]
9018 *
9019 * wrapped.value();
9020 * // => [1, 4]
9021 */
9022 function wrapperPlant(value) {
9023 var result,
9024 parent = this;
9025
9026 while (parent instanceof baseLodash) {
9027 var clone = wrapperClone(parent);
9028 clone.__index__ = 0;
9029 clone.__values__ = undefined$1;
9030 if (result) {
9031 previous.__wrapped__ = clone;
9032 } else {
9033 result = clone;
9034 }
9035 var previous = clone;
9036 parent = parent.__wrapped__;
9037 }
9038 previous.__wrapped__ = value;
9039 return result;
9040 }
9041
9042 /**
9043 * This method is the wrapper version of `_.reverse`.
9044 *
9045 * **Note:** This method mutates the wrapped array.
9046 *
9047 * @name reverse
9048 * @memberOf _
9049 * @since 0.1.0
9050 * @category Seq
9051 * @returns {Object} Returns the new `lodash` wrapper instance.
9052 * @example
9053 *
9054 * var array = [1, 2, 3];
9055 *
9056 * _(array).reverse().value()
9057 * // => [3, 2, 1]
9058 *
9059 * console.log(array);
9060 * // => [3, 2, 1]
9061 */
9062 function wrapperReverse() {
9063 var value = this.__wrapped__;
9064 if (value instanceof LazyWrapper) {
9065 var wrapped = value;
9066 if (this.__actions__.length) {
9067 wrapped = new LazyWrapper(this);
9068 }
9069 wrapped = wrapped.reverse();
9070 wrapped.__actions__.push({
9071 'func': thru,
9072 'args': [reverse],
9073 'thisArg': undefined$1
9074 });
9075 return new LodashWrapper(wrapped, this.__chain__);
9076 }
9077 return this.thru(reverse);
9078 }
9079
9080 /**
9081 * Executes the chain sequence to resolve the unwrapped value.
9082 *
9083 * @name value
9084 * @memberOf _
9085 * @since 0.1.0
9086 * @alias toJSON, valueOf
9087 * @category Seq
9088 * @returns {*} Returns the resolved unwrapped value.
9089 * @example
9090 *
9091 * _([1, 2, 3]).value();
9092 * // => [1, 2, 3]
9093 */
9094 function wrapperValue() {
9095 return baseWrapperValue(this.__wrapped__, this.__actions__);
9096 }
9097
9098 /*------------------------------------------------------------------------*/
9099
9100 /**
9101 * Creates an object composed of keys generated from the results of running
9102 * each element of `collection` thru `iteratee`. The corresponding value of
9103 * each key is the number of times the key was returned by `iteratee`. The
9104 * iteratee is invoked with one argument: (value).
9105 *
9106 * @static
9107 * @memberOf _
9108 * @since 0.5.0
9109 * @category Collection
9110 * @param {Array|Object} collection The collection to iterate over.
9111 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9112 * @returns {Object} Returns the composed aggregate object.
9113 * @example
9114 *
9115 * _.countBy([6.1, 4.2, 6.3], Math.floor);
9116 * // => { '4': 1, '6': 2 }
9117 *
9118 * // The `_.property` iteratee shorthand.
9119 * _.countBy(['one', 'two', 'three'], 'length');
9120 * // => { '3': 2, '5': 1 }
9121 */
9122 var countBy = createAggregator(function(result, value, key) {
9123 if (hasOwnProperty.call(result, key)) {
9124 ++result[key];
9125 } else {
9126 baseAssignValue(result, key, 1);
9127 }
9128 });
9129
9130 /**
9131 * Checks if `predicate` returns truthy for **all** elements of `collection`.
9132 * Iteration is stopped once `predicate` returns falsey. The predicate is
9133 * invoked with three arguments: (value, index|key, collection).
9134 *
9135 * **Note:** This method returns `true` for
9136 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
9137 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
9138 * elements of empty collections.
9139 *
9140 * @static
9141 * @memberOf _
9142 * @since 0.1.0
9143 * @category Collection
9144 * @param {Array|Object} collection The collection to iterate over.
9145 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9146 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9147 * @returns {boolean} Returns `true` if all elements pass the predicate check,
9148 * else `false`.
9149 * @example
9150 *
9151 * _.every([true, 1, null, 'yes'], Boolean);
9152 * // => false
9153 *
9154 * var users = [
9155 * { 'user': 'barney', 'age': 36, 'active': false },
9156 * { 'user': 'fred', 'age': 40, 'active': false }
9157 * ];
9158 *
9159 * // The `_.matches` iteratee shorthand.
9160 * _.every(users, { 'user': 'barney', 'active': false });
9161 * // => false
9162 *
9163 * // The `_.matchesProperty` iteratee shorthand.
9164 * _.every(users, ['active', false]);
9165 * // => true
9166 *
9167 * // The `_.property` iteratee shorthand.
9168 * _.every(users, 'active');
9169 * // => false
9170 */
9171 function every(collection, predicate, guard) {
9172 var func = isArray(collection) ? arrayEvery : baseEvery;
9173 if (guard && isIterateeCall(collection, predicate, guard)) {
9174 predicate = undefined$1;
9175 }
9176 return func(collection, getIteratee(predicate, 3));
9177 }
9178
9179 /**
9180 * Iterates over elements of `collection`, returning an array of all elements
9181 * `predicate` returns truthy for. The predicate is invoked with three
9182 * arguments: (value, index|key, collection).
9183 *
9184 * **Note:** Unlike `_.remove`, this method returns a new array.
9185 *
9186 * @static
9187 * @memberOf _
9188 * @since 0.1.0
9189 * @category Collection
9190 * @param {Array|Object} collection The collection to iterate over.
9191 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9192 * @returns {Array} Returns the new filtered array.
9193 * @see _.reject
9194 * @example
9195 *
9196 * var users = [
9197 * { 'user': 'barney', 'age': 36, 'active': true },
9198 * { 'user': 'fred', 'age': 40, 'active': false }
9199 * ];
9200 *
9201 * _.filter(users, function(o) { return !o.active; });
9202 * // => objects for ['fred']
9203 *
9204 * // The `_.matches` iteratee shorthand.
9205 * _.filter(users, { 'age': 36, 'active': true });
9206 * // => objects for ['barney']
9207 *
9208 * // The `_.matchesProperty` iteratee shorthand.
9209 * _.filter(users, ['active', false]);
9210 * // => objects for ['fred']
9211 *
9212 * // The `_.property` iteratee shorthand.
9213 * _.filter(users, 'active');
9214 * // => objects for ['barney']
9215 *
9216 * // Combining several predicates using `_.overEvery` or `_.overSome`.
9217 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
9218 * // => objects for ['fred', 'barney']
9219 */
9220 function filter(collection, predicate) {
9221 var func = isArray(collection) ? arrayFilter : baseFilter;
9222 return func(collection, getIteratee(predicate, 3));
9223 }
9224
9225 /**
9226 * Iterates over elements of `collection`, returning the first element
9227 * `predicate` returns truthy for. The predicate is invoked with three
9228 * arguments: (value, index|key, collection).
9229 *
9230 * @static
9231 * @memberOf _
9232 * @since 0.1.0
9233 * @category Collection
9234 * @param {Array|Object} collection The collection to inspect.
9235 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9236 * @param {number} [fromIndex=0] The index to search from.
9237 * @returns {*} Returns the matched element, else `undefined`.
9238 * @example
9239 *
9240 * var users = [
9241 * { 'user': 'barney', 'age': 36, 'active': true },
9242 * { 'user': 'fred', 'age': 40, 'active': false },
9243 * { 'user': 'pebbles', 'age': 1, 'active': true }
9244 * ];
9245 *
9246 * _.find(users, function(o) { return o.age < 40; });
9247 * // => object for 'barney'
9248 *
9249 * // The `_.matches` iteratee shorthand.
9250 * _.find(users, { 'age': 1, 'active': true });
9251 * // => object for 'pebbles'
9252 *
9253 * // The `_.matchesProperty` iteratee shorthand.
9254 * _.find(users, ['active', false]);
9255 * // => object for 'fred'
9256 *
9257 * // The `_.property` iteratee shorthand.
9258 * _.find(users, 'active');
9259 * // => object for 'barney'
9260 */
9261 var find = createFind(findIndex);
9262
9263 /**
9264 * This method is like `_.find` except that it iterates over elements of
9265 * `collection` from right to left.
9266 *
9267 * @static
9268 * @memberOf _
9269 * @since 2.0.0
9270 * @category Collection
9271 * @param {Array|Object} collection The collection to inspect.
9272 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9273 * @param {number} [fromIndex=collection.length-1] The index to search from.
9274 * @returns {*} Returns the matched element, else `undefined`.
9275 * @example
9276 *
9277 * _.findLast([1, 2, 3, 4], function(n) {
9278 * return n % 2 == 1;
9279 * });
9280 * // => 3
9281 */
9282 var findLast = createFind(findLastIndex);
9283
9284 /**
9285 * Creates a flattened array of values by running each element in `collection`
9286 * thru `iteratee` and flattening the mapped results. The iteratee is invoked
9287 * with three arguments: (value, index|key, collection).
9288 *
9289 * @static
9290 * @memberOf _
9291 * @since 4.0.0
9292 * @category Collection
9293 * @param {Array|Object} collection The collection to iterate over.
9294 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9295 * @returns {Array} Returns the new flattened array.
9296 * @example
9297 *
9298 * function duplicate(n) {
9299 * return [n, n];
9300 * }
9301 *
9302 * _.flatMap([1, 2], duplicate);
9303 * // => [1, 1, 2, 2]
9304 */
9305 function flatMap(collection, iteratee) {
9306 return baseFlatten(map(collection, iteratee), 1);
9307 }
9308
9309 /**
9310 * This method is like `_.flatMap` except that it recursively flattens the
9311 * mapped results.
9312 *
9313 * @static
9314 * @memberOf _
9315 * @since 4.7.0
9316 * @category Collection
9317 * @param {Array|Object} collection The collection to iterate over.
9318 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9319 * @returns {Array} Returns the new flattened array.
9320 * @example
9321 *
9322 * function duplicate(n) {
9323 * return [[[n, n]]];
9324 * }
9325 *
9326 * _.flatMapDeep([1, 2], duplicate);
9327 * // => [1, 1, 2, 2]
9328 */
9329 function flatMapDeep(collection, iteratee) {
9330 return baseFlatten(map(collection, iteratee), INFINITY);
9331 }
9332
9333 /**
9334 * This method is like `_.flatMap` except that it recursively flattens the
9335 * mapped results up to `depth` times.
9336 *
9337 * @static
9338 * @memberOf _
9339 * @since 4.7.0
9340 * @category Collection
9341 * @param {Array|Object} collection The collection to iterate over.
9342 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9343 * @param {number} [depth=1] The maximum recursion depth.
9344 * @returns {Array} Returns the new flattened array.
9345 * @example
9346 *
9347 * function duplicate(n) {
9348 * return [[[n, n]]];
9349 * }
9350 *
9351 * _.flatMapDepth([1, 2], duplicate, 2);
9352 * // => [[1, 1], [2, 2]]
9353 */
9354 function flatMapDepth(collection, iteratee, depth) {
9355 depth = depth === undefined$1 ? 1 : toInteger(depth);
9356 return baseFlatten(map(collection, iteratee), depth);
9357 }
9358
9359 /**
9360 * Iterates over elements of `collection` and invokes `iteratee` for each element.
9361 * The iteratee is invoked with three arguments: (value, index|key, collection).
9362 * Iteratee functions may exit iteration early by explicitly returning `false`.
9363 *
9364 * **Note:** As with other "Collections" methods, objects with a "length"
9365 * property are iterated like arrays. To avoid this behavior use `_.forIn`
9366 * or `_.forOwn` for object iteration.
9367 *
9368 * @static
9369 * @memberOf _
9370 * @since 0.1.0
9371 * @alias each
9372 * @category Collection
9373 * @param {Array|Object} collection The collection to iterate over.
9374 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9375 * @returns {Array|Object} Returns `collection`.
9376 * @see _.forEachRight
9377 * @example
9378 *
9379 * _.forEach([1, 2], function(value) {
9380 * console.log(value);
9381 * });
9382 * // => Logs `1` then `2`.
9383 *
9384 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
9385 * console.log(key);
9386 * });
9387 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
9388 */
9389 function forEach(collection, iteratee) {
9390 var func = isArray(collection) ? arrayEach : baseEach;
9391 return func(collection, getIteratee(iteratee, 3));
9392 }
9393
9394 /**
9395 * This method is like `_.forEach` except that it iterates over elements of
9396 * `collection` from right to left.
9397 *
9398 * @static
9399 * @memberOf _
9400 * @since 2.0.0
9401 * @alias eachRight
9402 * @category Collection
9403 * @param {Array|Object} collection The collection to iterate over.
9404 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9405 * @returns {Array|Object} Returns `collection`.
9406 * @see _.forEach
9407 * @example
9408 *
9409 * _.forEachRight([1, 2], function(value) {
9410 * console.log(value);
9411 * });
9412 * // => Logs `2` then `1`.
9413 */
9414 function forEachRight(collection, iteratee) {
9415 var func = isArray(collection) ? arrayEachRight : baseEachRight;
9416 return func(collection, getIteratee(iteratee, 3));
9417 }
9418
9419 /**
9420 * Creates an object composed of keys generated from the results of running
9421 * each element of `collection` thru `iteratee`. The order of grouped values
9422 * is determined by the order they occur in `collection`. The corresponding
9423 * value of each key is an array of elements responsible for generating the
9424 * key. The iteratee is invoked with one argument: (value).
9425 *
9426 * @static
9427 * @memberOf _
9428 * @since 0.1.0
9429 * @category Collection
9430 * @param {Array|Object} collection The collection to iterate over.
9431 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9432 * @returns {Object} Returns the composed aggregate object.
9433 * @example
9434 *
9435 * _.groupBy([6.1, 4.2, 6.3], Math.floor);
9436 * // => { '4': [4.2], '6': [6.1, 6.3] }
9437 *
9438 * // The `_.property` iteratee shorthand.
9439 * _.groupBy(['one', 'two', 'three'], 'length');
9440 * // => { '3': ['one', 'two'], '5': ['three'] }
9441 */
9442 var groupBy = createAggregator(function(result, value, key) {
9443 if (hasOwnProperty.call(result, key)) {
9444 result[key].push(value);
9445 } else {
9446 baseAssignValue(result, key, [value]);
9447 }
9448 });
9449
9450 /**
9451 * Checks if `value` is in `collection`. If `collection` is a string, it's
9452 * checked for a substring of `value`, otherwise
9453 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9454 * is used for equality comparisons. If `fromIndex` is negative, it's used as
9455 * the offset from the end of `collection`.
9456 *
9457 * @static
9458 * @memberOf _
9459 * @since 0.1.0
9460 * @category Collection
9461 * @param {Array|Object|string} collection The collection to inspect.
9462 * @param {*} value The value to search for.
9463 * @param {number} [fromIndex=0] The index to search from.
9464 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9465 * @returns {boolean} Returns `true` if `value` is found, else `false`.
9466 * @example
9467 *
9468 * _.includes([1, 2, 3], 1);
9469 * // => true
9470 *
9471 * _.includes([1, 2, 3], 1, 2);
9472 * // => false
9473 *
9474 * _.includes({ 'a': 1, 'b': 2 }, 1);
9475 * // => true
9476 *
9477 * _.includes('abcd', 'bc');
9478 * // => true
9479 */
9480 function includes(collection, value, fromIndex, guard) {
9481 collection = isArrayLike(collection) ? collection : values(collection);
9482 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
9483
9484 var length = collection.length;
9485 if (fromIndex < 0) {
9486 fromIndex = nativeMax(length + fromIndex, 0);
9487 }
9488 return isString(collection)
9489 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
9490 : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
9491 }
9492
9493 /**
9494 * Invokes the method at `path` of each element in `collection`, returning
9495 * an array of the results of each invoked method. Any additional arguments
9496 * are provided to each invoked method. If `path` is a function, it's invoked
9497 * for, and `this` bound to, each element in `collection`.
9498 *
9499 * @static
9500 * @memberOf _
9501 * @since 4.0.0
9502 * @category Collection
9503 * @param {Array|Object} collection The collection to iterate over.
9504 * @param {Array|Function|string} path The path of the method to invoke or
9505 * the function invoked per iteration.
9506 * @param {...*} [args] The arguments to invoke each method with.
9507 * @returns {Array} Returns the array of results.
9508 * @example
9509 *
9510 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
9511 * // => [[1, 5, 7], [1, 2, 3]]
9512 *
9513 * _.invokeMap([123, 456], String.prototype.split, '');
9514 * // => [['1', '2', '3'], ['4', '5', '6']]
9515 */
9516 var invokeMap = baseRest(function(collection, path, args) {
9517 var index = -1,
9518 isFunc = typeof path == 'function',
9519 result = isArrayLike(collection) ? Array(collection.length) : [];
9520
9521 baseEach(collection, function(value) {
9522 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
9523 });
9524 return result;
9525 });
9526
9527 /**
9528 * Creates an object composed of keys generated from the results of running
9529 * each element of `collection` thru `iteratee`. The corresponding value of
9530 * each key is the last element responsible for generating the key. The
9531 * iteratee is invoked with one argument: (value).
9532 *
9533 * @static
9534 * @memberOf _
9535 * @since 4.0.0
9536 * @category Collection
9537 * @param {Array|Object} collection The collection to iterate over.
9538 * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
9539 * @returns {Object} Returns the composed aggregate object.
9540 * @example
9541 *
9542 * var array = [
9543 * { 'dir': 'left', 'code': 97 },
9544 * { 'dir': 'right', 'code': 100 }
9545 * ];
9546 *
9547 * _.keyBy(array, function(o) {
9548 * return String.fromCharCode(o.code);
9549 * });
9550 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
9551 *
9552 * _.keyBy(array, 'dir');
9553 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
9554 */
9555 var keyBy = createAggregator(function(result, value, key) {
9556 baseAssignValue(result, key, value);
9557 });
9558
9559 /**
9560 * Creates an array of values by running each element in `collection` thru
9561 * `iteratee`. The iteratee is invoked with three arguments:
9562 * (value, index|key, collection).
9563 *
9564 * Many lodash methods are guarded to work as iteratees for methods like
9565 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
9566 *
9567 * The guarded methods are:
9568 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
9569 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
9570 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
9571 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
9572 *
9573 * @static
9574 * @memberOf _
9575 * @since 0.1.0
9576 * @category Collection
9577 * @param {Array|Object} collection The collection to iterate over.
9578 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9579 * @returns {Array} Returns the new mapped array.
9580 * @example
9581 *
9582 * function square(n) {
9583 * return n * n;
9584 * }
9585 *
9586 * _.map([4, 8], square);
9587 * // => [16, 64]
9588 *
9589 * _.map({ 'a': 4, 'b': 8 }, square);
9590 * // => [16, 64] (iteration order is not guaranteed)
9591 *
9592 * var users = [
9593 * { 'user': 'barney' },
9594 * { 'user': 'fred' }
9595 * ];
9596 *
9597 * // The `_.property` iteratee shorthand.
9598 * _.map(users, 'user');
9599 * // => ['barney', 'fred']
9600 */
9601 function map(collection, iteratee) {
9602 var func = isArray(collection) ? arrayMap : baseMap;
9603 return func(collection, getIteratee(iteratee, 3));
9604 }
9605
9606 /**
9607 * This method is like `_.sortBy` except that it allows specifying the sort
9608 * orders of the iteratees to sort by. If `orders` is unspecified, all values
9609 * are sorted in ascending order. Otherwise, specify an order of "desc" for
9610 * descending or "asc" for ascending sort order of corresponding values.
9611 *
9612 * @static
9613 * @memberOf _
9614 * @since 4.0.0
9615 * @category Collection
9616 * @param {Array|Object} collection The collection to iterate over.
9617 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
9618 * The iteratees to sort by.
9619 * @param {string[]} [orders] The sort orders of `iteratees`.
9620 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
9621 * @returns {Array} Returns the new sorted array.
9622 * @example
9623 *
9624 * var users = [
9625 * { 'user': 'fred', 'age': 48 },
9626 * { 'user': 'barney', 'age': 34 },
9627 * { 'user': 'fred', 'age': 40 },
9628 * { 'user': 'barney', 'age': 36 }
9629 * ];
9630 *
9631 * // Sort by `user` in ascending order and by `age` in descending order.
9632 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
9633 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
9634 */
9635 function orderBy(collection, iteratees, orders, guard) {
9636 if (collection == null) {
9637 return [];
9638 }
9639 if (!isArray(iteratees)) {
9640 iteratees = iteratees == null ? [] : [iteratees];
9641 }
9642 orders = guard ? undefined$1 : orders;
9643 if (!isArray(orders)) {
9644 orders = orders == null ? [] : [orders];
9645 }
9646 return baseOrderBy(collection, iteratees, orders);
9647 }
9648
9649 /**
9650 * Creates an array of elements split into two groups, the first of which
9651 * contains elements `predicate` returns truthy for, the second of which
9652 * contains elements `predicate` returns falsey for. The predicate is
9653 * invoked with one argument: (value).
9654 *
9655 * @static
9656 * @memberOf _
9657 * @since 3.0.0
9658 * @category Collection
9659 * @param {Array|Object} collection The collection to iterate over.
9660 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9661 * @returns {Array} Returns the array of grouped elements.
9662 * @example
9663 *
9664 * var users = [
9665 * { 'user': 'barney', 'age': 36, 'active': false },
9666 * { 'user': 'fred', 'age': 40, 'active': true },
9667 * { 'user': 'pebbles', 'age': 1, 'active': false }
9668 * ];
9669 *
9670 * _.partition(users, function(o) { return o.active; });
9671 * // => objects for [['fred'], ['barney', 'pebbles']]
9672 *
9673 * // The `_.matches` iteratee shorthand.
9674 * _.partition(users, { 'age': 1, 'active': false });
9675 * // => objects for [['pebbles'], ['barney', 'fred']]
9676 *
9677 * // The `_.matchesProperty` iteratee shorthand.
9678 * _.partition(users, ['active', false]);
9679 * // => objects for [['barney', 'pebbles'], ['fred']]
9680 *
9681 * // The `_.property` iteratee shorthand.
9682 * _.partition(users, 'active');
9683 * // => objects for [['fred'], ['barney', 'pebbles']]
9684 */
9685 var partition = createAggregator(function(result, value, key) {
9686 result[key ? 0 : 1].push(value);
9687 }, function() { return [[], []]; });
9688
9689 /**
9690 * Reduces `collection` to a value which is the accumulated result of running
9691 * each element in `collection` thru `iteratee`, where each successive
9692 * invocation is supplied the return value of the previous. If `accumulator`
9693 * is not given, the first element of `collection` is used as the initial
9694 * value. The iteratee is invoked with four arguments:
9695 * (accumulator, value, index|key, collection).
9696 *
9697 * Many lodash methods are guarded to work as iteratees for methods like
9698 * `_.reduce`, `_.reduceRight`, and `_.transform`.
9699 *
9700 * The guarded methods are:
9701 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
9702 * and `sortBy`
9703 *
9704 * @static
9705 * @memberOf _
9706 * @since 0.1.0
9707 * @category Collection
9708 * @param {Array|Object} collection The collection to iterate over.
9709 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9710 * @param {*} [accumulator] The initial value.
9711 * @returns {*} Returns the accumulated value.
9712 * @see _.reduceRight
9713 * @example
9714 *
9715 * _.reduce([1, 2], function(sum, n) {
9716 * return sum + n;
9717 * }, 0);
9718 * // => 3
9719 *
9720 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
9721 * (result[value] || (result[value] = [])).push(key);
9722 * return result;
9723 * }, {});
9724 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
9725 */
9726 function reduce(collection, iteratee, accumulator) {
9727 var func = isArray(collection) ? arrayReduce : baseReduce,
9728 initAccum = arguments.length < 3;
9729
9730 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
9731 }
9732
9733 /**
9734 * This method is like `_.reduce` except that it iterates over elements of
9735 * `collection` from right to left.
9736 *
9737 * @static
9738 * @memberOf _
9739 * @since 0.1.0
9740 * @category Collection
9741 * @param {Array|Object} collection The collection to iterate over.
9742 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9743 * @param {*} [accumulator] The initial value.
9744 * @returns {*} Returns the accumulated value.
9745 * @see _.reduce
9746 * @example
9747 *
9748 * var array = [[0, 1], [2, 3], [4, 5]];
9749 *
9750 * _.reduceRight(array, function(flattened, other) {
9751 * return flattened.concat(other);
9752 * }, []);
9753 * // => [4, 5, 2, 3, 0, 1]
9754 */
9755 function reduceRight(collection, iteratee, accumulator) {
9756 var func = isArray(collection) ? arrayReduceRight : baseReduce,
9757 initAccum = arguments.length < 3;
9758
9759 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
9760 }
9761
9762 /**
9763 * The opposite of `_.filter`; this method returns the elements of `collection`
9764 * that `predicate` does **not** return truthy for.
9765 *
9766 * @static
9767 * @memberOf _
9768 * @since 0.1.0
9769 * @category Collection
9770 * @param {Array|Object} collection The collection to iterate over.
9771 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9772 * @returns {Array} Returns the new filtered array.
9773 * @see _.filter
9774 * @example
9775 *
9776 * var users = [
9777 * { 'user': 'barney', 'age': 36, 'active': false },
9778 * { 'user': 'fred', 'age': 40, 'active': true }
9779 * ];
9780 *
9781 * _.reject(users, function(o) { return !o.active; });
9782 * // => objects for ['fred']
9783 *
9784 * // The `_.matches` iteratee shorthand.
9785 * _.reject(users, { 'age': 40, 'active': true });
9786 * // => objects for ['barney']
9787 *
9788 * // The `_.matchesProperty` iteratee shorthand.
9789 * _.reject(users, ['active', false]);
9790 * // => objects for ['fred']
9791 *
9792 * // The `_.property` iteratee shorthand.
9793 * _.reject(users, 'active');
9794 * // => objects for ['barney']
9795 */
9796 function reject(collection, predicate) {
9797 var func = isArray(collection) ? arrayFilter : baseFilter;
9798 return func(collection, negate(getIteratee(predicate, 3)));
9799 }
9800
9801 /**
9802 * Gets a random element from `collection`.
9803 *
9804 * @static
9805 * @memberOf _
9806 * @since 2.0.0
9807 * @category Collection
9808 * @param {Array|Object} collection The collection to sample.
9809 * @returns {*} Returns the random element.
9810 * @example
9811 *
9812 * _.sample([1, 2, 3, 4]);
9813 * // => 2
9814 */
9815 function sample(collection) {
9816 var func = isArray(collection) ? arraySample : baseSample;
9817 return func(collection);
9818 }
9819
9820 /**
9821 * Gets `n` random elements at unique keys from `collection` up to the
9822 * size of `collection`.
9823 *
9824 * @static
9825 * @memberOf _
9826 * @since 4.0.0
9827 * @category Collection
9828 * @param {Array|Object} collection The collection to sample.
9829 * @param {number} [n=1] The number of elements to sample.
9830 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9831 * @returns {Array} Returns the random elements.
9832 * @example
9833 *
9834 * _.sampleSize([1, 2, 3], 2);
9835 * // => [3, 1]
9836 *
9837 * _.sampleSize([1, 2, 3], 4);
9838 * // => [2, 3, 1]
9839 */
9840 function sampleSize(collection, n, guard) {
9841 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined$1)) {
9842 n = 1;
9843 } else {
9844 n = toInteger(n);
9845 }
9846 var func = isArray(collection) ? arraySampleSize : baseSampleSize;
9847 return func(collection, n);
9848 }
9849
9850 /**
9851 * Creates an array of shuffled values, using a version of the
9852 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
9853 *
9854 * @static
9855 * @memberOf _
9856 * @since 0.1.0
9857 * @category Collection
9858 * @param {Array|Object} collection The collection to shuffle.
9859 * @returns {Array} Returns the new shuffled array.
9860 * @example
9861 *
9862 * _.shuffle([1, 2, 3, 4]);
9863 * // => [4, 1, 3, 2]
9864 */
9865 function shuffle(collection) {
9866 var func = isArray(collection) ? arrayShuffle : baseShuffle;
9867 return func(collection);
9868 }
9869
9870 /**
9871 * Gets the size of `collection` by returning its length for array-like
9872 * values or the number of own enumerable string keyed properties for objects.
9873 *
9874 * @static
9875 * @memberOf _
9876 * @since 0.1.0
9877 * @category Collection
9878 * @param {Array|Object|string} collection The collection to inspect.
9879 * @returns {number} Returns the collection size.
9880 * @example
9881 *
9882 * _.size([1, 2, 3]);
9883 * // => 3
9884 *
9885 * _.size({ 'a': 1, 'b': 2 });
9886 * // => 2
9887 *
9888 * _.size('pebbles');
9889 * // => 7
9890 */
9891 function size(collection) {
9892 if (collection == null) {
9893 return 0;
9894 }
9895 if (isArrayLike(collection)) {
9896 return isString(collection) ? stringSize(collection) : collection.length;
9897 }
9898 var tag = getTag(collection);
9899 if (tag == mapTag || tag == setTag) {
9900 return collection.size;
9901 }
9902 return baseKeys(collection).length;
9903 }
9904
9905 /**
9906 * Checks if `predicate` returns truthy for **any** element of `collection`.
9907 * Iteration is stopped once `predicate` returns truthy. The predicate is
9908 * invoked with three arguments: (value, index|key, collection).
9909 *
9910 * @static
9911 * @memberOf _
9912 * @since 0.1.0
9913 * @category Collection
9914 * @param {Array|Object} collection The collection to iterate over.
9915 * @param {Function} [predicate=_.identity] The function invoked per iteration.
9916 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
9917 * @returns {boolean} Returns `true` if any element passes the predicate check,
9918 * else `false`.
9919 * @example
9920 *
9921 * _.some([null, 0, 'yes', false], Boolean);
9922 * // => true
9923 *
9924 * var users = [
9925 * { 'user': 'barney', 'active': true },
9926 * { 'user': 'fred', 'active': false }
9927 * ];
9928 *
9929 * // The `_.matches` iteratee shorthand.
9930 * _.some(users, { 'user': 'barney', 'active': false });
9931 * // => false
9932 *
9933 * // The `_.matchesProperty` iteratee shorthand.
9934 * _.some(users, ['active', false]);
9935 * // => true
9936 *
9937 * // The `_.property` iteratee shorthand.
9938 * _.some(users, 'active');
9939 * // => true
9940 */
9941 function some(collection, predicate, guard) {
9942 var func = isArray(collection) ? arraySome : baseSome;
9943 if (guard && isIterateeCall(collection, predicate, guard)) {
9944 predicate = undefined$1;
9945 }
9946 return func(collection, getIteratee(predicate, 3));
9947 }
9948
9949 /**
9950 * Creates an array of elements, sorted in ascending order by the results of
9951 * running each element in a collection thru each iteratee. This method
9952 * performs a stable sort, that is, it preserves the original sort order of
9953 * equal elements. The iteratees are invoked with one argument: (value).
9954 *
9955 * @static
9956 * @memberOf _
9957 * @since 0.1.0
9958 * @category Collection
9959 * @param {Array|Object} collection The collection to iterate over.
9960 * @param {...(Function|Function[])} [iteratees=[_.identity]]
9961 * The iteratees to sort by.
9962 * @returns {Array} Returns the new sorted array.
9963 * @example
9964 *
9965 * var users = [
9966 * { 'user': 'fred', 'age': 48 },
9967 * { 'user': 'barney', 'age': 36 },
9968 * { 'user': 'fred', 'age': 30 },
9969 * { 'user': 'barney', 'age': 34 }
9970 * ];
9971 *
9972 * _.sortBy(users, [function(o) { return o.user; }]);
9973 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
9974 *
9975 * _.sortBy(users, ['user', 'age']);
9976 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
9977 */
9978 var sortBy = baseRest(function(collection, iteratees) {
9979 if (collection == null) {
9980 return [];
9981 }
9982 var length = iteratees.length;
9983 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
9984 iteratees = [];
9985 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
9986 iteratees = [iteratees[0]];
9987 }
9988 return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
9989 });
9990
9991 /*------------------------------------------------------------------------*/
9992
9993 /**
9994 * Gets the timestamp of the number of milliseconds that have elapsed since
9995 * the Unix epoch (1 January 1970 00:00:00 UTC).
9996 *
9997 * @static
9998 * @memberOf _
9999 * @since 2.4.0
10000 * @category Date
10001 * @returns {number} Returns the timestamp.
10002 * @example
10003 *
10004 * _.defer(function(stamp) {
10005 * console.log(_.now() - stamp);
10006 * }, _.now());
10007 * // => Logs the number of milliseconds it took for the deferred invocation.
10008 */
10009 var now = ctxNow || function() {
10010 return root.Date.now();
10011 };
10012
10013 /*------------------------------------------------------------------------*/
10014
10015 /**
10016 * The opposite of `_.before`; this method creates a function that invokes
10017 * `func` once it's called `n` or more times.
10018 *
10019 * @static
10020 * @memberOf _
10021 * @since 0.1.0
10022 * @category Function
10023 * @param {number} n The number of calls before `func` is invoked.
10024 * @param {Function} func The function to restrict.
10025 * @returns {Function} Returns the new restricted function.
10026 * @example
10027 *
10028 * var saves = ['profile', 'settings'];
10029 *
10030 * var done = _.after(saves.length, function() {
10031 * console.log('done saving!');
10032 * });
10033 *
10034 * _.forEach(saves, function(type) {
10035 * asyncSave({ 'type': type, 'complete': done });
10036 * });
10037 * // => Logs 'done saving!' after the two async saves have completed.
10038 */
10039 function after(n, func) {
10040 if (typeof func != 'function') {
10041 throw new TypeError(FUNC_ERROR_TEXT);
10042 }
10043 n = toInteger(n);
10044 return function() {
10045 if (--n < 1) {
10046 return func.apply(this, arguments);
10047 }
10048 };
10049 }
10050
10051 /**
10052 * Creates a function that invokes `func`, with up to `n` arguments,
10053 * ignoring any additional arguments.
10054 *
10055 * @static
10056 * @memberOf _
10057 * @since 3.0.0
10058 * @category Function
10059 * @param {Function} func The function to cap arguments for.
10060 * @param {number} [n=func.length] The arity cap.
10061 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10062 * @returns {Function} Returns the new capped function.
10063 * @example
10064 *
10065 * _.map(['6', '8', '10'], _.ary(parseInt, 1));
10066 * // => [6, 8, 10]
10067 */
10068 function ary(func, n, guard) {
10069 n = guard ? undefined$1 : n;
10070 n = (func && n == null) ? func.length : n;
10071 return createWrap(func, WRAP_ARY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, n);
10072 }
10073
10074 /**
10075 * Creates a function that invokes `func`, with the `this` binding and arguments
10076 * of the created function, while it's called less than `n` times. Subsequent
10077 * calls to the created function return the result of the last `func` invocation.
10078 *
10079 * @static
10080 * @memberOf _
10081 * @since 3.0.0
10082 * @category Function
10083 * @param {number} n The number of calls at which `func` is no longer invoked.
10084 * @param {Function} func The function to restrict.
10085 * @returns {Function} Returns the new restricted function.
10086 * @example
10087 *
10088 * jQuery(element).on('click', _.before(5, addContactToList));
10089 * // => Allows adding up to 4 contacts to the list.
10090 */
10091 function before(n, func) {
10092 var result;
10093 if (typeof func != 'function') {
10094 throw new TypeError(FUNC_ERROR_TEXT);
10095 }
10096 n = toInteger(n);
10097 return function() {
10098 if (--n > 0) {
10099 result = func.apply(this, arguments);
10100 }
10101 if (n <= 1) {
10102 func = undefined$1;
10103 }
10104 return result;
10105 };
10106 }
10107
10108 /**
10109 * Creates a function that invokes `func` with the `this` binding of `thisArg`
10110 * and `partials` prepended to the arguments it receives.
10111 *
10112 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
10113 * may be used as a placeholder for partially applied arguments.
10114 *
10115 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
10116 * property of bound functions.
10117 *
10118 * @static
10119 * @memberOf _
10120 * @since 0.1.0
10121 * @category Function
10122 * @param {Function} func The function to bind.
10123 * @param {*} thisArg The `this` binding of `func`.
10124 * @param {...*} [partials] The arguments to be partially applied.
10125 * @returns {Function} Returns the new bound function.
10126 * @example
10127 *
10128 * function greet(greeting, punctuation) {
10129 * return greeting + ' ' + this.user + punctuation;
10130 * }
10131 *
10132 * var object = { 'user': 'fred' };
10133 *
10134 * var bound = _.bind(greet, object, 'hi');
10135 * bound('!');
10136 * // => 'hi fred!'
10137 *
10138 * // Bound with placeholders.
10139 * var bound = _.bind(greet, object, _, '!');
10140 * bound('hi');
10141 * // => 'hi fred!'
10142 */
10143 var bind = baseRest(function(func, thisArg, partials) {
10144 var bitmask = WRAP_BIND_FLAG;
10145 if (partials.length) {
10146 var holders = replaceHolders(partials, getHolder(bind));
10147 bitmask |= WRAP_PARTIAL_FLAG;
10148 }
10149 return createWrap(func, bitmask, thisArg, partials, holders);
10150 });
10151
10152 /**
10153 * Creates a function that invokes the method at `object[key]` with `partials`
10154 * prepended to the arguments it receives.
10155 *
10156 * This method differs from `_.bind` by allowing bound functions to reference
10157 * methods that may be redefined or don't yet exist. See
10158 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
10159 * for more details.
10160 *
10161 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
10162 * builds, may be used as a placeholder for partially applied arguments.
10163 *
10164 * @static
10165 * @memberOf _
10166 * @since 0.10.0
10167 * @category Function
10168 * @param {Object} object The object to invoke the method on.
10169 * @param {string} key The key of the method.
10170 * @param {...*} [partials] The arguments to be partially applied.
10171 * @returns {Function} Returns the new bound function.
10172 * @example
10173 *
10174 * var object = {
10175 * 'user': 'fred',
10176 * 'greet': function(greeting, punctuation) {
10177 * return greeting + ' ' + this.user + punctuation;
10178 * }
10179 * };
10180 *
10181 * var bound = _.bindKey(object, 'greet', 'hi');
10182 * bound('!');
10183 * // => 'hi fred!'
10184 *
10185 * object.greet = function(greeting, punctuation) {
10186 * return greeting + 'ya ' + this.user + punctuation;
10187 * };
10188 *
10189 * bound('!');
10190 * // => 'hiya fred!'
10191 *
10192 * // Bound with placeholders.
10193 * var bound = _.bindKey(object, 'greet', _, '!');
10194 * bound('hi');
10195 * // => 'hiya fred!'
10196 */
10197 var bindKey = baseRest(function(object, key, partials) {
10198 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
10199 if (partials.length) {
10200 var holders = replaceHolders(partials, getHolder(bindKey));
10201 bitmask |= WRAP_PARTIAL_FLAG;
10202 }
10203 return createWrap(key, bitmask, object, partials, holders);
10204 });
10205
10206 /**
10207 * Creates a function that accepts arguments of `func` and either invokes
10208 * `func` returning its result, if at least `arity` number of arguments have
10209 * been provided, or returns a function that accepts the remaining `func`
10210 * arguments, and so on. The arity of `func` may be specified if `func.length`
10211 * is not sufficient.
10212 *
10213 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
10214 * may be used as a placeholder for provided arguments.
10215 *
10216 * **Note:** This method doesn't set the "length" property of curried functions.
10217 *
10218 * @static
10219 * @memberOf _
10220 * @since 2.0.0
10221 * @category Function
10222 * @param {Function} func The function to curry.
10223 * @param {number} [arity=func.length] The arity of `func`.
10224 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10225 * @returns {Function} Returns the new curried function.
10226 * @example
10227 *
10228 * var abc = function(a, b, c) {
10229 * return [a, b, c];
10230 * };
10231 *
10232 * var curried = _.curry(abc);
10233 *
10234 * curried(1)(2)(3);
10235 * // => [1, 2, 3]
10236 *
10237 * curried(1, 2)(3);
10238 * // => [1, 2, 3]
10239 *
10240 * curried(1, 2, 3);
10241 * // => [1, 2, 3]
10242 *
10243 * // Curried with placeholders.
10244 * curried(1)(_, 3)(2);
10245 * // => [1, 2, 3]
10246 */
10247 function curry(func, arity, guard) {
10248 arity = guard ? undefined$1 : arity;
10249 var result = createWrap(func, WRAP_CURRY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity);
10250 result.placeholder = curry.placeholder;
10251 return result;
10252 }
10253
10254 /**
10255 * This method is like `_.curry` except that arguments are applied to `func`
10256 * in the manner of `_.partialRight` instead of `_.partial`.
10257 *
10258 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
10259 * builds, may be used as a placeholder for provided arguments.
10260 *
10261 * **Note:** This method doesn't set the "length" property of curried functions.
10262 *
10263 * @static
10264 * @memberOf _
10265 * @since 3.0.0
10266 * @category Function
10267 * @param {Function} func The function to curry.
10268 * @param {number} [arity=func.length] The arity of `func`.
10269 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
10270 * @returns {Function} Returns the new curried function.
10271 * @example
10272 *
10273 * var abc = function(a, b, c) {
10274 * return [a, b, c];
10275 * };
10276 *
10277 * var curried = _.curryRight(abc);
10278 *
10279 * curried(3)(2)(1);
10280 * // => [1, 2, 3]
10281 *
10282 * curried(2, 3)(1);
10283 * // => [1, 2, 3]
10284 *
10285 * curried(1, 2, 3);
10286 * // => [1, 2, 3]
10287 *
10288 * // Curried with placeholders.
10289 * curried(3)(1, _)(2);
10290 * // => [1, 2, 3]
10291 */
10292 function curryRight(func, arity, guard) {
10293 arity = guard ? undefined$1 : arity;
10294 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity);
10295 result.placeholder = curryRight.placeholder;
10296 return result;
10297 }
10298
10299 /**
10300 * Creates a debounced function that delays invoking `func` until after `wait`
10301 * milliseconds have elapsed since the last time the debounced function was
10302 * invoked. The debounced function comes with a `cancel` method to cancel
10303 * delayed `func` invocations and a `flush` method to immediately invoke them.
10304 * Provide `options` to indicate whether `func` should be invoked on the
10305 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
10306 * with the last arguments provided to the debounced function. Subsequent
10307 * calls to the debounced function return the result of the last `func`
10308 * invocation.
10309 *
10310 * **Note:** If `leading` and `trailing` options are `true`, `func` is
10311 * invoked on the trailing edge of the timeout only if the debounced function
10312 * is invoked more than once during the `wait` timeout.
10313 *
10314 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10315 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10316 *
10317 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10318 * for details over the differences between `_.debounce` and `_.throttle`.
10319 *
10320 * @static
10321 * @memberOf _
10322 * @since 0.1.0
10323 * @category Function
10324 * @param {Function} func The function to debounce.
10325 * @param {number} [wait=0] The number of milliseconds to delay.
10326 * @param {Object} [options={}] The options object.
10327 * @param {boolean} [options.leading=false]
10328 * Specify invoking on the leading edge of the timeout.
10329 * @param {number} [options.maxWait]
10330 * The maximum time `func` is allowed to be delayed before it's invoked.
10331 * @param {boolean} [options.trailing=true]
10332 * Specify invoking on the trailing edge of the timeout.
10333 * @returns {Function} Returns the new debounced function.
10334 * @example
10335 *
10336 * // Avoid costly calculations while the window size is in flux.
10337 * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
10338 *
10339 * // Invoke `sendMail` when clicked, debouncing subsequent calls.
10340 * jQuery(element).on('click', _.debounce(sendMail, 300, {
10341 * 'leading': true,
10342 * 'trailing': false
10343 * }));
10344 *
10345 * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
10346 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
10347 * var source = new EventSource('/stream');
10348 * jQuery(source).on('message', debounced);
10349 *
10350 * // Cancel the trailing debounced invocation.
10351 * jQuery(window).on('popstate', debounced.cancel);
10352 */
10353 function debounce(func, wait, options) {
10354 var lastArgs,
10355 lastThis,
10356 maxWait,
10357 result,
10358 timerId,
10359 lastCallTime,
10360 lastInvokeTime = 0,
10361 leading = false,
10362 maxing = false,
10363 trailing = true;
10364
10365 if (typeof func != 'function') {
10366 throw new TypeError(FUNC_ERROR_TEXT);
10367 }
10368 wait = toNumber(wait) || 0;
10369 if (isObject(options)) {
10370 leading = !!options.leading;
10371 maxing = 'maxWait' in options;
10372 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
10373 trailing = 'trailing' in options ? !!options.trailing : trailing;
10374 }
10375
10376 function invokeFunc(time) {
10377 var args = lastArgs,
10378 thisArg = lastThis;
10379
10380 lastArgs = lastThis = undefined$1;
10381 lastInvokeTime = time;
10382 result = func.apply(thisArg, args);
10383 return result;
10384 }
10385
10386 function leadingEdge(time) {
10387 // Reset any `maxWait` timer.
10388 lastInvokeTime = time;
10389 // Start the timer for the trailing edge.
10390 timerId = setTimeout(timerExpired, wait);
10391 // Invoke the leading edge.
10392 return leading ? invokeFunc(time) : result;
10393 }
10394
10395 function remainingWait(time) {
10396 var timeSinceLastCall = time - lastCallTime,
10397 timeSinceLastInvoke = time - lastInvokeTime,
10398 timeWaiting = wait - timeSinceLastCall;
10399
10400 return maxing
10401 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
10402 : timeWaiting;
10403 }
10404
10405 function shouldInvoke(time) {
10406 var timeSinceLastCall = time - lastCallTime,
10407 timeSinceLastInvoke = time - lastInvokeTime;
10408
10409 // Either this is the first call, activity has stopped and we're at the
10410 // trailing edge, the system time has gone backwards and we're treating
10411 // it as the trailing edge, or we've hit the `maxWait` limit.
10412 return (lastCallTime === undefined$1 || (timeSinceLastCall >= wait) ||
10413 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
10414 }
10415
10416 function timerExpired() {
10417 var time = now();
10418 if (shouldInvoke(time)) {
10419 return trailingEdge(time);
10420 }
10421 // Restart the timer.
10422 timerId = setTimeout(timerExpired, remainingWait(time));
10423 }
10424
10425 function trailingEdge(time) {
10426 timerId = undefined$1;
10427
10428 // Only invoke if we have `lastArgs` which means `func` has been
10429 // debounced at least once.
10430 if (trailing && lastArgs) {
10431 return invokeFunc(time);
10432 }
10433 lastArgs = lastThis = undefined$1;
10434 return result;
10435 }
10436
10437 function cancel() {
10438 if (timerId !== undefined$1) {
10439 clearTimeout(timerId);
10440 }
10441 lastInvokeTime = 0;
10442 lastArgs = lastCallTime = lastThis = timerId = undefined$1;
10443 }
10444
10445 function flush() {
10446 return timerId === undefined$1 ? result : trailingEdge(now());
10447 }
10448
10449 function debounced() {
10450 var time = now(),
10451 isInvoking = shouldInvoke(time);
10452
10453 lastArgs = arguments;
10454 lastThis = this;
10455 lastCallTime = time;
10456
10457 if (isInvoking) {
10458 if (timerId === undefined$1) {
10459 return leadingEdge(lastCallTime);
10460 }
10461 if (maxing) {
10462 // Handle invocations in a tight loop.
10463 clearTimeout(timerId);
10464 timerId = setTimeout(timerExpired, wait);
10465 return invokeFunc(lastCallTime);
10466 }
10467 }
10468 if (timerId === undefined$1) {
10469 timerId = setTimeout(timerExpired, wait);
10470 }
10471 return result;
10472 }
10473 debounced.cancel = cancel;
10474 debounced.flush = flush;
10475 return debounced;
10476 }
10477
10478 /**
10479 * Defers invoking the `func` until the current call stack has cleared. Any
10480 * additional arguments are provided to `func` when it's invoked.
10481 *
10482 * @static
10483 * @memberOf _
10484 * @since 0.1.0
10485 * @category Function
10486 * @param {Function} func The function to defer.
10487 * @param {...*} [args] The arguments to invoke `func` with.
10488 * @returns {number} Returns the timer id.
10489 * @example
10490 *
10491 * _.defer(function(text) {
10492 * console.log(text);
10493 * }, 'deferred');
10494 * // => Logs 'deferred' after one millisecond.
10495 */
10496 var defer = baseRest(function(func, args) {
10497 return baseDelay(func, 1, args);
10498 });
10499
10500 /**
10501 * Invokes `func` after `wait` milliseconds. Any additional arguments are
10502 * provided to `func` when it's invoked.
10503 *
10504 * @static
10505 * @memberOf _
10506 * @since 0.1.0
10507 * @category Function
10508 * @param {Function} func The function to delay.
10509 * @param {number} wait The number of milliseconds to delay invocation.
10510 * @param {...*} [args] The arguments to invoke `func` with.
10511 * @returns {number} Returns the timer id.
10512 * @example
10513 *
10514 * _.delay(function(text) {
10515 * console.log(text);
10516 * }, 1000, 'later');
10517 * // => Logs 'later' after one second.
10518 */
10519 var delay = baseRest(function(func, wait, args) {
10520 return baseDelay(func, toNumber(wait) || 0, args);
10521 });
10522
10523 /**
10524 * Creates a function that invokes `func` with arguments reversed.
10525 *
10526 * @static
10527 * @memberOf _
10528 * @since 4.0.0
10529 * @category Function
10530 * @param {Function} func The function to flip arguments for.
10531 * @returns {Function} Returns the new flipped function.
10532 * @example
10533 *
10534 * var flipped = _.flip(function() {
10535 * return _.toArray(arguments);
10536 * });
10537 *
10538 * flipped('a', 'b', 'c', 'd');
10539 * // => ['d', 'c', 'b', 'a']
10540 */
10541 function flip(func) {
10542 return createWrap(func, WRAP_FLIP_FLAG);
10543 }
10544
10545 /**
10546 * Creates a function that memoizes the result of `func`. If `resolver` is
10547 * provided, it determines the cache key for storing the result based on the
10548 * arguments provided to the memoized function. By default, the first argument
10549 * provided to the memoized function is used as the map cache key. The `func`
10550 * is invoked with the `this` binding of the memoized function.
10551 *
10552 * **Note:** The cache is exposed as the `cache` property on the memoized
10553 * function. Its creation may be customized by replacing the `_.memoize.Cache`
10554 * constructor with one whose instances implement the
10555 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
10556 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
10557 *
10558 * @static
10559 * @memberOf _
10560 * @since 0.1.0
10561 * @category Function
10562 * @param {Function} func The function to have its output memoized.
10563 * @param {Function} [resolver] The function to resolve the cache key.
10564 * @returns {Function} Returns the new memoized function.
10565 * @example
10566 *
10567 * var object = { 'a': 1, 'b': 2 };
10568 * var other = { 'c': 3, 'd': 4 };
10569 *
10570 * var values = _.memoize(_.values);
10571 * values(object);
10572 * // => [1, 2]
10573 *
10574 * values(other);
10575 * // => [3, 4]
10576 *
10577 * object.a = 2;
10578 * values(object);
10579 * // => [1, 2]
10580 *
10581 * // Modify the result cache.
10582 * values.cache.set(object, ['a', 'b']);
10583 * values(object);
10584 * // => ['a', 'b']
10585 *
10586 * // Replace `_.memoize.Cache`.
10587 * _.memoize.Cache = WeakMap;
10588 */
10589 function memoize(func, resolver) {
10590 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
10591 throw new TypeError(FUNC_ERROR_TEXT);
10592 }
10593 var memoized = function() {
10594 var args = arguments,
10595 key = resolver ? resolver.apply(this, args) : args[0],
10596 cache = memoized.cache;
10597
10598 if (cache.has(key)) {
10599 return cache.get(key);
10600 }
10601 var result = func.apply(this, args);
10602 memoized.cache = cache.set(key, result) || cache;
10603 return result;
10604 };
10605 memoized.cache = new (memoize.Cache || MapCache);
10606 return memoized;
10607 }
10608
10609 // Expose `MapCache`.
10610 memoize.Cache = MapCache;
10611
10612 /**
10613 * Creates a function that negates the result of the predicate `func`. The
10614 * `func` predicate is invoked with the `this` binding and arguments of the
10615 * created function.
10616 *
10617 * @static
10618 * @memberOf _
10619 * @since 3.0.0
10620 * @category Function
10621 * @param {Function} predicate The predicate to negate.
10622 * @returns {Function} Returns the new negated function.
10623 * @example
10624 *
10625 * function isEven(n) {
10626 * return n % 2 == 0;
10627 * }
10628 *
10629 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
10630 * // => [1, 3, 5]
10631 */
10632 function negate(predicate) {
10633 if (typeof predicate != 'function') {
10634 throw new TypeError(FUNC_ERROR_TEXT);
10635 }
10636 return function() {
10637 var args = arguments;
10638 switch (args.length) {
10639 case 0: return !predicate.call(this);
10640 case 1: return !predicate.call(this, args[0]);
10641 case 2: return !predicate.call(this, args[0], args[1]);
10642 case 3: return !predicate.call(this, args[0], args[1], args[2]);
10643 }
10644 return !predicate.apply(this, args);
10645 };
10646 }
10647
10648 /**
10649 * Creates a function that is restricted to invoking `func` once. Repeat calls
10650 * to the function return the value of the first invocation. The `func` is
10651 * invoked with the `this` binding and arguments of the created function.
10652 *
10653 * @static
10654 * @memberOf _
10655 * @since 0.1.0
10656 * @category Function
10657 * @param {Function} func The function to restrict.
10658 * @returns {Function} Returns the new restricted function.
10659 * @example
10660 *
10661 * var initialize = _.once(createApplication);
10662 * initialize();
10663 * initialize();
10664 * // => `createApplication` is invoked once
10665 */
10666 function once(func) {
10667 return before(2, func);
10668 }
10669
10670 /**
10671 * Creates a function that invokes `func` with its arguments transformed.
10672 *
10673 * @static
10674 * @since 4.0.0
10675 * @memberOf _
10676 * @category Function
10677 * @param {Function} func The function to wrap.
10678 * @param {...(Function|Function[])} [transforms=[_.identity]]
10679 * The argument transforms.
10680 * @returns {Function} Returns the new function.
10681 * @example
10682 *
10683 * function doubled(n) {
10684 * return n * 2;
10685 * }
10686 *
10687 * function square(n) {
10688 * return n * n;
10689 * }
10690 *
10691 * var func = _.overArgs(function(x, y) {
10692 * return [x, y];
10693 * }, [square, doubled]);
10694 *
10695 * func(9, 3);
10696 * // => [81, 6]
10697 *
10698 * func(10, 5);
10699 * // => [100, 10]
10700 */
10701 var overArgs = castRest(function(func, transforms) {
10702 transforms = (transforms.length == 1 && isArray(transforms[0]))
10703 ? arrayMap(transforms[0], baseUnary(getIteratee()))
10704 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
10705
10706 var funcsLength = transforms.length;
10707 return baseRest(function(args) {
10708 var index = -1,
10709 length = nativeMin(args.length, funcsLength);
10710
10711 while (++index < length) {
10712 args[index] = transforms[index].call(this, args[index]);
10713 }
10714 return apply(func, this, args);
10715 });
10716 });
10717
10718 /**
10719 * Creates a function that invokes `func` with `partials` prepended to the
10720 * arguments it receives. This method is like `_.bind` except it does **not**
10721 * alter the `this` binding.
10722 *
10723 * The `_.partial.placeholder` value, which defaults to `_` in monolithic
10724 * builds, may be used as a placeholder for partially applied arguments.
10725 *
10726 * **Note:** This method doesn't set the "length" property of partially
10727 * applied functions.
10728 *
10729 * @static
10730 * @memberOf _
10731 * @since 0.2.0
10732 * @category Function
10733 * @param {Function} func The function to partially apply arguments to.
10734 * @param {...*} [partials] The arguments to be partially applied.
10735 * @returns {Function} Returns the new partially applied function.
10736 * @example
10737 *
10738 * function greet(greeting, name) {
10739 * return greeting + ' ' + name;
10740 * }
10741 *
10742 * var sayHelloTo = _.partial(greet, 'hello');
10743 * sayHelloTo('fred');
10744 * // => 'hello fred'
10745 *
10746 * // Partially applied with placeholders.
10747 * var greetFred = _.partial(greet, _, 'fred');
10748 * greetFred('hi');
10749 * // => 'hi fred'
10750 */
10751 var partial = baseRest(function(func, partials) {
10752 var holders = replaceHolders(partials, getHolder(partial));
10753 return createWrap(func, WRAP_PARTIAL_FLAG, undefined$1, partials, holders);
10754 });
10755
10756 /**
10757 * This method is like `_.partial` except that partially applied arguments
10758 * are appended to the arguments it receives.
10759 *
10760 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
10761 * builds, may be used as a placeholder for partially applied arguments.
10762 *
10763 * **Note:** This method doesn't set the "length" property of partially
10764 * applied functions.
10765 *
10766 * @static
10767 * @memberOf _
10768 * @since 1.0.0
10769 * @category Function
10770 * @param {Function} func The function to partially apply arguments to.
10771 * @param {...*} [partials] The arguments to be partially applied.
10772 * @returns {Function} Returns the new partially applied function.
10773 * @example
10774 *
10775 * function greet(greeting, name) {
10776 * return greeting + ' ' + name;
10777 * }
10778 *
10779 * var greetFred = _.partialRight(greet, 'fred');
10780 * greetFred('hi');
10781 * // => 'hi fred'
10782 *
10783 * // Partially applied with placeholders.
10784 * var sayHelloTo = _.partialRight(greet, 'hello', _);
10785 * sayHelloTo('fred');
10786 * // => 'hello fred'
10787 */
10788 var partialRight = baseRest(function(func, partials) {
10789 var holders = replaceHolders(partials, getHolder(partialRight));
10790 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined$1, partials, holders);
10791 });
10792
10793 /**
10794 * Creates a function that invokes `func` with arguments arranged according
10795 * to the specified `indexes` where the argument value at the first index is
10796 * provided as the first argument, the argument value at the second index is
10797 * provided as the second argument, and so on.
10798 *
10799 * @static
10800 * @memberOf _
10801 * @since 3.0.0
10802 * @category Function
10803 * @param {Function} func The function to rearrange arguments for.
10804 * @param {...(number|number[])} indexes The arranged argument indexes.
10805 * @returns {Function} Returns the new function.
10806 * @example
10807 *
10808 * var rearged = _.rearg(function(a, b, c) {
10809 * return [a, b, c];
10810 * }, [2, 0, 1]);
10811 *
10812 * rearged('b', 'c', 'a')
10813 * // => ['a', 'b', 'c']
10814 */
10815 var rearg = flatRest(function(func, indexes) {
10816 return createWrap(func, WRAP_REARG_FLAG, undefined$1, undefined$1, undefined$1, indexes);
10817 });
10818
10819 /**
10820 * Creates a function that invokes `func` with the `this` binding of the
10821 * created function and arguments from `start` and beyond provided as
10822 * an array.
10823 *
10824 * **Note:** This method is based on the
10825 * [rest parameter](https://mdn.io/rest_parameters).
10826 *
10827 * @static
10828 * @memberOf _
10829 * @since 4.0.0
10830 * @category Function
10831 * @param {Function} func The function to apply a rest parameter to.
10832 * @param {number} [start=func.length-1] The start position of the rest parameter.
10833 * @returns {Function} Returns the new function.
10834 * @example
10835 *
10836 * var say = _.rest(function(what, names) {
10837 * return what + ' ' + _.initial(names).join(', ') +
10838 * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
10839 * });
10840 *
10841 * say('hello', 'fred', 'barney', 'pebbles');
10842 * // => 'hello fred, barney, & pebbles'
10843 */
10844 function rest(func, start) {
10845 if (typeof func != 'function') {
10846 throw new TypeError(FUNC_ERROR_TEXT);
10847 }
10848 start = start === undefined$1 ? start : toInteger(start);
10849 return baseRest(func, start);
10850 }
10851
10852 /**
10853 * Creates a function that invokes `func` with the `this` binding of the
10854 * create function and an array of arguments much like
10855 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
10856 *
10857 * **Note:** This method is based on the
10858 * [spread operator](https://mdn.io/spread_operator).
10859 *
10860 * @static
10861 * @memberOf _
10862 * @since 3.2.0
10863 * @category Function
10864 * @param {Function} func The function to spread arguments over.
10865 * @param {number} [start=0] The start position of the spread.
10866 * @returns {Function} Returns the new function.
10867 * @example
10868 *
10869 * var say = _.spread(function(who, what) {
10870 * return who + ' says ' + what;
10871 * });
10872 *
10873 * say(['fred', 'hello']);
10874 * // => 'fred says hello'
10875 *
10876 * var numbers = Promise.all([
10877 * Promise.resolve(40),
10878 * Promise.resolve(36)
10879 * ]);
10880 *
10881 * numbers.then(_.spread(function(x, y) {
10882 * return x + y;
10883 * }));
10884 * // => a Promise of 76
10885 */
10886 function spread(func, start) {
10887 if (typeof func != 'function') {
10888 throw new TypeError(FUNC_ERROR_TEXT);
10889 }
10890 start = start == null ? 0 : nativeMax(toInteger(start), 0);
10891 return baseRest(function(args) {
10892 var array = args[start],
10893 otherArgs = castSlice(args, 0, start);
10894
10895 if (array) {
10896 arrayPush(otherArgs, array);
10897 }
10898 return apply(func, this, otherArgs);
10899 });
10900 }
10901
10902 /**
10903 * Creates a throttled function that only invokes `func` at most once per
10904 * every `wait` milliseconds. The throttled function comes with a `cancel`
10905 * method to cancel delayed `func` invocations and a `flush` method to
10906 * immediately invoke them. Provide `options` to indicate whether `func`
10907 * should be invoked on the leading and/or trailing edge of the `wait`
10908 * timeout. The `func` is invoked with the last arguments provided to the
10909 * throttled function. Subsequent calls to the throttled function return the
10910 * result of the last `func` invocation.
10911 *
10912 * **Note:** If `leading` and `trailing` options are `true`, `func` is
10913 * invoked on the trailing edge of the timeout only if the throttled function
10914 * is invoked more than once during the `wait` timeout.
10915 *
10916 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
10917 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
10918 *
10919 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
10920 * for details over the differences between `_.throttle` and `_.debounce`.
10921 *
10922 * @static
10923 * @memberOf _
10924 * @since 0.1.0
10925 * @category Function
10926 * @param {Function} func The function to throttle.
10927 * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
10928 * @param {Object} [options={}] The options object.
10929 * @param {boolean} [options.leading=true]
10930 * Specify invoking on the leading edge of the timeout.
10931 * @param {boolean} [options.trailing=true]
10932 * Specify invoking on the trailing edge of the timeout.
10933 * @returns {Function} Returns the new throttled function.
10934 * @example
10935 *
10936 * // Avoid excessively updating the position while scrolling.
10937 * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
10938 *
10939 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
10940 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
10941 * jQuery(element).on('click', throttled);
10942 *
10943 * // Cancel the trailing throttled invocation.
10944 * jQuery(window).on('popstate', throttled.cancel);
10945 */
10946 function throttle(func, wait, options) {
10947 var leading = true,
10948 trailing = true;
10949
10950 if (typeof func != 'function') {
10951 throw new TypeError(FUNC_ERROR_TEXT);
10952 }
10953 if (isObject(options)) {
10954 leading = 'leading' in options ? !!options.leading : leading;
10955 trailing = 'trailing' in options ? !!options.trailing : trailing;
10956 }
10957 return debounce(func, wait, {
10958 'leading': leading,
10959 'maxWait': wait,
10960 'trailing': trailing
10961 });
10962 }
10963
10964 /**
10965 * Creates a function that accepts up to one argument, ignoring any
10966 * additional arguments.
10967 *
10968 * @static
10969 * @memberOf _
10970 * @since 4.0.0
10971 * @category Function
10972 * @param {Function} func The function to cap arguments for.
10973 * @returns {Function} Returns the new capped function.
10974 * @example
10975 *
10976 * _.map(['6', '8', '10'], _.unary(parseInt));
10977 * // => [6, 8, 10]
10978 */
10979 function unary(func) {
10980 return ary(func, 1);
10981 }
10982
10983 /**
10984 * Creates a function that provides `value` to `wrapper` as its first
10985 * argument. Any additional arguments provided to the function are appended
10986 * to those provided to the `wrapper`. The wrapper is invoked with the `this`
10987 * binding of the created function.
10988 *
10989 * @static
10990 * @memberOf _
10991 * @since 0.1.0
10992 * @category Function
10993 * @param {*} value The value to wrap.
10994 * @param {Function} [wrapper=identity] The wrapper function.
10995 * @returns {Function} Returns the new function.
10996 * @example
10997 *
10998 * var p = _.wrap(_.escape, function(func, text) {
10999 * return '<p>' + func(text) + '</p>';
11000 * });
11001 *
11002 * p('fred, barney, & pebbles');
11003 * // => '<p>fred, barney, &amp; pebbles</p>'
11004 */
11005 function wrap(value, wrapper) {
11006 return partial(castFunction(wrapper), value);
11007 }
11008
11009 /*------------------------------------------------------------------------*/
11010
11011 /**
11012 * Casts `value` as an array if it's not one.
11013 *
11014 * @static
11015 * @memberOf _
11016 * @since 4.4.0
11017 * @category Lang
11018 * @param {*} value The value to inspect.
11019 * @returns {Array} Returns the cast array.
11020 * @example
11021 *
11022 * _.castArray(1);
11023 * // => [1]
11024 *
11025 * _.castArray({ 'a': 1 });
11026 * // => [{ 'a': 1 }]
11027 *
11028 * _.castArray('abc');
11029 * // => ['abc']
11030 *
11031 * _.castArray(null);
11032 * // => [null]
11033 *
11034 * _.castArray(undefined);
11035 * // => [undefined]
11036 *
11037 * _.castArray();
11038 * // => []
11039 *
11040 * var array = [1, 2, 3];
11041 * console.log(_.castArray(array) === array);
11042 * // => true
11043 */
11044 function castArray() {
11045 if (!arguments.length) {
11046 return [];
11047 }
11048 var value = arguments[0];
11049 return isArray(value) ? value : [value];
11050 }
11051
11052 /**
11053 * Creates a shallow clone of `value`.
11054 *
11055 * **Note:** This method is loosely based on the
11056 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
11057 * and supports cloning arrays, array buffers, booleans, date objects, maps,
11058 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
11059 * arrays. The own enumerable properties of `arguments` objects are cloned
11060 * as plain objects. An empty object is returned for uncloneable values such
11061 * as error objects, functions, DOM nodes, and WeakMaps.
11062 *
11063 * @static
11064 * @memberOf _
11065 * @since 0.1.0
11066 * @category Lang
11067 * @param {*} value The value to clone.
11068 * @returns {*} Returns the cloned value.
11069 * @see _.cloneDeep
11070 * @example
11071 *
11072 * var objects = [{ 'a': 1 }, { 'b': 2 }];
11073 *
11074 * var shallow = _.clone(objects);
11075 * console.log(shallow[0] === objects[0]);
11076 * // => true
11077 */
11078 function clone(value) {
11079 return baseClone(value, CLONE_SYMBOLS_FLAG);
11080 }
11081
11082 /**
11083 * This method is like `_.clone` except that it accepts `customizer` which
11084 * is invoked to produce the cloned value. If `customizer` returns `undefined`,
11085 * cloning is handled by the method instead. The `customizer` is invoked with
11086 * up to four arguments; (value [, index|key, object, stack]).
11087 *
11088 * @static
11089 * @memberOf _
11090 * @since 4.0.0
11091 * @category Lang
11092 * @param {*} value The value to clone.
11093 * @param {Function} [customizer] The function to customize cloning.
11094 * @returns {*} Returns the cloned value.
11095 * @see _.cloneDeepWith
11096 * @example
11097 *
11098 * function customizer(value) {
11099 * if (_.isElement(value)) {
11100 * return value.cloneNode(false);
11101 * }
11102 * }
11103 *
11104 * var el = _.cloneWith(document.body, customizer);
11105 *
11106 * console.log(el === document.body);
11107 * // => false
11108 * console.log(el.nodeName);
11109 * // => 'BODY'
11110 * console.log(el.childNodes.length);
11111 * // => 0
11112 */
11113 function cloneWith(value, customizer) {
11114 customizer = typeof customizer == 'function' ? customizer : undefined$1;
11115 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
11116 }
11117
11118 /**
11119 * This method is like `_.clone` except that it recursively clones `value`.
11120 *
11121 * @static
11122 * @memberOf _
11123 * @since 1.0.0
11124 * @category Lang
11125 * @param {*} value The value to recursively clone.
11126 * @returns {*} Returns the deep cloned value.
11127 * @see _.clone
11128 * @example
11129 *
11130 * var objects = [{ 'a': 1 }, { 'b': 2 }];
11131 *
11132 * var deep = _.cloneDeep(objects);
11133 * console.log(deep[0] === objects[0]);
11134 * // => false
11135 */
11136 function cloneDeep(value) {
11137 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
11138 }
11139
11140 /**
11141 * This method is like `_.cloneWith` except that it recursively clones `value`.
11142 *
11143 * @static
11144 * @memberOf _
11145 * @since 4.0.0
11146 * @category Lang
11147 * @param {*} value The value to recursively clone.
11148 * @param {Function} [customizer] The function to customize cloning.
11149 * @returns {*} Returns the deep cloned value.
11150 * @see _.cloneWith
11151 * @example
11152 *
11153 * function customizer(value) {
11154 * if (_.isElement(value)) {
11155 * return value.cloneNode(true);
11156 * }
11157 * }
11158 *
11159 * var el = _.cloneDeepWith(document.body, customizer);
11160 *
11161 * console.log(el === document.body);
11162 * // => false
11163 * console.log(el.nodeName);
11164 * // => 'BODY'
11165 * console.log(el.childNodes.length);
11166 * // => 20
11167 */
11168 function cloneDeepWith(value, customizer) {
11169 customizer = typeof customizer == 'function' ? customizer : undefined$1;
11170 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
11171 }
11172
11173 /**
11174 * Checks if `object` conforms to `source` by invoking the predicate
11175 * properties of `source` with the corresponding property values of `object`.
11176 *
11177 * **Note:** This method is equivalent to `_.conforms` when `source` is
11178 * partially applied.
11179 *
11180 * @static
11181 * @memberOf _
11182 * @since 4.14.0
11183 * @category Lang
11184 * @param {Object} object The object to inspect.
11185 * @param {Object} source The object of property predicates to conform to.
11186 * @returns {boolean} Returns `true` if `object` conforms, else `false`.
11187 * @example
11188 *
11189 * var object = { 'a': 1, 'b': 2 };
11190 *
11191 * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
11192 * // => true
11193 *
11194 * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
11195 * // => false
11196 */
11197 function conformsTo(object, source) {
11198 return source == null || baseConformsTo(object, source, keys(source));
11199 }
11200
11201 /**
11202 * Performs a
11203 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11204 * comparison between two values to determine if they are equivalent.
11205 *
11206 * @static
11207 * @memberOf _
11208 * @since 4.0.0
11209 * @category Lang
11210 * @param {*} value The value to compare.
11211 * @param {*} other The other value to compare.
11212 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11213 * @example
11214 *
11215 * var object = { 'a': 1 };
11216 * var other = { 'a': 1 };
11217 *
11218 * _.eq(object, object);
11219 * // => true
11220 *
11221 * _.eq(object, other);
11222 * // => false
11223 *
11224 * _.eq('a', 'a');
11225 * // => true
11226 *
11227 * _.eq('a', Object('a'));
11228 * // => false
11229 *
11230 * _.eq(NaN, NaN);
11231 * // => true
11232 */
11233 function eq(value, other) {
11234 return value === other || (value !== value && other !== other);
11235 }
11236
11237 /**
11238 * Checks if `value` is greater than `other`.
11239 *
11240 * @static
11241 * @memberOf _
11242 * @since 3.9.0
11243 * @category Lang
11244 * @param {*} value The value to compare.
11245 * @param {*} other The other value to compare.
11246 * @returns {boolean} Returns `true` if `value` is greater than `other`,
11247 * else `false`.
11248 * @see _.lt
11249 * @example
11250 *
11251 * _.gt(3, 1);
11252 * // => true
11253 *
11254 * _.gt(3, 3);
11255 * // => false
11256 *
11257 * _.gt(1, 3);
11258 * // => false
11259 */
11260 var gt = createRelationalOperation(baseGt);
11261
11262 /**
11263 * Checks if `value` is greater than or equal to `other`.
11264 *
11265 * @static
11266 * @memberOf _
11267 * @since 3.9.0
11268 * @category Lang
11269 * @param {*} value The value to compare.
11270 * @param {*} other The other value to compare.
11271 * @returns {boolean} Returns `true` if `value` is greater than or equal to
11272 * `other`, else `false`.
11273 * @see _.lte
11274 * @example
11275 *
11276 * _.gte(3, 1);
11277 * // => true
11278 *
11279 * _.gte(3, 3);
11280 * // => true
11281 *
11282 * _.gte(1, 3);
11283 * // => false
11284 */
11285 var gte = createRelationalOperation(function(value, other) {
11286 return value >= other;
11287 });
11288
11289 /**
11290 * Checks if `value` is likely an `arguments` object.
11291 *
11292 * @static
11293 * @memberOf _
11294 * @since 0.1.0
11295 * @category Lang
11296 * @param {*} value The value to check.
11297 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11298 * else `false`.
11299 * @example
11300 *
11301 * _.isArguments(function() { return arguments; }());
11302 * // => true
11303 *
11304 * _.isArguments([1, 2, 3]);
11305 * // => false
11306 */
11307 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
11308 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
11309 !propertyIsEnumerable.call(value, 'callee');
11310 };
11311
11312 /**
11313 * Checks if `value` is classified as an `Array` object.
11314 *
11315 * @static
11316 * @memberOf _
11317 * @since 0.1.0
11318 * @category Lang
11319 * @param {*} value The value to check.
11320 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11321 * @example
11322 *
11323 * _.isArray([1, 2, 3]);
11324 * // => true
11325 *
11326 * _.isArray(document.body.children);
11327 * // => false
11328 *
11329 * _.isArray('abc');
11330 * // => false
11331 *
11332 * _.isArray(_.noop);
11333 * // => false
11334 */
11335 var isArray = Array.isArray;
11336
11337 /**
11338 * Checks if `value` is classified as an `ArrayBuffer` object.
11339 *
11340 * @static
11341 * @memberOf _
11342 * @since 4.3.0
11343 * @category Lang
11344 * @param {*} value The value to check.
11345 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
11346 * @example
11347 *
11348 * _.isArrayBuffer(new ArrayBuffer(2));
11349 * // => true
11350 *
11351 * _.isArrayBuffer(new Array(2));
11352 * // => false
11353 */
11354 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
11355
11356 /**
11357 * Checks if `value` is array-like. A value is considered array-like if it's
11358 * not a function and has a `value.length` that's an integer greater than or
11359 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
11360 *
11361 * @static
11362 * @memberOf _
11363 * @since 4.0.0
11364 * @category Lang
11365 * @param {*} value The value to check.
11366 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11367 * @example
11368 *
11369 * _.isArrayLike([1, 2, 3]);
11370 * // => true
11371 *
11372 * _.isArrayLike(document.body.children);
11373 * // => true
11374 *
11375 * _.isArrayLike('abc');
11376 * // => true
11377 *
11378 * _.isArrayLike(_.noop);
11379 * // => false
11380 */
11381 function isArrayLike(value) {
11382 return value != null && isLength(value.length) && !isFunction(value);
11383 }
11384
11385 /**
11386 * This method is like `_.isArrayLike` except that it also checks if `value`
11387 * is an object.
11388 *
11389 * @static
11390 * @memberOf _
11391 * @since 4.0.0
11392 * @category Lang
11393 * @param {*} value The value to check.
11394 * @returns {boolean} Returns `true` if `value` is an array-like object,
11395 * else `false`.
11396 * @example
11397 *
11398 * _.isArrayLikeObject([1, 2, 3]);
11399 * // => true
11400 *
11401 * _.isArrayLikeObject(document.body.children);
11402 * // => true
11403 *
11404 * _.isArrayLikeObject('abc');
11405 * // => false
11406 *
11407 * _.isArrayLikeObject(_.noop);
11408 * // => false
11409 */
11410 function isArrayLikeObject(value) {
11411 return isObjectLike(value) && isArrayLike(value);
11412 }
11413
11414 /**
11415 * Checks if `value` is classified as a boolean primitive or object.
11416 *
11417 * @static
11418 * @memberOf _
11419 * @since 0.1.0
11420 * @category Lang
11421 * @param {*} value The value to check.
11422 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
11423 * @example
11424 *
11425 * _.isBoolean(false);
11426 * // => true
11427 *
11428 * _.isBoolean(null);
11429 * // => false
11430 */
11431 function isBoolean(value) {
11432 return value === true || value === false ||
11433 (isObjectLike(value) && baseGetTag(value) == boolTag);
11434 }
11435
11436 /**
11437 * Checks if `value` is a buffer.
11438 *
11439 * @static
11440 * @memberOf _
11441 * @since 4.3.0
11442 * @category Lang
11443 * @param {*} value The value to check.
11444 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
11445 * @example
11446 *
11447 * _.isBuffer(new Buffer(2));
11448 * // => true
11449 *
11450 * _.isBuffer(new Uint8Array(2));
11451 * // => false
11452 */
11453 var isBuffer = nativeIsBuffer || stubFalse;
11454
11455 /**
11456 * Checks if `value` is classified as a `Date` object.
11457 *
11458 * @static
11459 * @memberOf _
11460 * @since 0.1.0
11461 * @category Lang
11462 * @param {*} value The value to check.
11463 * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
11464 * @example
11465 *
11466 * _.isDate(new Date);
11467 * // => true
11468 *
11469 * _.isDate('Mon April 23 2012');
11470 * // => false
11471 */
11472 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
11473
11474 /**
11475 * Checks if `value` is likely a DOM element.
11476 *
11477 * @static
11478 * @memberOf _
11479 * @since 0.1.0
11480 * @category Lang
11481 * @param {*} value The value to check.
11482 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
11483 * @example
11484 *
11485 * _.isElement(document.body);
11486 * // => true
11487 *
11488 * _.isElement('<body>');
11489 * // => false
11490 */
11491 function isElement(value) {
11492 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
11493 }
11494
11495 /**
11496 * Checks if `value` is an empty object, collection, map, or set.
11497 *
11498 * Objects are considered empty if they have no own enumerable string keyed
11499 * properties.
11500 *
11501 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
11502 * jQuery-like collections are considered empty if they have a `length` of `0`.
11503 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
11504 *
11505 * @static
11506 * @memberOf _
11507 * @since 0.1.0
11508 * @category Lang
11509 * @param {*} value The value to check.
11510 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
11511 * @example
11512 *
11513 * _.isEmpty(null);
11514 * // => true
11515 *
11516 * _.isEmpty(true);
11517 * // => true
11518 *
11519 * _.isEmpty(1);
11520 * // => true
11521 *
11522 * _.isEmpty([1, 2, 3]);
11523 * // => false
11524 *
11525 * _.isEmpty({ 'a': 1 });
11526 * // => false
11527 */
11528 function isEmpty(value) {
11529 if (value == null) {
11530 return true;
11531 }
11532 if (isArrayLike(value) &&
11533 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
11534 isBuffer(value) || isTypedArray(value) || isArguments(value))) {
11535 return !value.length;
11536 }
11537 var tag = getTag(value);
11538 if (tag == mapTag || tag == setTag) {
11539 return !value.size;
11540 }
11541 if (isPrototype(value)) {
11542 return !baseKeys(value).length;
11543 }
11544 for (var key in value) {
11545 if (hasOwnProperty.call(value, key)) {
11546 return false;
11547 }
11548 }
11549 return true;
11550 }
11551
11552 /**
11553 * Performs a deep comparison between two values to determine if they are
11554 * equivalent.
11555 *
11556 * **Note:** This method supports comparing arrays, array buffers, booleans,
11557 * date objects, error objects, maps, numbers, `Object` objects, regexes,
11558 * sets, strings, symbols, and typed arrays. `Object` objects are compared
11559 * by their own, not inherited, enumerable properties. Functions and DOM
11560 * nodes are compared by strict equality, i.e. `===`.
11561 *
11562 * @static
11563 * @memberOf _
11564 * @since 0.1.0
11565 * @category Lang
11566 * @param {*} value The value to compare.
11567 * @param {*} other The other value to compare.
11568 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11569 * @example
11570 *
11571 * var object = { 'a': 1 };
11572 * var other = { 'a': 1 };
11573 *
11574 * _.isEqual(object, other);
11575 * // => true
11576 *
11577 * object === other;
11578 * // => false
11579 */
11580 function isEqual(value, other) {
11581 return baseIsEqual(value, other);
11582 }
11583
11584 /**
11585 * This method is like `_.isEqual` except that it accepts `customizer` which
11586 * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11587 * are handled by the method instead. The `customizer` is invoked with up to
11588 * six arguments: (objValue, othValue [, index|key, object, other, stack]).
11589 *
11590 * @static
11591 * @memberOf _
11592 * @since 4.0.0
11593 * @category Lang
11594 * @param {*} value The value to compare.
11595 * @param {*} other The other value to compare.
11596 * @param {Function} [customizer] The function to customize comparisons.
11597 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11598 * @example
11599 *
11600 * function isGreeting(value) {
11601 * return /^h(?:i|ello)$/.test(value);
11602 * }
11603 *
11604 * function customizer(objValue, othValue) {
11605 * if (isGreeting(objValue) && isGreeting(othValue)) {
11606 * return true;
11607 * }
11608 * }
11609 *
11610 * var array = ['hello', 'goodbye'];
11611 * var other = ['hi', 'goodbye'];
11612 *
11613 * _.isEqualWith(array, other, customizer);
11614 * // => true
11615 */
11616 function isEqualWith(value, other, customizer) {
11617 customizer = typeof customizer == 'function' ? customizer : undefined$1;
11618 var result = customizer ? customizer(value, other) : undefined$1;
11619 return result === undefined$1 ? baseIsEqual(value, other, undefined$1, customizer) : !!result;
11620 }
11621
11622 /**
11623 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
11624 * `SyntaxError`, `TypeError`, or `URIError` object.
11625 *
11626 * @static
11627 * @memberOf _
11628 * @since 3.0.0
11629 * @category Lang
11630 * @param {*} value The value to check.
11631 * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
11632 * @example
11633 *
11634 * _.isError(new Error);
11635 * // => true
11636 *
11637 * _.isError(Error);
11638 * // => false
11639 */
11640 function isError(value) {
11641 if (!isObjectLike(value)) {
11642 return false;
11643 }
11644 var tag = baseGetTag(value);
11645 return tag == errorTag || tag == domExcTag ||
11646 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
11647 }
11648
11649 /**
11650 * Checks if `value` is a finite primitive number.
11651 *
11652 * **Note:** This method is based on
11653 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
11654 *
11655 * @static
11656 * @memberOf _
11657 * @since 0.1.0
11658 * @category Lang
11659 * @param {*} value The value to check.
11660 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
11661 * @example
11662 *
11663 * _.isFinite(3);
11664 * // => true
11665 *
11666 * _.isFinite(Number.MIN_VALUE);
11667 * // => true
11668 *
11669 * _.isFinite(Infinity);
11670 * // => false
11671 *
11672 * _.isFinite('3');
11673 * // => false
11674 */
11675 function isFinite(value) {
11676 return typeof value == 'number' && nativeIsFinite(value);
11677 }
11678
11679 /**
11680 * Checks if `value` is classified as a `Function` object.
11681 *
11682 * @static
11683 * @memberOf _
11684 * @since 0.1.0
11685 * @category Lang
11686 * @param {*} value The value to check.
11687 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11688 * @example
11689 *
11690 * _.isFunction(_);
11691 * // => true
11692 *
11693 * _.isFunction(/abc/);
11694 * // => false
11695 */
11696 function isFunction(value) {
11697 if (!isObject(value)) {
11698 return false;
11699 }
11700 // The use of `Object#toString` avoids issues with the `typeof` operator
11701 // in Safari 9 which returns 'object' for typed arrays and other constructors.
11702 var tag = baseGetTag(value);
11703 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11704 }
11705
11706 /**
11707 * Checks if `value` is an integer.
11708 *
11709 * **Note:** This method is based on
11710 * [`Number.isInteger`](https://mdn.io/Number/isInteger).
11711 *
11712 * @static
11713 * @memberOf _
11714 * @since 4.0.0
11715 * @category Lang
11716 * @param {*} value The value to check.
11717 * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
11718 * @example
11719 *
11720 * _.isInteger(3);
11721 * // => true
11722 *
11723 * _.isInteger(Number.MIN_VALUE);
11724 * // => false
11725 *
11726 * _.isInteger(Infinity);
11727 * // => false
11728 *
11729 * _.isInteger('3');
11730 * // => false
11731 */
11732 function isInteger(value) {
11733 return typeof value == 'number' && value == toInteger(value);
11734 }
11735
11736 /**
11737 * Checks if `value` is a valid array-like length.
11738 *
11739 * **Note:** This method is loosely based on
11740 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
11741 *
11742 * @static
11743 * @memberOf _
11744 * @since 4.0.0
11745 * @category Lang
11746 * @param {*} value The value to check.
11747 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
11748 * @example
11749 *
11750 * _.isLength(3);
11751 * // => true
11752 *
11753 * _.isLength(Number.MIN_VALUE);
11754 * // => false
11755 *
11756 * _.isLength(Infinity);
11757 * // => false
11758 *
11759 * _.isLength('3');
11760 * // => false
11761 */
11762 function isLength(value) {
11763 return typeof value == 'number' &&
11764 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
11765 }
11766
11767 /**
11768 * Checks if `value` is the
11769 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11770 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11771 *
11772 * @static
11773 * @memberOf _
11774 * @since 0.1.0
11775 * @category Lang
11776 * @param {*} value The value to check.
11777 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11778 * @example
11779 *
11780 * _.isObject({});
11781 * // => true
11782 *
11783 * _.isObject([1, 2, 3]);
11784 * // => true
11785 *
11786 * _.isObject(_.noop);
11787 * // => true
11788 *
11789 * _.isObject(null);
11790 * // => false
11791 */
11792 function isObject(value) {
11793 var type = typeof value;
11794 return value != null && (type == 'object' || type == 'function');
11795 }
11796
11797 /**
11798 * Checks if `value` is object-like. A value is object-like if it's not `null`
11799 * and has a `typeof` result of "object".
11800 *
11801 * @static
11802 * @memberOf _
11803 * @since 4.0.0
11804 * @category Lang
11805 * @param {*} value The value to check.
11806 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11807 * @example
11808 *
11809 * _.isObjectLike({});
11810 * // => true
11811 *
11812 * _.isObjectLike([1, 2, 3]);
11813 * // => true
11814 *
11815 * _.isObjectLike(_.noop);
11816 * // => false
11817 *
11818 * _.isObjectLike(null);
11819 * // => false
11820 */
11821 function isObjectLike(value) {
11822 return value != null && typeof value == 'object';
11823 }
11824
11825 /**
11826 * Checks if `value` is classified as a `Map` object.
11827 *
11828 * @static
11829 * @memberOf _
11830 * @since 4.3.0
11831 * @category Lang
11832 * @param {*} value The value to check.
11833 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
11834 * @example
11835 *
11836 * _.isMap(new Map);
11837 * // => true
11838 *
11839 * _.isMap(new WeakMap);
11840 * // => false
11841 */
11842 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
11843
11844 /**
11845 * Performs a partial deep comparison between `object` and `source` to
11846 * determine if `object` contains equivalent property values.
11847 *
11848 * **Note:** This method is equivalent to `_.matches` when `source` is
11849 * partially applied.
11850 *
11851 * Partial comparisons will match empty array and empty object `source`
11852 * values against any array or object value, respectively. See `_.isEqual`
11853 * for a list of supported value comparisons.
11854 *
11855 * @static
11856 * @memberOf _
11857 * @since 3.0.0
11858 * @category Lang
11859 * @param {Object} object The object to inspect.
11860 * @param {Object} source The object of property values to match.
11861 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11862 * @example
11863 *
11864 * var object = { 'a': 1, 'b': 2 };
11865 *
11866 * _.isMatch(object, { 'b': 2 });
11867 * // => true
11868 *
11869 * _.isMatch(object, { 'b': 1 });
11870 * // => false
11871 */
11872 function isMatch(object, source) {
11873 return object === source || baseIsMatch(object, source, getMatchData(source));
11874 }
11875
11876 /**
11877 * This method is like `_.isMatch` except that it accepts `customizer` which
11878 * is invoked to compare values. If `customizer` returns `undefined`, comparisons
11879 * are handled by the method instead. The `customizer` is invoked with five
11880 * arguments: (objValue, srcValue, index|key, object, source).
11881 *
11882 * @static
11883 * @memberOf _
11884 * @since 4.0.0
11885 * @category Lang
11886 * @param {Object} object The object to inspect.
11887 * @param {Object} source The object of property values to match.
11888 * @param {Function} [customizer] The function to customize comparisons.
11889 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
11890 * @example
11891 *
11892 * function isGreeting(value) {
11893 * return /^h(?:i|ello)$/.test(value);
11894 * }
11895 *
11896 * function customizer(objValue, srcValue) {
11897 * if (isGreeting(objValue) && isGreeting(srcValue)) {
11898 * return true;
11899 * }
11900 * }
11901 *
11902 * var object = { 'greeting': 'hello' };
11903 * var source = { 'greeting': 'hi' };
11904 *
11905 * _.isMatchWith(object, source, customizer);
11906 * // => true
11907 */
11908 function isMatchWith(object, source, customizer) {
11909 customizer = typeof customizer == 'function' ? customizer : undefined$1;
11910 return baseIsMatch(object, source, getMatchData(source), customizer);
11911 }
11912
11913 /**
11914 * Checks if `value` is `NaN`.
11915 *
11916 * **Note:** This method is based on
11917 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
11918 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
11919 * `undefined` and other non-number values.
11920 *
11921 * @static
11922 * @memberOf _
11923 * @since 0.1.0
11924 * @category Lang
11925 * @param {*} value The value to check.
11926 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
11927 * @example
11928 *
11929 * _.isNaN(NaN);
11930 * // => true
11931 *
11932 * _.isNaN(new Number(NaN));
11933 * // => true
11934 *
11935 * isNaN(undefined);
11936 * // => true
11937 *
11938 * _.isNaN(undefined);
11939 * // => false
11940 */
11941 function isNaN(value) {
11942 // An `NaN` primitive is the only value that is not equal to itself.
11943 // Perform the `toStringTag` check first to avoid errors with some
11944 // ActiveX objects in IE.
11945 return isNumber(value) && value != +value;
11946 }
11947
11948 /**
11949 * Checks if `value` is a pristine native function.
11950 *
11951 * **Note:** This method can't reliably detect native functions in the presence
11952 * of the core-js package because core-js circumvents this kind of detection.
11953 * Despite multiple requests, the core-js maintainer has made it clear: any
11954 * attempt to fix the detection will be obstructed. As a result, we're left
11955 * with little choice but to throw an error. Unfortunately, this also affects
11956 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
11957 * which rely on core-js.
11958 *
11959 * @static
11960 * @memberOf _
11961 * @since 3.0.0
11962 * @category Lang
11963 * @param {*} value The value to check.
11964 * @returns {boolean} Returns `true` if `value` is a native function,
11965 * else `false`.
11966 * @example
11967 *
11968 * _.isNative(Array.prototype.push);
11969 * // => true
11970 *
11971 * _.isNative(_);
11972 * // => false
11973 */
11974 function isNative(value) {
11975 if (isMaskable(value)) {
11976 throw new Error(CORE_ERROR_TEXT);
11977 }
11978 return baseIsNative(value);
11979 }
11980
11981 /**
11982 * Checks if `value` is `null`.
11983 *
11984 * @static
11985 * @memberOf _
11986 * @since 0.1.0
11987 * @category Lang
11988 * @param {*} value The value to check.
11989 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
11990 * @example
11991 *
11992 * _.isNull(null);
11993 * // => true
11994 *
11995 * _.isNull(void 0);
11996 * // => false
11997 */
11998 function isNull(value) {
11999 return value === null;
12000 }
12001
12002 /**
12003 * Checks if `value` is `null` or `undefined`.
12004 *
12005 * @static
12006 * @memberOf _
12007 * @since 4.0.0
12008 * @category Lang
12009 * @param {*} value The value to check.
12010 * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
12011 * @example
12012 *
12013 * _.isNil(null);
12014 * // => true
12015 *
12016 * _.isNil(void 0);
12017 * // => true
12018 *
12019 * _.isNil(NaN);
12020 * // => false
12021 */
12022 function isNil(value) {
12023 return value == null;
12024 }
12025
12026 /**
12027 * Checks if `value` is classified as a `Number` primitive or object.
12028 *
12029 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
12030 * classified as numbers, use the `_.isFinite` method.
12031 *
12032 * @static
12033 * @memberOf _
12034 * @since 0.1.0
12035 * @category Lang
12036 * @param {*} value The value to check.
12037 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
12038 * @example
12039 *
12040 * _.isNumber(3);
12041 * // => true
12042 *
12043 * _.isNumber(Number.MIN_VALUE);
12044 * // => true
12045 *
12046 * _.isNumber(Infinity);
12047 * // => true
12048 *
12049 * _.isNumber('3');
12050 * // => false
12051 */
12052 function isNumber(value) {
12053 return typeof value == 'number' ||
12054 (isObjectLike(value) && baseGetTag(value) == numberTag);
12055 }
12056
12057 /**
12058 * Checks if `value` is a plain object, that is, an object created by the
12059 * `Object` constructor or one with a `[[Prototype]]` of `null`.
12060 *
12061 * @static
12062 * @memberOf _
12063 * @since 0.8.0
12064 * @category Lang
12065 * @param {*} value The value to check.
12066 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
12067 * @example
12068 *
12069 * function Foo() {
12070 * this.a = 1;
12071 * }
12072 *
12073 * _.isPlainObject(new Foo);
12074 * // => false
12075 *
12076 * _.isPlainObject([1, 2, 3]);
12077 * // => false
12078 *
12079 * _.isPlainObject({ 'x': 0, 'y': 0 });
12080 * // => true
12081 *
12082 * _.isPlainObject(Object.create(null));
12083 * // => true
12084 */
12085 function isPlainObject(value) {
12086 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
12087 return false;
12088 }
12089 var proto = getPrototype(value);
12090 if (proto === null) {
12091 return true;
12092 }
12093 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
12094 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
12095 funcToString.call(Ctor) == objectCtorString;
12096 }
12097
12098 /**
12099 * Checks if `value` is classified as a `RegExp` object.
12100 *
12101 * @static
12102 * @memberOf _
12103 * @since 0.1.0
12104 * @category Lang
12105 * @param {*} value The value to check.
12106 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
12107 * @example
12108 *
12109 * _.isRegExp(/abc/);
12110 * // => true
12111 *
12112 * _.isRegExp('/abc/');
12113 * // => false
12114 */
12115 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
12116
12117 /**
12118 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
12119 * double precision number which isn't the result of a rounded unsafe integer.
12120 *
12121 * **Note:** This method is based on
12122 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
12123 *
12124 * @static
12125 * @memberOf _
12126 * @since 4.0.0
12127 * @category Lang
12128 * @param {*} value The value to check.
12129 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
12130 * @example
12131 *
12132 * _.isSafeInteger(3);
12133 * // => true
12134 *
12135 * _.isSafeInteger(Number.MIN_VALUE);
12136 * // => false
12137 *
12138 * _.isSafeInteger(Infinity);
12139 * // => false
12140 *
12141 * _.isSafeInteger('3');
12142 * // => false
12143 */
12144 function isSafeInteger(value) {
12145 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
12146 }
12147
12148 /**
12149 * Checks if `value` is classified as a `Set` object.
12150 *
12151 * @static
12152 * @memberOf _
12153 * @since 4.3.0
12154 * @category Lang
12155 * @param {*} value The value to check.
12156 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
12157 * @example
12158 *
12159 * _.isSet(new Set);
12160 * // => true
12161 *
12162 * _.isSet(new WeakSet);
12163 * // => false
12164 */
12165 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
12166
12167 /**
12168 * Checks if `value` is classified as a `String` primitive or object.
12169 *
12170 * @static
12171 * @since 0.1.0
12172 * @memberOf _
12173 * @category Lang
12174 * @param {*} value The value to check.
12175 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
12176 * @example
12177 *
12178 * _.isString('abc');
12179 * // => true
12180 *
12181 * _.isString(1);
12182 * // => false
12183 */
12184 function isString(value) {
12185 return typeof value == 'string' ||
12186 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
12187 }
12188
12189 /**
12190 * Checks if `value` is classified as a `Symbol` primitive or object.
12191 *
12192 * @static
12193 * @memberOf _
12194 * @since 4.0.0
12195 * @category Lang
12196 * @param {*} value The value to check.
12197 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
12198 * @example
12199 *
12200 * _.isSymbol(Symbol.iterator);
12201 * // => true
12202 *
12203 * _.isSymbol('abc');
12204 * // => false
12205 */
12206 function isSymbol(value) {
12207 return typeof value == 'symbol' ||
12208 (isObjectLike(value) && baseGetTag(value) == symbolTag);
12209 }
12210
12211 /**
12212 * Checks if `value` is classified as a typed array.
12213 *
12214 * @static
12215 * @memberOf _
12216 * @since 3.0.0
12217 * @category Lang
12218 * @param {*} value The value to check.
12219 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12220 * @example
12221 *
12222 * _.isTypedArray(new Uint8Array);
12223 * // => true
12224 *
12225 * _.isTypedArray([]);
12226 * // => false
12227 */
12228 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12229
12230 /**
12231 * Checks if `value` is `undefined`.
12232 *
12233 * @static
12234 * @since 0.1.0
12235 * @memberOf _
12236 * @category Lang
12237 * @param {*} value The value to check.
12238 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
12239 * @example
12240 *
12241 * _.isUndefined(void 0);
12242 * // => true
12243 *
12244 * _.isUndefined(null);
12245 * // => false
12246 */
12247 function isUndefined(value) {
12248 return value === undefined$1;
12249 }
12250
12251 /**
12252 * Checks if `value` is classified as a `WeakMap` object.
12253 *
12254 * @static
12255 * @memberOf _
12256 * @since 4.3.0
12257 * @category Lang
12258 * @param {*} value The value to check.
12259 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
12260 * @example
12261 *
12262 * _.isWeakMap(new WeakMap);
12263 * // => true
12264 *
12265 * _.isWeakMap(new Map);
12266 * // => false
12267 */
12268 function isWeakMap(value) {
12269 return isObjectLike(value) && getTag(value) == weakMapTag;
12270 }
12271
12272 /**
12273 * Checks if `value` is classified as a `WeakSet` object.
12274 *
12275 * @static
12276 * @memberOf _
12277 * @since 4.3.0
12278 * @category Lang
12279 * @param {*} value The value to check.
12280 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
12281 * @example
12282 *
12283 * _.isWeakSet(new WeakSet);
12284 * // => true
12285 *
12286 * _.isWeakSet(new Set);
12287 * // => false
12288 */
12289 function isWeakSet(value) {
12290 return isObjectLike(value) && baseGetTag(value) == weakSetTag;
12291 }
12292
12293 /**
12294 * Checks if `value` is less than `other`.
12295 *
12296 * @static
12297 * @memberOf _
12298 * @since 3.9.0
12299 * @category Lang
12300 * @param {*} value The value to compare.
12301 * @param {*} other The other value to compare.
12302 * @returns {boolean} Returns `true` if `value` is less than `other`,
12303 * else `false`.
12304 * @see _.gt
12305 * @example
12306 *
12307 * _.lt(1, 3);
12308 * // => true
12309 *
12310 * _.lt(3, 3);
12311 * // => false
12312 *
12313 * _.lt(3, 1);
12314 * // => false
12315 */
12316 var lt = createRelationalOperation(baseLt);
12317
12318 /**
12319 * Checks if `value` is less than or equal to `other`.
12320 *
12321 * @static
12322 * @memberOf _
12323 * @since 3.9.0
12324 * @category Lang
12325 * @param {*} value The value to compare.
12326 * @param {*} other The other value to compare.
12327 * @returns {boolean} Returns `true` if `value` is less than or equal to
12328 * `other`, else `false`.
12329 * @see _.gte
12330 * @example
12331 *
12332 * _.lte(1, 3);
12333 * // => true
12334 *
12335 * _.lte(3, 3);
12336 * // => true
12337 *
12338 * _.lte(3, 1);
12339 * // => false
12340 */
12341 var lte = createRelationalOperation(function(value, other) {
12342 return value <= other;
12343 });
12344
12345 /**
12346 * Converts `value` to an array.
12347 *
12348 * @static
12349 * @since 0.1.0
12350 * @memberOf _
12351 * @category Lang
12352 * @param {*} value The value to convert.
12353 * @returns {Array} Returns the converted array.
12354 * @example
12355 *
12356 * _.toArray({ 'a': 1, 'b': 2 });
12357 * // => [1, 2]
12358 *
12359 * _.toArray('abc');
12360 * // => ['a', 'b', 'c']
12361 *
12362 * _.toArray(1);
12363 * // => []
12364 *
12365 * _.toArray(null);
12366 * // => []
12367 */
12368 function toArray(value) {
12369 if (!value) {
12370 return [];
12371 }
12372 if (isArrayLike(value)) {
12373 return isString(value) ? stringToArray(value) : copyArray(value);
12374 }
12375 if (symIterator && value[symIterator]) {
12376 return iteratorToArray(value[symIterator]());
12377 }
12378 var tag = getTag(value),
12379 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
12380
12381 return func(value);
12382 }
12383
12384 /**
12385 * Converts `value` to a finite number.
12386 *
12387 * @static
12388 * @memberOf _
12389 * @since 4.12.0
12390 * @category Lang
12391 * @param {*} value The value to convert.
12392 * @returns {number} Returns the converted number.
12393 * @example
12394 *
12395 * _.toFinite(3.2);
12396 * // => 3.2
12397 *
12398 * _.toFinite(Number.MIN_VALUE);
12399 * // => 5e-324
12400 *
12401 * _.toFinite(Infinity);
12402 * // => 1.7976931348623157e+308
12403 *
12404 * _.toFinite('3.2');
12405 * // => 3.2
12406 */
12407 function toFinite(value) {
12408 if (!value) {
12409 return value === 0 ? value : 0;
12410 }
12411 value = toNumber(value);
12412 if (value === INFINITY || value === -INFINITY) {
12413 var sign = (value < 0 ? -1 : 1);
12414 return sign * MAX_INTEGER;
12415 }
12416 return value === value ? value : 0;
12417 }
12418
12419 /**
12420 * Converts `value` to an integer.
12421 *
12422 * **Note:** This method is loosely based on
12423 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
12424 *
12425 * @static
12426 * @memberOf _
12427 * @since 4.0.0
12428 * @category Lang
12429 * @param {*} value The value to convert.
12430 * @returns {number} Returns the converted integer.
12431 * @example
12432 *
12433 * _.toInteger(3.2);
12434 * // => 3
12435 *
12436 * _.toInteger(Number.MIN_VALUE);
12437 * // => 0
12438 *
12439 * _.toInteger(Infinity);
12440 * // => 1.7976931348623157e+308
12441 *
12442 * _.toInteger('3.2');
12443 * // => 3
12444 */
12445 function toInteger(value) {
12446 var result = toFinite(value),
12447 remainder = result % 1;
12448
12449 return result === result ? (remainder ? result - remainder : result) : 0;
12450 }
12451
12452 /**
12453 * Converts `value` to an integer suitable for use as the length of an
12454 * array-like object.
12455 *
12456 * **Note:** This method is based on
12457 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12458 *
12459 * @static
12460 * @memberOf _
12461 * @since 4.0.0
12462 * @category Lang
12463 * @param {*} value The value to convert.
12464 * @returns {number} Returns the converted integer.
12465 * @example
12466 *
12467 * _.toLength(3.2);
12468 * // => 3
12469 *
12470 * _.toLength(Number.MIN_VALUE);
12471 * // => 0
12472 *
12473 * _.toLength(Infinity);
12474 * // => 4294967295
12475 *
12476 * _.toLength('3.2');
12477 * // => 3
12478 */
12479 function toLength(value) {
12480 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
12481 }
12482
12483 /**
12484 * Converts `value` to a number.
12485 *
12486 * @static
12487 * @memberOf _
12488 * @since 4.0.0
12489 * @category Lang
12490 * @param {*} value The value to process.
12491 * @returns {number} Returns the number.
12492 * @example
12493 *
12494 * _.toNumber(3.2);
12495 * // => 3.2
12496 *
12497 * _.toNumber(Number.MIN_VALUE);
12498 * // => 5e-324
12499 *
12500 * _.toNumber(Infinity);
12501 * // => Infinity
12502 *
12503 * _.toNumber('3.2');
12504 * // => 3.2
12505 */
12506 function toNumber(value) {
12507 if (typeof value == 'number') {
12508 return value;
12509 }
12510 if (isSymbol(value)) {
12511 return NAN;
12512 }
12513 if (isObject(value)) {
12514 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
12515 value = isObject(other) ? (other + '') : other;
12516 }
12517 if (typeof value != 'string') {
12518 return value === 0 ? value : +value;
12519 }
12520 value = value.replace(reTrim, '');
12521 var isBinary = reIsBinary.test(value);
12522 return (isBinary || reIsOctal.test(value))
12523 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
12524 : (reIsBadHex.test(value) ? NAN : +value);
12525 }
12526
12527 /**
12528 * Converts `value` to a plain object flattening inherited enumerable string
12529 * keyed properties of `value` to own properties of the plain object.
12530 *
12531 * @static
12532 * @memberOf _
12533 * @since 3.0.0
12534 * @category Lang
12535 * @param {*} value The value to convert.
12536 * @returns {Object} Returns the converted plain object.
12537 * @example
12538 *
12539 * function Foo() {
12540 * this.b = 2;
12541 * }
12542 *
12543 * Foo.prototype.c = 3;
12544 *
12545 * _.assign({ 'a': 1 }, new Foo);
12546 * // => { 'a': 1, 'b': 2 }
12547 *
12548 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
12549 * // => { 'a': 1, 'b': 2, 'c': 3 }
12550 */
12551 function toPlainObject(value) {
12552 return copyObject(value, keysIn(value));
12553 }
12554
12555 /**
12556 * Converts `value` to a safe integer. A safe integer can be compared and
12557 * represented correctly.
12558 *
12559 * @static
12560 * @memberOf _
12561 * @since 4.0.0
12562 * @category Lang
12563 * @param {*} value The value to convert.
12564 * @returns {number} Returns the converted integer.
12565 * @example
12566 *
12567 * _.toSafeInteger(3.2);
12568 * // => 3
12569 *
12570 * _.toSafeInteger(Number.MIN_VALUE);
12571 * // => 0
12572 *
12573 * _.toSafeInteger(Infinity);
12574 * // => 9007199254740991
12575 *
12576 * _.toSafeInteger('3.2');
12577 * // => 3
12578 */
12579 function toSafeInteger(value) {
12580 return value
12581 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
12582 : (value === 0 ? value : 0);
12583 }
12584
12585 /**
12586 * Converts `value` to a string. An empty string is returned for `null`
12587 * and `undefined` values. The sign of `-0` is preserved.
12588 *
12589 * @static
12590 * @memberOf _
12591 * @since 4.0.0
12592 * @category Lang
12593 * @param {*} value The value to convert.
12594 * @returns {string} Returns the converted string.
12595 * @example
12596 *
12597 * _.toString(null);
12598 * // => ''
12599 *
12600 * _.toString(-0);
12601 * // => '-0'
12602 *
12603 * _.toString([1, 2, 3]);
12604 * // => '1,2,3'
12605 */
12606 function toString(value) {
12607 return value == null ? '' : baseToString(value);
12608 }
12609
12610 /*------------------------------------------------------------------------*/
12611
12612 /**
12613 * Assigns own enumerable string keyed properties of source objects to the
12614 * destination object. Source objects are applied from left to right.
12615 * Subsequent sources overwrite property assignments of previous sources.
12616 *
12617 * **Note:** This method mutates `object` and is loosely based on
12618 * [`Object.assign`](https://mdn.io/Object/assign).
12619 *
12620 * @static
12621 * @memberOf _
12622 * @since 0.10.0
12623 * @category Object
12624 * @param {Object} object The destination object.
12625 * @param {...Object} [sources] The source objects.
12626 * @returns {Object} Returns `object`.
12627 * @see _.assignIn
12628 * @example
12629 *
12630 * function Foo() {
12631 * this.a = 1;
12632 * }
12633 *
12634 * function Bar() {
12635 * this.c = 3;
12636 * }
12637 *
12638 * Foo.prototype.b = 2;
12639 * Bar.prototype.d = 4;
12640 *
12641 * _.assign({ 'a': 0 }, new Foo, new Bar);
12642 * // => { 'a': 1, 'c': 3 }
12643 */
12644 var assign = createAssigner(function(object, source) {
12645 if (isPrototype(source) || isArrayLike(source)) {
12646 copyObject(source, keys(source), object);
12647 return;
12648 }
12649 for (var key in source) {
12650 if (hasOwnProperty.call(source, key)) {
12651 assignValue(object, key, source[key]);
12652 }
12653 }
12654 });
12655
12656 /**
12657 * This method is like `_.assign` except that it iterates over own and
12658 * inherited source properties.
12659 *
12660 * **Note:** This method mutates `object`.
12661 *
12662 * @static
12663 * @memberOf _
12664 * @since 4.0.0
12665 * @alias extend
12666 * @category Object
12667 * @param {Object} object The destination object.
12668 * @param {...Object} [sources] The source objects.
12669 * @returns {Object} Returns `object`.
12670 * @see _.assign
12671 * @example
12672 *
12673 * function Foo() {
12674 * this.a = 1;
12675 * }
12676 *
12677 * function Bar() {
12678 * this.c = 3;
12679 * }
12680 *
12681 * Foo.prototype.b = 2;
12682 * Bar.prototype.d = 4;
12683 *
12684 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
12685 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
12686 */
12687 var assignIn = createAssigner(function(object, source) {
12688 copyObject(source, keysIn(source), object);
12689 });
12690
12691 /**
12692 * This method is like `_.assignIn` except that it accepts `customizer`
12693 * which is invoked to produce the assigned values. If `customizer` returns
12694 * `undefined`, assignment is handled by the method instead. The `customizer`
12695 * is invoked with five arguments: (objValue, srcValue, key, object, source).
12696 *
12697 * **Note:** This method mutates `object`.
12698 *
12699 * @static
12700 * @memberOf _
12701 * @since 4.0.0
12702 * @alias extendWith
12703 * @category Object
12704 * @param {Object} object The destination object.
12705 * @param {...Object} sources The source objects.
12706 * @param {Function} [customizer] The function to customize assigned values.
12707 * @returns {Object} Returns `object`.
12708 * @see _.assignWith
12709 * @example
12710 *
12711 * function customizer(objValue, srcValue) {
12712 * return _.isUndefined(objValue) ? srcValue : objValue;
12713 * }
12714 *
12715 * var defaults = _.partialRight(_.assignInWith, customizer);
12716 *
12717 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12718 * // => { 'a': 1, 'b': 2 }
12719 */
12720 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
12721 copyObject(source, keysIn(source), object, customizer);
12722 });
12723
12724 /**
12725 * This method is like `_.assign` except that it accepts `customizer`
12726 * which is invoked to produce the assigned values. If `customizer` returns
12727 * `undefined`, assignment is handled by the method instead. The `customizer`
12728 * is invoked with five arguments: (objValue, srcValue, key, object, source).
12729 *
12730 * **Note:** This method mutates `object`.
12731 *
12732 * @static
12733 * @memberOf _
12734 * @since 4.0.0
12735 * @category Object
12736 * @param {Object} object The destination object.
12737 * @param {...Object} sources The source objects.
12738 * @param {Function} [customizer] The function to customize assigned values.
12739 * @returns {Object} Returns `object`.
12740 * @see _.assignInWith
12741 * @example
12742 *
12743 * function customizer(objValue, srcValue) {
12744 * return _.isUndefined(objValue) ? srcValue : objValue;
12745 * }
12746 *
12747 * var defaults = _.partialRight(_.assignWith, customizer);
12748 *
12749 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12750 * // => { 'a': 1, 'b': 2 }
12751 */
12752 var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
12753 copyObject(source, keys(source), object, customizer);
12754 });
12755
12756 /**
12757 * Creates an array of values corresponding to `paths` of `object`.
12758 *
12759 * @static
12760 * @memberOf _
12761 * @since 1.0.0
12762 * @category Object
12763 * @param {Object} object The object to iterate over.
12764 * @param {...(string|string[])} [paths] The property paths to pick.
12765 * @returns {Array} Returns the picked values.
12766 * @example
12767 *
12768 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
12769 *
12770 * _.at(object, ['a[0].b.c', 'a[1]']);
12771 * // => [3, 4]
12772 */
12773 var at = flatRest(baseAt);
12774
12775 /**
12776 * Creates an object that inherits from the `prototype` object. If a
12777 * `properties` object is given, its own enumerable string keyed properties
12778 * are assigned to the created object.
12779 *
12780 * @static
12781 * @memberOf _
12782 * @since 2.3.0
12783 * @category Object
12784 * @param {Object} prototype The object to inherit from.
12785 * @param {Object} [properties] The properties to assign to the object.
12786 * @returns {Object} Returns the new object.
12787 * @example
12788 *
12789 * function Shape() {
12790 * this.x = 0;
12791 * this.y = 0;
12792 * }
12793 *
12794 * function Circle() {
12795 * Shape.call(this);
12796 * }
12797 *
12798 * Circle.prototype = _.create(Shape.prototype, {
12799 * 'constructor': Circle
12800 * });
12801 *
12802 * var circle = new Circle;
12803 * circle instanceof Circle;
12804 * // => true
12805 *
12806 * circle instanceof Shape;
12807 * // => true
12808 */
12809 function create(prototype, properties) {
12810 var result = baseCreate(prototype);
12811 return properties == null ? result : baseAssign(result, properties);
12812 }
12813
12814 /**
12815 * Assigns own and inherited enumerable string keyed properties of source
12816 * objects to the destination object for all destination properties that
12817 * resolve to `undefined`. Source objects are applied from left to right.
12818 * Once a property is set, additional values of the same property are ignored.
12819 *
12820 * **Note:** This method mutates `object`.
12821 *
12822 * @static
12823 * @since 0.1.0
12824 * @memberOf _
12825 * @category Object
12826 * @param {Object} object The destination object.
12827 * @param {...Object} [sources] The source objects.
12828 * @returns {Object} Returns `object`.
12829 * @see _.defaultsDeep
12830 * @example
12831 *
12832 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
12833 * // => { 'a': 1, 'b': 2 }
12834 */
12835 var defaults = baseRest(function(object, sources) {
12836 object = Object(object);
12837
12838 var index = -1;
12839 var length = sources.length;
12840 var guard = length > 2 ? sources[2] : undefined$1;
12841
12842 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
12843 length = 1;
12844 }
12845
12846 while (++index < length) {
12847 var source = sources[index];
12848 var props = keysIn(source);
12849 var propsIndex = -1;
12850 var propsLength = props.length;
12851
12852 while (++propsIndex < propsLength) {
12853 var key = props[propsIndex];
12854 var value = object[key];
12855
12856 if (value === undefined$1 ||
12857 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
12858 object[key] = source[key];
12859 }
12860 }
12861 }
12862
12863 return object;
12864 });
12865
12866 /**
12867 * This method is like `_.defaults` except that it recursively assigns
12868 * default properties.
12869 *
12870 * **Note:** This method mutates `object`.
12871 *
12872 * @static
12873 * @memberOf _
12874 * @since 3.10.0
12875 * @category Object
12876 * @param {Object} object The destination object.
12877 * @param {...Object} [sources] The source objects.
12878 * @returns {Object} Returns `object`.
12879 * @see _.defaults
12880 * @example
12881 *
12882 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
12883 * // => { 'a': { 'b': 2, 'c': 3 } }
12884 */
12885 var defaultsDeep = baseRest(function(args) {
12886 args.push(undefined$1, customDefaultsMerge);
12887 return apply(mergeWith, undefined$1, args);
12888 });
12889
12890 /**
12891 * This method is like `_.find` except that it returns the key of the first
12892 * element `predicate` returns truthy for instead of the element itself.
12893 *
12894 * @static
12895 * @memberOf _
12896 * @since 1.1.0
12897 * @category Object
12898 * @param {Object} object The object to inspect.
12899 * @param {Function} [predicate=_.identity] The function invoked per iteration.
12900 * @returns {string|undefined} Returns the key of the matched element,
12901 * else `undefined`.
12902 * @example
12903 *
12904 * var users = {
12905 * 'barney': { 'age': 36, 'active': true },
12906 * 'fred': { 'age': 40, 'active': false },
12907 * 'pebbles': { 'age': 1, 'active': true }
12908 * };
12909 *
12910 * _.findKey(users, function(o) { return o.age < 40; });
12911 * // => 'barney' (iteration order is not guaranteed)
12912 *
12913 * // The `_.matches` iteratee shorthand.
12914 * _.findKey(users, { 'age': 1, 'active': true });
12915 * // => 'pebbles'
12916 *
12917 * // The `_.matchesProperty` iteratee shorthand.
12918 * _.findKey(users, ['active', false]);
12919 * // => 'fred'
12920 *
12921 * // The `_.property` iteratee shorthand.
12922 * _.findKey(users, 'active');
12923 * // => 'barney'
12924 */
12925 function findKey(object, predicate) {
12926 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
12927 }
12928
12929 /**
12930 * This method is like `_.findKey` except that it iterates over elements of
12931 * a collection in the opposite order.
12932 *
12933 * @static
12934 * @memberOf _
12935 * @since 2.0.0
12936 * @category Object
12937 * @param {Object} object The object to inspect.
12938 * @param {Function} [predicate=_.identity] The function invoked per iteration.
12939 * @returns {string|undefined} Returns the key of the matched element,
12940 * else `undefined`.
12941 * @example
12942 *
12943 * var users = {
12944 * 'barney': { 'age': 36, 'active': true },
12945 * 'fred': { 'age': 40, 'active': false },
12946 * 'pebbles': { 'age': 1, 'active': true }
12947 * };
12948 *
12949 * _.findLastKey(users, function(o) { return o.age < 40; });
12950 * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
12951 *
12952 * // The `_.matches` iteratee shorthand.
12953 * _.findLastKey(users, { 'age': 36, 'active': true });
12954 * // => 'barney'
12955 *
12956 * // The `_.matchesProperty` iteratee shorthand.
12957 * _.findLastKey(users, ['active', false]);
12958 * // => 'fred'
12959 *
12960 * // The `_.property` iteratee shorthand.
12961 * _.findLastKey(users, 'active');
12962 * // => 'pebbles'
12963 */
12964 function findLastKey(object, predicate) {
12965 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
12966 }
12967
12968 /**
12969 * Iterates over own and inherited enumerable string keyed properties of an
12970 * object and invokes `iteratee` for each property. The iteratee is invoked
12971 * with three arguments: (value, key, object). Iteratee functions may exit
12972 * iteration early by explicitly returning `false`.
12973 *
12974 * @static
12975 * @memberOf _
12976 * @since 0.3.0
12977 * @category Object
12978 * @param {Object} object The object to iterate over.
12979 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
12980 * @returns {Object} Returns `object`.
12981 * @see _.forInRight
12982 * @example
12983 *
12984 * function Foo() {
12985 * this.a = 1;
12986 * this.b = 2;
12987 * }
12988 *
12989 * Foo.prototype.c = 3;
12990 *
12991 * _.forIn(new Foo, function(value, key) {
12992 * console.log(key);
12993 * });
12994 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
12995 */
12996 function forIn(object, iteratee) {
12997 return object == null
12998 ? object
12999 : baseFor(object, getIteratee(iteratee, 3), keysIn);
13000 }
13001
13002 /**
13003 * This method is like `_.forIn` except that it iterates over properties of
13004 * `object` in the opposite order.
13005 *
13006 * @static
13007 * @memberOf _
13008 * @since 2.0.0
13009 * @category Object
13010 * @param {Object} object The object to iterate over.
13011 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13012 * @returns {Object} Returns `object`.
13013 * @see _.forIn
13014 * @example
13015 *
13016 * function Foo() {
13017 * this.a = 1;
13018 * this.b = 2;
13019 * }
13020 *
13021 * Foo.prototype.c = 3;
13022 *
13023 * _.forInRight(new Foo, function(value, key) {
13024 * console.log(key);
13025 * });
13026 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
13027 */
13028 function forInRight(object, iteratee) {
13029 return object == null
13030 ? object
13031 : baseForRight(object, getIteratee(iteratee, 3), keysIn);
13032 }
13033
13034 /**
13035 * Iterates over own enumerable string keyed properties of an object and
13036 * invokes `iteratee` for each property. The iteratee is invoked with three
13037 * arguments: (value, key, object). Iteratee functions may exit iteration
13038 * early by explicitly returning `false`.
13039 *
13040 * @static
13041 * @memberOf _
13042 * @since 0.3.0
13043 * @category Object
13044 * @param {Object} object The object to iterate over.
13045 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13046 * @returns {Object} Returns `object`.
13047 * @see _.forOwnRight
13048 * @example
13049 *
13050 * function Foo() {
13051 * this.a = 1;
13052 * this.b = 2;
13053 * }
13054 *
13055 * Foo.prototype.c = 3;
13056 *
13057 * _.forOwn(new Foo, function(value, key) {
13058 * console.log(key);
13059 * });
13060 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
13061 */
13062 function forOwn(object, iteratee) {
13063 return object && baseForOwn(object, getIteratee(iteratee, 3));
13064 }
13065
13066 /**
13067 * This method is like `_.forOwn` except that it iterates over properties of
13068 * `object` in the opposite order.
13069 *
13070 * @static
13071 * @memberOf _
13072 * @since 2.0.0
13073 * @category Object
13074 * @param {Object} object The object to iterate over.
13075 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13076 * @returns {Object} Returns `object`.
13077 * @see _.forOwn
13078 * @example
13079 *
13080 * function Foo() {
13081 * this.a = 1;
13082 * this.b = 2;
13083 * }
13084 *
13085 * Foo.prototype.c = 3;
13086 *
13087 * _.forOwnRight(new Foo, function(value, key) {
13088 * console.log(key);
13089 * });
13090 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
13091 */
13092 function forOwnRight(object, iteratee) {
13093 return object && baseForOwnRight(object, getIteratee(iteratee, 3));
13094 }
13095
13096 /**
13097 * Creates an array of function property names from own enumerable properties
13098 * of `object`.
13099 *
13100 * @static
13101 * @since 0.1.0
13102 * @memberOf _
13103 * @category Object
13104 * @param {Object} object The object to inspect.
13105 * @returns {Array} Returns the function names.
13106 * @see _.functionsIn
13107 * @example
13108 *
13109 * function Foo() {
13110 * this.a = _.constant('a');
13111 * this.b = _.constant('b');
13112 * }
13113 *
13114 * Foo.prototype.c = _.constant('c');
13115 *
13116 * _.functions(new Foo);
13117 * // => ['a', 'b']
13118 */
13119 function functions(object) {
13120 return object == null ? [] : baseFunctions(object, keys(object));
13121 }
13122
13123 /**
13124 * Creates an array of function property names from own and inherited
13125 * enumerable properties of `object`.
13126 *
13127 * @static
13128 * @memberOf _
13129 * @since 4.0.0
13130 * @category Object
13131 * @param {Object} object The object to inspect.
13132 * @returns {Array} Returns the function names.
13133 * @see _.functions
13134 * @example
13135 *
13136 * function Foo() {
13137 * this.a = _.constant('a');
13138 * this.b = _.constant('b');
13139 * }
13140 *
13141 * Foo.prototype.c = _.constant('c');
13142 *
13143 * _.functionsIn(new Foo);
13144 * // => ['a', 'b', 'c']
13145 */
13146 function functionsIn(object) {
13147 return object == null ? [] : baseFunctions(object, keysIn(object));
13148 }
13149
13150 /**
13151 * Gets the value at `path` of `object`. If the resolved value is
13152 * `undefined`, the `defaultValue` is returned in its place.
13153 *
13154 * @static
13155 * @memberOf _
13156 * @since 3.7.0
13157 * @category Object
13158 * @param {Object} object The object to query.
13159 * @param {Array|string} path The path of the property to get.
13160 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13161 * @returns {*} Returns the resolved value.
13162 * @example
13163 *
13164 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13165 *
13166 * _.get(object, 'a[0].b.c');
13167 * // => 3
13168 *
13169 * _.get(object, ['a', '0', 'b', 'c']);
13170 * // => 3
13171 *
13172 * _.get(object, 'a.b.c', 'default');
13173 * // => 'default'
13174 */
13175 function get(object, path, defaultValue) {
13176 var result = object == null ? undefined$1 : baseGet(object, path);
13177 return result === undefined$1 ? defaultValue : result;
13178 }
13179
13180 /**
13181 * Checks if `path` is a direct property of `object`.
13182 *
13183 * @static
13184 * @since 0.1.0
13185 * @memberOf _
13186 * @category Object
13187 * @param {Object} object The object to query.
13188 * @param {Array|string} path The path to check.
13189 * @returns {boolean} Returns `true` if `path` exists, else `false`.
13190 * @example
13191 *
13192 * var object = { 'a': { 'b': 2 } };
13193 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
13194 *
13195 * _.has(object, 'a');
13196 * // => true
13197 *
13198 * _.has(object, 'a.b');
13199 * // => true
13200 *
13201 * _.has(object, ['a', 'b']);
13202 * // => true
13203 *
13204 * _.has(other, 'a');
13205 * // => false
13206 */
13207 function has(object, path) {
13208 return object != null && hasPath(object, path, baseHas);
13209 }
13210
13211 /**
13212 * Checks if `path` is a direct or inherited property of `object`.
13213 *
13214 * @static
13215 * @memberOf _
13216 * @since 4.0.0
13217 * @category Object
13218 * @param {Object} object The object to query.
13219 * @param {Array|string} path The path to check.
13220 * @returns {boolean} Returns `true` if `path` exists, else `false`.
13221 * @example
13222 *
13223 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
13224 *
13225 * _.hasIn(object, 'a');
13226 * // => true
13227 *
13228 * _.hasIn(object, 'a.b');
13229 * // => true
13230 *
13231 * _.hasIn(object, ['a', 'b']);
13232 * // => true
13233 *
13234 * _.hasIn(object, 'b');
13235 * // => false
13236 */
13237 function hasIn(object, path) {
13238 return object != null && hasPath(object, path, baseHasIn);
13239 }
13240
13241 /**
13242 * Creates an object composed of the inverted keys and values of `object`.
13243 * If `object` contains duplicate values, subsequent values overwrite
13244 * property assignments of previous values.
13245 *
13246 * @static
13247 * @memberOf _
13248 * @since 0.7.0
13249 * @category Object
13250 * @param {Object} object The object to invert.
13251 * @returns {Object} Returns the new inverted object.
13252 * @example
13253 *
13254 * var object = { 'a': 1, 'b': 2, 'c': 1 };
13255 *
13256 * _.invert(object);
13257 * // => { '1': 'c', '2': 'b' }
13258 */
13259 var invert = createInverter(function(result, value, key) {
13260 if (value != null &&
13261 typeof value.toString != 'function') {
13262 value = nativeObjectToString.call(value);
13263 }
13264
13265 result[value] = key;
13266 }, constant(identity));
13267
13268 /**
13269 * This method is like `_.invert` except that the inverted object is generated
13270 * from the results of running each element of `object` thru `iteratee`. The
13271 * corresponding inverted value of each inverted key is an array of keys
13272 * responsible for generating the inverted value. The iteratee is invoked
13273 * with one argument: (value).
13274 *
13275 * @static
13276 * @memberOf _
13277 * @since 4.1.0
13278 * @category Object
13279 * @param {Object} object The object to invert.
13280 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
13281 * @returns {Object} Returns the new inverted object.
13282 * @example
13283 *
13284 * var object = { 'a': 1, 'b': 2, 'c': 1 };
13285 *
13286 * _.invertBy(object);
13287 * // => { '1': ['a', 'c'], '2': ['b'] }
13288 *
13289 * _.invertBy(object, function(value) {
13290 * return 'group' + value;
13291 * });
13292 * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
13293 */
13294 var invertBy = createInverter(function(result, value, key) {
13295 if (value != null &&
13296 typeof value.toString != 'function') {
13297 value = nativeObjectToString.call(value);
13298 }
13299
13300 if (hasOwnProperty.call(result, value)) {
13301 result[value].push(key);
13302 } else {
13303 result[value] = [key];
13304 }
13305 }, getIteratee);
13306
13307 /**
13308 * Invokes the method at `path` of `object`.
13309 *
13310 * @static
13311 * @memberOf _
13312 * @since 4.0.0
13313 * @category Object
13314 * @param {Object} object The object to query.
13315 * @param {Array|string} path The path of the method to invoke.
13316 * @param {...*} [args] The arguments to invoke the method with.
13317 * @returns {*} Returns the result of the invoked method.
13318 * @example
13319 *
13320 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
13321 *
13322 * _.invoke(object, 'a[0].b.c.slice', 1, 3);
13323 * // => [2, 3]
13324 */
13325 var invoke = baseRest(baseInvoke);
13326
13327 /**
13328 * Creates an array of the own enumerable property names of `object`.
13329 *
13330 * **Note:** Non-object values are coerced to objects. See the
13331 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
13332 * for more details.
13333 *
13334 * @static
13335 * @since 0.1.0
13336 * @memberOf _
13337 * @category Object
13338 * @param {Object} object The object to query.
13339 * @returns {Array} Returns the array of property names.
13340 * @example
13341 *
13342 * function Foo() {
13343 * this.a = 1;
13344 * this.b = 2;
13345 * }
13346 *
13347 * Foo.prototype.c = 3;
13348 *
13349 * _.keys(new Foo);
13350 * // => ['a', 'b'] (iteration order is not guaranteed)
13351 *
13352 * _.keys('hi');
13353 * // => ['0', '1']
13354 */
13355 function keys(object) {
13356 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
13357 }
13358
13359 /**
13360 * Creates an array of the own and inherited enumerable property names of `object`.
13361 *
13362 * **Note:** Non-object values are coerced to objects.
13363 *
13364 * @static
13365 * @memberOf _
13366 * @since 3.0.0
13367 * @category Object
13368 * @param {Object} object The object to query.
13369 * @returns {Array} Returns the array of property names.
13370 * @example
13371 *
13372 * function Foo() {
13373 * this.a = 1;
13374 * this.b = 2;
13375 * }
13376 *
13377 * Foo.prototype.c = 3;
13378 *
13379 * _.keysIn(new Foo);
13380 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
13381 */
13382 function keysIn(object) {
13383 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
13384 }
13385
13386 /**
13387 * The opposite of `_.mapValues`; this method creates an object with the
13388 * same values as `object` and keys generated by running each own enumerable
13389 * string keyed property of `object` thru `iteratee`. The iteratee is invoked
13390 * with three arguments: (value, key, object).
13391 *
13392 * @static
13393 * @memberOf _
13394 * @since 3.8.0
13395 * @category Object
13396 * @param {Object} object The object to iterate over.
13397 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13398 * @returns {Object} Returns the new mapped object.
13399 * @see _.mapValues
13400 * @example
13401 *
13402 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
13403 * return key + value;
13404 * });
13405 * // => { 'a1': 1, 'b2': 2 }
13406 */
13407 function mapKeys(object, iteratee) {
13408 var result = {};
13409 iteratee = getIteratee(iteratee, 3);
13410
13411 baseForOwn(object, function(value, key, object) {
13412 baseAssignValue(result, iteratee(value, key, object), value);
13413 });
13414 return result;
13415 }
13416
13417 /**
13418 * Creates an object with the same keys as `object` and values generated
13419 * by running each own enumerable string keyed property of `object` thru
13420 * `iteratee`. The iteratee is invoked with three arguments:
13421 * (value, key, object).
13422 *
13423 * @static
13424 * @memberOf _
13425 * @since 2.4.0
13426 * @category Object
13427 * @param {Object} object The object to iterate over.
13428 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13429 * @returns {Object} Returns the new mapped object.
13430 * @see _.mapKeys
13431 * @example
13432 *
13433 * var users = {
13434 * 'fred': { 'user': 'fred', 'age': 40 },
13435 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
13436 * };
13437 *
13438 * _.mapValues(users, function(o) { return o.age; });
13439 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13440 *
13441 * // The `_.property` iteratee shorthand.
13442 * _.mapValues(users, 'age');
13443 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
13444 */
13445 function mapValues(object, iteratee) {
13446 var result = {};
13447 iteratee = getIteratee(iteratee, 3);
13448
13449 baseForOwn(object, function(value, key, object) {
13450 baseAssignValue(result, key, iteratee(value, key, object));
13451 });
13452 return result;
13453 }
13454
13455 /**
13456 * This method is like `_.assign` except that it recursively merges own and
13457 * inherited enumerable string keyed properties of source objects into the
13458 * destination object. Source properties that resolve to `undefined` are
13459 * skipped if a destination value exists. Array and plain object properties
13460 * are merged recursively. Other objects and value types are overridden by
13461 * assignment. Source objects are applied from left to right. Subsequent
13462 * sources overwrite property assignments of previous sources.
13463 *
13464 * **Note:** This method mutates `object`.
13465 *
13466 * @static
13467 * @memberOf _
13468 * @since 0.5.0
13469 * @category Object
13470 * @param {Object} object The destination object.
13471 * @param {...Object} [sources] The source objects.
13472 * @returns {Object} Returns `object`.
13473 * @example
13474 *
13475 * var object = {
13476 * 'a': [{ 'b': 2 }, { 'd': 4 }]
13477 * };
13478 *
13479 * var other = {
13480 * 'a': [{ 'c': 3 }, { 'e': 5 }]
13481 * };
13482 *
13483 * _.merge(object, other);
13484 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
13485 */
13486 var merge = createAssigner(function(object, source, srcIndex) {
13487 baseMerge(object, source, srcIndex);
13488 });
13489
13490 /**
13491 * This method is like `_.merge` except that it accepts `customizer` which
13492 * is invoked to produce the merged values of the destination and source
13493 * properties. If `customizer` returns `undefined`, merging is handled by the
13494 * method instead. The `customizer` is invoked with six arguments:
13495 * (objValue, srcValue, key, object, source, stack).
13496 *
13497 * **Note:** This method mutates `object`.
13498 *
13499 * @static
13500 * @memberOf _
13501 * @since 4.0.0
13502 * @category Object
13503 * @param {Object} object The destination object.
13504 * @param {...Object} sources The source objects.
13505 * @param {Function} customizer The function to customize assigned values.
13506 * @returns {Object} Returns `object`.
13507 * @example
13508 *
13509 * function customizer(objValue, srcValue) {
13510 * if (_.isArray(objValue)) {
13511 * return objValue.concat(srcValue);
13512 * }
13513 * }
13514 *
13515 * var object = { 'a': [1], 'b': [2] };
13516 * var other = { 'a': [3], 'b': [4] };
13517 *
13518 * _.mergeWith(object, other, customizer);
13519 * // => { 'a': [1, 3], 'b': [2, 4] }
13520 */
13521 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
13522 baseMerge(object, source, srcIndex, customizer);
13523 });
13524
13525 /**
13526 * The opposite of `_.pick`; this method creates an object composed of the
13527 * own and inherited enumerable property paths of `object` that are not omitted.
13528 *
13529 * **Note:** This method is considerably slower than `_.pick`.
13530 *
13531 * @static
13532 * @since 0.1.0
13533 * @memberOf _
13534 * @category Object
13535 * @param {Object} object The source object.
13536 * @param {...(string|string[])} [paths] The property paths to omit.
13537 * @returns {Object} Returns the new object.
13538 * @example
13539 *
13540 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13541 *
13542 * _.omit(object, ['a', 'c']);
13543 * // => { 'b': '2' }
13544 */
13545 var omit = flatRest(function(object, paths) {
13546 var result = {};
13547 if (object == null) {
13548 return result;
13549 }
13550 var isDeep = false;
13551 paths = arrayMap(paths, function(path) {
13552 path = castPath(path, object);
13553 isDeep || (isDeep = path.length > 1);
13554 return path;
13555 });
13556 copyObject(object, getAllKeysIn(object), result);
13557 if (isDeep) {
13558 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
13559 }
13560 var length = paths.length;
13561 while (length--) {
13562 baseUnset(result, paths[length]);
13563 }
13564 return result;
13565 });
13566
13567 /**
13568 * The opposite of `_.pickBy`; this method creates an object composed of
13569 * the own and inherited enumerable string keyed properties of `object` that
13570 * `predicate` doesn't return truthy for. The predicate is invoked with two
13571 * arguments: (value, key).
13572 *
13573 * @static
13574 * @memberOf _
13575 * @since 4.0.0
13576 * @category Object
13577 * @param {Object} object The source object.
13578 * @param {Function} [predicate=_.identity] The function invoked per property.
13579 * @returns {Object} Returns the new object.
13580 * @example
13581 *
13582 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13583 *
13584 * _.omitBy(object, _.isNumber);
13585 * // => { 'b': '2' }
13586 */
13587 function omitBy(object, predicate) {
13588 return pickBy(object, negate(getIteratee(predicate)));
13589 }
13590
13591 /**
13592 * Creates an object composed of the picked `object` properties.
13593 *
13594 * @static
13595 * @since 0.1.0
13596 * @memberOf _
13597 * @category Object
13598 * @param {Object} object The source object.
13599 * @param {...(string|string[])} [paths] The property paths to pick.
13600 * @returns {Object} Returns the new object.
13601 * @example
13602 *
13603 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13604 *
13605 * _.pick(object, ['a', 'c']);
13606 * // => { 'a': 1, 'c': 3 }
13607 */
13608 var pick = flatRest(function(object, paths) {
13609 return object == null ? {} : basePick(object, paths);
13610 });
13611
13612 /**
13613 * Creates an object composed of the `object` properties `predicate` returns
13614 * truthy for. The predicate is invoked with two arguments: (value, key).
13615 *
13616 * @static
13617 * @memberOf _
13618 * @since 4.0.0
13619 * @category Object
13620 * @param {Object} object The source object.
13621 * @param {Function} [predicate=_.identity] The function invoked per property.
13622 * @returns {Object} Returns the new object.
13623 * @example
13624 *
13625 * var object = { 'a': 1, 'b': '2', 'c': 3 };
13626 *
13627 * _.pickBy(object, _.isNumber);
13628 * // => { 'a': 1, 'c': 3 }
13629 */
13630 function pickBy(object, predicate) {
13631 if (object == null) {
13632 return {};
13633 }
13634 var props = arrayMap(getAllKeysIn(object), function(prop) {
13635 return [prop];
13636 });
13637 predicate = getIteratee(predicate);
13638 return basePickBy(object, props, function(value, path) {
13639 return predicate(value, path[0]);
13640 });
13641 }
13642
13643 /**
13644 * This method is like `_.get` except that if the resolved value is a
13645 * function it's invoked with the `this` binding of its parent object and
13646 * its result is returned.
13647 *
13648 * @static
13649 * @since 0.1.0
13650 * @memberOf _
13651 * @category Object
13652 * @param {Object} object The object to query.
13653 * @param {Array|string} path The path of the property to resolve.
13654 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
13655 * @returns {*} Returns the resolved value.
13656 * @example
13657 *
13658 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
13659 *
13660 * _.result(object, 'a[0].b.c1');
13661 * // => 3
13662 *
13663 * _.result(object, 'a[0].b.c2');
13664 * // => 4
13665 *
13666 * _.result(object, 'a[0].b.c3', 'default');
13667 * // => 'default'
13668 *
13669 * _.result(object, 'a[0].b.c3', _.constant('default'));
13670 * // => 'default'
13671 */
13672 function result(object, path, defaultValue) {
13673 path = castPath(path, object);
13674
13675 var index = -1,
13676 length = path.length;
13677
13678 // Ensure the loop is entered when path is empty.
13679 if (!length) {
13680 length = 1;
13681 object = undefined$1;
13682 }
13683 while (++index < length) {
13684 var value = object == null ? undefined$1 : object[toKey(path[index])];
13685 if (value === undefined$1) {
13686 index = length;
13687 value = defaultValue;
13688 }
13689 object = isFunction(value) ? value.call(object) : value;
13690 }
13691 return object;
13692 }
13693
13694 /**
13695 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
13696 * it's created. Arrays are created for missing index properties while objects
13697 * are created for all other missing properties. Use `_.setWith` to customize
13698 * `path` creation.
13699 *
13700 * **Note:** This method mutates `object`.
13701 *
13702 * @static
13703 * @memberOf _
13704 * @since 3.7.0
13705 * @category Object
13706 * @param {Object} object The object to modify.
13707 * @param {Array|string} path The path of the property to set.
13708 * @param {*} value The value to set.
13709 * @returns {Object} Returns `object`.
13710 * @example
13711 *
13712 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13713 *
13714 * _.set(object, 'a[0].b.c', 4);
13715 * console.log(object.a[0].b.c);
13716 * // => 4
13717 *
13718 * _.set(object, ['x', '0', 'y', 'z'], 5);
13719 * console.log(object.x[0].y.z);
13720 * // => 5
13721 */
13722 function set(object, path, value) {
13723 return object == null ? object : baseSet(object, path, value);
13724 }
13725
13726 /**
13727 * This method is like `_.set` except that it accepts `customizer` which is
13728 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
13729 * path creation is handled by the method instead. The `customizer` is invoked
13730 * with three arguments: (nsValue, key, nsObject).
13731 *
13732 * **Note:** This method mutates `object`.
13733 *
13734 * @static
13735 * @memberOf _
13736 * @since 4.0.0
13737 * @category Object
13738 * @param {Object} object The object to modify.
13739 * @param {Array|string} path The path of the property to set.
13740 * @param {*} value The value to set.
13741 * @param {Function} [customizer] The function to customize assigned values.
13742 * @returns {Object} Returns `object`.
13743 * @example
13744 *
13745 * var object = {};
13746 *
13747 * _.setWith(object, '[0][1]', 'a', Object);
13748 * // => { '0': { '1': 'a' } }
13749 */
13750 function setWith(object, path, value, customizer) {
13751 customizer = typeof customizer == 'function' ? customizer : undefined$1;
13752 return object == null ? object : baseSet(object, path, value, customizer);
13753 }
13754
13755 /**
13756 * Creates an array of own enumerable string keyed-value pairs for `object`
13757 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
13758 * entries are returned.
13759 *
13760 * @static
13761 * @memberOf _
13762 * @since 4.0.0
13763 * @alias entries
13764 * @category Object
13765 * @param {Object} object The object to query.
13766 * @returns {Array} Returns the key-value pairs.
13767 * @example
13768 *
13769 * function Foo() {
13770 * this.a = 1;
13771 * this.b = 2;
13772 * }
13773 *
13774 * Foo.prototype.c = 3;
13775 *
13776 * _.toPairs(new Foo);
13777 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
13778 */
13779 var toPairs = createToPairs(keys);
13780
13781 /**
13782 * Creates an array of own and inherited enumerable string keyed-value pairs
13783 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
13784 * or set, its entries are returned.
13785 *
13786 * @static
13787 * @memberOf _
13788 * @since 4.0.0
13789 * @alias entriesIn
13790 * @category Object
13791 * @param {Object} object The object to query.
13792 * @returns {Array} Returns the key-value pairs.
13793 * @example
13794 *
13795 * function Foo() {
13796 * this.a = 1;
13797 * this.b = 2;
13798 * }
13799 *
13800 * Foo.prototype.c = 3;
13801 *
13802 * _.toPairsIn(new Foo);
13803 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
13804 */
13805 var toPairsIn = createToPairs(keysIn);
13806
13807 /**
13808 * An alternative to `_.reduce`; this method transforms `object` to a new
13809 * `accumulator` object which is the result of running each of its own
13810 * enumerable string keyed properties thru `iteratee`, with each invocation
13811 * potentially mutating the `accumulator` object. If `accumulator` is not
13812 * provided, a new object with the same `[[Prototype]]` will be used. The
13813 * iteratee is invoked with four arguments: (accumulator, value, key, object).
13814 * Iteratee functions may exit iteration early by explicitly returning `false`.
13815 *
13816 * @static
13817 * @memberOf _
13818 * @since 1.3.0
13819 * @category Object
13820 * @param {Object} object The object to iterate over.
13821 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
13822 * @param {*} [accumulator] The custom accumulator value.
13823 * @returns {*} Returns the accumulated value.
13824 * @example
13825 *
13826 * _.transform([2, 3, 4], function(result, n) {
13827 * result.push(n *= n);
13828 * return n % 2 == 0;
13829 * }, []);
13830 * // => [4, 9]
13831 *
13832 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
13833 * (result[value] || (result[value] = [])).push(key);
13834 * }, {});
13835 * // => { '1': ['a', 'c'], '2': ['b'] }
13836 */
13837 function transform(object, iteratee, accumulator) {
13838 var isArr = isArray(object),
13839 isArrLike = isArr || isBuffer(object) || isTypedArray(object);
13840
13841 iteratee = getIteratee(iteratee, 4);
13842 if (accumulator == null) {
13843 var Ctor = object && object.constructor;
13844 if (isArrLike) {
13845 accumulator = isArr ? new Ctor : [];
13846 }
13847 else if (isObject(object)) {
13848 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
13849 }
13850 else {
13851 accumulator = {};
13852 }
13853 }
13854 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
13855 return iteratee(accumulator, value, index, object);
13856 });
13857 return accumulator;
13858 }
13859
13860 /**
13861 * Removes the property at `path` of `object`.
13862 *
13863 * **Note:** This method mutates `object`.
13864 *
13865 * @static
13866 * @memberOf _
13867 * @since 4.0.0
13868 * @category Object
13869 * @param {Object} object The object to modify.
13870 * @param {Array|string} path The path of the property to unset.
13871 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
13872 * @example
13873 *
13874 * var object = { 'a': [{ 'b': { 'c': 7 } }] };
13875 * _.unset(object, 'a[0].b.c');
13876 * // => true
13877 *
13878 * console.log(object);
13879 * // => { 'a': [{ 'b': {} }] };
13880 *
13881 * _.unset(object, ['a', '0', 'b', 'c']);
13882 * // => true
13883 *
13884 * console.log(object);
13885 * // => { 'a': [{ 'b': {} }] };
13886 */
13887 function unset(object, path) {
13888 return object == null ? true : baseUnset(object, path);
13889 }
13890
13891 /**
13892 * This method is like `_.set` except that accepts `updater` to produce the
13893 * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
13894 * is invoked with one argument: (value).
13895 *
13896 * **Note:** This method mutates `object`.
13897 *
13898 * @static
13899 * @memberOf _
13900 * @since 4.6.0
13901 * @category Object
13902 * @param {Object} object The object to modify.
13903 * @param {Array|string} path The path of the property to set.
13904 * @param {Function} updater The function to produce the updated value.
13905 * @returns {Object} Returns `object`.
13906 * @example
13907 *
13908 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
13909 *
13910 * _.update(object, 'a[0].b.c', function(n) { return n * n; });
13911 * console.log(object.a[0].b.c);
13912 * // => 9
13913 *
13914 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
13915 * console.log(object.x[0].y.z);
13916 * // => 0
13917 */
13918 function update(object, path, updater) {
13919 return object == null ? object : baseUpdate(object, path, castFunction(updater));
13920 }
13921
13922 /**
13923 * This method is like `_.update` except that it accepts `customizer` which is
13924 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
13925 * path creation is handled by the method instead. The `customizer` is invoked
13926 * with three arguments: (nsValue, key, nsObject).
13927 *
13928 * **Note:** This method mutates `object`.
13929 *
13930 * @static
13931 * @memberOf _
13932 * @since 4.6.0
13933 * @category Object
13934 * @param {Object} object The object to modify.
13935 * @param {Array|string} path The path of the property to set.
13936 * @param {Function} updater The function to produce the updated value.
13937 * @param {Function} [customizer] The function to customize assigned values.
13938 * @returns {Object} Returns `object`.
13939 * @example
13940 *
13941 * var object = {};
13942 *
13943 * _.updateWith(object, '[0][1]', _.constant('a'), Object);
13944 * // => { '0': { '1': 'a' } }
13945 */
13946 function updateWith(object, path, updater, customizer) {
13947 customizer = typeof customizer == 'function' ? customizer : undefined$1;
13948 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
13949 }
13950
13951 /**
13952 * Creates an array of the own enumerable string keyed property values of `object`.
13953 *
13954 * **Note:** Non-object values are coerced to objects.
13955 *
13956 * @static
13957 * @since 0.1.0
13958 * @memberOf _
13959 * @category Object
13960 * @param {Object} object The object to query.
13961 * @returns {Array} Returns the array of property values.
13962 * @example
13963 *
13964 * function Foo() {
13965 * this.a = 1;
13966 * this.b = 2;
13967 * }
13968 *
13969 * Foo.prototype.c = 3;
13970 *
13971 * _.values(new Foo);
13972 * // => [1, 2] (iteration order is not guaranteed)
13973 *
13974 * _.values('hi');
13975 * // => ['h', 'i']
13976 */
13977 function values(object) {
13978 return object == null ? [] : baseValues(object, keys(object));
13979 }
13980
13981 /**
13982 * Creates an array of the own and inherited enumerable string keyed property
13983 * values of `object`.
13984 *
13985 * **Note:** Non-object values are coerced to objects.
13986 *
13987 * @static
13988 * @memberOf _
13989 * @since 3.0.0
13990 * @category Object
13991 * @param {Object} object The object to query.
13992 * @returns {Array} Returns the array of property values.
13993 * @example
13994 *
13995 * function Foo() {
13996 * this.a = 1;
13997 * this.b = 2;
13998 * }
13999 *
14000 * Foo.prototype.c = 3;
14001 *
14002 * _.valuesIn(new Foo);
14003 * // => [1, 2, 3] (iteration order is not guaranteed)
14004 */
14005 function valuesIn(object) {
14006 return object == null ? [] : baseValues(object, keysIn(object));
14007 }
14008
14009 /*------------------------------------------------------------------------*/
14010
14011 /**
14012 * Clamps `number` within the inclusive `lower` and `upper` bounds.
14013 *
14014 * @static
14015 * @memberOf _
14016 * @since 4.0.0
14017 * @category Number
14018 * @param {number} number The number to clamp.
14019 * @param {number} [lower] The lower bound.
14020 * @param {number} upper The upper bound.
14021 * @returns {number} Returns the clamped number.
14022 * @example
14023 *
14024 * _.clamp(-10, -5, 5);
14025 * // => -5
14026 *
14027 * _.clamp(10, -5, 5);
14028 * // => 5
14029 */
14030 function clamp(number, lower, upper) {
14031 if (upper === undefined$1) {
14032 upper = lower;
14033 lower = undefined$1;
14034 }
14035 if (upper !== undefined$1) {
14036 upper = toNumber(upper);
14037 upper = upper === upper ? upper : 0;
14038 }
14039 if (lower !== undefined$1) {
14040 lower = toNumber(lower);
14041 lower = lower === lower ? lower : 0;
14042 }
14043 return baseClamp(toNumber(number), lower, upper);
14044 }
14045
14046 /**
14047 * Checks if `n` is between `start` and up to, but not including, `end`. If
14048 * `end` is not specified, it's set to `start` with `start` then set to `0`.
14049 * If `start` is greater than `end` the params are swapped to support
14050 * negative ranges.
14051 *
14052 * @static
14053 * @memberOf _
14054 * @since 3.3.0
14055 * @category Number
14056 * @param {number} number The number to check.
14057 * @param {number} [start=0] The start of the range.
14058 * @param {number} end The end of the range.
14059 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
14060 * @see _.range, _.rangeRight
14061 * @example
14062 *
14063 * _.inRange(3, 2, 4);
14064 * // => true
14065 *
14066 * _.inRange(4, 8);
14067 * // => true
14068 *
14069 * _.inRange(4, 2);
14070 * // => false
14071 *
14072 * _.inRange(2, 2);
14073 * // => false
14074 *
14075 * _.inRange(1.2, 2);
14076 * // => true
14077 *
14078 * _.inRange(5.2, 4);
14079 * // => false
14080 *
14081 * _.inRange(-3, -2, -6);
14082 * // => true
14083 */
14084 function inRange(number, start, end) {
14085 start = toFinite(start);
14086 if (end === undefined$1) {
14087 end = start;
14088 start = 0;
14089 } else {
14090 end = toFinite(end);
14091 }
14092 number = toNumber(number);
14093 return baseInRange(number, start, end);
14094 }
14095
14096 /**
14097 * Produces a random number between the inclusive `lower` and `upper` bounds.
14098 * If only one argument is provided a number between `0` and the given number
14099 * is returned. If `floating` is `true`, or either `lower` or `upper` are
14100 * floats, a floating-point number is returned instead of an integer.
14101 *
14102 * **Note:** JavaScript follows the IEEE-754 standard for resolving
14103 * floating-point values which can produce unexpected results.
14104 *
14105 * @static
14106 * @memberOf _
14107 * @since 0.7.0
14108 * @category Number
14109 * @param {number} [lower=0] The lower bound.
14110 * @param {number} [upper=1] The upper bound.
14111 * @param {boolean} [floating] Specify returning a floating-point number.
14112 * @returns {number} Returns the random number.
14113 * @example
14114 *
14115 * _.random(0, 5);
14116 * // => an integer between 0 and 5
14117 *
14118 * _.random(5);
14119 * // => also an integer between 0 and 5
14120 *
14121 * _.random(5, true);
14122 * // => a floating-point number between 0 and 5
14123 *
14124 * _.random(1.2, 5.2);
14125 * // => a floating-point number between 1.2 and 5.2
14126 */
14127 function random(lower, upper, floating) {
14128 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
14129 upper = floating = undefined$1;
14130 }
14131 if (floating === undefined$1) {
14132 if (typeof upper == 'boolean') {
14133 floating = upper;
14134 upper = undefined$1;
14135 }
14136 else if (typeof lower == 'boolean') {
14137 floating = lower;
14138 lower = undefined$1;
14139 }
14140 }
14141 if (lower === undefined$1 && upper === undefined$1) {
14142 lower = 0;
14143 upper = 1;
14144 }
14145 else {
14146 lower = toFinite(lower);
14147 if (upper === undefined$1) {
14148 upper = lower;
14149 lower = 0;
14150 } else {
14151 upper = toFinite(upper);
14152 }
14153 }
14154 if (lower > upper) {
14155 var temp = lower;
14156 lower = upper;
14157 upper = temp;
14158 }
14159 if (floating || lower % 1 || upper % 1) {
14160 var rand = nativeRandom();
14161 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
14162 }
14163 return baseRandom(lower, upper);
14164 }
14165
14166 /*------------------------------------------------------------------------*/
14167
14168 /**
14169 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
14170 *
14171 * @static
14172 * @memberOf _
14173 * @since 3.0.0
14174 * @category String
14175 * @param {string} [string=''] The string to convert.
14176 * @returns {string} Returns the camel cased string.
14177 * @example
14178 *
14179 * _.camelCase('Foo Bar');
14180 * // => 'fooBar'
14181 *
14182 * _.camelCase('--foo-bar--');
14183 * // => 'fooBar'
14184 *
14185 * _.camelCase('__FOO_BAR__');
14186 * // => 'fooBar'
14187 */
14188 var camelCase = createCompounder(function(result, word, index) {
14189 word = word.toLowerCase();
14190 return result + (index ? capitalize(word) : word);
14191 });
14192
14193 /**
14194 * Converts the first character of `string` to upper case and the remaining
14195 * to lower case.
14196 *
14197 * @static
14198 * @memberOf _
14199 * @since 3.0.0
14200 * @category String
14201 * @param {string} [string=''] The string to capitalize.
14202 * @returns {string} Returns the capitalized string.
14203 * @example
14204 *
14205 * _.capitalize('FRED');
14206 * // => 'Fred'
14207 */
14208 function capitalize(string) {
14209 return upperFirst(toString(string).toLowerCase());
14210 }
14211
14212 /**
14213 * Deburrs `string` by converting
14214 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
14215 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
14216 * letters to basic Latin letters and removing
14217 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
14218 *
14219 * @static
14220 * @memberOf _
14221 * @since 3.0.0
14222 * @category String
14223 * @param {string} [string=''] The string to deburr.
14224 * @returns {string} Returns the deburred string.
14225 * @example
14226 *
14227 * _.deburr('déjà vu');
14228 * // => 'deja vu'
14229 */
14230 function deburr(string) {
14231 string = toString(string);
14232 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
14233 }
14234
14235 /**
14236 * Checks if `string` ends with the given target string.
14237 *
14238 * @static
14239 * @memberOf _
14240 * @since 3.0.0
14241 * @category String
14242 * @param {string} [string=''] The string to inspect.
14243 * @param {string} [target] The string to search for.
14244 * @param {number} [position=string.length] The position to search up to.
14245 * @returns {boolean} Returns `true` if `string` ends with `target`,
14246 * else `false`.
14247 * @example
14248 *
14249 * _.endsWith('abc', 'c');
14250 * // => true
14251 *
14252 * _.endsWith('abc', 'b');
14253 * // => false
14254 *
14255 * _.endsWith('abc', 'b', 2);
14256 * // => true
14257 */
14258 function endsWith(string, target, position) {
14259 string = toString(string);
14260 target = baseToString(target);
14261
14262 var length = string.length;
14263 position = position === undefined$1
14264 ? length
14265 : baseClamp(toInteger(position), 0, length);
14266
14267 var end = position;
14268 position -= target.length;
14269 return position >= 0 && string.slice(position, end) == target;
14270 }
14271
14272 /**
14273 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
14274 * corresponding HTML entities.
14275 *
14276 * **Note:** No other characters are escaped. To escape additional
14277 * characters use a third-party library like [_he_](https://mths.be/he).
14278 *
14279 * Though the ">" character is escaped for symmetry, characters like
14280 * ">" and "/" don't need escaping in HTML and have no special meaning
14281 * unless they're part of a tag or unquoted attribute value. See
14282 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
14283 * (under "semi-related fun fact") for more details.
14284 *
14285 * When working with HTML you should always
14286 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
14287 * XSS vectors.
14288 *
14289 * @static
14290 * @since 0.1.0
14291 * @memberOf _
14292 * @category String
14293 * @param {string} [string=''] The string to escape.
14294 * @returns {string} Returns the escaped string.
14295 * @example
14296 *
14297 * _.escape('fred, barney, & pebbles');
14298 * // => 'fred, barney, &amp; pebbles'
14299 */
14300 function escape(string) {
14301 string = toString(string);
14302 return (string && reHasUnescapedHtml.test(string))
14303 ? string.replace(reUnescapedHtml, escapeHtmlChar)
14304 : string;
14305 }
14306
14307 /**
14308 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
14309 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
14310 *
14311 * @static
14312 * @memberOf _
14313 * @since 3.0.0
14314 * @category String
14315 * @param {string} [string=''] The string to escape.
14316 * @returns {string} Returns the escaped string.
14317 * @example
14318 *
14319 * _.escapeRegExp('[lodash](https://lodash.com/)');
14320 * // => '\[lodash\]\(https://lodash\.com/\)'
14321 */
14322 function escapeRegExp(string) {
14323 string = toString(string);
14324 return (string && reHasRegExpChar.test(string))
14325 ? string.replace(reRegExpChar, '\\$&')
14326 : string;
14327 }
14328
14329 /**
14330 * Converts `string` to
14331 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
14332 *
14333 * @static
14334 * @memberOf _
14335 * @since 3.0.0
14336 * @category String
14337 * @param {string} [string=''] The string to convert.
14338 * @returns {string} Returns the kebab cased string.
14339 * @example
14340 *
14341 * _.kebabCase('Foo Bar');
14342 * // => 'foo-bar'
14343 *
14344 * _.kebabCase('fooBar');
14345 * // => 'foo-bar'
14346 *
14347 * _.kebabCase('__FOO_BAR__');
14348 * // => 'foo-bar'
14349 */
14350 var kebabCase = createCompounder(function(result, word, index) {
14351 return result + (index ? '-' : '') + word.toLowerCase();
14352 });
14353
14354 /**
14355 * Converts `string`, as space separated words, to lower case.
14356 *
14357 * @static
14358 * @memberOf _
14359 * @since 4.0.0
14360 * @category String
14361 * @param {string} [string=''] The string to convert.
14362 * @returns {string} Returns the lower cased string.
14363 * @example
14364 *
14365 * _.lowerCase('--Foo-Bar--');
14366 * // => 'foo bar'
14367 *
14368 * _.lowerCase('fooBar');
14369 * // => 'foo bar'
14370 *
14371 * _.lowerCase('__FOO_BAR__');
14372 * // => 'foo bar'
14373 */
14374 var lowerCase = createCompounder(function(result, word, index) {
14375 return result + (index ? ' ' : '') + word.toLowerCase();
14376 });
14377
14378 /**
14379 * Converts the first character of `string` to lower case.
14380 *
14381 * @static
14382 * @memberOf _
14383 * @since 4.0.0
14384 * @category String
14385 * @param {string} [string=''] The string to convert.
14386 * @returns {string} Returns the converted string.
14387 * @example
14388 *
14389 * _.lowerFirst('Fred');
14390 * // => 'fred'
14391 *
14392 * _.lowerFirst('FRED');
14393 * // => 'fRED'
14394 */
14395 var lowerFirst = createCaseFirst('toLowerCase');
14396
14397 /**
14398 * Pads `string` on the left and right sides if it's shorter than `length`.
14399 * Padding characters are truncated if they can't be evenly divided by `length`.
14400 *
14401 * @static
14402 * @memberOf _
14403 * @since 3.0.0
14404 * @category String
14405 * @param {string} [string=''] The string to pad.
14406 * @param {number} [length=0] The padding length.
14407 * @param {string} [chars=' '] The string used as padding.
14408 * @returns {string} Returns the padded string.
14409 * @example
14410 *
14411 * _.pad('abc', 8);
14412 * // => ' abc '
14413 *
14414 * _.pad('abc', 8, '_-');
14415 * // => '_-abc_-_'
14416 *
14417 * _.pad('abc', 3);
14418 * // => 'abc'
14419 */
14420 function pad(string, length, chars) {
14421 string = toString(string);
14422 length = toInteger(length);
14423
14424 var strLength = length ? stringSize(string) : 0;
14425 if (!length || strLength >= length) {
14426 return string;
14427 }
14428 var mid = (length - strLength) / 2;
14429 return (
14430 createPadding(nativeFloor(mid), chars) +
14431 string +
14432 createPadding(nativeCeil(mid), chars)
14433 );
14434 }
14435
14436 /**
14437 * Pads `string` on the right side if it's shorter than `length`. Padding
14438 * characters are truncated if they exceed `length`.
14439 *
14440 * @static
14441 * @memberOf _
14442 * @since 4.0.0
14443 * @category String
14444 * @param {string} [string=''] The string to pad.
14445 * @param {number} [length=0] The padding length.
14446 * @param {string} [chars=' '] The string used as padding.
14447 * @returns {string} Returns the padded string.
14448 * @example
14449 *
14450 * _.padEnd('abc', 6);
14451 * // => 'abc '
14452 *
14453 * _.padEnd('abc', 6, '_-');
14454 * // => 'abc_-_'
14455 *
14456 * _.padEnd('abc', 3);
14457 * // => 'abc'
14458 */
14459 function padEnd(string, length, chars) {
14460 string = toString(string);
14461 length = toInteger(length);
14462
14463 var strLength = length ? stringSize(string) : 0;
14464 return (length && strLength < length)
14465 ? (string + createPadding(length - strLength, chars))
14466 : string;
14467 }
14468
14469 /**
14470 * Pads `string` on the left side if it's shorter than `length`. Padding
14471 * characters are truncated if they exceed `length`.
14472 *
14473 * @static
14474 * @memberOf _
14475 * @since 4.0.0
14476 * @category String
14477 * @param {string} [string=''] The string to pad.
14478 * @param {number} [length=0] The padding length.
14479 * @param {string} [chars=' '] The string used as padding.
14480 * @returns {string} Returns the padded string.
14481 * @example
14482 *
14483 * _.padStart('abc', 6);
14484 * // => ' abc'
14485 *
14486 * _.padStart('abc', 6, '_-');
14487 * // => '_-_abc'
14488 *
14489 * _.padStart('abc', 3);
14490 * // => 'abc'
14491 */
14492 function padStart(string, length, chars) {
14493 string = toString(string);
14494 length = toInteger(length);
14495
14496 var strLength = length ? stringSize(string) : 0;
14497 return (length && strLength < length)
14498 ? (createPadding(length - strLength, chars) + string)
14499 : string;
14500 }
14501
14502 /**
14503 * Converts `string` to an integer of the specified radix. If `radix` is
14504 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
14505 * hexadecimal, in which case a `radix` of `16` is used.
14506 *
14507 * **Note:** This method aligns with the
14508 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
14509 *
14510 * @static
14511 * @memberOf _
14512 * @since 1.1.0
14513 * @category String
14514 * @param {string} string The string to convert.
14515 * @param {number} [radix=10] The radix to interpret `value` by.
14516 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14517 * @returns {number} Returns the converted integer.
14518 * @example
14519 *
14520 * _.parseInt('08');
14521 * // => 8
14522 *
14523 * _.map(['6', '08', '10'], _.parseInt);
14524 * // => [6, 8, 10]
14525 */
14526 function parseInt(string, radix, guard) {
14527 if (guard || radix == null) {
14528 radix = 0;
14529 } else if (radix) {
14530 radix = +radix;
14531 }
14532 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
14533 }
14534
14535 /**
14536 * Repeats the given string `n` times.
14537 *
14538 * @static
14539 * @memberOf _
14540 * @since 3.0.0
14541 * @category String
14542 * @param {string} [string=''] The string to repeat.
14543 * @param {number} [n=1] The number of times to repeat the string.
14544 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14545 * @returns {string} Returns the repeated string.
14546 * @example
14547 *
14548 * _.repeat('*', 3);
14549 * // => '***'
14550 *
14551 * _.repeat('abc', 2);
14552 * // => 'abcabc'
14553 *
14554 * _.repeat('abc', 0);
14555 * // => ''
14556 */
14557 function repeat(string, n, guard) {
14558 if ((guard ? isIterateeCall(string, n, guard) : n === undefined$1)) {
14559 n = 1;
14560 } else {
14561 n = toInteger(n);
14562 }
14563 return baseRepeat(toString(string), n);
14564 }
14565
14566 /**
14567 * Replaces matches for `pattern` in `string` with `replacement`.
14568 *
14569 * **Note:** This method is based on
14570 * [`String#replace`](https://mdn.io/String/replace).
14571 *
14572 * @static
14573 * @memberOf _
14574 * @since 4.0.0
14575 * @category String
14576 * @param {string} [string=''] The string to modify.
14577 * @param {RegExp|string} pattern The pattern to replace.
14578 * @param {Function|string} replacement The match replacement.
14579 * @returns {string} Returns the modified string.
14580 * @example
14581 *
14582 * _.replace('Hi Fred', 'Fred', 'Barney');
14583 * // => 'Hi Barney'
14584 */
14585 function replace() {
14586 var args = arguments,
14587 string = toString(args[0]);
14588
14589 return args.length < 3 ? string : string.replace(args[1], args[2]);
14590 }
14591
14592 /**
14593 * Converts `string` to
14594 * [snake case](https://en.wikipedia.org/wiki/Snake_case).
14595 *
14596 * @static
14597 * @memberOf _
14598 * @since 3.0.0
14599 * @category String
14600 * @param {string} [string=''] The string to convert.
14601 * @returns {string} Returns the snake cased string.
14602 * @example
14603 *
14604 * _.snakeCase('Foo Bar');
14605 * // => 'foo_bar'
14606 *
14607 * _.snakeCase('fooBar');
14608 * // => 'foo_bar'
14609 *
14610 * _.snakeCase('--FOO-BAR--');
14611 * // => 'foo_bar'
14612 */
14613 var snakeCase = createCompounder(function(result, word, index) {
14614 return result + (index ? '_' : '') + word.toLowerCase();
14615 });
14616
14617 /**
14618 * Splits `string` by `separator`.
14619 *
14620 * **Note:** This method is based on
14621 * [`String#split`](https://mdn.io/String/split).
14622 *
14623 * @static
14624 * @memberOf _
14625 * @since 4.0.0
14626 * @category String
14627 * @param {string} [string=''] The string to split.
14628 * @param {RegExp|string} separator The separator pattern to split by.
14629 * @param {number} [limit] The length to truncate results to.
14630 * @returns {Array} Returns the string segments.
14631 * @example
14632 *
14633 * _.split('a-b-c', '-', 2);
14634 * // => ['a', 'b']
14635 */
14636 function split(string, separator, limit) {
14637 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
14638 separator = limit = undefined$1;
14639 }
14640 limit = limit === undefined$1 ? MAX_ARRAY_LENGTH : limit >>> 0;
14641 if (!limit) {
14642 return [];
14643 }
14644 string = toString(string);
14645 if (string && (
14646 typeof separator == 'string' ||
14647 (separator != null && !isRegExp(separator))
14648 )) {
14649 separator = baseToString(separator);
14650 if (!separator && hasUnicode(string)) {
14651 return castSlice(stringToArray(string), 0, limit);
14652 }
14653 }
14654 return string.split(separator, limit);
14655 }
14656
14657 /**
14658 * Converts `string` to
14659 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
14660 *
14661 * @static
14662 * @memberOf _
14663 * @since 3.1.0
14664 * @category String
14665 * @param {string} [string=''] The string to convert.
14666 * @returns {string} Returns the start cased string.
14667 * @example
14668 *
14669 * _.startCase('--foo-bar--');
14670 * // => 'Foo Bar'
14671 *
14672 * _.startCase('fooBar');
14673 * // => 'Foo Bar'
14674 *
14675 * _.startCase('__FOO_BAR__');
14676 * // => 'FOO BAR'
14677 */
14678 var startCase = createCompounder(function(result, word, index) {
14679 return result + (index ? ' ' : '') + upperFirst(word);
14680 });
14681
14682 /**
14683 * Checks if `string` starts with the given target string.
14684 *
14685 * @static
14686 * @memberOf _
14687 * @since 3.0.0
14688 * @category String
14689 * @param {string} [string=''] The string to inspect.
14690 * @param {string} [target] The string to search for.
14691 * @param {number} [position=0] The position to search from.
14692 * @returns {boolean} Returns `true` if `string` starts with `target`,
14693 * else `false`.
14694 * @example
14695 *
14696 * _.startsWith('abc', 'a');
14697 * // => true
14698 *
14699 * _.startsWith('abc', 'b');
14700 * // => false
14701 *
14702 * _.startsWith('abc', 'b', 1);
14703 * // => true
14704 */
14705 function startsWith(string, target, position) {
14706 string = toString(string);
14707 position = position == null
14708 ? 0
14709 : baseClamp(toInteger(position), 0, string.length);
14710
14711 target = baseToString(target);
14712 return string.slice(position, position + target.length) == target;
14713 }
14714
14715 /**
14716 * Creates a compiled template function that can interpolate data properties
14717 * in "interpolate" delimiters, HTML-escape interpolated data properties in
14718 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
14719 * properties may be accessed as free variables in the template. If a setting
14720 * object is given, it takes precedence over `_.templateSettings` values.
14721 *
14722 * **Note:** In the development build `_.template` utilizes
14723 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
14724 * for easier debugging.
14725 *
14726 * For more information on precompiling templates see
14727 * [lodash's custom builds documentation](https://lodash.com/custom-builds).
14728 *
14729 * For more information on Chrome extension sandboxes see
14730 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
14731 *
14732 * @static
14733 * @since 0.1.0
14734 * @memberOf _
14735 * @category String
14736 * @param {string} [string=''] The template string.
14737 * @param {Object} [options={}] The options object.
14738 * @param {RegExp} [options.escape=_.templateSettings.escape]
14739 * The HTML "escape" delimiter.
14740 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
14741 * The "evaluate" delimiter.
14742 * @param {Object} [options.imports=_.templateSettings.imports]
14743 * An object to import into the template as free variables.
14744 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
14745 * The "interpolate" delimiter.
14746 * @param {string} [options.sourceURL='lodash.templateSources[n]']
14747 * The sourceURL of the compiled template.
14748 * @param {string} [options.variable='obj']
14749 * The data object variable name.
14750 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14751 * @returns {Function} Returns the compiled template function.
14752 * @example
14753 *
14754 * // Use the "interpolate" delimiter to create a compiled template.
14755 * var compiled = _.template('hello <%= user %>!');
14756 * compiled({ 'user': 'fred' });
14757 * // => 'hello fred!'
14758 *
14759 * // Use the HTML "escape" delimiter to escape data property values.
14760 * var compiled = _.template('<b><%- value %></b>');
14761 * compiled({ 'value': '<script>' });
14762 * // => '<b>&lt;script&gt;</b>'
14763 *
14764 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
14765 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
14766 * compiled({ 'users': ['fred', 'barney'] });
14767 * // => '<li>fred</li><li>barney</li>'
14768 *
14769 * // Use the internal `print` function in "evaluate" delimiters.
14770 * var compiled = _.template('<% print("hello " + user); %>!');
14771 * compiled({ 'user': 'barney' });
14772 * // => 'hello barney!'
14773 *
14774 * // Use the ES template literal delimiter as an "interpolate" delimiter.
14775 * // Disable support by replacing the "interpolate" delimiter.
14776 * var compiled = _.template('hello ${ user }!');
14777 * compiled({ 'user': 'pebbles' });
14778 * // => 'hello pebbles!'
14779 *
14780 * // Use backslashes to treat delimiters as plain text.
14781 * var compiled = _.template('<%= "\\<%- value %\\>" %>');
14782 * compiled({ 'value': 'ignored' });
14783 * // => '<%- value %>'
14784 *
14785 * // Use the `imports` option to import `jQuery` as `jq`.
14786 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
14787 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
14788 * compiled({ 'users': ['fred', 'barney'] });
14789 * // => '<li>fred</li><li>barney</li>'
14790 *
14791 * // Use the `sourceURL` option to specify a custom sourceURL for the template.
14792 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
14793 * compiled(data);
14794 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
14795 *
14796 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
14797 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
14798 * compiled.source;
14799 * // => function(data) {
14800 * // var __t, __p = '';
14801 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
14802 * // return __p;
14803 * // }
14804 *
14805 * // Use custom template delimiters.
14806 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
14807 * var compiled = _.template('hello {{ user }}!');
14808 * compiled({ 'user': 'mustache' });
14809 * // => 'hello mustache!'
14810 *
14811 * // Use the `source` property to inline compiled templates for meaningful
14812 * // line numbers in error messages and stack traces.
14813 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
14814 * var JST = {\
14815 * "main": ' + _.template(mainText).source + '\
14816 * };\
14817 * ');
14818 */
14819 function template(string, options, guard) {
14820 // Based on John Resig's `tmpl` implementation
14821 // (http://ejohn.org/blog/javascript-micro-templating/)
14822 // and Laura Doktorova's doT.js (https://github.com/olado/doT).
14823 var settings = lodash.templateSettings;
14824
14825 if (guard && isIterateeCall(string, options, guard)) {
14826 options = undefined$1;
14827 }
14828 string = toString(string);
14829 options = assignInWith({}, options, settings, customDefaultsAssignIn);
14830
14831 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
14832 importsKeys = keys(imports),
14833 importsValues = baseValues(imports, importsKeys);
14834
14835 var isEscaping,
14836 isEvaluating,
14837 index = 0,
14838 interpolate = options.interpolate || reNoMatch,
14839 source = "__p += '";
14840
14841 // Compile the regexp to match each delimiter.
14842 var reDelimiters = RegExp(
14843 (options.escape || reNoMatch).source + '|' +
14844 interpolate.source + '|' +
14845 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
14846 (options.evaluate || reNoMatch).source + '|$'
14847 , 'g');
14848
14849 // Use a sourceURL for easier debugging.
14850 // The sourceURL gets injected into the source that's eval-ed, so be careful
14851 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
14852 // and escape the comment, thus injecting code that gets evaled.
14853 var sourceURL = '//# sourceURL=' +
14854 (hasOwnProperty.call(options, 'sourceURL')
14855 ? (options.sourceURL + '').replace(/\s/g, ' ')
14856 : ('lodash.templateSources[' + (++templateCounter) + ']')
14857 ) + '\n';
14858
14859 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
14860 interpolateValue || (interpolateValue = esTemplateValue);
14861
14862 // Escape characters that can't be included in string literals.
14863 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
14864
14865 // Replace delimiters with snippets.
14866 if (escapeValue) {
14867 isEscaping = true;
14868 source += "' +\n__e(" + escapeValue + ") +\n'";
14869 }
14870 if (evaluateValue) {
14871 isEvaluating = true;
14872 source += "';\n" + evaluateValue + ";\n__p += '";
14873 }
14874 if (interpolateValue) {
14875 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
14876 }
14877 index = offset + match.length;
14878
14879 // The JS engine embedded in Adobe products needs `match` returned in
14880 // order to produce the correct `offset` value.
14881 return match;
14882 });
14883
14884 source += "';\n";
14885
14886 // If `variable` is not specified wrap a with-statement around the generated
14887 // code to add the data object to the top of the scope chain.
14888 var variable = hasOwnProperty.call(options, 'variable') && options.variable;
14889 if (!variable) {
14890 source = 'with (obj) {\n' + source + '\n}\n';
14891 }
14892 // Cleanup code by stripping empty strings.
14893 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
14894 .replace(reEmptyStringMiddle, '$1')
14895 .replace(reEmptyStringTrailing, '$1;');
14896
14897 // Frame code as the function body.
14898 source = 'function(' + (variable || 'obj') + ') {\n' +
14899 (variable
14900 ? ''
14901 : 'obj || (obj = {});\n'
14902 ) +
14903 "var __t, __p = ''" +
14904 (isEscaping
14905 ? ', __e = _.escape'
14906 : ''
14907 ) +
14908 (isEvaluating
14909 ? ', __j = Array.prototype.join;\n' +
14910 "function print() { __p += __j.call(arguments, '') }\n"
14911 : ';\n'
14912 ) +
14913 source +
14914 'return __p\n}';
14915
14916 var result = attempt(function() {
14917 return Function(importsKeys, sourceURL + 'return ' + source)
14918 .apply(undefined$1, importsValues);
14919 });
14920
14921 // Provide the compiled function's source by its `toString` method or
14922 // the `source` property as a convenience for inlining compiled templates.
14923 result.source = source;
14924 if (isError(result)) {
14925 throw result;
14926 }
14927 return result;
14928 }
14929
14930 /**
14931 * Converts `string`, as a whole, to lower case just like
14932 * [String#toLowerCase](https://mdn.io/toLowerCase).
14933 *
14934 * @static
14935 * @memberOf _
14936 * @since 4.0.0
14937 * @category String
14938 * @param {string} [string=''] The string to convert.
14939 * @returns {string} Returns the lower cased string.
14940 * @example
14941 *
14942 * _.toLower('--Foo-Bar--');
14943 * // => '--foo-bar--'
14944 *
14945 * _.toLower('fooBar');
14946 * // => 'foobar'
14947 *
14948 * _.toLower('__FOO_BAR__');
14949 * // => '__foo_bar__'
14950 */
14951 function toLower(value) {
14952 return toString(value).toLowerCase();
14953 }
14954
14955 /**
14956 * Converts `string`, as a whole, to upper case just like
14957 * [String#toUpperCase](https://mdn.io/toUpperCase).
14958 *
14959 * @static
14960 * @memberOf _
14961 * @since 4.0.0
14962 * @category String
14963 * @param {string} [string=''] The string to convert.
14964 * @returns {string} Returns the upper cased string.
14965 * @example
14966 *
14967 * _.toUpper('--foo-bar--');
14968 * // => '--FOO-BAR--'
14969 *
14970 * _.toUpper('fooBar');
14971 * // => 'FOOBAR'
14972 *
14973 * _.toUpper('__foo_bar__');
14974 * // => '__FOO_BAR__'
14975 */
14976 function toUpper(value) {
14977 return toString(value).toUpperCase();
14978 }
14979
14980 /**
14981 * Removes leading and trailing whitespace or specified characters from `string`.
14982 *
14983 * @static
14984 * @memberOf _
14985 * @since 3.0.0
14986 * @category String
14987 * @param {string} [string=''] The string to trim.
14988 * @param {string} [chars=whitespace] The characters to trim.
14989 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
14990 * @returns {string} Returns the trimmed string.
14991 * @example
14992 *
14993 * _.trim(' abc ');
14994 * // => 'abc'
14995 *
14996 * _.trim('-_-abc-_-', '_-');
14997 * // => 'abc'
14998 *
14999 * _.map([' foo ', ' bar '], _.trim);
15000 * // => ['foo', 'bar']
15001 */
15002 function trim(string, chars, guard) {
15003 string = toString(string);
15004 if (string && (guard || chars === undefined$1)) {
15005 return string.replace(reTrim, '');
15006 }
15007 if (!string || !(chars = baseToString(chars))) {
15008 return string;
15009 }
15010 var strSymbols = stringToArray(string),
15011 chrSymbols = stringToArray(chars),
15012 start = charsStartIndex(strSymbols, chrSymbols),
15013 end = charsEndIndex(strSymbols, chrSymbols) + 1;
15014
15015 return castSlice(strSymbols, start, end).join('');
15016 }
15017
15018 /**
15019 * Removes trailing whitespace or specified characters from `string`.
15020 *
15021 * @static
15022 * @memberOf _
15023 * @since 4.0.0
15024 * @category String
15025 * @param {string} [string=''] The string to trim.
15026 * @param {string} [chars=whitespace] The characters to trim.
15027 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15028 * @returns {string} Returns the trimmed string.
15029 * @example
15030 *
15031 * _.trimEnd(' abc ');
15032 * // => ' abc'
15033 *
15034 * _.trimEnd('-_-abc-_-', '_-');
15035 * // => '-_-abc'
15036 */
15037 function trimEnd(string, chars, guard) {
15038 string = toString(string);
15039 if (string && (guard || chars === undefined$1)) {
15040 return string.replace(reTrimEnd, '');
15041 }
15042 if (!string || !(chars = baseToString(chars))) {
15043 return string;
15044 }
15045 var strSymbols = stringToArray(string),
15046 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
15047
15048 return castSlice(strSymbols, 0, end).join('');
15049 }
15050
15051 /**
15052 * Removes leading whitespace or specified characters from `string`.
15053 *
15054 * @static
15055 * @memberOf _
15056 * @since 4.0.0
15057 * @category String
15058 * @param {string} [string=''] The string to trim.
15059 * @param {string} [chars=whitespace] The characters to trim.
15060 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15061 * @returns {string} Returns the trimmed string.
15062 * @example
15063 *
15064 * _.trimStart(' abc ');
15065 * // => 'abc '
15066 *
15067 * _.trimStart('-_-abc-_-', '_-');
15068 * // => 'abc-_-'
15069 */
15070 function trimStart(string, chars, guard) {
15071 string = toString(string);
15072 if (string && (guard || chars === undefined$1)) {
15073 return string.replace(reTrimStart, '');
15074 }
15075 if (!string || !(chars = baseToString(chars))) {
15076 return string;
15077 }
15078 var strSymbols = stringToArray(string),
15079 start = charsStartIndex(strSymbols, stringToArray(chars));
15080
15081 return castSlice(strSymbols, start).join('');
15082 }
15083
15084 /**
15085 * Truncates `string` if it's longer than the given maximum string length.
15086 * The last characters of the truncated string are replaced with the omission
15087 * string which defaults to "...".
15088 *
15089 * @static
15090 * @memberOf _
15091 * @since 4.0.0
15092 * @category String
15093 * @param {string} [string=''] The string to truncate.
15094 * @param {Object} [options={}] The options object.
15095 * @param {number} [options.length=30] The maximum string length.
15096 * @param {string} [options.omission='...'] The string to indicate text is omitted.
15097 * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
15098 * @returns {string} Returns the truncated string.
15099 * @example
15100 *
15101 * _.truncate('hi-diddly-ho there, neighborino');
15102 * // => 'hi-diddly-ho there, neighbo...'
15103 *
15104 * _.truncate('hi-diddly-ho there, neighborino', {
15105 * 'length': 24,
15106 * 'separator': ' '
15107 * });
15108 * // => 'hi-diddly-ho there,...'
15109 *
15110 * _.truncate('hi-diddly-ho there, neighborino', {
15111 * 'length': 24,
15112 * 'separator': /,? +/
15113 * });
15114 * // => 'hi-diddly-ho there...'
15115 *
15116 * _.truncate('hi-diddly-ho there, neighborino', {
15117 * 'omission': ' [...]'
15118 * });
15119 * // => 'hi-diddly-ho there, neig [...]'
15120 */
15121 function truncate(string, options) {
15122 var length = DEFAULT_TRUNC_LENGTH,
15123 omission = DEFAULT_TRUNC_OMISSION;
15124
15125 if (isObject(options)) {
15126 var separator = 'separator' in options ? options.separator : separator;
15127 length = 'length' in options ? toInteger(options.length) : length;
15128 omission = 'omission' in options ? baseToString(options.omission) : omission;
15129 }
15130 string = toString(string);
15131
15132 var strLength = string.length;
15133 if (hasUnicode(string)) {
15134 var strSymbols = stringToArray(string);
15135 strLength = strSymbols.length;
15136 }
15137 if (length >= strLength) {
15138 return string;
15139 }
15140 var end = length - stringSize(omission);
15141 if (end < 1) {
15142 return omission;
15143 }
15144 var result = strSymbols
15145 ? castSlice(strSymbols, 0, end).join('')
15146 : string.slice(0, end);
15147
15148 if (separator === undefined$1) {
15149 return result + omission;
15150 }
15151 if (strSymbols) {
15152 end += (result.length - end);
15153 }
15154 if (isRegExp(separator)) {
15155 if (string.slice(end).search(separator)) {
15156 var match,
15157 substring = result;
15158
15159 if (!separator.global) {
15160 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
15161 }
15162 separator.lastIndex = 0;
15163 while ((match = separator.exec(substring))) {
15164 var newEnd = match.index;
15165 }
15166 result = result.slice(0, newEnd === undefined$1 ? end : newEnd);
15167 }
15168 } else if (string.indexOf(baseToString(separator), end) != end) {
15169 var index = result.lastIndexOf(separator);
15170 if (index > -1) {
15171 result = result.slice(0, index);
15172 }
15173 }
15174 return result + omission;
15175 }
15176
15177 /**
15178 * The inverse of `_.escape`; this method converts the HTML entities
15179 * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
15180 * their corresponding characters.
15181 *
15182 * **Note:** No other HTML entities are unescaped. To unescape additional
15183 * HTML entities use a third-party library like [_he_](https://mths.be/he).
15184 *
15185 * @static
15186 * @memberOf _
15187 * @since 0.6.0
15188 * @category String
15189 * @param {string} [string=''] The string to unescape.
15190 * @returns {string} Returns the unescaped string.
15191 * @example
15192 *
15193 * _.unescape('fred, barney, &amp; pebbles');
15194 * // => 'fred, barney, & pebbles'
15195 */
15196 function unescape(string) {
15197 string = toString(string);
15198 return (string && reHasEscapedHtml.test(string))
15199 ? string.replace(reEscapedHtml, unescapeHtmlChar)
15200 : string;
15201 }
15202
15203 /**
15204 * Converts `string`, as space separated words, to upper case.
15205 *
15206 * @static
15207 * @memberOf _
15208 * @since 4.0.0
15209 * @category String
15210 * @param {string} [string=''] The string to convert.
15211 * @returns {string} Returns the upper cased string.
15212 * @example
15213 *
15214 * _.upperCase('--foo-bar');
15215 * // => 'FOO BAR'
15216 *
15217 * _.upperCase('fooBar');
15218 * // => 'FOO BAR'
15219 *
15220 * _.upperCase('__foo_bar__');
15221 * // => 'FOO BAR'
15222 */
15223 var upperCase = createCompounder(function(result, word, index) {
15224 return result + (index ? ' ' : '') + word.toUpperCase();
15225 });
15226
15227 /**
15228 * Converts the first character of `string` to upper case.
15229 *
15230 * @static
15231 * @memberOf _
15232 * @since 4.0.0
15233 * @category String
15234 * @param {string} [string=''] The string to convert.
15235 * @returns {string} Returns the converted string.
15236 * @example
15237 *
15238 * _.upperFirst('fred');
15239 * // => 'Fred'
15240 *
15241 * _.upperFirst('FRED');
15242 * // => 'FRED'
15243 */
15244 var upperFirst = createCaseFirst('toUpperCase');
15245
15246 /**
15247 * Splits `string` into an array of its words.
15248 *
15249 * @static
15250 * @memberOf _
15251 * @since 3.0.0
15252 * @category String
15253 * @param {string} [string=''] The string to inspect.
15254 * @param {RegExp|string} [pattern] The pattern to match words.
15255 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
15256 * @returns {Array} Returns the words of `string`.
15257 * @example
15258 *
15259 * _.words('fred, barney, & pebbles');
15260 * // => ['fred', 'barney', 'pebbles']
15261 *
15262 * _.words('fred, barney, & pebbles', /[^, ]+/g);
15263 * // => ['fred', 'barney', '&', 'pebbles']
15264 */
15265 function words(string, pattern, guard) {
15266 string = toString(string);
15267 pattern = guard ? undefined$1 : pattern;
15268
15269 if (pattern === undefined$1) {
15270 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
15271 }
15272 return string.match(pattern) || [];
15273 }
15274
15275 /*------------------------------------------------------------------------*/
15276
15277 /**
15278 * Attempts to invoke `func`, returning either the result or the caught error
15279 * object. Any additional arguments are provided to `func` when it's invoked.
15280 *
15281 * @static
15282 * @memberOf _
15283 * @since 3.0.0
15284 * @category Util
15285 * @param {Function} func The function to attempt.
15286 * @param {...*} [args] The arguments to invoke `func` with.
15287 * @returns {*} Returns the `func` result or error object.
15288 * @example
15289 *
15290 * // Avoid throwing errors for invalid selectors.
15291 * var elements = _.attempt(function(selector) {
15292 * return document.querySelectorAll(selector);
15293 * }, '>_>');
15294 *
15295 * if (_.isError(elements)) {
15296 * elements = [];
15297 * }
15298 */
15299 var attempt = baseRest(function(func, args) {
15300 try {
15301 return apply(func, undefined$1, args);
15302 } catch (e) {
15303 return isError(e) ? e : new Error(e);
15304 }
15305 });
15306
15307 /**
15308 * Binds methods of an object to the object itself, overwriting the existing
15309 * method.
15310 *
15311 * **Note:** This method doesn't set the "length" property of bound functions.
15312 *
15313 * @static
15314 * @since 0.1.0
15315 * @memberOf _
15316 * @category Util
15317 * @param {Object} object The object to bind and assign the bound methods to.
15318 * @param {...(string|string[])} methodNames The object method names to bind.
15319 * @returns {Object} Returns `object`.
15320 * @example
15321 *
15322 * var view = {
15323 * 'label': 'docs',
15324 * 'click': function() {
15325 * console.log('clicked ' + this.label);
15326 * }
15327 * };
15328 *
15329 * _.bindAll(view, ['click']);
15330 * jQuery(element).on('click', view.click);
15331 * // => Logs 'clicked docs' when clicked.
15332 */
15333 var bindAll = flatRest(function(object, methodNames) {
15334 arrayEach(methodNames, function(key) {
15335 key = toKey(key);
15336 baseAssignValue(object, key, bind(object[key], object));
15337 });
15338 return object;
15339 });
15340
15341 /**
15342 * Creates a function that iterates over `pairs` and invokes the corresponding
15343 * function of the first predicate to return truthy. The predicate-function
15344 * pairs are invoked with the `this` binding and arguments of the created
15345 * function.
15346 *
15347 * @static
15348 * @memberOf _
15349 * @since 4.0.0
15350 * @category Util
15351 * @param {Array} pairs The predicate-function pairs.
15352 * @returns {Function} Returns the new composite function.
15353 * @example
15354 *
15355 * var func = _.cond([
15356 * [_.matches({ 'a': 1 }), _.constant('matches A')],
15357 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
15358 * [_.stubTrue, _.constant('no match')]
15359 * ]);
15360 *
15361 * func({ 'a': 1, 'b': 2 });
15362 * // => 'matches A'
15363 *
15364 * func({ 'a': 0, 'b': 1 });
15365 * // => 'matches B'
15366 *
15367 * func({ 'a': '1', 'b': '2' });
15368 * // => 'no match'
15369 */
15370 function cond(pairs) {
15371 var length = pairs == null ? 0 : pairs.length,
15372 toIteratee = getIteratee();
15373
15374 pairs = !length ? [] : arrayMap(pairs, function(pair) {
15375 if (typeof pair[1] != 'function') {
15376 throw new TypeError(FUNC_ERROR_TEXT);
15377 }
15378 return [toIteratee(pair[0]), pair[1]];
15379 });
15380
15381 return baseRest(function(args) {
15382 var index = -1;
15383 while (++index < length) {
15384 var pair = pairs[index];
15385 if (apply(pair[0], this, args)) {
15386 return apply(pair[1], this, args);
15387 }
15388 }
15389 });
15390 }
15391
15392 /**
15393 * Creates a function that invokes the predicate properties of `source` with
15394 * the corresponding property values of a given object, returning `true` if
15395 * all predicates return truthy, else `false`.
15396 *
15397 * **Note:** The created function is equivalent to `_.conformsTo` with
15398 * `source` partially applied.
15399 *
15400 * @static
15401 * @memberOf _
15402 * @since 4.0.0
15403 * @category Util
15404 * @param {Object} source The object of property predicates to conform to.
15405 * @returns {Function} Returns the new spec function.
15406 * @example
15407 *
15408 * var objects = [
15409 * { 'a': 2, 'b': 1 },
15410 * { 'a': 1, 'b': 2 }
15411 * ];
15412 *
15413 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
15414 * // => [{ 'a': 1, 'b': 2 }]
15415 */
15416 function conforms(source) {
15417 return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
15418 }
15419
15420 /**
15421 * Creates a function that returns `value`.
15422 *
15423 * @static
15424 * @memberOf _
15425 * @since 2.4.0
15426 * @category Util
15427 * @param {*} value The value to return from the new function.
15428 * @returns {Function} Returns the new constant function.
15429 * @example
15430 *
15431 * var objects = _.times(2, _.constant({ 'a': 1 }));
15432 *
15433 * console.log(objects);
15434 * // => [{ 'a': 1 }, { 'a': 1 }]
15435 *
15436 * console.log(objects[0] === objects[1]);
15437 * // => true
15438 */
15439 function constant(value) {
15440 return function() {
15441 return value;
15442 };
15443 }
15444
15445 /**
15446 * Checks `value` to determine whether a default value should be returned in
15447 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
15448 * or `undefined`.
15449 *
15450 * @static
15451 * @memberOf _
15452 * @since 4.14.0
15453 * @category Util
15454 * @param {*} value The value to check.
15455 * @param {*} defaultValue The default value.
15456 * @returns {*} Returns the resolved value.
15457 * @example
15458 *
15459 * _.defaultTo(1, 10);
15460 * // => 1
15461 *
15462 * _.defaultTo(undefined, 10);
15463 * // => 10
15464 */
15465 function defaultTo(value, defaultValue) {
15466 return (value == null || value !== value) ? defaultValue : value;
15467 }
15468
15469 /**
15470 * Creates a function that returns the result of invoking the given functions
15471 * with the `this` binding of the created function, where each successive
15472 * invocation is supplied the return value of the previous.
15473 *
15474 * @static
15475 * @memberOf _
15476 * @since 3.0.0
15477 * @category Util
15478 * @param {...(Function|Function[])} [funcs] The functions to invoke.
15479 * @returns {Function} Returns the new composite function.
15480 * @see _.flowRight
15481 * @example
15482 *
15483 * function square(n) {
15484 * return n * n;
15485 * }
15486 *
15487 * var addSquare = _.flow([_.add, square]);
15488 * addSquare(1, 2);
15489 * // => 9
15490 */
15491 var flow = createFlow();
15492
15493 /**
15494 * This method is like `_.flow` except that it creates a function that
15495 * invokes the given functions from right to left.
15496 *
15497 * @static
15498 * @since 3.0.0
15499 * @memberOf _
15500 * @category Util
15501 * @param {...(Function|Function[])} [funcs] The functions to invoke.
15502 * @returns {Function} Returns the new composite function.
15503 * @see _.flow
15504 * @example
15505 *
15506 * function square(n) {
15507 * return n * n;
15508 * }
15509 *
15510 * var addSquare = _.flowRight([square, _.add]);
15511 * addSquare(1, 2);
15512 * // => 9
15513 */
15514 var flowRight = createFlow(true);
15515
15516 /**
15517 * This method returns the first argument it receives.
15518 *
15519 * @static
15520 * @since 0.1.0
15521 * @memberOf _
15522 * @category Util
15523 * @param {*} value Any value.
15524 * @returns {*} Returns `value`.
15525 * @example
15526 *
15527 * var object = { 'a': 1 };
15528 *
15529 * console.log(_.identity(object) === object);
15530 * // => true
15531 */
15532 function identity(value) {
15533 return value;
15534 }
15535
15536 /**
15537 * Creates a function that invokes `func` with the arguments of the created
15538 * function. If `func` is a property name, the created function returns the
15539 * property value for a given element. If `func` is an array or object, the
15540 * created function returns `true` for elements that contain the equivalent
15541 * source properties, otherwise it returns `false`.
15542 *
15543 * @static
15544 * @since 4.0.0
15545 * @memberOf _
15546 * @category Util
15547 * @param {*} [func=_.identity] The value to convert to a callback.
15548 * @returns {Function} Returns the callback.
15549 * @example
15550 *
15551 * var users = [
15552 * { 'user': 'barney', 'age': 36, 'active': true },
15553 * { 'user': 'fred', 'age': 40, 'active': false }
15554 * ];
15555 *
15556 * // The `_.matches` iteratee shorthand.
15557 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
15558 * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
15559 *
15560 * // The `_.matchesProperty` iteratee shorthand.
15561 * _.filter(users, _.iteratee(['user', 'fred']));
15562 * // => [{ 'user': 'fred', 'age': 40 }]
15563 *
15564 * // The `_.property` iteratee shorthand.
15565 * _.map(users, _.iteratee('user'));
15566 * // => ['barney', 'fred']
15567 *
15568 * // Create custom iteratee shorthands.
15569 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
15570 * return !_.isRegExp(func) ? iteratee(func) : function(string) {
15571 * return func.test(string);
15572 * };
15573 * });
15574 *
15575 * _.filter(['abc', 'def'], /ef/);
15576 * // => ['def']
15577 */
15578 function iteratee(func) {
15579 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
15580 }
15581
15582 /**
15583 * Creates a function that performs a partial deep comparison between a given
15584 * object and `source`, returning `true` if the given object has equivalent
15585 * property values, else `false`.
15586 *
15587 * **Note:** The created function is equivalent to `_.isMatch` with `source`
15588 * partially applied.
15589 *
15590 * Partial comparisons will match empty array and empty object `source`
15591 * values against any array or object value, respectively. See `_.isEqual`
15592 * for a list of supported value comparisons.
15593 *
15594 * **Note:** Multiple values can be checked by combining several matchers
15595 * using `_.overSome`
15596 *
15597 * @static
15598 * @memberOf _
15599 * @since 3.0.0
15600 * @category Util
15601 * @param {Object} source The object of property values to match.
15602 * @returns {Function} Returns the new spec function.
15603 * @example
15604 *
15605 * var objects = [
15606 * { 'a': 1, 'b': 2, 'c': 3 },
15607 * { 'a': 4, 'b': 5, 'c': 6 }
15608 * ];
15609 *
15610 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
15611 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
15612 *
15613 * // Checking for several possible values
15614 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
15615 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
15616 */
15617 function matches(source) {
15618 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
15619 }
15620
15621 /**
15622 * Creates a function that performs a partial deep comparison between the
15623 * value at `path` of a given object to `srcValue`, returning `true` if the
15624 * object value is equivalent, else `false`.
15625 *
15626 * **Note:** Partial comparisons will match empty array and empty object
15627 * `srcValue` values against any array or object value, respectively. See
15628 * `_.isEqual` for a list of supported value comparisons.
15629 *
15630 * **Note:** Multiple values can be checked by combining several matchers
15631 * using `_.overSome`
15632 *
15633 * @static
15634 * @memberOf _
15635 * @since 3.2.0
15636 * @category Util
15637 * @param {Array|string} path The path of the property to get.
15638 * @param {*} srcValue The value to match.
15639 * @returns {Function} Returns the new spec function.
15640 * @example
15641 *
15642 * var objects = [
15643 * { 'a': 1, 'b': 2, 'c': 3 },
15644 * { 'a': 4, 'b': 5, 'c': 6 }
15645 * ];
15646 *
15647 * _.find(objects, _.matchesProperty('a', 4));
15648 * // => { 'a': 4, 'b': 5, 'c': 6 }
15649 *
15650 * // Checking for several possible values
15651 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
15652 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
15653 */
15654 function matchesProperty(path, srcValue) {
15655 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
15656 }
15657
15658 /**
15659 * Creates a function that invokes the method at `path` of a given object.
15660 * Any additional arguments are provided to the invoked method.
15661 *
15662 * @static
15663 * @memberOf _
15664 * @since 3.7.0
15665 * @category Util
15666 * @param {Array|string} path The path of the method to invoke.
15667 * @param {...*} [args] The arguments to invoke the method with.
15668 * @returns {Function} Returns the new invoker function.
15669 * @example
15670 *
15671 * var objects = [
15672 * { 'a': { 'b': _.constant(2) } },
15673 * { 'a': { 'b': _.constant(1) } }
15674 * ];
15675 *
15676 * _.map(objects, _.method('a.b'));
15677 * // => [2, 1]
15678 *
15679 * _.map(objects, _.method(['a', 'b']));
15680 * // => [2, 1]
15681 */
15682 var method = baseRest(function(path, args) {
15683 return function(object) {
15684 return baseInvoke(object, path, args);
15685 };
15686 });
15687
15688 /**
15689 * The opposite of `_.method`; this method creates a function that invokes
15690 * the method at a given path of `object`. Any additional arguments are
15691 * provided to the invoked method.
15692 *
15693 * @static
15694 * @memberOf _
15695 * @since 3.7.0
15696 * @category Util
15697 * @param {Object} object The object to query.
15698 * @param {...*} [args] The arguments to invoke the method with.
15699 * @returns {Function} Returns the new invoker function.
15700 * @example
15701 *
15702 * var array = _.times(3, _.constant),
15703 * object = { 'a': array, 'b': array, 'c': array };
15704 *
15705 * _.map(['a[2]', 'c[0]'], _.methodOf(object));
15706 * // => [2, 0]
15707 *
15708 * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
15709 * // => [2, 0]
15710 */
15711 var methodOf = baseRest(function(object, args) {
15712 return function(path) {
15713 return baseInvoke(object, path, args);
15714 };
15715 });
15716
15717 /**
15718 * Adds all own enumerable string keyed function properties of a source
15719 * object to the destination object. If `object` is a function, then methods
15720 * are added to its prototype as well.
15721 *
15722 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
15723 * avoid conflicts caused by modifying the original.
15724 *
15725 * @static
15726 * @since 0.1.0
15727 * @memberOf _
15728 * @category Util
15729 * @param {Function|Object} [object=lodash] The destination object.
15730 * @param {Object} source The object of functions to add.
15731 * @param {Object} [options={}] The options object.
15732 * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
15733 * @returns {Function|Object} Returns `object`.
15734 * @example
15735 *
15736 * function vowels(string) {
15737 * return _.filter(string, function(v) {
15738 * return /[aeiou]/i.test(v);
15739 * });
15740 * }
15741 *
15742 * _.mixin({ 'vowels': vowels });
15743 * _.vowels('fred');
15744 * // => ['e']
15745 *
15746 * _('fred').vowels().value();
15747 * // => ['e']
15748 *
15749 * _.mixin({ 'vowels': vowels }, { 'chain': false });
15750 * _('fred').vowels();
15751 * // => ['e']
15752 */
15753 function mixin(object, source, options) {
15754 var props = keys(source),
15755 methodNames = baseFunctions(source, props);
15756
15757 if (options == null &&
15758 !(isObject(source) && (methodNames.length || !props.length))) {
15759 options = source;
15760 source = object;
15761 object = this;
15762 methodNames = baseFunctions(source, keys(source));
15763 }
15764 var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
15765 isFunc = isFunction(object);
15766
15767 arrayEach(methodNames, function(methodName) {
15768 var func = source[methodName];
15769 object[methodName] = func;
15770 if (isFunc) {
15771 object.prototype[methodName] = function() {
15772 var chainAll = this.__chain__;
15773 if (chain || chainAll) {
15774 var result = object(this.__wrapped__),
15775 actions = result.__actions__ = copyArray(this.__actions__);
15776
15777 actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
15778 result.__chain__ = chainAll;
15779 return result;
15780 }
15781 return func.apply(object, arrayPush([this.value()], arguments));
15782 };
15783 }
15784 });
15785
15786 return object;
15787 }
15788
15789 /**
15790 * Reverts the `_` variable to its previous value and returns a reference to
15791 * the `lodash` function.
15792 *
15793 * @static
15794 * @since 0.1.0
15795 * @memberOf _
15796 * @category Util
15797 * @returns {Function} Returns the `lodash` function.
15798 * @example
15799 *
15800 * var lodash = _.noConflict();
15801 */
15802 function noConflict() {
15803 if (root._ === this) {
15804 root._ = oldDash;
15805 }
15806 return this;
15807 }
15808
15809 /**
15810 * This method returns `undefined`.
15811 *
15812 * @static
15813 * @memberOf _
15814 * @since 2.3.0
15815 * @category Util
15816 * @example
15817 *
15818 * _.times(2, _.noop);
15819 * // => [undefined, undefined]
15820 */
15821 function noop() {
15822 // No operation performed.
15823 }
15824
15825 /**
15826 * Creates a function that gets the argument at index `n`. If `n` is negative,
15827 * the nth argument from the end is returned.
15828 *
15829 * @static
15830 * @memberOf _
15831 * @since 4.0.0
15832 * @category Util
15833 * @param {number} [n=0] The index of the argument to return.
15834 * @returns {Function} Returns the new pass-thru function.
15835 * @example
15836 *
15837 * var func = _.nthArg(1);
15838 * func('a', 'b', 'c', 'd');
15839 * // => 'b'
15840 *
15841 * var func = _.nthArg(-2);
15842 * func('a', 'b', 'c', 'd');
15843 * // => 'c'
15844 */
15845 function nthArg(n) {
15846 n = toInteger(n);
15847 return baseRest(function(args) {
15848 return baseNth(args, n);
15849 });
15850 }
15851
15852 /**
15853 * Creates a function that invokes `iteratees` with the arguments it receives
15854 * and returns their results.
15855 *
15856 * @static
15857 * @memberOf _
15858 * @since 4.0.0
15859 * @category Util
15860 * @param {...(Function|Function[])} [iteratees=[_.identity]]
15861 * The iteratees to invoke.
15862 * @returns {Function} Returns the new function.
15863 * @example
15864 *
15865 * var func = _.over([Math.max, Math.min]);
15866 *
15867 * func(1, 2, 3, 4);
15868 * // => [4, 1]
15869 */
15870 var over = createOver(arrayMap);
15871
15872 /**
15873 * Creates a function that checks if **all** of the `predicates` return
15874 * truthy when invoked with the arguments it receives.
15875 *
15876 * Following shorthands are possible for providing predicates.
15877 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
15878 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
15879 *
15880 * @static
15881 * @memberOf _
15882 * @since 4.0.0
15883 * @category Util
15884 * @param {...(Function|Function[])} [predicates=[_.identity]]
15885 * The predicates to check.
15886 * @returns {Function} Returns the new function.
15887 * @example
15888 *
15889 * var func = _.overEvery([Boolean, isFinite]);
15890 *
15891 * func('1');
15892 * // => true
15893 *
15894 * func(null);
15895 * // => false
15896 *
15897 * func(NaN);
15898 * // => false
15899 */
15900 var overEvery = createOver(arrayEvery);
15901
15902 /**
15903 * Creates a function that checks if **any** of the `predicates` return
15904 * truthy when invoked with the arguments it receives.
15905 *
15906 * Following shorthands are possible for providing predicates.
15907 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
15908 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
15909 *
15910 * @static
15911 * @memberOf _
15912 * @since 4.0.0
15913 * @category Util
15914 * @param {...(Function|Function[])} [predicates=[_.identity]]
15915 * The predicates to check.
15916 * @returns {Function} Returns the new function.
15917 * @example
15918 *
15919 * var func = _.overSome([Boolean, isFinite]);
15920 *
15921 * func('1');
15922 * // => true
15923 *
15924 * func(null);
15925 * // => true
15926 *
15927 * func(NaN);
15928 * // => false
15929 *
15930 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
15931 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
15932 */
15933 var overSome = createOver(arraySome);
15934
15935 /**
15936 * Creates a function that returns the value at `path` of a given object.
15937 *
15938 * @static
15939 * @memberOf _
15940 * @since 2.4.0
15941 * @category Util
15942 * @param {Array|string} path The path of the property to get.
15943 * @returns {Function} Returns the new accessor function.
15944 * @example
15945 *
15946 * var objects = [
15947 * { 'a': { 'b': 2 } },
15948 * { 'a': { 'b': 1 } }
15949 * ];
15950 *
15951 * _.map(objects, _.property('a.b'));
15952 * // => [2, 1]
15953 *
15954 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
15955 * // => [1, 2]
15956 */
15957 function property(path) {
15958 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
15959 }
15960
15961 /**
15962 * The opposite of `_.property`; this method creates a function that returns
15963 * the value at a given path of `object`.
15964 *
15965 * @static
15966 * @memberOf _
15967 * @since 3.0.0
15968 * @category Util
15969 * @param {Object} object The object to query.
15970 * @returns {Function} Returns the new accessor function.
15971 * @example
15972 *
15973 * var array = [0, 1, 2],
15974 * object = { 'a': array, 'b': array, 'c': array };
15975 *
15976 * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
15977 * // => [2, 0]
15978 *
15979 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
15980 * // => [2, 0]
15981 */
15982 function propertyOf(object) {
15983 return function(path) {
15984 return object == null ? undefined$1 : baseGet(object, path);
15985 };
15986 }
15987
15988 /**
15989 * Creates an array of numbers (positive and/or negative) progressing from
15990 * `start` up to, but not including, `end`. A step of `-1` is used if a negative
15991 * `start` is specified without an `end` or `step`. If `end` is not specified,
15992 * it's set to `start` with `start` then set to `0`.
15993 *
15994 * **Note:** JavaScript follows the IEEE-754 standard for resolving
15995 * floating-point values which can produce unexpected results.
15996 *
15997 * @static
15998 * @since 0.1.0
15999 * @memberOf _
16000 * @category Util
16001 * @param {number} [start=0] The start of the range.
16002 * @param {number} end The end of the range.
16003 * @param {number} [step=1] The value to increment or decrement by.
16004 * @returns {Array} Returns the range of numbers.
16005 * @see _.inRange, _.rangeRight
16006 * @example
16007 *
16008 * _.range(4);
16009 * // => [0, 1, 2, 3]
16010 *
16011 * _.range(-4);
16012 * // => [0, -1, -2, -3]
16013 *
16014 * _.range(1, 5);
16015 * // => [1, 2, 3, 4]
16016 *
16017 * _.range(0, 20, 5);
16018 * // => [0, 5, 10, 15]
16019 *
16020 * _.range(0, -4, -1);
16021 * // => [0, -1, -2, -3]
16022 *
16023 * _.range(1, 4, 0);
16024 * // => [1, 1, 1]
16025 *
16026 * _.range(0);
16027 * // => []
16028 */
16029 var range = createRange();
16030
16031 /**
16032 * This method is like `_.range` except that it populates values in
16033 * descending order.
16034 *
16035 * @static
16036 * @memberOf _
16037 * @since 4.0.0
16038 * @category Util
16039 * @param {number} [start=0] The start of the range.
16040 * @param {number} end The end of the range.
16041 * @param {number} [step=1] The value to increment or decrement by.
16042 * @returns {Array} Returns the range of numbers.
16043 * @see _.inRange, _.range
16044 * @example
16045 *
16046 * _.rangeRight(4);
16047 * // => [3, 2, 1, 0]
16048 *
16049 * _.rangeRight(-4);
16050 * // => [-3, -2, -1, 0]
16051 *
16052 * _.rangeRight(1, 5);
16053 * // => [4, 3, 2, 1]
16054 *
16055 * _.rangeRight(0, 20, 5);
16056 * // => [15, 10, 5, 0]
16057 *
16058 * _.rangeRight(0, -4, -1);
16059 * // => [-3, -2, -1, 0]
16060 *
16061 * _.rangeRight(1, 4, 0);
16062 * // => [1, 1, 1]
16063 *
16064 * _.rangeRight(0);
16065 * // => []
16066 */
16067 var rangeRight = createRange(true);
16068
16069 /**
16070 * This method returns a new empty array.
16071 *
16072 * @static
16073 * @memberOf _
16074 * @since 4.13.0
16075 * @category Util
16076 * @returns {Array} Returns the new empty array.
16077 * @example
16078 *
16079 * var arrays = _.times(2, _.stubArray);
16080 *
16081 * console.log(arrays);
16082 * // => [[], []]
16083 *
16084 * console.log(arrays[0] === arrays[1]);
16085 * // => false
16086 */
16087 function stubArray() {
16088 return [];
16089 }
16090
16091 /**
16092 * This method returns `false`.
16093 *
16094 * @static
16095 * @memberOf _
16096 * @since 4.13.0
16097 * @category Util
16098 * @returns {boolean} Returns `false`.
16099 * @example
16100 *
16101 * _.times(2, _.stubFalse);
16102 * // => [false, false]
16103 */
16104 function stubFalse() {
16105 return false;
16106 }
16107
16108 /**
16109 * This method returns a new empty object.
16110 *
16111 * @static
16112 * @memberOf _
16113 * @since 4.13.0
16114 * @category Util
16115 * @returns {Object} Returns the new empty object.
16116 * @example
16117 *
16118 * var objects = _.times(2, _.stubObject);
16119 *
16120 * console.log(objects);
16121 * // => [{}, {}]
16122 *
16123 * console.log(objects[0] === objects[1]);
16124 * // => false
16125 */
16126 function stubObject() {
16127 return {};
16128 }
16129
16130 /**
16131 * This method returns an empty string.
16132 *
16133 * @static
16134 * @memberOf _
16135 * @since 4.13.0
16136 * @category Util
16137 * @returns {string} Returns the empty string.
16138 * @example
16139 *
16140 * _.times(2, _.stubString);
16141 * // => ['', '']
16142 */
16143 function stubString() {
16144 return '';
16145 }
16146
16147 /**
16148 * This method returns `true`.
16149 *
16150 * @static
16151 * @memberOf _
16152 * @since 4.13.0
16153 * @category Util
16154 * @returns {boolean} Returns `true`.
16155 * @example
16156 *
16157 * _.times(2, _.stubTrue);
16158 * // => [true, true]
16159 */
16160 function stubTrue() {
16161 return true;
16162 }
16163
16164 /**
16165 * Invokes the iteratee `n` times, returning an array of the results of
16166 * each invocation. The iteratee is invoked with one argument; (index).
16167 *
16168 * @static
16169 * @since 0.1.0
16170 * @memberOf _
16171 * @category Util
16172 * @param {number} n The number of times to invoke `iteratee`.
16173 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
16174 * @returns {Array} Returns the array of results.
16175 * @example
16176 *
16177 * _.times(3, String);
16178 * // => ['0', '1', '2']
16179 *
16180 * _.times(4, _.constant(0));
16181 * // => [0, 0, 0, 0]
16182 */
16183 function times(n, iteratee) {
16184 n = toInteger(n);
16185 if (n < 1 || n > MAX_SAFE_INTEGER) {
16186 return [];
16187 }
16188 var index = MAX_ARRAY_LENGTH,
16189 length = nativeMin(n, MAX_ARRAY_LENGTH);
16190
16191 iteratee = getIteratee(iteratee);
16192 n -= MAX_ARRAY_LENGTH;
16193
16194 var result = baseTimes(length, iteratee);
16195 while (++index < n) {
16196 iteratee(index);
16197 }
16198 return result;
16199 }
16200
16201 /**
16202 * Converts `value` to a property path array.
16203 *
16204 * @static
16205 * @memberOf _
16206 * @since 4.0.0
16207 * @category Util
16208 * @param {*} value The value to convert.
16209 * @returns {Array} Returns the new property path array.
16210 * @example
16211 *
16212 * _.toPath('a.b.c');
16213 * // => ['a', 'b', 'c']
16214 *
16215 * _.toPath('a[0].b.c');
16216 * // => ['a', '0', 'b', 'c']
16217 */
16218 function toPath(value) {
16219 if (isArray(value)) {
16220 return arrayMap(value, toKey);
16221 }
16222 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
16223 }
16224
16225 /**
16226 * Generates a unique ID. If `prefix` is given, the ID is appended to it.
16227 *
16228 * @static
16229 * @since 0.1.0
16230 * @memberOf _
16231 * @category Util
16232 * @param {string} [prefix=''] The value to prefix the ID with.
16233 * @returns {string} Returns the unique ID.
16234 * @example
16235 *
16236 * _.uniqueId('contact_');
16237 * // => 'contact_104'
16238 *
16239 * _.uniqueId();
16240 * // => '105'
16241 */
16242 function uniqueId(prefix) {
16243 var id = ++idCounter;
16244 return toString(prefix) + id;
16245 }
16246
16247 /*------------------------------------------------------------------------*/
16248
16249 /**
16250 * Adds two numbers.
16251 *
16252 * @static
16253 * @memberOf _
16254 * @since 3.4.0
16255 * @category Math
16256 * @param {number} augend The first number in an addition.
16257 * @param {number} addend The second number in an addition.
16258 * @returns {number} Returns the total.
16259 * @example
16260 *
16261 * _.add(6, 4);
16262 * // => 10
16263 */
16264 var add = createMathOperation(function(augend, addend) {
16265 return augend + addend;
16266 }, 0);
16267
16268 /**
16269 * Computes `number` rounded up to `precision`.
16270 *
16271 * @static
16272 * @memberOf _
16273 * @since 3.10.0
16274 * @category Math
16275 * @param {number} number The number to round up.
16276 * @param {number} [precision=0] The precision to round up to.
16277 * @returns {number} Returns the rounded up number.
16278 * @example
16279 *
16280 * _.ceil(4.006);
16281 * // => 5
16282 *
16283 * _.ceil(6.004, 2);
16284 * // => 6.01
16285 *
16286 * _.ceil(6040, -2);
16287 * // => 6100
16288 */
16289 var ceil = createRound('ceil');
16290
16291 /**
16292 * Divide two numbers.
16293 *
16294 * @static
16295 * @memberOf _
16296 * @since 4.7.0
16297 * @category Math
16298 * @param {number} dividend The first number in a division.
16299 * @param {number} divisor The second number in a division.
16300 * @returns {number} Returns the quotient.
16301 * @example
16302 *
16303 * _.divide(6, 4);
16304 * // => 1.5
16305 */
16306 var divide = createMathOperation(function(dividend, divisor) {
16307 return dividend / divisor;
16308 }, 1);
16309
16310 /**
16311 * Computes `number` rounded down to `precision`.
16312 *
16313 * @static
16314 * @memberOf _
16315 * @since 3.10.0
16316 * @category Math
16317 * @param {number} number The number to round down.
16318 * @param {number} [precision=0] The precision to round down to.
16319 * @returns {number} Returns the rounded down number.
16320 * @example
16321 *
16322 * _.floor(4.006);
16323 * // => 4
16324 *
16325 * _.floor(0.046, 2);
16326 * // => 0.04
16327 *
16328 * _.floor(4060, -2);
16329 * // => 4000
16330 */
16331 var floor = createRound('floor');
16332
16333 /**
16334 * Computes the maximum value of `array`. If `array` is empty or falsey,
16335 * `undefined` is returned.
16336 *
16337 * @static
16338 * @since 0.1.0
16339 * @memberOf _
16340 * @category Math
16341 * @param {Array} array The array to iterate over.
16342 * @returns {*} Returns the maximum value.
16343 * @example
16344 *
16345 * _.max([4, 2, 8, 6]);
16346 * // => 8
16347 *
16348 * _.max([]);
16349 * // => undefined
16350 */
16351 function max(array) {
16352 return (array && array.length)
16353 ? baseExtremum(array, identity, baseGt)
16354 : undefined$1;
16355 }
16356
16357 /**
16358 * This method is like `_.max` except that it accepts `iteratee` which is
16359 * invoked for each element in `array` to generate the criterion by which
16360 * the value is ranked. The iteratee is invoked with one argument: (value).
16361 *
16362 * @static
16363 * @memberOf _
16364 * @since 4.0.0
16365 * @category Math
16366 * @param {Array} array The array to iterate over.
16367 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16368 * @returns {*} Returns the maximum value.
16369 * @example
16370 *
16371 * var objects = [{ 'n': 1 }, { 'n': 2 }];
16372 *
16373 * _.maxBy(objects, function(o) { return o.n; });
16374 * // => { 'n': 2 }
16375 *
16376 * // The `_.property` iteratee shorthand.
16377 * _.maxBy(objects, 'n');
16378 * // => { 'n': 2 }
16379 */
16380 function maxBy(array, iteratee) {
16381 return (array && array.length)
16382 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
16383 : undefined$1;
16384 }
16385
16386 /**
16387 * Computes the mean of the values in `array`.
16388 *
16389 * @static
16390 * @memberOf _
16391 * @since 4.0.0
16392 * @category Math
16393 * @param {Array} array The array to iterate over.
16394 * @returns {number} Returns the mean.
16395 * @example
16396 *
16397 * _.mean([4, 2, 8, 6]);
16398 * // => 5
16399 */
16400 function mean(array) {
16401 return baseMean(array, identity);
16402 }
16403
16404 /**
16405 * This method is like `_.mean` except that it accepts `iteratee` which is
16406 * invoked for each element in `array` to generate the value to be averaged.
16407 * The iteratee is invoked with one argument: (value).
16408 *
16409 * @static
16410 * @memberOf _
16411 * @since 4.7.0
16412 * @category Math
16413 * @param {Array} array The array to iterate over.
16414 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16415 * @returns {number} Returns the mean.
16416 * @example
16417 *
16418 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16419 *
16420 * _.meanBy(objects, function(o) { return o.n; });
16421 * // => 5
16422 *
16423 * // The `_.property` iteratee shorthand.
16424 * _.meanBy(objects, 'n');
16425 * // => 5
16426 */
16427 function meanBy(array, iteratee) {
16428 return baseMean(array, getIteratee(iteratee, 2));
16429 }
16430
16431 /**
16432 * Computes the minimum value of `array`. If `array` is empty or falsey,
16433 * `undefined` is returned.
16434 *
16435 * @static
16436 * @since 0.1.0
16437 * @memberOf _
16438 * @category Math
16439 * @param {Array} array The array to iterate over.
16440 * @returns {*} Returns the minimum value.
16441 * @example
16442 *
16443 * _.min([4, 2, 8, 6]);
16444 * // => 2
16445 *
16446 * _.min([]);
16447 * // => undefined
16448 */
16449 function min(array) {
16450 return (array && array.length)
16451 ? baseExtremum(array, identity, baseLt)
16452 : undefined$1;
16453 }
16454
16455 /**
16456 * This method is like `_.min` except that it accepts `iteratee` which is
16457 * invoked for each element in `array` to generate the criterion by which
16458 * the value is ranked. The iteratee is invoked with one argument: (value).
16459 *
16460 * @static
16461 * @memberOf _
16462 * @since 4.0.0
16463 * @category Math
16464 * @param {Array} array The array to iterate over.
16465 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16466 * @returns {*} Returns the minimum value.
16467 * @example
16468 *
16469 * var objects = [{ 'n': 1 }, { 'n': 2 }];
16470 *
16471 * _.minBy(objects, function(o) { return o.n; });
16472 * // => { 'n': 1 }
16473 *
16474 * // The `_.property` iteratee shorthand.
16475 * _.minBy(objects, 'n');
16476 * // => { 'n': 1 }
16477 */
16478 function minBy(array, iteratee) {
16479 return (array && array.length)
16480 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
16481 : undefined$1;
16482 }
16483
16484 /**
16485 * Multiply two numbers.
16486 *
16487 * @static
16488 * @memberOf _
16489 * @since 4.7.0
16490 * @category Math
16491 * @param {number} multiplier The first number in a multiplication.
16492 * @param {number} multiplicand The second number in a multiplication.
16493 * @returns {number} Returns the product.
16494 * @example
16495 *
16496 * _.multiply(6, 4);
16497 * // => 24
16498 */
16499 var multiply = createMathOperation(function(multiplier, multiplicand) {
16500 return multiplier * multiplicand;
16501 }, 1);
16502
16503 /**
16504 * Computes `number` rounded to `precision`.
16505 *
16506 * @static
16507 * @memberOf _
16508 * @since 3.10.0
16509 * @category Math
16510 * @param {number} number The number to round.
16511 * @param {number} [precision=0] The precision to round to.
16512 * @returns {number} Returns the rounded number.
16513 * @example
16514 *
16515 * _.round(4.006);
16516 * // => 4
16517 *
16518 * _.round(4.006, 2);
16519 * // => 4.01
16520 *
16521 * _.round(4060, -2);
16522 * // => 4100
16523 */
16524 var round = createRound('round');
16525
16526 /**
16527 * Subtract two numbers.
16528 *
16529 * @static
16530 * @memberOf _
16531 * @since 4.0.0
16532 * @category Math
16533 * @param {number} minuend The first number in a subtraction.
16534 * @param {number} subtrahend The second number in a subtraction.
16535 * @returns {number} Returns the difference.
16536 * @example
16537 *
16538 * _.subtract(6, 4);
16539 * // => 2
16540 */
16541 var subtract = createMathOperation(function(minuend, subtrahend) {
16542 return minuend - subtrahend;
16543 }, 0);
16544
16545 /**
16546 * Computes the sum of the values in `array`.
16547 *
16548 * @static
16549 * @memberOf _
16550 * @since 3.4.0
16551 * @category Math
16552 * @param {Array} array The array to iterate over.
16553 * @returns {number} Returns the sum.
16554 * @example
16555 *
16556 * _.sum([4, 2, 8, 6]);
16557 * // => 20
16558 */
16559 function sum(array) {
16560 return (array && array.length)
16561 ? baseSum(array, identity)
16562 : 0;
16563 }
16564
16565 /**
16566 * This method is like `_.sum` except that it accepts `iteratee` which is
16567 * invoked for each element in `array` to generate the value to be summed.
16568 * The iteratee is invoked with one argument: (value).
16569 *
16570 * @static
16571 * @memberOf _
16572 * @since 4.0.0
16573 * @category Math
16574 * @param {Array} array The array to iterate over.
16575 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
16576 * @returns {number} Returns the sum.
16577 * @example
16578 *
16579 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
16580 *
16581 * _.sumBy(objects, function(o) { return o.n; });
16582 * // => 20
16583 *
16584 * // The `_.property` iteratee shorthand.
16585 * _.sumBy(objects, 'n');
16586 * // => 20
16587 */
16588 function sumBy(array, iteratee) {
16589 return (array && array.length)
16590 ? baseSum(array, getIteratee(iteratee, 2))
16591 : 0;
16592 }
16593
16594 /*------------------------------------------------------------------------*/
16595
16596 // Add methods that return wrapped values in chain sequences.
16597 lodash.after = after;
16598 lodash.ary = ary;
16599 lodash.assign = assign;
16600 lodash.assignIn = assignIn;
16601 lodash.assignInWith = assignInWith;
16602 lodash.assignWith = assignWith;
16603 lodash.at = at;
16604 lodash.before = before;
16605 lodash.bind = bind;
16606 lodash.bindAll = bindAll;
16607 lodash.bindKey = bindKey;
16608 lodash.castArray = castArray;
16609 lodash.chain = chain;
16610 lodash.chunk = chunk;
16611 lodash.compact = compact;
16612 lodash.concat = concat;
16613 lodash.cond = cond;
16614 lodash.conforms = conforms;
16615 lodash.constant = constant;
16616 lodash.countBy = countBy;
16617 lodash.create = create;
16618 lodash.curry = curry;
16619 lodash.curryRight = curryRight;
16620 lodash.debounce = debounce;
16621 lodash.defaults = defaults;
16622 lodash.defaultsDeep = defaultsDeep;
16623 lodash.defer = defer;
16624 lodash.delay = delay;
16625 lodash.difference = difference;
16626 lodash.differenceBy = differenceBy;
16627 lodash.differenceWith = differenceWith;
16628 lodash.drop = drop;
16629 lodash.dropRight = dropRight;
16630 lodash.dropRightWhile = dropRightWhile;
16631 lodash.dropWhile = dropWhile;
16632 lodash.fill = fill;
16633 lodash.filter = filter;
16634 lodash.flatMap = flatMap;
16635 lodash.flatMapDeep = flatMapDeep;
16636 lodash.flatMapDepth = flatMapDepth;
16637 lodash.flatten = flatten;
16638 lodash.flattenDeep = flattenDeep;
16639 lodash.flattenDepth = flattenDepth;
16640 lodash.flip = flip;
16641 lodash.flow = flow;
16642 lodash.flowRight = flowRight;
16643 lodash.fromPairs = fromPairs;
16644 lodash.functions = functions;
16645 lodash.functionsIn = functionsIn;
16646 lodash.groupBy = groupBy;
16647 lodash.initial = initial;
16648 lodash.intersection = intersection;
16649 lodash.intersectionBy = intersectionBy;
16650 lodash.intersectionWith = intersectionWith;
16651 lodash.invert = invert;
16652 lodash.invertBy = invertBy;
16653 lodash.invokeMap = invokeMap;
16654 lodash.iteratee = iteratee;
16655 lodash.keyBy = keyBy;
16656 lodash.keys = keys;
16657 lodash.keysIn = keysIn;
16658 lodash.map = map;
16659 lodash.mapKeys = mapKeys;
16660 lodash.mapValues = mapValues;
16661 lodash.matches = matches;
16662 lodash.matchesProperty = matchesProperty;
16663 lodash.memoize = memoize;
16664 lodash.merge = merge;
16665 lodash.mergeWith = mergeWith;
16666 lodash.method = method;
16667 lodash.methodOf = methodOf;
16668 lodash.mixin = mixin;
16669 lodash.negate = negate;
16670 lodash.nthArg = nthArg;
16671 lodash.omit = omit;
16672 lodash.omitBy = omitBy;
16673 lodash.once = once;
16674 lodash.orderBy = orderBy;
16675 lodash.over = over;
16676 lodash.overArgs = overArgs;
16677 lodash.overEvery = overEvery;
16678 lodash.overSome = overSome;
16679 lodash.partial = partial;
16680 lodash.partialRight = partialRight;
16681 lodash.partition = partition;
16682 lodash.pick = pick;
16683 lodash.pickBy = pickBy;
16684 lodash.property = property;
16685 lodash.propertyOf = propertyOf;
16686 lodash.pull = pull;
16687 lodash.pullAll = pullAll;
16688 lodash.pullAllBy = pullAllBy;
16689 lodash.pullAllWith = pullAllWith;
16690 lodash.pullAt = pullAt;
16691 lodash.range = range;
16692 lodash.rangeRight = rangeRight;
16693 lodash.rearg = rearg;
16694 lodash.reject = reject;
16695 lodash.remove = remove;
16696 lodash.rest = rest;
16697 lodash.reverse = reverse;
16698 lodash.sampleSize = sampleSize;
16699 lodash.set = set;
16700 lodash.setWith = setWith;
16701 lodash.shuffle = shuffle;
16702 lodash.slice = slice;
16703 lodash.sortBy = sortBy;
16704 lodash.sortedUniq = sortedUniq;
16705 lodash.sortedUniqBy = sortedUniqBy;
16706 lodash.split = split;
16707 lodash.spread = spread;
16708 lodash.tail = tail;
16709 lodash.take = take;
16710 lodash.takeRight = takeRight;
16711 lodash.takeRightWhile = takeRightWhile;
16712 lodash.takeWhile = takeWhile;
16713 lodash.tap = tap;
16714 lodash.throttle = throttle;
16715 lodash.thru = thru;
16716 lodash.toArray = toArray;
16717 lodash.toPairs = toPairs;
16718 lodash.toPairsIn = toPairsIn;
16719 lodash.toPath = toPath;
16720 lodash.toPlainObject = toPlainObject;
16721 lodash.transform = transform;
16722 lodash.unary = unary;
16723 lodash.union = union;
16724 lodash.unionBy = unionBy;
16725 lodash.unionWith = unionWith;
16726 lodash.uniq = uniq;
16727 lodash.uniqBy = uniqBy;
16728 lodash.uniqWith = uniqWith;
16729 lodash.unset = unset;
16730 lodash.unzip = unzip;
16731 lodash.unzipWith = unzipWith;
16732 lodash.update = update;
16733 lodash.updateWith = updateWith;
16734 lodash.values = values;
16735 lodash.valuesIn = valuesIn;
16736 lodash.without = without;
16737 lodash.words = words;
16738 lodash.wrap = wrap;
16739 lodash.xor = xor;
16740 lodash.xorBy = xorBy;
16741 lodash.xorWith = xorWith;
16742 lodash.zip = zip;
16743 lodash.zipObject = zipObject;
16744 lodash.zipObjectDeep = zipObjectDeep;
16745 lodash.zipWith = zipWith;
16746
16747 // Add aliases.
16748 lodash.entries = toPairs;
16749 lodash.entriesIn = toPairsIn;
16750 lodash.extend = assignIn;
16751 lodash.extendWith = assignInWith;
16752
16753 // Add methods to `lodash.prototype`.
16754 mixin(lodash, lodash);
16755
16756 /*------------------------------------------------------------------------*/
16757
16758 // Add methods that return unwrapped values in chain sequences.
16759 lodash.add = add;
16760 lodash.attempt = attempt;
16761 lodash.camelCase = camelCase;
16762 lodash.capitalize = capitalize;
16763 lodash.ceil = ceil;
16764 lodash.clamp = clamp;
16765 lodash.clone = clone;
16766 lodash.cloneDeep = cloneDeep;
16767 lodash.cloneDeepWith = cloneDeepWith;
16768 lodash.cloneWith = cloneWith;
16769 lodash.conformsTo = conformsTo;
16770 lodash.deburr = deburr;
16771 lodash.defaultTo = defaultTo;
16772 lodash.divide = divide;
16773 lodash.endsWith = endsWith;
16774 lodash.eq = eq;
16775 lodash.escape = escape;
16776 lodash.escapeRegExp = escapeRegExp;
16777 lodash.every = every;
16778 lodash.find = find;
16779 lodash.findIndex = findIndex;
16780 lodash.findKey = findKey;
16781 lodash.findLast = findLast;
16782 lodash.findLastIndex = findLastIndex;
16783 lodash.findLastKey = findLastKey;
16784 lodash.floor = floor;
16785 lodash.forEach = forEach;
16786 lodash.forEachRight = forEachRight;
16787 lodash.forIn = forIn;
16788 lodash.forInRight = forInRight;
16789 lodash.forOwn = forOwn;
16790 lodash.forOwnRight = forOwnRight;
16791 lodash.get = get;
16792 lodash.gt = gt;
16793 lodash.gte = gte;
16794 lodash.has = has;
16795 lodash.hasIn = hasIn;
16796 lodash.head = head;
16797 lodash.identity = identity;
16798 lodash.includes = includes;
16799 lodash.indexOf = indexOf;
16800 lodash.inRange = inRange;
16801 lodash.invoke = invoke;
16802 lodash.isArguments = isArguments;
16803 lodash.isArray = isArray;
16804 lodash.isArrayBuffer = isArrayBuffer;
16805 lodash.isArrayLike = isArrayLike;
16806 lodash.isArrayLikeObject = isArrayLikeObject;
16807 lodash.isBoolean = isBoolean;
16808 lodash.isBuffer = isBuffer;
16809 lodash.isDate = isDate;
16810 lodash.isElement = isElement;
16811 lodash.isEmpty = isEmpty;
16812 lodash.isEqual = isEqual;
16813 lodash.isEqualWith = isEqualWith;
16814 lodash.isError = isError;
16815 lodash.isFinite = isFinite;
16816 lodash.isFunction = isFunction;
16817 lodash.isInteger = isInteger;
16818 lodash.isLength = isLength;
16819 lodash.isMap = isMap;
16820 lodash.isMatch = isMatch;
16821 lodash.isMatchWith = isMatchWith;
16822 lodash.isNaN = isNaN;
16823 lodash.isNative = isNative;
16824 lodash.isNil = isNil;
16825 lodash.isNull = isNull;
16826 lodash.isNumber = isNumber;
16827 lodash.isObject = isObject;
16828 lodash.isObjectLike = isObjectLike;
16829 lodash.isPlainObject = isPlainObject;
16830 lodash.isRegExp = isRegExp;
16831 lodash.isSafeInteger = isSafeInteger;
16832 lodash.isSet = isSet;
16833 lodash.isString = isString;
16834 lodash.isSymbol = isSymbol;
16835 lodash.isTypedArray = isTypedArray;
16836 lodash.isUndefined = isUndefined;
16837 lodash.isWeakMap = isWeakMap;
16838 lodash.isWeakSet = isWeakSet;
16839 lodash.join = join;
16840 lodash.kebabCase = kebabCase;
16841 lodash.last = last;
16842 lodash.lastIndexOf = lastIndexOf;
16843 lodash.lowerCase = lowerCase;
16844 lodash.lowerFirst = lowerFirst;
16845 lodash.lt = lt;
16846 lodash.lte = lte;
16847 lodash.max = max;
16848 lodash.maxBy = maxBy;
16849 lodash.mean = mean;
16850 lodash.meanBy = meanBy;
16851 lodash.min = min;
16852 lodash.minBy = minBy;
16853 lodash.stubArray = stubArray;
16854 lodash.stubFalse = stubFalse;
16855 lodash.stubObject = stubObject;
16856 lodash.stubString = stubString;
16857 lodash.stubTrue = stubTrue;
16858 lodash.multiply = multiply;
16859 lodash.nth = nth;
16860 lodash.noConflict = noConflict;
16861 lodash.noop = noop;
16862 lodash.now = now;
16863 lodash.pad = pad;
16864 lodash.padEnd = padEnd;
16865 lodash.padStart = padStart;
16866 lodash.parseInt = parseInt;
16867 lodash.random = random;
16868 lodash.reduce = reduce;
16869 lodash.reduceRight = reduceRight;
16870 lodash.repeat = repeat;
16871 lodash.replace = replace;
16872 lodash.result = result;
16873 lodash.round = round;
16874 lodash.runInContext = runInContext;
16875 lodash.sample = sample;
16876 lodash.size = size;
16877 lodash.snakeCase = snakeCase;
16878 lodash.some = some;
16879 lodash.sortedIndex = sortedIndex;
16880 lodash.sortedIndexBy = sortedIndexBy;
16881 lodash.sortedIndexOf = sortedIndexOf;
16882 lodash.sortedLastIndex = sortedLastIndex;
16883 lodash.sortedLastIndexBy = sortedLastIndexBy;
16884 lodash.sortedLastIndexOf = sortedLastIndexOf;
16885 lodash.startCase = startCase;
16886 lodash.startsWith = startsWith;
16887 lodash.subtract = subtract;
16888 lodash.sum = sum;
16889 lodash.sumBy = sumBy;
16890 lodash.template = template;
16891 lodash.times = times;
16892 lodash.toFinite = toFinite;
16893 lodash.toInteger = toInteger;
16894 lodash.toLength = toLength;
16895 lodash.toLower = toLower;
16896 lodash.toNumber = toNumber;
16897 lodash.toSafeInteger = toSafeInteger;
16898 lodash.toString = toString;
16899 lodash.toUpper = toUpper;
16900 lodash.trim = trim;
16901 lodash.trimEnd = trimEnd;
16902 lodash.trimStart = trimStart;
16903 lodash.truncate = truncate;
16904 lodash.unescape = unescape;
16905 lodash.uniqueId = uniqueId;
16906 lodash.upperCase = upperCase;
16907 lodash.upperFirst = upperFirst;
16908
16909 // Add aliases.
16910 lodash.each = forEach;
16911 lodash.eachRight = forEachRight;
16912 lodash.first = head;
16913
16914 mixin(lodash, (function() {
16915 var source = {};
16916 baseForOwn(lodash, function(func, methodName) {
16917 if (!hasOwnProperty.call(lodash.prototype, methodName)) {
16918 source[methodName] = func;
16919 }
16920 });
16921 return source;
16922 }()), { 'chain': false });
16923
16924 /*------------------------------------------------------------------------*/
16925
16926 /**
16927 * The semantic version number.
16928 *
16929 * @static
16930 * @memberOf _
16931 * @type {string}
16932 */
16933 lodash.VERSION = VERSION;
16934
16935 // Assign default placeholders.
16936 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
16937 lodash[methodName].placeholder = lodash;
16938 });
16939
16940 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
16941 arrayEach(['drop', 'take'], function(methodName, index) {
16942 LazyWrapper.prototype[methodName] = function(n) {
16943 n = n === undefined$1 ? 1 : nativeMax(toInteger(n), 0);
16944
16945 var result = (this.__filtered__ && !index)
16946 ? new LazyWrapper(this)
16947 : this.clone();
16948
16949 if (result.__filtered__) {
16950 result.__takeCount__ = nativeMin(n, result.__takeCount__);
16951 } else {
16952 result.__views__.push({
16953 'size': nativeMin(n, MAX_ARRAY_LENGTH),
16954 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
16955 });
16956 }
16957 return result;
16958 };
16959
16960 LazyWrapper.prototype[methodName + 'Right'] = function(n) {
16961 return this.reverse()[methodName](n).reverse();
16962 };
16963 });
16964
16965 // Add `LazyWrapper` methods that accept an `iteratee` value.
16966 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
16967 var type = index + 1,
16968 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
16969
16970 LazyWrapper.prototype[methodName] = function(iteratee) {
16971 var result = this.clone();
16972 result.__iteratees__.push({
16973 'iteratee': getIteratee(iteratee, 3),
16974 'type': type
16975 });
16976 result.__filtered__ = result.__filtered__ || isFilter;
16977 return result;
16978 };
16979 });
16980
16981 // Add `LazyWrapper` methods for `_.head` and `_.last`.
16982 arrayEach(['head', 'last'], function(methodName, index) {
16983 var takeName = 'take' + (index ? 'Right' : '');
16984
16985 LazyWrapper.prototype[methodName] = function() {
16986 return this[takeName](1).value()[0];
16987 };
16988 });
16989
16990 // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
16991 arrayEach(['initial', 'tail'], function(methodName, index) {
16992 var dropName = 'drop' + (index ? '' : 'Right');
16993
16994 LazyWrapper.prototype[methodName] = function() {
16995 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
16996 };
16997 });
16998
16999 LazyWrapper.prototype.compact = function() {
17000 return this.filter(identity);
17001 };
17002
17003 LazyWrapper.prototype.find = function(predicate) {
17004 return this.filter(predicate).head();
17005 };
17006
17007 LazyWrapper.prototype.findLast = function(predicate) {
17008 return this.reverse().find(predicate);
17009 };
17010
17011 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
17012 if (typeof path == 'function') {
17013 return new LazyWrapper(this);
17014 }
17015 return this.map(function(value) {
17016 return baseInvoke(value, path, args);
17017 });
17018 });
17019
17020 LazyWrapper.prototype.reject = function(predicate) {
17021 return this.filter(negate(getIteratee(predicate)));
17022 };
17023
17024 LazyWrapper.prototype.slice = function(start, end) {
17025 start = toInteger(start);
17026
17027 var result = this;
17028 if (result.__filtered__ && (start > 0 || end < 0)) {
17029 return new LazyWrapper(result);
17030 }
17031 if (start < 0) {
17032 result = result.takeRight(-start);
17033 } else if (start) {
17034 result = result.drop(start);
17035 }
17036 if (end !== undefined$1) {
17037 end = toInteger(end);
17038 result = end < 0 ? result.dropRight(-end) : result.take(end - start);
17039 }
17040 return result;
17041 };
17042
17043 LazyWrapper.prototype.takeRightWhile = function(predicate) {
17044 return this.reverse().takeWhile(predicate).reverse();
17045 };
17046
17047 LazyWrapper.prototype.toArray = function() {
17048 return this.take(MAX_ARRAY_LENGTH);
17049 };
17050
17051 // Add `LazyWrapper` methods to `lodash.prototype`.
17052 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17053 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
17054 isTaker = /^(?:head|last)$/.test(methodName),
17055 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
17056 retUnwrapped = isTaker || /^find/.test(methodName);
17057
17058 if (!lodashFunc) {
17059 return;
17060 }
17061 lodash.prototype[methodName] = function() {
17062 var value = this.__wrapped__,
17063 args = isTaker ? [1] : arguments,
17064 isLazy = value instanceof LazyWrapper,
17065 iteratee = args[0],
17066 useLazy = isLazy || isArray(value);
17067
17068 var interceptor = function(value) {
17069 var result = lodashFunc.apply(lodash, arrayPush([value], args));
17070 return (isTaker && chainAll) ? result[0] : result;
17071 };
17072
17073 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
17074 // Avoid lazy use if the iteratee has a "length" value other than `1`.
17075 isLazy = useLazy = false;
17076 }
17077 var chainAll = this.__chain__,
17078 isHybrid = !!this.__actions__.length,
17079 isUnwrapped = retUnwrapped && !chainAll,
17080 onlyLazy = isLazy && !isHybrid;
17081
17082 if (!retUnwrapped && useLazy) {
17083 value = onlyLazy ? value : new LazyWrapper(this);
17084 var result = func.apply(value, args);
17085 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined$1 });
17086 return new LodashWrapper(result, chainAll);
17087 }
17088 if (isUnwrapped && onlyLazy) {
17089 return func.apply(this, args);
17090 }
17091 result = this.thru(interceptor);
17092 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
17093 };
17094 });
17095
17096 // Add `Array` methods to `lodash.prototype`.
17097 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
17098 var func = arrayProto[methodName],
17099 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
17100 retUnwrapped = /^(?:pop|shift)$/.test(methodName);
17101
17102 lodash.prototype[methodName] = function() {
17103 var args = arguments;
17104 if (retUnwrapped && !this.__chain__) {
17105 var value = this.value();
17106 return func.apply(isArray(value) ? value : [], args);
17107 }
17108 return this[chainName](function(value) {
17109 return func.apply(isArray(value) ? value : [], args);
17110 });
17111 };
17112 });
17113
17114 // Map minified method names to their real names.
17115 baseForOwn(LazyWrapper.prototype, function(func, methodName) {
17116 var lodashFunc = lodash[methodName];
17117 if (lodashFunc) {
17118 var key = lodashFunc.name + '';
17119 if (!hasOwnProperty.call(realNames, key)) {
17120 realNames[key] = [];
17121 }
17122 realNames[key].push({ 'name': methodName, 'func': lodashFunc });
17123 }
17124 });
17125
17126 realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
17127 'name': 'wrapper',
17128 'func': undefined$1
17129 }];
17130
17131 // Add methods to `LazyWrapper`.
17132 LazyWrapper.prototype.clone = lazyClone;
17133 LazyWrapper.prototype.reverse = lazyReverse;
17134 LazyWrapper.prototype.value = lazyValue;
17135
17136 // Add chain sequence methods to the `lodash` wrapper.
17137 lodash.prototype.at = wrapperAt;
17138 lodash.prototype.chain = wrapperChain;
17139 lodash.prototype.commit = wrapperCommit;
17140 lodash.prototype.next = wrapperNext;
17141 lodash.prototype.plant = wrapperPlant;
17142 lodash.prototype.reverse = wrapperReverse;
17143 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
17144
17145 // Add lazy aliases.
17146 lodash.prototype.first = lodash.prototype.head;
17147
17148 if (symIterator) {
17149 lodash.prototype[symIterator] = wrapperToIterator;
17150 }
17151 return lodash;
17152 });
17153
17154 /*--------------------------------------------------------------------------*/
17155
17156 // Export lodash.
17157 var _ = runInContext();
17158
17159 // Some AMD build optimizers, like r.js, check for condition patterns like:
17160 if (freeModule) {
17161 // Export for Node.js.
17162 (freeModule.exports = _)._ = _;
17163 // Export for CommonJS support.
17164 freeExports._ = _;
17165 }
17166 else {
17167 // Export to the global object.
17168 root._ = _;
17169 }
17170}.call(commonjsGlobal));
17171});
17172
17173var VerbosityLevel;
17174(function (VerbosityLevel) {
17175 VerbosityLevel[VerbosityLevel["Error"] = 0] = "Error";
17176 VerbosityLevel[VerbosityLevel["Warning"] = 1] = "Warning";
17177 VerbosityLevel[VerbosityLevel["Info"] = 2] = "Info";
17178 VerbosityLevel[VerbosityLevel["Debug"] = 3] = "Debug";
17179})(VerbosityLevel || (VerbosityLevel = {}));
17180class ConsoleContext {
17181 constructor(verbosity, prefix = "") {
17182 this.verbosity = verbosity;
17183 this.prefix = prefix;
17184 }
17185 warn(message) {
17186 if (this.verbosity < VerbosityLevel.Warning)
17187 return;
17188 console.log(`${this.prefix}${lodash.isFunction(message) ? message() : message}`);
17189 }
17190 error(message) {
17191 if (this.verbosity < VerbosityLevel.Error)
17192 return;
17193 console.log(`${this.prefix}${lodash.isFunction(message) ? message() : message}`);
17194 }
17195 info(message) {
17196 if (this.verbosity < VerbosityLevel.Info)
17197 return;
17198 console.log(`${this.prefix}${lodash.isFunction(message) ? message() : message}`);
17199 }
17200 debug(message) {
17201 if (this.verbosity < VerbosityLevel.Debug)
17202 return;
17203 console.log(`${this.prefix}${lodash.isFunction(message) ? message() : message}`);
17204 }
17205}
17206
17207class RollupContext {
17208 constructor(verbosity, bail, context, prefix = "") {
17209 this.verbosity = verbosity;
17210 this.bail = bail;
17211 this.context = context;
17212 this.prefix = prefix;
17213 this.hasContext = true;
17214 this.hasContext = lodash.isFunction(this.context.warn) && lodash.isFunction(this.context.error);
17215 }
17216 warn(message) {
17217 if (this.verbosity < VerbosityLevel.Warning)
17218 return;
17219 const text = lodash.isFunction(message) ? message() : message;
17220 if (this.hasContext)
17221 this.context.warn(`${text}`);
17222 else
17223 console.log(`${this.prefix}${text}`);
17224 }
17225 error(message) {
17226 if (this.verbosity < VerbosityLevel.Error)
17227 return;
17228 const text = lodash.isFunction(message) ? message() : message;
17229 if (this.hasContext) {
17230 if (this.bail)
17231 this.context.error(`${text}`);
17232 else
17233 this.context.warn(`${text}`);
17234 }
17235 else
17236 console.log(`${this.prefix}${text}`);
17237 }
17238 info(message) {
17239 if (this.verbosity < VerbosityLevel.Info)
17240 return;
17241 const text = lodash.isFunction(message) ? message() : message;
17242 console.log(`${this.prefix}${text}`);
17243 }
17244 debug(message) {
17245 if (this.verbosity < VerbosityLevel.Debug)
17246 return;
17247 const text = lodash.isFunction(message) ? message() : message;
17248 console.log(`${this.prefix}${text}`);
17249 }
17250}
17251
17252let tsModule;
17253function setTypescriptModule(override) {
17254 tsModule = override;
17255}
17256
17257function normalize(fileName) {
17258 return fileName.split("\\").join("/");
17259}
17260
17261class LanguageServiceHost {
17262 constructor(parsedConfig, transformers, cwd) {
17263 this.parsedConfig = parsedConfig;
17264 this.transformers = transformers;
17265 this.snapshots = {};
17266 this.versions = {};
17267 this.fileNames = new Set(parsedConfig.fileNames);
17268 this.cwd = cwd;
17269 }
17270 reset() {
17271 this.snapshots = {};
17272 this.versions = {};
17273 }
17274 setLanguageService(service) {
17275 this.service = service;
17276 }
17277 setSnapshot(fileName, data) {
17278 fileName = normalize(fileName);
17279 const snapshot = tsModule.ScriptSnapshot.fromString(data);
17280 this.snapshots[fileName] = snapshot;
17281 this.versions[fileName] = (this.versions[fileName] || 0) + 1;
17282 this.fileNames.add(fileName);
17283 return snapshot;
17284 }
17285 getScriptSnapshot(fileName) {
17286 fileName = normalize(fileName);
17287 if (lodash.has(this.snapshots, fileName))
17288 return this.snapshots[fileName];
17289 const source = tsModule.sys.readFile(fileName);
17290 if (source) {
17291 this.snapshots[fileName] = tsModule.ScriptSnapshot.fromString(source);
17292 this.versions[fileName] = (this.versions[fileName] || 0) + 1;
17293 return this.snapshots[fileName];
17294 }
17295 return undefined;
17296 }
17297 getCurrentDirectory() {
17298 return this.cwd;
17299 }
17300 getScriptVersion(fileName) {
17301 fileName = normalize(fileName);
17302 return (this.versions[fileName] || 0).toString();
17303 }
17304 getScriptFileNames() {
17305 return Array.from(this.fileNames.values());
17306 }
17307 getCompilationSettings() {
17308 return this.parsedConfig.options;
17309 }
17310 getDefaultLibFileName(opts) {
17311 return tsModule.getDefaultLibFilePath(opts);
17312 }
17313 useCaseSensitiveFileNames() {
17314 return tsModule.sys.useCaseSensitiveFileNames;
17315 }
17316 readDirectory(path, extensions, exclude, include) {
17317 return tsModule.sys.readDirectory(path, extensions, exclude, include);
17318 }
17319 readFile(path, encoding) {
17320 return tsModule.sys.readFile(path, encoding);
17321 }
17322 fileExists(path) {
17323 return tsModule.sys.fileExists(path);
17324 }
17325 getTypeRootsVersion() {
17326 return 0;
17327 }
17328 directoryExists(directoryName) {
17329 return tsModule.sys.directoryExists(directoryName);
17330 }
17331 getDirectories(directoryName) {
17332 return tsModule.sys.getDirectories(directoryName);
17333 }
17334 getCustomTransformers() {
17335 if (this.service === undefined || this.transformers === undefined || this.transformers.length === 0)
17336 return undefined;
17337 const transformer = {
17338 before: [],
17339 after: [],
17340 afterDeclarations: [],
17341 };
17342 for (const creator of this.transformers) {
17343 const factory = creator(this.service);
17344 if (factory.before)
17345 transformer.before = lodash.concat(transformer.before, factory.before);
17346 if (factory.after)
17347 transformer.after = lodash.concat(transformer.after, factory.after);
17348 if (factory.afterDeclarations)
17349 transformer.afterDeclarations = lodash.concat(transformer.afterDeclarations, factory.afterDeclarations);
17350 }
17351 return transformer;
17352 }
17353}
17354
17355/**
17356 * Removes all key-value entries from the list cache.
17357 *
17358 * @private
17359 * @name clear
17360 * @memberOf ListCache
17361 */
17362function listCacheClear() {
17363 this.__data__ = [];
17364 this.size = 0;
17365}
17366
17367var _listCacheClear = listCacheClear;
17368
17369/**
17370 * Performs a
17371 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
17372 * comparison between two values to determine if they are equivalent.
17373 *
17374 * @static
17375 * @memberOf _
17376 * @since 4.0.0
17377 * @category Lang
17378 * @param {*} value The value to compare.
17379 * @param {*} other The other value to compare.
17380 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
17381 * @example
17382 *
17383 * var object = { 'a': 1 };
17384 * var other = { 'a': 1 };
17385 *
17386 * _.eq(object, object);
17387 * // => true
17388 *
17389 * _.eq(object, other);
17390 * // => false
17391 *
17392 * _.eq('a', 'a');
17393 * // => true
17394 *
17395 * _.eq('a', Object('a'));
17396 * // => false
17397 *
17398 * _.eq(NaN, NaN);
17399 * // => true
17400 */
17401function eq(value, other) {
17402 return value === other || (value !== value && other !== other);
17403}
17404
17405var eq_1 = eq;
17406
17407/**
17408 * Gets the index at which the `key` is found in `array` of key-value pairs.
17409 *
17410 * @private
17411 * @param {Array} array The array to inspect.
17412 * @param {*} key The key to search for.
17413 * @returns {number} Returns the index of the matched value, else `-1`.
17414 */
17415function assocIndexOf(array, key) {
17416 var length = array.length;
17417 while (length--) {
17418 if (eq_1(array[length][0], key)) {
17419 return length;
17420 }
17421 }
17422 return -1;
17423}
17424
17425var _assocIndexOf = assocIndexOf;
17426
17427/** Used for built-in method references. */
17428var arrayProto = Array.prototype;
17429
17430/** Built-in value references. */
17431var splice = arrayProto.splice;
17432
17433/**
17434 * Removes `key` and its value from the list cache.
17435 *
17436 * @private
17437 * @name delete
17438 * @memberOf ListCache
17439 * @param {string} key The key of the value to remove.
17440 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
17441 */
17442function listCacheDelete(key) {
17443 var data = this.__data__,
17444 index = _assocIndexOf(data, key);
17445
17446 if (index < 0) {
17447 return false;
17448 }
17449 var lastIndex = data.length - 1;
17450 if (index == lastIndex) {
17451 data.pop();
17452 } else {
17453 splice.call(data, index, 1);
17454 }
17455 --this.size;
17456 return true;
17457}
17458
17459var _listCacheDelete = listCacheDelete;
17460
17461/**
17462 * Gets the list cache value for `key`.
17463 *
17464 * @private
17465 * @name get
17466 * @memberOf ListCache
17467 * @param {string} key The key of the value to get.
17468 * @returns {*} Returns the entry value.
17469 */
17470function listCacheGet(key) {
17471 var data = this.__data__,
17472 index = _assocIndexOf(data, key);
17473
17474 return index < 0 ? undefined : data[index][1];
17475}
17476
17477var _listCacheGet = listCacheGet;
17478
17479/**
17480 * Checks if a list cache value for `key` exists.
17481 *
17482 * @private
17483 * @name has
17484 * @memberOf ListCache
17485 * @param {string} key The key of the entry to check.
17486 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
17487 */
17488function listCacheHas(key) {
17489 return _assocIndexOf(this.__data__, key) > -1;
17490}
17491
17492var _listCacheHas = listCacheHas;
17493
17494/**
17495 * Sets the list cache `key` to `value`.
17496 *
17497 * @private
17498 * @name set
17499 * @memberOf ListCache
17500 * @param {string} key The key of the value to set.
17501 * @param {*} value The value to set.
17502 * @returns {Object} Returns the list cache instance.
17503 */
17504function listCacheSet(key, value) {
17505 var data = this.__data__,
17506 index = _assocIndexOf(data, key);
17507
17508 if (index < 0) {
17509 ++this.size;
17510 data.push([key, value]);
17511 } else {
17512 data[index][1] = value;
17513 }
17514 return this;
17515}
17516
17517var _listCacheSet = listCacheSet;
17518
17519/**
17520 * Creates an list cache object.
17521 *
17522 * @private
17523 * @constructor
17524 * @param {Array} [entries] The key-value pairs to cache.
17525 */
17526function ListCache(entries) {
17527 var index = -1,
17528 length = entries == null ? 0 : entries.length;
17529
17530 this.clear();
17531 while (++index < length) {
17532 var entry = entries[index];
17533 this.set(entry[0], entry[1]);
17534 }
17535}
17536
17537// Add methods to `ListCache`.
17538ListCache.prototype.clear = _listCacheClear;
17539ListCache.prototype['delete'] = _listCacheDelete;
17540ListCache.prototype.get = _listCacheGet;
17541ListCache.prototype.has = _listCacheHas;
17542ListCache.prototype.set = _listCacheSet;
17543
17544var _ListCache = ListCache;
17545
17546/**
17547 * Removes all key-value entries from the stack.
17548 *
17549 * @private
17550 * @name clear
17551 * @memberOf Stack
17552 */
17553function stackClear() {
17554 this.__data__ = new _ListCache;
17555 this.size = 0;
17556}
17557
17558var _stackClear = stackClear;
17559
17560/**
17561 * Removes `key` and its value from the stack.
17562 *
17563 * @private
17564 * @name delete
17565 * @memberOf Stack
17566 * @param {string} key The key of the value to remove.
17567 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
17568 */
17569function stackDelete(key) {
17570 var data = this.__data__,
17571 result = data['delete'](key);
17572
17573 this.size = data.size;
17574 return result;
17575}
17576
17577var _stackDelete = stackDelete;
17578
17579/**
17580 * Gets the stack value for `key`.
17581 *
17582 * @private
17583 * @name get
17584 * @memberOf Stack
17585 * @param {string} key The key of the value to get.
17586 * @returns {*} Returns the entry value.
17587 */
17588function stackGet(key) {
17589 return this.__data__.get(key);
17590}
17591
17592var _stackGet = stackGet;
17593
17594/**
17595 * Checks if a stack value for `key` exists.
17596 *
17597 * @private
17598 * @name has
17599 * @memberOf Stack
17600 * @param {string} key The key of the entry to check.
17601 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
17602 */
17603function stackHas(key) {
17604 return this.__data__.has(key);
17605}
17606
17607var _stackHas = stackHas;
17608
17609/** Detect free variable `global` from Node.js. */
17610
17611var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
17612
17613var _freeGlobal = freeGlobal;
17614
17615/** Detect free variable `self`. */
17616var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
17617
17618/** Used as a reference to the global object. */
17619var root = _freeGlobal || freeSelf || Function('return this')();
17620
17621var _root = root;
17622
17623/** Built-in value references. */
17624var Symbol$1 = _root.Symbol;
17625
17626var _Symbol = Symbol$1;
17627
17628/** Used for built-in method references. */
17629var objectProto = Object.prototype;
17630
17631/** Used to check objects for own properties. */
17632var hasOwnProperty = objectProto.hasOwnProperty;
17633
17634/**
17635 * Used to resolve the
17636 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
17637 * of values.
17638 */
17639var nativeObjectToString = objectProto.toString;
17640
17641/** Built-in value references. */
17642var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
17643
17644/**
17645 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
17646 *
17647 * @private
17648 * @param {*} value The value to query.
17649 * @returns {string} Returns the raw `toStringTag`.
17650 */
17651function getRawTag(value) {
17652 var isOwn = hasOwnProperty.call(value, symToStringTag),
17653 tag = value[symToStringTag];
17654
17655 try {
17656 value[symToStringTag] = undefined;
17657 var unmasked = true;
17658 } catch (e) {}
17659
17660 var result = nativeObjectToString.call(value);
17661 if (unmasked) {
17662 if (isOwn) {
17663 value[symToStringTag] = tag;
17664 } else {
17665 delete value[symToStringTag];
17666 }
17667 }
17668 return result;
17669}
17670
17671var _getRawTag = getRawTag;
17672
17673/** Used for built-in method references. */
17674var objectProto$1 = Object.prototype;
17675
17676/**
17677 * Used to resolve the
17678 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
17679 * of values.
17680 */
17681var nativeObjectToString$1 = objectProto$1.toString;
17682
17683/**
17684 * Converts `value` to a string using `Object.prototype.toString`.
17685 *
17686 * @private
17687 * @param {*} value The value to convert.
17688 * @returns {string} Returns the converted string.
17689 */
17690function objectToString(value) {
17691 return nativeObjectToString$1.call(value);
17692}
17693
17694var _objectToString = objectToString;
17695
17696/** `Object#toString` result references. */
17697var nullTag = '[object Null]',
17698 undefinedTag = '[object Undefined]';
17699
17700/** Built-in value references. */
17701var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
17702
17703/**
17704 * The base implementation of `getTag` without fallbacks for buggy environments.
17705 *
17706 * @private
17707 * @param {*} value The value to query.
17708 * @returns {string} Returns the `toStringTag`.
17709 */
17710function baseGetTag(value) {
17711 if (value == null) {
17712 return value === undefined ? undefinedTag : nullTag;
17713 }
17714 return (symToStringTag$1 && symToStringTag$1 in Object(value))
17715 ? _getRawTag(value)
17716 : _objectToString(value);
17717}
17718
17719var _baseGetTag = baseGetTag;
17720
17721/**
17722 * Checks if `value` is the
17723 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
17724 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
17725 *
17726 * @static
17727 * @memberOf _
17728 * @since 0.1.0
17729 * @category Lang
17730 * @param {*} value The value to check.
17731 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
17732 * @example
17733 *
17734 * _.isObject({});
17735 * // => true
17736 *
17737 * _.isObject([1, 2, 3]);
17738 * // => true
17739 *
17740 * _.isObject(_.noop);
17741 * // => true
17742 *
17743 * _.isObject(null);
17744 * // => false
17745 */
17746function isObject(value) {
17747 var type = typeof value;
17748 return value != null && (type == 'object' || type == 'function');
17749}
17750
17751var isObject_1 = isObject;
17752
17753/** `Object#toString` result references. */
17754var asyncTag = '[object AsyncFunction]',
17755 funcTag = '[object Function]',
17756 genTag = '[object GeneratorFunction]',
17757 proxyTag = '[object Proxy]';
17758
17759/**
17760 * Checks if `value` is classified as a `Function` object.
17761 *
17762 * @static
17763 * @memberOf _
17764 * @since 0.1.0
17765 * @category Lang
17766 * @param {*} value The value to check.
17767 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
17768 * @example
17769 *
17770 * _.isFunction(_);
17771 * // => true
17772 *
17773 * _.isFunction(/abc/);
17774 * // => false
17775 */
17776function isFunction(value) {
17777 if (!isObject_1(value)) {
17778 return false;
17779 }
17780 // The use of `Object#toString` avoids issues with the `typeof` operator
17781 // in Safari 9 which returns 'object' for typed arrays and other constructors.
17782 var tag = _baseGetTag(value);
17783 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
17784}
17785
17786var isFunction_1 = isFunction;
17787
17788/** Used to detect overreaching core-js shims. */
17789var coreJsData = _root['__core-js_shared__'];
17790
17791var _coreJsData = coreJsData;
17792
17793/** Used to detect methods masquerading as native. */
17794var maskSrcKey = (function() {
17795 var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
17796 return uid ? ('Symbol(src)_1.' + uid) : '';
17797}());
17798
17799/**
17800 * Checks if `func` has its source masked.
17801 *
17802 * @private
17803 * @param {Function} func The function to check.
17804 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
17805 */
17806function isMasked(func) {
17807 return !!maskSrcKey && (maskSrcKey in func);
17808}
17809
17810var _isMasked = isMasked;
17811
17812/** Used for built-in method references. */
17813var funcProto = Function.prototype;
17814
17815/** Used to resolve the decompiled source of functions. */
17816var funcToString = funcProto.toString;
17817
17818/**
17819 * Converts `func` to its source code.
17820 *
17821 * @private
17822 * @param {Function} func The function to convert.
17823 * @returns {string} Returns the source code.
17824 */
17825function toSource(func) {
17826 if (func != null) {
17827 try {
17828 return funcToString.call(func);
17829 } catch (e) {}
17830 try {
17831 return (func + '');
17832 } catch (e) {}
17833 }
17834 return '';
17835}
17836
17837var _toSource = toSource;
17838
17839/**
17840 * Used to match `RegExp`
17841 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
17842 */
17843var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
17844
17845/** Used to detect host constructors (Safari). */
17846var reIsHostCtor = /^\[object .+?Constructor\]$/;
17847
17848/** Used for built-in method references. */
17849var funcProto$1 = Function.prototype,
17850 objectProto$2 = Object.prototype;
17851
17852/** Used to resolve the decompiled source of functions. */
17853var funcToString$1 = funcProto$1.toString;
17854
17855/** Used to check objects for own properties. */
17856var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
17857
17858/** Used to detect if a method is native. */
17859var reIsNative = RegExp('^' +
17860 funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
17861 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
17862);
17863
17864/**
17865 * The base implementation of `_.isNative` without bad shim checks.
17866 *
17867 * @private
17868 * @param {*} value The value to check.
17869 * @returns {boolean} Returns `true` if `value` is a native function,
17870 * else `false`.
17871 */
17872function baseIsNative(value) {
17873 if (!isObject_1(value) || _isMasked(value)) {
17874 return false;
17875 }
17876 var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
17877 return pattern.test(_toSource(value));
17878}
17879
17880var _baseIsNative = baseIsNative;
17881
17882/**
17883 * Gets the value at `key` of `object`.
17884 *
17885 * @private
17886 * @param {Object} [object] The object to query.
17887 * @param {string} key The key of the property to get.
17888 * @returns {*} Returns the property value.
17889 */
17890function getValue(object, key) {
17891 return object == null ? undefined : object[key];
17892}
17893
17894var _getValue = getValue;
17895
17896/**
17897 * Gets the native function at `key` of `object`.
17898 *
17899 * @private
17900 * @param {Object} object The object to query.
17901 * @param {string} key The key of the method to get.
17902 * @returns {*} Returns the function if it's native, else `undefined`.
17903 */
17904function getNative(object, key) {
17905 var value = _getValue(object, key);
17906 return _baseIsNative(value) ? value : undefined;
17907}
17908
17909var _getNative = getNative;
17910
17911/* Built-in method references that are verified to be native. */
17912var Map$1 = _getNative(_root, 'Map');
17913
17914var _Map = Map$1;
17915
17916/* Built-in method references that are verified to be native. */
17917var nativeCreate = _getNative(Object, 'create');
17918
17919var _nativeCreate = nativeCreate;
17920
17921/**
17922 * Removes all key-value entries from the hash.
17923 *
17924 * @private
17925 * @name clear
17926 * @memberOf Hash
17927 */
17928function hashClear() {
17929 this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
17930 this.size = 0;
17931}
17932
17933var _hashClear = hashClear;
17934
17935/**
17936 * Removes `key` and its value from the hash.
17937 *
17938 * @private
17939 * @name delete
17940 * @memberOf Hash
17941 * @param {Object} hash The hash to modify.
17942 * @param {string} key The key of the value to remove.
17943 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
17944 */
17945function hashDelete(key) {
17946 var result = this.has(key) && delete this.__data__[key];
17947 this.size -= result ? 1 : 0;
17948 return result;
17949}
17950
17951var _hashDelete = hashDelete;
17952
17953/** Used to stand-in for `undefined` hash values. */
17954var HASH_UNDEFINED = '__lodash_hash_undefined__';
17955
17956/** Used for built-in method references. */
17957var objectProto$3 = Object.prototype;
17958
17959/** Used to check objects for own properties. */
17960var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
17961
17962/**
17963 * Gets the hash value for `key`.
17964 *
17965 * @private
17966 * @name get
17967 * @memberOf Hash
17968 * @param {string} key The key of the value to get.
17969 * @returns {*} Returns the entry value.
17970 */
17971function hashGet(key) {
17972 var data = this.__data__;
17973 if (_nativeCreate) {
17974 var result = data[key];
17975 return result === HASH_UNDEFINED ? undefined : result;
17976 }
17977 return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
17978}
17979
17980var _hashGet = hashGet;
17981
17982/** Used for built-in method references. */
17983var objectProto$4 = Object.prototype;
17984
17985/** Used to check objects for own properties. */
17986var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
17987
17988/**
17989 * Checks if a hash value for `key` exists.
17990 *
17991 * @private
17992 * @name has
17993 * @memberOf Hash
17994 * @param {string} key The key of the entry to check.
17995 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
17996 */
17997function hashHas(key) {
17998 var data = this.__data__;
17999 return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
18000}
18001
18002var _hashHas = hashHas;
18003
18004/** Used to stand-in for `undefined` hash values. */
18005var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
18006
18007/**
18008 * Sets the hash `key` to `value`.
18009 *
18010 * @private
18011 * @name set
18012 * @memberOf Hash
18013 * @param {string} key The key of the value to set.
18014 * @param {*} value The value to set.
18015 * @returns {Object} Returns the hash instance.
18016 */
18017function hashSet(key, value) {
18018 var data = this.__data__;
18019 this.size += this.has(key) ? 0 : 1;
18020 data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
18021 return this;
18022}
18023
18024var _hashSet = hashSet;
18025
18026/**
18027 * Creates a hash object.
18028 *
18029 * @private
18030 * @constructor
18031 * @param {Array} [entries] The key-value pairs to cache.
18032 */
18033function Hash(entries) {
18034 var index = -1,
18035 length = entries == null ? 0 : entries.length;
18036
18037 this.clear();
18038 while (++index < length) {
18039 var entry = entries[index];
18040 this.set(entry[0], entry[1]);
18041 }
18042}
18043
18044// Add methods to `Hash`.
18045Hash.prototype.clear = _hashClear;
18046Hash.prototype['delete'] = _hashDelete;
18047Hash.prototype.get = _hashGet;
18048Hash.prototype.has = _hashHas;
18049Hash.prototype.set = _hashSet;
18050
18051var _Hash = Hash;
18052
18053/**
18054 * Removes all key-value entries from the map.
18055 *
18056 * @private
18057 * @name clear
18058 * @memberOf MapCache
18059 */
18060function mapCacheClear() {
18061 this.size = 0;
18062 this.__data__ = {
18063 'hash': new _Hash,
18064 'map': new (_Map || _ListCache),
18065 'string': new _Hash
18066 };
18067}
18068
18069var _mapCacheClear = mapCacheClear;
18070
18071/**
18072 * Checks if `value` is suitable for use as unique object key.
18073 *
18074 * @private
18075 * @param {*} value The value to check.
18076 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
18077 */
18078function isKeyable(value) {
18079 var type = typeof value;
18080 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
18081 ? (value !== '__proto__')
18082 : (value === null);
18083}
18084
18085var _isKeyable = isKeyable;
18086
18087/**
18088 * Gets the data for `map`.
18089 *
18090 * @private
18091 * @param {Object} map The map to query.
18092 * @param {string} key The reference key.
18093 * @returns {*} Returns the map data.
18094 */
18095function getMapData(map, key) {
18096 var data = map.__data__;
18097 return _isKeyable(key)
18098 ? data[typeof key == 'string' ? 'string' : 'hash']
18099 : data.map;
18100}
18101
18102var _getMapData = getMapData;
18103
18104/**
18105 * Removes `key` and its value from the map.
18106 *
18107 * @private
18108 * @name delete
18109 * @memberOf MapCache
18110 * @param {string} key The key of the value to remove.
18111 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
18112 */
18113function mapCacheDelete(key) {
18114 var result = _getMapData(this, key)['delete'](key);
18115 this.size -= result ? 1 : 0;
18116 return result;
18117}
18118
18119var _mapCacheDelete = mapCacheDelete;
18120
18121/**
18122 * Gets the map value for `key`.
18123 *
18124 * @private
18125 * @name get
18126 * @memberOf MapCache
18127 * @param {string} key The key of the value to get.
18128 * @returns {*} Returns the entry value.
18129 */
18130function mapCacheGet(key) {
18131 return _getMapData(this, key).get(key);
18132}
18133
18134var _mapCacheGet = mapCacheGet;
18135
18136/**
18137 * Checks if a map value for `key` exists.
18138 *
18139 * @private
18140 * @name has
18141 * @memberOf MapCache
18142 * @param {string} key The key of the entry to check.
18143 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
18144 */
18145function mapCacheHas(key) {
18146 return _getMapData(this, key).has(key);
18147}
18148
18149var _mapCacheHas = mapCacheHas;
18150
18151/**
18152 * Sets the map `key` to `value`.
18153 *
18154 * @private
18155 * @name set
18156 * @memberOf MapCache
18157 * @param {string} key The key of the value to set.
18158 * @param {*} value The value to set.
18159 * @returns {Object} Returns the map cache instance.
18160 */
18161function mapCacheSet(key, value) {
18162 var data = _getMapData(this, key),
18163 size = data.size;
18164
18165 data.set(key, value);
18166 this.size += data.size == size ? 0 : 1;
18167 return this;
18168}
18169
18170var _mapCacheSet = mapCacheSet;
18171
18172/**
18173 * Creates a map cache object to store key-value pairs.
18174 *
18175 * @private
18176 * @constructor
18177 * @param {Array} [entries] The key-value pairs to cache.
18178 */
18179function MapCache(entries) {
18180 var index = -1,
18181 length = entries == null ? 0 : entries.length;
18182
18183 this.clear();
18184 while (++index < length) {
18185 var entry = entries[index];
18186 this.set(entry[0], entry[1]);
18187 }
18188}
18189
18190// Add methods to `MapCache`.
18191MapCache.prototype.clear = _mapCacheClear;
18192MapCache.prototype['delete'] = _mapCacheDelete;
18193MapCache.prototype.get = _mapCacheGet;
18194MapCache.prototype.has = _mapCacheHas;
18195MapCache.prototype.set = _mapCacheSet;
18196
18197var _MapCache = MapCache;
18198
18199/** Used as the size to enable large array optimizations. */
18200var LARGE_ARRAY_SIZE = 200;
18201
18202/**
18203 * Sets the stack `key` to `value`.
18204 *
18205 * @private
18206 * @name set
18207 * @memberOf Stack
18208 * @param {string} key The key of the value to set.
18209 * @param {*} value The value to set.
18210 * @returns {Object} Returns the stack cache instance.
18211 */
18212function stackSet(key, value) {
18213 var data = this.__data__;
18214 if (data instanceof _ListCache) {
18215 var pairs = data.__data__;
18216 if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
18217 pairs.push([key, value]);
18218 this.size = ++data.size;
18219 return this;
18220 }
18221 data = this.__data__ = new _MapCache(pairs);
18222 }
18223 data.set(key, value);
18224 this.size = data.size;
18225 return this;
18226}
18227
18228var _stackSet = stackSet;
18229
18230/**
18231 * Creates a stack cache object to store key-value pairs.
18232 *
18233 * @private
18234 * @constructor
18235 * @param {Array} [entries] The key-value pairs to cache.
18236 */
18237function Stack(entries) {
18238 var data = this.__data__ = new _ListCache(entries);
18239 this.size = data.size;
18240}
18241
18242// Add methods to `Stack`.
18243Stack.prototype.clear = _stackClear;
18244Stack.prototype['delete'] = _stackDelete;
18245Stack.prototype.get = _stackGet;
18246Stack.prototype.has = _stackHas;
18247Stack.prototype.set = _stackSet;
18248
18249var _Stack = Stack;
18250
18251/**
18252 * A specialized version of `_.forEach` for arrays without support for
18253 * iteratee shorthands.
18254 *
18255 * @private
18256 * @param {Array} [array] The array to iterate over.
18257 * @param {Function} iteratee The function invoked per iteration.
18258 * @returns {Array} Returns `array`.
18259 */
18260function arrayEach(array, iteratee) {
18261 var index = -1,
18262 length = array == null ? 0 : array.length;
18263
18264 while (++index < length) {
18265 if (iteratee(array[index], index, array) === false) {
18266 break;
18267 }
18268 }
18269 return array;
18270}
18271
18272var _arrayEach = arrayEach;
18273
18274var defineProperty = (function() {
18275 try {
18276 var func = _getNative(Object, 'defineProperty');
18277 func({}, '', {});
18278 return func;
18279 } catch (e) {}
18280}());
18281
18282var _defineProperty = defineProperty;
18283
18284/**
18285 * The base implementation of `assignValue` and `assignMergeValue` without
18286 * value checks.
18287 *
18288 * @private
18289 * @param {Object} object The object to modify.
18290 * @param {string} key The key of the property to assign.
18291 * @param {*} value The value to assign.
18292 */
18293function baseAssignValue(object, key, value) {
18294 if (key == '__proto__' && _defineProperty) {
18295 _defineProperty(object, key, {
18296 'configurable': true,
18297 'enumerable': true,
18298 'value': value,
18299 'writable': true
18300 });
18301 } else {
18302 object[key] = value;
18303 }
18304}
18305
18306var _baseAssignValue = baseAssignValue;
18307
18308/** Used for built-in method references. */
18309var objectProto$5 = Object.prototype;
18310
18311/** Used to check objects for own properties. */
18312var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
18313
18314/**
18315 * Assigns `value` to `key` of `object` if the existing value is not equivalent
18316 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
18317 * for equality comparisons.
18318 *
18319 * @private
18320 * @param {Object} object The object to modify.
18321 * @param {string} key The key of the property to assign.
18322 * @param {*} value The value to assign.
18323 */
18324function assignValue(object, key, value) {
18325 var objValue = object[key];
18326 if (!(hasOwnProperty$4.call(object, key) && eq_1(objValue, value)) ||
18327 (value === undefined && !(key in object))) {
18328 _baseAssignValue(object, key, value);
18329 }
18330}
18331
18332var _assignValue = assignValue;
18333
18334/**
18335 * Copies properties of `source` to `object`.
18336 *
18337 * @private
18338 * @param {Object} source The object to copy properties from.
18339 * @param {Array} props The property identifiers to copy.
18340 * @param {Object} [object={}] The object to copy properties to.
18341 * @param {Function} [customizer] The function to customize copied values.
18342 * @returns {Object} Returns `object`.
18343 */
18344function copyObject(source, props, object, customizer) {
18345 var isNew = !object;
18346 object || (object = {});
18347
18348 var index = -1,
18349 length = props.length;
18350
18351 while (++index < length) {
18352 var key = props[index];
18353
18354 var newValue = customizer
18355 ? customizer(object[key], source[key], key, object, source)
18356 : undefined;
18357
18358 if (newValue === undefined) {
18359 newValue = source[key];
18360 }
18361 if (isNew) {
18362 _baseAssignValue(object, key, newValue);
18363 } else {
18364 _assignValue(object, key, newValue);
18365 }
18366 }
18367 return object;
18368}
18369
18370var _copyObject = copyObject;
18371
18372/**
18373 * The base implementation of `_.times` without support for iteratee shorthands
18374 * or max array length checks.
18375 *
18376 * @private
18377 * @param {number} n The number of times to invoke `iteratee`.
18378 * @param {Function} iteratee The function invoked per iteration.
18379 * @returns {Array} Returns the array of results.
18380 */
18381function baseTimes(n, iteratee) {
18382 var index = -1,
18383 result = Array(n);
18384
18385 while (++index < n) {
18386 result[index] = iteratee(index);
18387 }
18388 return result;
18389}
18390
18391var _baseTimes = baseTimes;
18392
18393/**
18394 * Checks if `value` is object-like. A value is object-like if it's not `null`
18395 * and has a `typeof` result of "object".
18396 *
18397 * @static
18398 * @memberOf _
18399 * @since 4.0.0
18400 * @category Lang
18401 * @param {*} value The value to check.
18402 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
18403 * @example
18404 *
18405 * _.isObjectLike({});
18406 * // => true
18407 *
18408 * _.isObjectLike([1, 2, 3]);
18409 * // => true
18410 *
18411 * _.isObjectLike(_.noop);
18412 * // => false
18413 *
18414 * _.isObjectLike(null);
18415 * // => false
18416 */
18417function isObjectLike(value) {
18418 return value != null && typeof value == 'object';
18419}
18420
18421var isObjectLike_1 = isObjectLike;
18422
18423/** `Object#toString` result references. */
18424var argsTag = '[object Arguments]';
18425
18426/**
18427 * The base implementation of `_.isArguments`.
18428 *
18429 * @private
18430 * @param {*} value The value to check.
18431 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
18432 */
18433function baseIsArguments(value) {
18434 return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
18435}
18436
18437var _baseIsArguments = baseIsArguments;
18438
18439/** Used for built-in method references. */
18440var objectProto$6 = Object.prototype;
18441
18442/** Used to check objects for own properties. */
18443var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
18444
18445/** Built-in value references. */
18446var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
18447
18448/**
18449 * Checks if `value` is likely an `arguments` object.
18450 *
18451 * @static
18452 * @memberOf _
18453 * @since 0.1.0
18454 * @category Lang
18455 * @param {*} value The value to check.
18456 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
18457 * else `false`.
18458 * @example
18459 *
18460 * _.isArguments(function() { return arguments; }());
18461 * // => true
18462 *
18463 * _.isArguments([1, 2, 3]);
18464 * // => false
18465 */
18466var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
18467 return isObjectLike_1(value) && hasOwnProperty$5.call(value, 'callee') &&
18468 !propertyIsEnumerable.call(value, 'callee');
18469};
18470
18471var isArguments_1 = isArguments;
18472
18473/**
18474 * Checks if `value` is classified as an `Array` object.
18475 *
18476 * @static
18477 * @memberOf _
18478 * @since 0.1.0
18479 * @category Lang
18480 * @param {*} value The value to check.
18481 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
18482 * @example
18483 *
18484 * _.isArray([1, 2, 3]);
18485 * // => true
18486 *
18487 * _.isArray(document.body.children);
18488 * // => false
18489 *
18490 * _.isArray('abc');
18491 * // => false
18492 *
18493 * _.isArray(_.noop);
18494 * // => false
18495 */
18496var isArray = Array.isArray;
18497
18498var isArray_1 = isArray;
18499
18500/**
18501 * This method returns `false`.
18502 *
18503 * @static
18504 * @memberOf _
18505 * @since 4.13.0
18506 * @category Util
18507 * @returns {boolean} Returns `false`.
18508 * @example
18509 *
18510 * _.times(2, _.stubFalse);
18511 * // => [false, false]
18512 */
18513function stubFalse() {
18514 return false;
18515}
18516
18517var stubFalse_1 = stubFalse;
18518
18519var isBuffer_1 = createCommonjsModule(function (module, exports) {
18520/** Detect free variable `exports`. */
18521var freeExports = exports && !exports.nodeType && exports;
18522
18523/** Detect free variable `module`. */
18524var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
18525
18526/** Detect the popular CommonJS extension `module.exports`. */
18527var moduleExports = freeModule && freeModule.exports === freeExports;
18528
18529/** Built-in value references. */
18530var Buffer = moduleExports ? _root.Buffer : undefined;
18531
18532/* Built-in method references for those with the same name as other `lodash` methods. */
18533var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
18534
18535/**
18536 * Checks if `value` is a buffer.
18537 *
18538 * @static
18539 * @memberOf _
18540 * @since 4.3.0
18541 * @category Lang
18542 * @param {*} value The value to check.
18543 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
18544 * @example
18545 *
18546 * _.isBuffer(new Buffer(2));
18547 * // => true
18548 *
18549 * _.isBuffer(new Uint8Array(2));
18550 * // => false
18551 */
18552var isBuffer = nativeIsBuffer || stubFalse_1;
18553
18554module.exports = isBuffer;
18555});
18556
18557/** Used as references for various `Number` constants. */
18558var MAX_SAFE_INTEGER = 9007199254740991;
18559
18560/** Used to detect unsigned integer values. */
18561var reIsUint = /^(?:0|[1-9]\d*)$/;
18562
18563/**
18564 * Checks if `value` is a valid array-like index.
18565 *
18566 * @private
18567 * @param {*} value The value to check.
18568 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
18569 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
18570 */
18571function isIndex(value, length) {
18572 var type = typeof value;
18573 length = length == null ? MAX_SAFE_INTEGER : length;
18574
18575 return !!length &&
18576 (type == 'number' ||
18577 (type != 'symbol' && reIsUint.test(value))) &&
18578 (value > -1 && value % 1 == 0 && value < length);
18579}
18580
18581var _isIndex = isIndex;
18582
18583/** Used as references for various `Number` constants. */
18584var MAX_SAFE_INTEGER$1 = 9007199254740991;
18585
18586/**
18587 * Checks if `value` is a valid array-like length.
18588 *
18589 * **Note:** This method is loosely based on
18590 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
18591 *
18592 * @static
18593 * @memberOf _
18594 * @since 4.0.0
18595 * @category Lang
18596 * @param {*} value The value to check.
18597 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
18598 * @example
18599 *
18600 * _.isLength(3);
18601 * // => true
18602 *
18603 * _.isLength(Number.MIN_VALUE);
18604 * // => false
18605 *
18606 * _.isLength(Infinity);
18607 * // => false
18608 *
18609 * _.isLength('3');
18610 * // => false
18611 */
18612function isLength(value) {
18613 return typeof value == 'number' &&
18614 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
18615}
18616
18617var isLength_1 = isLength;
18618
18619/** `Object#toString` result references. */
18620var argsTag$1 = '[object Arguments]',
18621 arrayTag = '[object Array]',
18622 boolTag = '[object Boolean]',
18623 dateTag = '[object Date]',
18624 errorTag = '[object Error]',
18625 funcTag$1 = '[object Function]',
18626 mapTag = '[object Map]',
18627 numberTag = '[object Number]',
18628 objectTag = '[object Object]',
18629 regexpTag = '[object RegExp]',
18630 setTag = '[object Set]',
18631 stringTag = '[object String]',
18632 weakMapTag = '[object WeakMap]';
18633
18634var arrayBufferTag = '[object ArrayBuffer]',
18635 dataViewTag = '[object DataView]',
18636 float32Tag = '[object Float32Array]',
18637 float64Tag = '[object Float64Array]',
18638 int8Tag = '[object Int8Array]',
18639 int16Tag = '[object Int16Array]',
18640 int32Tag = '[object Int32Array]',
18641 uint8Tag = '[object Uint8Array]',
18642 uint8ClampedTag = '[object Uint8ClampedArray]',
18643 uint16Tag = '[object Uint16Array]',
18644 uint32Tag = '[object Uint32Array]';
18645
18646/** Used to identify `toStringTag` values of typed arrays. */
18647var typedArrayTags = {};
18648typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
18649typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
18650typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
18651typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
18652typedArrayTags[uint32Tag] = true;
18653typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
18654typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
18655typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
18656typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
18657typedArrayTags[mapTag] = typedArrayTags[numberTag] =
18658typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
18659typedArrayTags[setTag] = typedArrayTags[stringTag] =
18660typedArrayTags[weakMapTag] = false;
18661
18662/**
18663 * The base implementation of `_.isTypedArray` without Node.js optimizations.
18664 *
18665 * @private
18666 * @param {*} value The value to check.
18667 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
18668 */
18669function baseIsTypedArray(value) {
18670 return isObjectLike_1(value) &&
18671 isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
18672}
18673
18674var _baseIsTypedArray = baseIsTypedArray;
18675
18676/**
18677 * The base implementation of `_.unary` without support for storing metadata.
18678 *
18679 * @private
18680 * @param {Function} func The function to cap arguments for.
18681 * @returns {Function} Returns the new capped function.
18682 */
18683function baseUnary(func) {
18684 return function(value) {
18685 return func(value);
18686 };
18687}
18688
18689var _baseUnary = baseUnary;
18690
18691var _nodeUtil = createCommonjsModule(function (module, exports) {
18692/** Detect free variable `exports`. */
18693var freeExports = exports && !exports.nodeType && exports;
18694
18695/** Detect free variable `module`. */
18696var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
18697
18698/** Detect the popular CommonJS extension `module.exports`. */
18699var moduleExports = freeModule && freeModule.exports === freeExports;
18700
18701/** Detect free variable `process` from Node.js. */
18702var freeProcess = moduleExports && _freeGlobal.process;
18703
18704/** Used to access faster Node.js helpers. */
18705var nodeUtil = (function() {
18706 try {
18707 // Use `util.types` for Node.js 10+.
18708 var types = freeModule && freeModule.require && freeModule.require('util').types;
18709
18710 if (types) {
18711 return types;
18712 }
18713
18714 // Legacy `process.binding('util')` for Node.js < 10.
18715 return freeProcess && freeProcess.binding && freeProcess.binding('util');
18716 } catch (e) {}
18717}());
18718
18719module.exports = nodeUtil;
18720});
18721
18722/* Node.js helper references. */
18723var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
18724
18725/**
18726 * Checks if `value` is classified as a typed array.
18727 *
18728 * @static
18729 * @memberOf _
18730 * @since 3.0.0
18731 * @category Lang
18732 * @param {*} value The value to check.
18733 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
18734 * @example
18735 *
18736 * _.isTypedArray(new Uint8Array);
18737 * // => true
18738 *
18739 * _.isTypedArray([]);
18740 * // => false
18741 */
18742var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
18743
18744var isTypedArray_1 = isTypedArray;
18745
18746/** Used for built-in method references. */
18747var objectProto$7 = Object.prototype;
18748
18749/** Used to check objects for own properties. */
18750var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
18751
18752/**
18753 * Creates an array of the enumerable property names of the array-like `value`.
18754 *
18755 * @private
18756 * @param {*} value The value to query.
18757 * @param {boolean} inherited Specify returning inherited property names.
18758 * @returns {Array} Returns the array of property names.
18759 */
18760function arrayLikeKeys(value, inherited) {
18761 var isArr = isArray_1(value),
18762 isArg = !isArr && isArguments_1(value),
18763 isBuff = !isArr && !isArg && isBuffer_1(value),
18764 isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
18765 skipIndexes = isArr || isArg || isBuff || isType,
18766 result = skipIndexes ? _baseTimes(value.length, String) : [],
18767 length = result.length;
18768
18769 for (var key in value) {
18770 if ((inherited || hasOwnProperty$6.call(value, key)) &&
18771 !(skipIndexes && (
18772 // Safari 9 has enumerable `arguments.length` in strict mode.
18773 key == 'length' ||
18774 // Node.js 0.10 has enumerable non-index properties on buffers.
18775 (isBuff && (key == 'offset' || key == 'parent')) ||
18776 // PhantomJS 2 has enumerable non-index properties on typed arrays.
18777 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
18778 // Skip index properties.
18779 _isIndex(key, length)
18780 ))) {
18781 result.push(key);
18782 }
18783 }
18784 return result;
18785}
18786
18787var _arrayLikeKeys = arrayLikeKeys;
18788
18789/** Used for built-in method references. */
18790var objectProto$8 = Object.prototype;
18791
18792/**
18793 * Checks if `value` is likely a prototype object.
18794 *
18795 * @private
18796 * @param {*} value The value to check.
18797 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
18798 */
18799function isPrototype(value) {
18800 var Ctor = value && value.constructor,
18801 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
18802
18803 return value === proto;
18804}
18805
18806var _isPrototype = isPrototype;
18807
18808/**
18809 * Creates a unary function that invokes `func` with its argument transformed.
18810 *
18811 * @private
18812 * @param {Function} func The function to wrap.
18813 * @param {Function} transform The argument transform.
18814 * @returns {Function} Returns the new function.
18815 */
18816function overArg(func, transform) {
18817 return function(arg) {
18818 return func(transform(arg));
18819 };
18820}
18821
18822var _overArg = overArg;
18823
18824/* Built-in method references for those with the same name as other `lodash` methods. */
18825var nativeKeys = _overArg(Object.keys, Object);
18826
18827var _nativeKeys = nativeKeys;
18828
18829/** Used for built-in method references. */
18830var objectProto$9 = Object.prototype;
18831
18832/** Used to check objects for own properties. */
18833var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
18834
18835/**
18836 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
18837 *
18838 * @private
18839 * @param {Object} object The object to query.
18840 * @returns {Array} Returns the array of property names.
18841 */
18842function baseKeys(object) {
18843 if (!_isPrototype(object)) {
18844 return _nativeKeys(object);
18845 }
18846 var result = [];
18847 for (var key in Object(object)) {
18848 if (hasOwnProperty$7.call(object, key) && key != 'constructor') {
18849 result.push(key);
18850 }
18851 }
18852 return result;
18853}
18854
18855var _baseKeys = baseKeys;
18856
18857/**
18858 * Checks if `value` is array-like. A value is considered array-like if it's
18859 * not a function and has a `value.length` that's an integer greater than or
18860 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
18861 *
18862 * @static
18863 * @memberOf _
18864 * @since 4.0.0
18865 * @category Lang
18866 * @param {*} value The value to check.
18867 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
18868 * @example
18869 *
18870 * _.isArrayLike([1, 2, 3]);
18871 * // => true
18872 *
18873 * _.isArrayLike(document.body.children);
18874 * // => true
18875 *
18876 * _.isArrayLike('abc');
18877 * // => true
18878 *
18879 * _.isArrayLike(_.noop);
18880 * // => false
18881 */
18882function isArrayLike(value) {
18883 return value != null && isLength_1(value.length) && !isFunction_1(value);
18884}
18885
18886var isArrayLike_1 = isArrayLike;
18887
18888/**
18889 * Creates an array of the own enumerable property names of `object`.
18890 *
18891 * **Note:** Non-object values are coerced to objects. See the
18892 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
18893 * for more details.
18894 *
18895 * @static
18896 * @since 0.1.0
18897 * @memberOf _
18898 * @category Object
18899 * @param {Object} object The object to query.
18900 * @returns {Array} Returns the array of property names.
18901 * @example
18902 *
18903 * function Foo() {
18904 * this.a = 1;
18905 * this.b = 2;
18906 * }
18907 *
18908 * Foo.prototype.c = 3;
18909 *
18910 * _.keys(new Foo);
18911 * // => ['a', 'b'] (iteration order is not guaranteed)
18912 *
18913 * _.keys('hi');
18914 * // => ['0', '1']
18915 */
18916function keys(object) {
18917 return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
18918}
18919
18920var keys_1 = keys;
18921
18922/**
18923 * The base implementation of `_.assign` without support for multiple sources
18924 * or `customizer` functions.
18925 *
18926 * @private
18927 * @param {Object} object The destination object.
18928 * @param {Object} source The source object.
18929 * @returns {Object} Returns `object`.
18930 */
18931function baseAssign(object, source) {
18932 return object && _copyObject(source, keys_1(source), object);
18933}
18934
18935var _baseAssign = baseAssign;
18936
18937/**
18938 * This function is like
18939 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
18940 * except that it includes inherited enumerable properties.
18941 *
18942 * @private
18943 * @param {Object} object The object to query.
18944 * @returns {Array} Returns the array of property names.
18945 */
18946function nativeKeysIn(object) {
18947 var result = [];
18948 if (object != null) {
18949 for (var key in Object(object)) {
18950 result.push(key);
18951 }
18952 }
18953 return result;
18954}
18955
18956var _nativeKeysIn = nativeKeysIn;
18957
18958/** Used for built-in method references. */
18959var objectProto$a = Object.prototype;
18960
18961/** Used to check objects for own properties. */
18962var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
18963
18964/**
18965 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
18966 *
18967 * @private
18968 * @param {Object} object The object to query.
18969 * @returns {Array} Returns the array of property names.
18970 */
18971function baseKeysIn(object) {
18972 if (!isObject_1(object)) {
18973 return _nativeKeysIn(object);
18974 }
18975 var isProto = _isPrototype(object),
18976 result = [];
18977
18978 for (var key in object) {
18979 if (!(key == 'constructor' && (isProto || !hasOwnProperty$8.call(object, key)))) {
18980 result.push(key);
18981 }
18982 }
18983 return result;
18984}
18985
18986var _baseKeysIn = baseKeysIn;
18987
18988/**
18989 * Creates an array of the own and inherited enumerable property names of `object`.
18990 *
18991 * **Note:** Non-object values are coerced to objects.
18992 *
18993 * @static
18994 * @memberOf _
18995 * @since 3.0.0
18996 * @category Object
18997 * @param {Object} object The object to query.
18998 * @returns {Array} Returns the array of property names.
18999 * @example
19000 *
19001 * function Foo() {
19002 * this.a = 1;
19003 * this.b = 2;
19004 * }
19005 *
19006 * Foo.prototype.c = 3;
19007 *
19008 * _.keysIn(new Foo);
19009 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
19010 */
19011function keysIn(object) {
19012 return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
19013}
19014
19015var keysIn_1 = keysIn;
19016
19017/**
19018 * The base implementation of `_.assignIn` without support for multiple sources
19019 * or `customizer` functions.
19020 *
19021 * @private
19022 * @param {Object} object The destination object.
19023 * @param {Object} source The source object.
19024 * @returns {Object} Returns `object`.
19025 */
19026function baseAssignIn(object, source) {
19027 return object && _copyObject(source, keysIn_1(source), object);
19028}
19029
19030var _baseAssignIn = baseAssignIn;
19031
19032var _cloneBuffer = createCommonjsModule(function (module, exports) {
19033/** Detect free variable `exports`. */
19034var freeExports = exports && !exports.nodeType && exports;
19035
19036/** Detect free variable `module`. */
19037var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
19038
19039/** Detect the popular CommonJS extension `module.exports`. */
19040var moduleExports = freeModule && freeModule.exports === freeExports;
19041
19042/** Built-in value references. */
19043var Buffer = moduleExports ? _root.Buffer : undefined,
19044 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
19045
19046/**
19047 * Creates a clone of `buffer`.
19048 *
19049 * @private
19050 * @param {Buffer} buffer The buffer to clone.
19051 * @param {boolean} [isDeep] Specify a deep clone.
19052 * @returns {Buffer} Returns the cloned buffer.
19053 */
19054function cloneBuffer(buffer, isDeep) {
19055 if (isDeep) {
19056 return buffer.slice();
19057 }
19058 var length = buffer.length,
19059 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
19060
19061 buffer.copy(result);
19062 return result;
19063}
19064
19065module.exports = cloneBuffer;
19066});
19067
19068/**
19069 * Copies the values of `source` to `array`.
19070 *
19071 * @private
19072 * @param {Array} source The array to copy values from.
19073 * @param {Array} [array=[]] The array to copy values to.
19074 * @returns {Array} Returns `array`.
19075 */
19076function copyArray(source, array) {
19077 var index = -1,
19078 length = source.length;
19079
19080 array || (array = Array(length));
19081 while (++index < length) {
19082 array[index] = source[index];
19083 }
19084 return array;
19085}
19086
19087var _copyArray = copyArray;
19088
19089/**
19090 * A specialized version of `_.filter` for arrays without support for
19091 * iteratee shorthands.
19092 *
19093 * @private
19094 * @param {Array} [array] The array to iterate over.
19095 * @param {Function} predicate The function invoked per iteration.
19096 * @returns {Array} Returns the new filtered array.
19097 */
19098function arrayFilter(array, predicate) {
19099 var index = -1,
19100 length = array == null ? 0 : array.length,
19101 resIndex = 0,
19102 result = [];
19103
19104 while (++index < length) {
19105 var value = array[index];
19106 if (predicate(value, index, array)) {
19107 result[resIndex++] = value;
19108 }
19109 }
19110 return result;
19111}
19112
19113var _arrayFilter = arrayFilter;
19114
19115/**
19116 * This method returns a new empty array.
19117 *
19118 * @static
19119 * @memberOf _
19120 * @since 4.13.0
19121 * @category Util
19122 * @returns {Array} Returns the new empty array.
19123 * @example
19124 *
19125 * var arrays = _.times(2, _.stubArray);
19126 *
19127 * console.log(arrays);
19128 * // => [[], []]
19129 *
19130 * console.log(arrays[0] === arrays[1]);
19131 * // => false
19132 */
19133function stubArray() {
19134 return [];
19135}
19136
19137var stubArray_1 = stubArray;
19138
19139/** Used for built-in method references. */
19140var objectProto$b = Object.prototype;
19141
19142/** Built-in value references. */
19143var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
19144
19145/* Built-in method references for those with the same name as other `lodash` methods. */
19146var nativeGetSymbols = Object.getOwnPropertySymbols;
19147
19148/**
19149 * Creates an array of the own enumerable symbols of `object`.
19150 *
19151 * @private
19152 * @param {Object} object The object to query.
19153 * @returns {Array} Returns the array of symbols.
19154 */
19155var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
19156 if (object == null) {
19157 return [];
19158 }
19159 object = Object(object);
19160 return _arrayFilter(nativeGetSymbols(object), function(symbol) {
19161 return propertyIsEnumerable$1.call(object, symbol);
19162 });
19163};
19164
19165var _getSymbols = getSymbols;
19166
19167/**
19168 * Copies own symbols of `source` to `object`.
19169 *
19170 * @private
19171 * @param {Object} source The object to copy symbols from.
19172 * @param {Object} [object={}] The object to copy symbols to.
19173 * @returns {Object} Returns `object`.
19174 */
19175function copySymbols(source, object) {
19176 return _copyObject(source, _getSymbols(source), object);
19177}
19178
19179var _copySymbols = copySymbols;
19180
19181/**
19182 * Appends the elements of `values` to `array`.
19183 *
19184 * @private
19185 * @param {Array} array The array to modify.
19186 * @param {Array} values The values to append.
19187 * @returns {Array} Returns `array`.
19188 */
19189function arrayPush(array, values) {
19190 var index = -1,
19191 length = values.length,
19192 offset = array.length;
19193
19194 while (++index < length) {
19195 array[offset + index] = values[index];
19196 }
19197 return array;
19198}
19199
19200var _arrayPush = arrayPush;
19201
19202/** Built-in value references. */
19203var getPrototype = _overArg(Object.getPrototypeOf, Object);
19204
19205var _getPrototype = getPrototype;
19206
19207/* Built-in method references for those with the same name as other `lodash` methods. */
19208var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
19209
19210/**
19211 * Creates an array of the own and inherited enumerable symbols of `object`.
19212 *
19213 * @private
19214 * @param {Object} object The object to query.
19215 * @returns {Array} Returns the array of symbols.
19216 */
19217var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
19218 var result = [];
19219 while (object) {
19220 _arrayPush(result, _getSymbols(object));
19221 object = _getPrototype(object);
19222 }
19223 return result;
19224};
19225
19226var _getSymbolsIn = getSymbolsIn;
19227
19228/**
19229 * Copies own and inherited symbols of `source` to `object`.
19230 *
19231 * @private
19232 * @param {Object} source The object to copy symbols from.
19233 * @param {Object} [object={}] The object to copy symbols to.
19234 * @returns {Object} Returns `object`.
19235 */
19236function copySymbolsIn(source, object) {
19237 return _copyObject(source, _getSymbolsIn(source), object);
19238}
19239
19240var _copySymbolsIn = copySymbolsIn;
19241
19242/**
19243 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
19244 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
19245 * symbols of `object`.
19246 *
19247 * @private
19248 * @param {Object} object The object to query.
19249 * @param {Function} keysFunc The function to get the keys of `object`.
19250 * @param {Function} symbolsFunc The function to get the symbols of `object`.
19251 * @returns {Array} Returns the array of property names and symbols.
19252 */
19253function baseGetAllKeys(object, keysFunc, symbolsFunc) {
19254 var result = keysFunc(object);
19255 return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
19256}
19257
19258var _baseGetAllKeys = baseGetAllKeys;
19259
19260/**
19261 * Creates an array of own enumerable property names and symbols of `object`.
19262 *
19263 * @private
19264 * @param {Object} object The object to query.
19265 * @returns {Array} Returns the array of property names and symbols.
19266 */
19267function getAllKeys(object) {
19268 return _baseGetAllKeys(object, keys_1, _getSymbols);
19269}
19270
19271var _getAllKeys = getAllKeys;
19272
19273/**
19274 * Creates an array of own and inherited enumerable property names and
19275 * symbols of `object`.
19276 *
19277 * @private
19278 * @param {Object} object The object to query.
19279 * @returns {Array} Returns the array of property names and symbols.
19280 */
19281function getAllKeysIn(object) {
19282 return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
19283}
19284
19285var _getAllKeysIn = getAllKeysIn;
19286
19287/* Built-in method references that are verified to be native. */
19288var DataView = _getNative(_root, 'DataView');
19289
19290var _DataView = DataView;
19291
19292/* Built-in method references that are verified to be native. */
19293var Promise$1 = _getNative(_root, 'Promise');
19294
19295var _Promise = Promise$1;
19296
19297/* Built-in method references that are verified to be native. */
19298var Set$1 = _getNative(_root, 'Set');
19299
19300var _Set = Set$1;
19301
19302/* Built-in method references that are verified to be native. */
19303var WeakMap = _getNative(_root, 'WeakMap');
19304
19305var _WeakMap = WeakMap;
19306
19307/** `Object#toString` result references. */
19308var mapTag$1 = '[object Map]',
19309 objectTag$1 = '[object Object]',
19310 promiseTag = '[object Promise]',
19311 setTag$1 = '[object Set]',
19312 weakMapTag$1 = '[object WeakMap]';
19313
19314var dataViewTag$1 = '[object DataView]';
19315
19316/** Used to detect maps, sets, and weakmaps. */
19317var dataViewCtorString = _toSource(_DataView),
19318 mapCtorString = _toSource(_Map),
19319 promiseCtorString = _toSource(_Promise),
19320 setCtorString = _toSource(_Set),
19321 weakMapCtorString = _toSource(_WeakMap);
19322
19323/**
19324 * Gets the `toStringTag` of `value`.
19325 *
19326 * @private
19327 * @param {*} value The value to query.
19328 * @returns {string} Returns the `toStringTag`.
19329 */
19330var getTag = _baseGetTag;
19331
19332// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
19333if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
19334 (_Map && getTag(new _Map) != mapTag$1) ||
19335 (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
19336 (_Set && getTag(new _Set) != setTag$1) ||
19337 (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
19338 getTag = function(value) {
19339 var result = _baseGetTag(value),
19340 Ctor = result == objectTag$1 ? value.constructor : undefined,
19341 ctorString = Ctor ? _toSource(Ctor) : '';
19342
19343 if (ctorString) {
19344 switch (ctorString) {
19345 case dataViewCtorString: return dataViewTag$1;
19346 case mapCtorString: return mapTag$1;
19347 case promiseCtorString: return promiseTag;
19348 case setCtorString: return setTag$1;
19349 case weakMapCtorString: return weakMapTag$1;
19350 }
19351 }
19352 return result;
19353 };
19354}
19355
19356var _getTag = getTag;
19357
19358/** Used for built-in method references. */
19359var objectProto$c = Object.prototype;
19360
19361/** Used to check objects for own properties. */
19362var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
19363
19364/**
19365 * Initializes an array clone.
19366 *
19367 * @private
19368 * @param {Array} array The array to clone.
19369 * @returns {Array} Returns the initialized clone.
19370 */
19371function initCloneArray(array) {
19372 var length = array.length,
19373 result = new array.constructor(length);
19374
19375 // Add properties assigned by `RegExp#exec`.
19376 if (length && typeof array[0] == 'string' && hasOwnProperty$9.call(array, 'index')) {
19377 result.index = array.index;
19378 result.input = array.input;
19379 }
19380 return result;
19381}
19382
19383var _initCloneArray = initCloneArray;
19384
19385/** Built-in value references. */
19386var Uint8Array$1 = _root.Uint8Array;
19387
19388var _Uint8Array = Uint8Array$1;
19389
19390/**
19391 * Creates a clone of `arrayBuffer`.
19392 *
19393 * @private
19394 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
19395 * @returns {ArrayBuffer} Returns the cloned array buffer.
19396 */
19397function cloneArrayBuffer(arrayBuffer) {
19398 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
19399 new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
19400 return result;
19401}
19402
19403var _cloneArrayBuffer = cloneArrayBuffer;
19404
19405/**
19406 * Creates a clone of `dataView`.
19407 *
19408 * @private
19409 * @param {Object} dataView The data view to clone.
19410 * @param {boolean} [isDeep] Specify a deep clone.
19411 * @returns {Object} Returns the cloned data view.
19412 */
19413function cloneDataView(dataView, isDeep) {
19414 var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
19415 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
19416}
19417
19418var _cloneDataView = cloneDataView;
19419
19420/** Used to match `RegExp` flags from their coerced string values. */
19421var reFlags = /\w*$/;
19422
19423/**
19424 * Creates a clone of `regexp`.
19425 *
19426 * @private
19427 * @param {Object} regexp The regexp to clone.
19428 * @returns {Object} Returns the cloned regexp.
19429 */
19430function cloneRegExp(regexp) {
19431 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
19432 result.lastIndex = regexp.lastIndex;
19433 return result;
19434}
19435
19436var _cloneRegExp = cloneRegExp;
19437
19438/** Used to convert symbols to primitives and strings. */
19439var symbolProto = _Symbol ? _Symbol.prototype : undefined,
19440 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
19441
19442/**
19443 * Creates a clone of the `symbol` object.
19444 *
19445 * @private
19446 * @param {Object} symbol The symbol object to clone.
19447 * @returns {Object} Returns the cloned symbol object.
19448 */
19449function cloneSymbol(symbol) {
19450 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
19451}
19452
19453var _cloneSymbol = cloneSymbol;
19454
19455/**
19456 * Creates a clone of `typedArray`.
19457 *
19458 * @private
19459 * @param {Object} typedArray The typed array to clone.
19460 * @param {boolean} [isDeep] Specify a deep clone.
19461 * @returns {Object} Returns the cloned typed array.
19462 */
19463function cloneTypedArray(typedArray, isDeep) {
19464 var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
19465 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
19466}
19467
19468var _cloneTypedArray = cloneTypedArray;
19469
19470/** `Object#toString` result references. */
19471var boolTag$1 = '[object Boolean]',
19472 dateTag$1 = '[object Date]',
19473 mapTag$2 = '[object Map]',
19474 numberTag$1 = '[object Number]',
19475 regexpTag$1 = '[object RegExp]',
19476 setTag$2 = '[object Set]',
19477 stringTag$1 = '[object String]',
19478 symbolTag = '[object Symbol]';
19479
19480var arrayBufferTag$1 = '[object ArrayBuffer]',
19481 dataViewTag$2 = '[object DataView]',
19482 float32Tag$1 = '[object Float32Array]',
19483 float64Tag$1 = '[object Float64Array]',
19484 int8Tag$1 = '[object Int8Array]',
19485 int16Tag$1 = '[object Int16Array]',
19486 int32Tag$1 = '[object Int32Array]',
19487 uint8Tag$1 = '[object Uint8Array]',
19488 uint8ClampedTag$1 = '[object Uint8ClampedArray]',
19489 uint16Tag$1 = '[object Uint16Array]',
19490 uint32Tag$1 = '[object Uint32Array]';
19491
19492/**
19493 * Initializes an object clone based on its `toStringTag`.
19494 *
19495 * **Note:** This function only supports cloning values with tags of
19496 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
19497 *
19498 * @private
19499 * @param {Object} object The object to clone.
19500 * @param {string} tag The `toStringTag` of the object to clone.
19501 * @param {boolean} [isDeep] Specify a deep clone.
19502 * @returns {Object} Returns the initialized clone.
19503 */
19504function initCloneByTag(object, tag, isDeep) {
19505 var Ctor = object.constructor;
19506 switch (tag) {
19507 case arrayBufferTag$1:
19508 return _cloneArrayBuffer(object);
19509
19510 case boolTag$1:
19511 case dateTag$1:
19512 return new Ctor(+object);
19513
19514 case dataViewTag$2:
19515 return _cloneDataView(object, isDeep);
19516
19517 case float32Tag$1: case float64Tag$1:
19518 case int8Tag$1: case int16Tag$1: case int32Tag$1:
19519 case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
19520 return _cloneTypedArray(object, isDeep);
19521
19522 case mapTag$2:
19523 return new Ctor;
19524
19525 case numberTag$1:
19526 case stringTag$1:
19527 return new Ctor(object);
19528
19529 case regexpTag$1:
19530 return _cloneRegExp(object);
19531
19532 case setTag$2:
19533 return new Ctor;
19534
19535 case symbolTag:
19536 return _cloneSymbol(object);
19537 }
19538}
19539
19540var _initCloneByTag = initCloneByTag;
19541
19542/** Built-in value references. */
19543var objectCreate = Object.create;
19544
19545/**
19546 * The base implementation of `_.create` without support for assigning
19547 * properties to the created object.
19548 *
19549 * @private
19550 * @param {Object} proto The object to inherit from.
19551 * @returns {Object} Returns the new object.
19552 */
19553var baseCreate = (function() {
19554 function object() {}
19555 return function(proto) {
19556 if (!isObject_1(proto)) {
19557 return {};
19558 }
19559 if (objectCreate) {
19560 return objectCreate(proto);
19561 }
19562 object.prototype = proto;
19563 var result = new object;
19564 object.prototype = undefined;
19565 return result;
19566 };
19567}());
19568
19569var _baseCreate = baseCreate;
19570
19571/**
19572 * Initializes an object clone.
19573 *
19574 * @private
19575 * @param {Object} object The object to clone.
19576 * @returns {Object} Returns the initialized clone.
19577 */
19578function initCloneObject(object) {
19579 return (typeof object.constructor == 'function' && !_isPrototype(object))
19580 ? _baseCreate(_getPrototype(object))
19581 : {};
19582}
19583
19584var _initCloneObject = initCloneObject;
19585
19586/** `Object#toString` result references. */
19587var mapTag$3 = '[object Map]';
19588
19589/**
19590 * The base implementation of `_.isMap` without Node.js optimizations.
19591 *
19592 * @private
19593 * @param {*} value The value to check.
19594 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
19595 */
19596function baseIsMap(value) {
19597 return isObjectLike_1(value) && _getTag(value) == mapTag$3;
19598}
19599
19600var _baseIsMap = baseIsMap;
19601
19602/* Node.js helper references. */
19603var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
19604
19605/**
19606 * Checks if `value` is classified as a `Map` object.
19607 *
19608 * @static
19609 * @memberOf _
19610 * @since 4.3.0
19611 * @category Lang
19612 * @param {*} value The value to check.
19613 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
19614 * @example
19615 *
19616 * _.isMap(new Map);
19617 * // => true
19618 *
19619 * _.isMap(new WeakMap);
19620 * // => false
19621 */
19622var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
19623
19624var isMap_1 = isMap;
19625
19626/** `Object#toString` result references. */
19627var setTag$3 = '[object Set]';
19628
19629/**
19630 * The base implementation of `_.isSet` without Node.js optimizations.
19631 *
19632 * @private
19633 * @param {*} value The value to check.
19634 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
19635 */
19636function baseIsSet(value) {
19637 return isObjectLike_1(value) && _getTag(value) == setTag$3;
19638}
19639
19640var _baseIsSet = baseIsSet;
19641
19642/* Node.js helper references. */
19643var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
19644
19645/**
19646 * Checks if `value` is classified as a `Set` object.
19647 *
19648 * @static
19649 * @memberOf _
19650 * @since 4.3.0
19651 * @category Lang
19652 * @param {*} value The value to check.
19653 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
19654 * @example
19655 *
19656 * _.isSet(new Set);
19657 * // => true
19658 *
19659 * _.isSet(new WeakSet);
19660 * // => false
19661 */
19662var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
19663
19664var isSet_1 = isSet;
19665
19666/** Used to compose bitmasks for cloning. */
19667var CLONE_DEEP_FLAG = 1,
19668 CLONE_FLAT_FLAG = 2,
19669 CLONE_SYMBOLS_FLAG = 4;
19670
19671/** `Object#toString` result references. */
19672var argsTag$2 = '[object Arguments]',
19673 arrayTag$1 = '[object Array]',
19674 boolTag$2 = '[object Boolean]',
19675 dateTag$2 = '[object Date]',
19676 errorTag$1 = '[object Error]',
19677 funcTag$2 = '[object Function]',
19678 genTag$1 = '[object GeneratorFunction]',
19679 mapTag$4 = '[object Map]',
19680 numberTag$2 = '[object Number]',
19681 objectTag$2 = '[object Object]',
19682 regexpTag$2 = '[object RegExp]',
19683 setTag$4 = '[object Set]',
19684 stringTag$2 = '[object String]',
19685 symbolTag$1 = '[object Symbol]',
19686 weakMapTag$2 = '[object WeakMap]';
19687
19688var arrayBufferTag$2 = '[object ArrayBuffer]',
19689 dataViewTag$3 = '[object DataView]',
19690 float32Tag$2 = '[object Float32Array]',
19691 float64Tag$2 = '[object Float64Array]',
19692 int8Tag$2 = '[object Int8Array]',
19693 int16Tag$2 = '[object Int16Array]',
19694 int32Tag$2 = '[object Int32Array]',
19695 uint8Tag$2 = '[object Uint8Array]',
19696 uint8ClampedTag$2 = '[object Uint8ClampedArray]',
19697 uint16Tag$2 = '[object Uint16Array]',
19698 uint32Tag$2 = '[object Uint32Array]';
19699
19700/** Used to identify `toStringTag` values supported by `_.clone`. */
19701var cloneableTags = {};
19702cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
19703cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
19704cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
19705cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
19706cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
19707cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
19708cloneableTags[numberTag$2] = cloneableTags[objectTag$2] =
19709cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
19710cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
19711cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
19712cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
19713cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
19714cloneableTags[weakMapTag$2] = false;
19715
19716/**
19717 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
19718 * traversed objects.
19719 *
19720 * @private
19721 * @param {*} value The value to clone.
19722 * @param {boolean} bitmask The bitmask flags.
19723 * 1 - Deep clone
19724 * 2 - Flatten inherited properties
19725 * 4 - Clone symbols
19726 * @param {Function} [customizer] The function to customize cloning.
19727 * @param {string} [key] The key of `value`.
19728 * @param {Object} [object] The parent object of `value`.
19729 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
19730 * @returns {*} Returns the cloned value.
19731 */
19732function baseClone(value, bitmask, customizer, key, object, stack) {
19733 var result,
19734 isDeep = bitmask & CLONE_DEEP_FLAG,
19735 isFlat = bitmask & CLONE_FLAT_FLAG,
19736 isFull = bitmask & CLONE_SYMBOLS_FLAG;
19737
19738 if (customizer) {
19739 result = object ? customizer(value, key, object, stack) : customizer(value);
19740 }
19741 if (result !== undefined) {
19742 return result;
19743 }
19744 if (!isObject_1(value)) {
19745 return value;
19746 }
19747 var isArr = isArray_1(value);
19748 if (isArr) {
19749 result = _initCloneArray(value);
19750 if (!isDeep) {
19751 return _copyArray(value, result);
19752 }
19753 } else {
19754 var tag = _getTag(value),
19755 isFunc = tag == funcTag$2 || tag == genTag$1;
19756
19757 if (isBuffer_1(value)) {
19758 return _cloneBuffer(value, isDeep);
19759 }
19760 if (tag == objectTag$2 || tag == argsTag$2 || (isFunc && !object)) {
19761 result = (isFlat || isFunc) ? {} : _initCloneObject(value);
19762 if (!isDeep) {
19763 return isFlat
19764 ? _copySymbolsIn(value, _baseAssignIn(result, value))
19765 : _copySymbols(value, _baseAssign(result, value));
19766 }
19767 } else {
19768 if (!cloneableTags[tag]) {
19769 return object ? value : {};
19770 }
19771 result = _initCloneByTag(value, tag, isDeep);
19772 }
19773 }
19774 // Check for circular references and return its corresponding clone.
19775 stack || (stack = new _Stack);
19776 var stacked = stack.get(value);
19777 if (stacked) {
19778 return stacked;
19779 }
19780 stack.set(value, result);
19781
19782 if (isSet_1(value)) {
19783 value.forEach(function(subValue) {
19784 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
19785 });
19786 } else if (isMap_1(value)) {
19787 value.forEach(function(subValue, key) {
19788 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
19789 });
19790 }
19791
19792 var keysFunc = isFull
19793 ? (isFlat ? _getAllKeysIn : _getAllKeys)
19794 : (isFlat ? keysIn_1 : keys_1);
19795
19796 var props = isArr ? undefined : keysFunc(value);
19797 _arrayEach(props || value, function(subValue, key) {
19798 if (props) {
19799 key = subValue;
19800 subValue = value[key];
19801 }
19802 // Recursively populate clone (susceptible to call stack limits).
19803 _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
19804 });
19805 return result;
19806}
19807
19808var _baseClone = baseClone;
19809
19810/** Used to compose bitmasks for cloning. */
19811var CLONE_SYMBOLS_FLAG$1 = 4;
19812
19813/**
19814 * Creates a shallow clone of `value`.
19815 *
19816 * **Note:** This method is loosely based on the
19817 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
19818 * and supports cloning arrays, array buffers, booleans, date objects, maps,
19819 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
19820 * arrays. The own enumerable properties of `arguments` objects are cloned
19821 * as plain objects. An empty object is returned for uncloneable values such
19822 * as error objects, functions, DOM nodes, and WeakMaps.
19823 *
19824 * @static
19825 * @memberOf _
19826 * @since 0.1.0
19827 * @category Lang
19828 * @param {*} value The value to clone.
19829 * @returns {*} Returns the cloned value.
19830 * @see _.cloneDeep
19831 * @example
19832 *
19833 * var objects = [{ 'a': 1 }, { 'b': 2 }];
19834 *
19835 * var shallow = _.clone(objects);
19836 * console.log(shallow[0] === objects[0]);
19837 * // => true
19838 */
19839function clone(value) {
19840 return _baseClone(value, CLONE_SYMBOLS_FLAG$1);
19841}
19842
19843var clone_1 = clone;
19844
19845/**
19846 * Creates a function that returns `value`.
19847 *
19848 * @static
19849 * @memberOf _
19850 * @since 2.4.0
19851 * @category Util
19852 * @param {*} value The value to return from the new function.
19853 * @returns {Function} Returns the new constant function.
19854 * @example
19855 *
19856 * var objects = _.times(2, _.constant({ 'a': 1 }));
19857 *
19858 * console.log(objects);
19859 * // => [{ 'a': 1 }, { 'a': 1 }]
19860 *
19861 * console.log(objects[0] === objects[1]);
19862 * // => true
19863 */
19864function constant(value) {
19865 return function() {
19866 return value;
19867 };
19868}
19869
19870var constant_1 = constant;
19871
19872/**
19873 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
19874 *
19875 * @private
19876 * @param {boolean} [fromRight] Specify iterating from right to left.
19877 * @returns {Function} Returns the new base function.
19878 */
19879function createBaseFor(fromRight) {
19880 return function(object, iteratee, keysFunc) {
19881 var index = -1,
19882 iterable = Object(object),
19883 props = keysFunc(object),
19884 length = props.length;
19885
19886 while (length--) {
19887 var key = props[fromRight ? length : ++index];
19888 if (iteratee(iterable[key], key, iterable) === false) {
19889 break;
19890 }
19891 }
19892 return object;
19893 };
19894}
19895
19896var _createBaseFor = createBaseFor;
19897
19898/**
19899 * The base implementation of `baseForOwn` which iterates over `object`
19900 * properties returned by `keysFunc` and invokes `iteratee` for each property.
19901 * Iteratee functions may exit iteration early by explicitly returning `false`.
19902 *
19903 * @private
19904 * @param {Object} object The object to iterate over.
19905 * @param {Function} iteratee The function invoked per iteration.
19906 * @param {Function} keysFunc The function to get the keys of `object`.
19907 * @returns {Object} Returns `object`.
19908 */
19909var baseFor = _createBaseFor();
19910
19911var _baseFor = baseFor;
19912
19913/**
19914 * The base implementation of `_.forOwn` without support for iteratee shorthands.
19915 *
19916 * @private
19917 * @param {Object} object The object to iterate over.
19918 * @param {Function} iteratee The function invoked per iteration.
19919 * @returns {Object} Returns `object`.
19920 */
19921function baseForOwn(object, iteratee) {
19922 return object && _baseFor(object, iteratee, keys_1);
19923}
19924
19925var _baseForOwn = baseForOwn;
19926
19927/**
19928 * Creates a `baseEach` or `baseEachRight` function.
19929 *
19930 * @private
19931 * @param {Function} eachFunc The function to iterate over a collection.
19932 * @param {boolean} [fromRight] Specify iterating from right to left.
19933 * @returns {Function} Returns the new base function.
19934 */
19935function createBaseEach(eachFunc, fromRight) {
19936 return function(collection, iteratee) {
19937 if (collection == null) {
19938 return collection;
19939 }
19940 if (!isArrayLike_1(collection)) {
19941 return eachFunc(collection, iteratee);
19942 }
19943 var length = collection.length,
19944 index = fromRight ? length : -1,
19945 iterable = Object(collection);
19946
19947 while ((fromRight ? index-- : ++index < length)) {
19948 if (iteratee(iterable[index], index, iterable) === false) {
19949 break;
19950 }
19951 }
19952 return collection;
19953 };
19954}
19955
19956var _createBaseEach = createBaseEach;
19957
19958/**
19959 * The base implementation of `_.forEach` without support for iteratee shorthands.
19960 *
19961 * @private
19962 * @param {Array|Object} collection The collection to iterate over.
19963 * @param {Function} iteratee The function invoked per iteration.
19964 * @returns {Array|Object} Returns `collection`.
19965 */
19966var baseEach = _createBaseEach(_baseForOwn);
19967
19968var _baseEach = baseEach;
19969
19970/**
19971 * This method returns the first argument it receives.
19972 *
19973 * @static
19974 * @since 0.1.0
19975 * @memberOf _
19976 * @category Util
19977 * @param {*} value Any value.
19978 * @returns {*} Returns `value`.
19979 * @example
19980 *
19981 * var object = { 'a': 1 };
19982 *
19983 * console.log(_.identity(object) === object);
19984 * // => true
19985 */
19986function identity(value) {
19987 return value;
19988}
19989
19990var identity_1 = identity;
19991
19992/**
19993 * Casts `value` to `identity` if it's not a function.
19994 *
19995 * @private
19996 * @param {*} value The value to inspect.
19997 * @returns {Function} Returns cast function.
19998 */
19999function castFunction(value) {
20000 return typeof value == 'function' ? value : identity_1;
20001}
20002
20003var _castFunction = castFunction;
20004
20005/**
20006 * Iterates over elements of `collection` and invokes `iteratee` for each element.
20007 * The iteratee is invoked with three arguments: (value, index|key, collection).
20008 * Iteratee functions may exit iteration early by explicitly returning `false`.
20009 *
20010 * **Note:** As with other "Collections" methods, objects with a "length"
20011 * property are iterated like arrays. To avoid this behavior use `_.forIn`
20012 * or `_.forOwn` for object iteration.
20013 *
20014 * @static
20015 * @memberOf _
20016 * @since 0.1.0
20017 * @alias each
20018 * @category Collection
20019 * @param {Array|Object} collection The collection to iterate over.
20020 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
20021 * @returns {Array|Object} Returns `collection`.
20022 * @see _.forEachRight
20023 * @example
20024 *
20025 * _.forEach([1, 2], function(value) {
20026 * console.log(value);
20027 * });
20028 * // => Logs `1` then `2`.
20029 *
20030 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
20031 * console.log(key);
20032 * });
20033 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
20034 */
20035function forEach(collection, iteratee) {
20036 var func = isArray_1(collection) ? _arrayEach : _baseEach;
20037 return func(collection, _castFunction(iteratee));
20038}
20039
20040var forEach_1 = forEach;
20041
20042var each = forEach_1;
20043
20044/**
20045 * The base implementation of `_.filter` without support for iteratee shorthands.
20046 *
20047 * @private
20048 * @param {Array|Object} collection The collection to iterate over.
20049 * @param {Function} predicate The function invoked per iteration.
20050 * @returns {Array} Returns the new filtered array.
20051 */
20052function baseFilter(collection, predicate) {
20053 var result = [];
20054 _baseEach(collection, function(value, index, collection) {
20055 if (predicate(value, index, collection)) {
20056 result.push(value);
20057 }
20058 });
20059 return result;
20060}
20061
20062var _baseFilter = baseFilter;
20063
20064/** Used to stand-in for `undefined` hash values. */
20065var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
20066
20067/**
20068 * Adds `value` to the array cache.
20069 *
20070 * @private
20071 * @name add
20072 * @memberOf SetCache
20073 * @alias push
20074 * @param {*} value The value to cache.
20075 * @returns {Object} Returns the cache instance.
20076 */
20077function setCacheAdd(value) {
20078 this.__data__.set(value, HASH_UNDEFINED$2);
20079 return this;
20080}
20081
20082var _setCacheAdd = setCacheAdd;
20083
20084/**
20085 * Checks if `value` is in the array cache.
20086 *
20087 * @private
20088 * @name has
20089 * @memberOf SetCache
20090 * @param {*} value The value to search for.
20091 * @returns {number} Returns `true` if `value` is found, else `false`.
20092 */
20093function setCacheHas(value) {
20094 return this.__data__.has(value);
20095}
20096
20097var _setCacheHas = setCacheHas;
20098
20099/**
20100 *
20101 * Creates an array cache object to store unique values.
20102 *
20103 * @private
20104 * @constructor
20105 * @param {Array} [values] The values to cache.
20106 */
20107function SetCache(values) {
20108 var index = -1,
20109 length = values == null ? 0 : values.length;
20110
20111 this.__data__ = new _MapCache;
20112 while (++index < length) {
20113 this.add(values[index]);
20114 }
20115}
20116
20117// Add methods to `SetCache`.
20118SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd;
20119SetCache.prototype.has = _setCacheHas;
20120
20121var _SetCache = SetCache;
20122
20123/**
20124 * A specialized version of `_.some` for arrays without support for iteratee
20125 * shorthands.
20126 *
20127 * @private
20128 * @param {Array} [array] The array to iterate over.
20129 * @param {Function} predicate The function invoked per iteration.
20130 * @returns {boolean} Returns `true` if any element passes the predicate check,
20131 * else `false`.
20132 */
20133function arraySome(array, predicate) {
20134 var index = -1,
20135 length = array == null ? 0 : array.length;
20136
20137 while (++index < length) {
20138 if (predicate(array[index], index, array)) {
20139 return true;
20140 }
20141 }
20142 return false;
20143}
20144
20145var _arraySome = arraySome;
20146
20147/**
20148 * Checks if a `cache` value for `key` exists.
20149 *
20150 * @private
20151 * @param {Object} cache The cache to query.
20152 * @param {string} key The key of the entry to check.
20153 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
20154 */
20155function cacheHas(cache, key) {
20156 return cache.has(key);
20157}
20158
20159var _cacheHas = cacheHas;
20160
20161/** Used to compose bitmasks for value comparisons. */
20162var COMPARE_PARTIAL_FLAG = 1,
20163 COMPARE_UNORDERED_FLAG = 2;
20164
20165/**
20166 * A specialized version of `baseIsEqualDeep` for arrays with support for
20167 * partial deep comparisons.
20168 *
20169 * @private
20170 * @param {Array} array The array to compare.
20171 * @param {Array} other The other array to compare.
20172 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
20173 * @param {Function} customizer The function to customize comparisons.
20174 * @param {Function} equalFunc The function to determine equivalents of values.
20175 * @param {Object} stack Tracks traversed `array` and `other` objects.
20176 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
20177 */
20178function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
20179 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
20180 arrLength = array.length,
20181 othLength = other.length;
20182
20183 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
20184 return false;
20185 }
20186 // Check that cyclic values are equal.
20187 var arrStacked = stack.get(array);
20188 var othStacked = stack.get(other);
20189 if (arrStacked && othStacked) {
20190 return arrStacked == other && othStacked == array;
20191 }
20192 var index = -1,
20193 result = true,
20194 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new _SetCache : undefined;
20195
20196 stack.set(array, other);
20197 stack.set(other, array);
20198
20199 // Ignore non-index properties.
20200 while (++index < arrLength) {
20201 var arrValue = array[index],
20202 othValue = other[index];
20203
20204 if (customizer) {
20205 var compared = isPartial
20206 ? customizer(othValue, arrValue, index, other, array, stack)
20207 : customizer(arrValue, othValue, index, array, other, stack);
20208 }
20209 if (compared !== undefined) {
20210 if (compared) {
20211 continue;
20212 }
20213 result = false;
20214 break;
20215 }
20216 // Recursively compare arrays (susceptible to call stack limits).
20217 if (seen) {
20218 if (!_arraySome(other, function(othValue, othIndex) {
20219 if (!_cacheHas(seen, othIndex) &&
20220 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
20221 return seen.push(othIndex);
20222 }
20223 })) {
20224 result = false;
20225 break;
20226 }
20227 } else if (!(
20228 arrValue === othValue ||
20229 equalFunc(arrValue, othValue, bitmask, customizer, stack)
20230 )) {
20231 result = false;
20232 break;
20233 }
20234 }
20235 stack['delete'](array);
20236 stack['delete'](other);
20237 return result;
20238}
20239
20240var _equalArrays = equalArrays;
20241
20242/**
20243 * Converts `map` to its key-value pairs.
20244 *
20245 * @private
20246 * @param {Object} map The map to convert.
20247 * @returns {Array} Returns the key-value pairs.
20248 */
20249function mapToArray(map) {
20250 var index = -1,
20251 result = Array(map.size);
20252
20253 map.forEach(function(value, key) {
20254 result[++index] = [key, value];
20255 });
20256 return result;
20257}
20258
20259var _mapToArray = mapToArray;
20260
20261/**
20262 * Converts `set` to an array of its values.
20263 *
20264 * @private
20265 * @param {Object} set The set to convert.
20266 * @returns {Array} Returns the values.
20267 */
20268function setToArray(set) {
20269 var index = -1,
20270 result = Array(set.size);
20271
20272 set.forEach(function(value) {
20273 result[++index] = value;
20274 });
20275 return result;
20276}
20277
20278var _setToArray = setToArray;
20279
20280/** Used to compose bitmasks for value comparisons. */
20281var COMPARE_PARTIAL_FLAG$1 = 1,
20282 COMPARE_UNORDERED_FLAG$1 = 2;
20283
20284/** `Object#toString` result references. */
20285var boolTag$3 = '[object Boolean]',
20286 dateTag$3 = '[object Date]',
20287 errorTag$2 = '[object Error]',
20288 mapTag$5 = '[object Map]',
20289 numberTag$3 = '[object Number]',
20290 regexpTag$3 = '[object RegExp]',
20291 setTag$5 = '[object Set]',
20292 stringTag$3 = '[object String]',
20293 symbolTag$2 = '[object Symbol]';
20294
20295var arrayBufferTag$3 = '[object ArrayBuffer]',
20296 dataViewTag$4 = '[object DataView]';
20297
20298/** Used to convert symbols to primitives and strings. */
20299var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
20300 symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : undefined;
20301
20302/**
20303 * A specialized version of `baseIsEqualDeep` for comparing objects of
20304 * the same `toStringTag`.
20305 *
20306 * **Note:** This function only supports comparing values with tags of
20307 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
20308 *
20309 * @private
20310 * @param {Object} object The object to compare.
20311 * @param {Object} other The other object to compare.
20312 * @param {string} tag The `toStringTag` of the objects to compare.
20313 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
20314 * @param {Function} customizer The function to customize comparisons.
20315 * @param {Function} equalFunc The function to determine equivalents of values.
20316 * @param {Object} stack Tracks traversed `object` and `other` objects.
20317 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
20318 */
20319function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
20320 switch (tag) {
20321 case dataViewTag$4:
20322 if ((object.byteLength != other.byteLength) ||
20323 (object.byteOffset != other.byteOffset)) {
20324 return false;
20325 }
20326 object = object.buffer;
20327 other = other.buffer;
20328
20329 case arrayBufferTag$3:
20330 if ((object.byteLength != other.byteLength) ||
20331 !equalFunc(new _Uint8Array(object), new _Uint8Array(other))) {
20332 return false;
20333 }
20334 return true;
20335
20336 case boolTag$3:
20337 case dateTag$3:
20338 case numberTag$3:
20339 // Coerce booleans to `1` or `0` and dates to milliseconds.
20340 // Invalid dates are coerced to `NaN`.
20341 return eq_1(+object, +other);
20342
20343 case errorTag$2:
20344 return object.name == other.name && object.message == other.message;
20345
20346 case regexpTag$3:
20347 case stringTag$3:
20348 // Coerce regexes to strings and treat strings, primitives and objects,
20349 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
20350 // for more details.
20351 return object == (other + '');
20352
20353 case mapTag$5:
20354 var convert = _mapToArray;
20355
20356 case setTag$5:
20357 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1;
20358 convert || (convert = _setToArray);
20359
20360 if (object.size != other.size && !isPartial) {
20361 return false;
20362 }
20363 // Assume cyclic values are equal.
20364 var stacked = stack.get(object);
20365 if (stacked) {
20366 return stacked == other;
20367 }
20368 bitmask |= COMPARE_UNORDERED_FLAG$1;
20369
20370 // Recursively compare objects (susceptible to call stack limits).
20371 stack.set(object, other);
20372 var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
20373 stack['delete'](object);
20374 return result;
20375
20376 case symbolTag$2:
20377 if (symbolValueOf$1) {
20378 return symbolValueOf$1.call(object) == symbolValueOf$1.call(other);
20379 }
20380 }
20381 return false;
20382}
20383
20384var _equalByTag = equalByTag;
20385
20386/** Used to compose bitmasks for value comparisons. */
20387var COMPARE_PARTIAL_FLAG$2 = 1;
20388
20389/** Used for built-in method references. */
20390var objectProto$d = Object.prototype;
20391
20392/** Used to check objects for own properties. */
20393var hasOwnProperty$a = objectProto$d.hasOwnProperty;
20394
20395/**
20396 * A specialized version of `baseIsEqualDeep` for objects with support for
20397 * partial deep comparisons.
20398 *
20399 * @private
20400 * @param {Object} object The object to compare.
20401 * @param {Object} other The other object to compare.
20402 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
20403 * @param {Function} customizer The function to customize comparisons.
20404 * @param {Function} equalFunc The function to determine equivalents of values.
20405 * @param {Object} stack Tracks traversed `object` and `other` objects.
20406 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
20407 */
20408function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
20409 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2,
20410 objProps = _getAllKeys(object),
20411 objLength = objProps.length,
20412 othProps = _getAllKeys(other),
20413 othLength = othProps.length;
20414
20415 if (objLength != othLength && !isPartial) {
20416 return false;
20417 }
20418 var index = objLength;
20419 while (index--) {
20420 var key = objProps[index];
20421 if (!(isPartial ? key in other : hasOwnProperty$a.call(other, key))) {
20422 return false;
20423 }
20424 }
20425 // Check that cyclic values are equal.
20426 var objStacked = stack.get(object);
20427 var othStacked = stack.get(other);
20428 if (objStacked && othStacked) {
20429 return objStacked == other && othStacked == object;
20430 }
20431 var result = true;
20432 stack.set(object, other);
20433 stack.set(other, object);
20434
20435 var skipCtor = isPartial;
20436 while (++index < objLength) {
20437 key = objProps[index];
20438 var objValue = object[key],
20439 othValue = other[key];
20440
20441 if (customizer) {
20442 var compared = isPartial
20443 ? customizer(othValue, objValue, key, other, object, stack)
20444 : customizer(objValue, othValue, key, object, other, stack);
20445 }
20446 // Recursively compare objects (susceptible to call stack limits).
20447 if (!(compared === undefined
20448 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
20449 : compared
20450 )) {
20451 result = false;
20452 break;
20453 }
20454 skipCtor || (skipCtor = key == 'constructor');
20455 }
20456 if (result && !skipCtor) {
20457 var objCtor = object.constructor,
20458 othCtor = other.constructor;
20459
20460 // Non `Object` object instances with different constructors are not equal.
20461 if (objCtor != othCtor &&
20462 ('constructor' in object && 'constructor' in other) &&
20463 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
20464 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
20465 result = false;
20466 }
20467 }
20468 stack['delete'](object);
20469 stack['delete'](other);
20470 return result;
20471}
20472
20473var _equalObjects = equalObjects;
20474
20475/** Used to compose bitmasks for value comparisons. */
20476var COMPARE_PARTIAL_FLAG$3 = 1;
20477
20478/** `Object#toString` result references. */
20479var argsTag$3 = '[object Arguments]',
20480 arrayTag$2 = '[object Array]',
20481 objectTag$3 = '[object Object]';
20482
20483/** Used for built-in method references. */
20484var objectProto$e = Object.prototype;
20485
20486/** Used to check objects for own properties. */
20487var hasOwnProperty$b = objectProto$e.hasOwnProperty;
20488
20489/**
20490 * A specialized version of `baseIsEqual` for arrays and objects which performs
20491 * deep comparisons and tracks traversed objects enabling objects with circular
20492 * references to be compared.
20493 *
20494 * @private
20495 * @param {Object} object The object to compare.
20496 * @param {Object} other The other object to compare.
20497 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
20498 * @param {Function} customizer The function to customize comparisons.
20499 * @param {Function} equalFunc The function to determine equivalents of values.
20500 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
20501 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
20502 */
20503function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
20504 var objIsArr = isArray_1(object),
20505 othIsArr = isArray_1(other),
20506 objTag = objIsArr ? arrayTag$2 : _getTag(object),
20507 othTag = othIsArr ? arrayTag$2 : _getTag(other);
20508
20509 objTag = objTag == argsTag$3 ? objectTag$3 : objTag;
20510 othTag = othTag == argsTag$3 ? objectTag$3 : othTag;
20511
20512 var objIsObj = objTag == objectTag$3,
20513 othIsObj = othTag == objectTag$3,
20514 isSameTag = objTag == othTag;
20515
20516 if (isSameTag && isBuffer_1(object)) {
20517 if (!isBuffer_1(other)) {
20518 return false;
20519 }
20520 objIsArr = true;
20521 objIsObj = false;
20522 }
20523 if (isSameTag && !objIsObj) {
20524 stack || (stack = new _Stack);
20525 return (objIsArr || isTypedArray_1(object))
20526 ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
20527 : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
20528 }
20529 if (!(bitmask & COMPARE_PARTIAL_FLAG$3)) {
20530 var objIsWrapped = objIsObj && hasOwnProperty$b.call(object, '__wrapped__'),
20531 othIsWrapped = othIsObj && hasOwnProperty$b.call(other, '__wrapped__');
20532
20533 if (objIsWrapped || othIsWrapped) {
20534 var objUnwrapped = objIsWrapped ? object.value() : object,
20535 othUnwrapped = othIsWrapped ? other.value() : other;
20536
20537 stack || (stack = new _Stack);
20538 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
20539 }
20540 }
20541 if (!isSameTag) {
20542 return false;
20543 }
20544 stack || (stack = new _Stack);
20545 return _equalObjects(object, other, bitmask, customizer, equalFunc, stack);
20546}
20547
20548var _baseIsEqualDeep = baseIsEqualDeep;
20549
20550/**
20551 * The base implementation of `_.isEqual` which supports partial comparisons
20552 * and tracks traversed objects.
20553 *
20554 * @private
20555 * @param {*} value The value to compare.
20556 * @param {*} other The other value to compare.
20557 * @param {boolean} bitmask The bitmask flags.
20558 * 1 - Unordered comparison
20559 * 2 - Partial comparison
20560 * @param {Function} [customizer] The function to customize comparisons.
20561 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
20562 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
20563 */
20564function baseIsEqual(value, other, bitmask, customizer, stack) {
20565 if (value === other) {
20566 return true;
20567 }
20568 if (value == null || other == null || (!isObjectLike_1(value) && !isObjectLike_1(other))) {
20569 return value !== value && other !== other;
20570 }
20571 return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
20572}
20573
20574var _baseIsEqual = baseIsEqual;
20575
20576/** Used to compose bitmasks for value comparisons. */
20577var COMPARE_PARTIAL_FLAG$4 = 1,
20578 COMPARE_UNORDERED_FLAG$2 = 2;
20579
20580/**
20581 * The base implementation of `_.isMatch` without support for iteratee shorthands.
20582 *
20583 * @private
20584 * @param {Object} object The object to inspect.
20585 * @param {Object} source The object of property values to match.
20586 * @param {Array} matchData The property names, values, and compare flags to match.
20587 * @param {Function} [customizer] The function to customize comparisons.
20588 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
20589 */
20590function baseIsMatch(object, source, matchData, customizer) {
20591 var index = matchData.length,
20592 length = index,
20593 noCustomizer = !customizer;
20594
20595 if (object == null) {
20596 return !length;
20597 }
20598 object = Object(object);
20599 while (index--) {
20600 var data = matchData[index];
20601 if ((noCustomizer && data[2])
20602 ? data[1] !== object[data[0]]
20603 : !(data[0] in object)
20604 ) {
20605 return false;
20606 }
20607 }
20608 while (++index < length) {
20609 data = matchData[index];
20610 var key = data[0],
20611 objValue = object[key],
20612 srcValue = data[1];
20613
20614 if (noCustomizer && data[2]) {
20615 if (objValue === undefined && !(key in object)) {
20616 return false;
20617 }
20618 } else {
20619 var stack = new _Stack;
20620 if (customizer) {
20621 var result = customizer(objValue, srcValue, key, object, source, stack);
20622 }
20623 if (!(result === undefined
20624 ? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$4 | COMPARE_UNORDERED_FLAG$2, customizer, stack)
20625 : result
20626 )) {
20627 return false;
20628 }
20629 }
20630 }
20631 return true;
20632}
20633
20634var _baseIsMatch = baseIsMatch;
20635
20636/**
20637 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
20638 *
20639 * @private
20640 * @param {*} value The value to check.
20641 * @returns {boolean} Returns `true` if `value` if suitable for strict
20642 * equality comparisons, else `false`.
20643 */
20644function isStrictComparable(value) {
20645 return value === value && !isObject_1(value);
20646}
20647
20648var _isStrictComparable = isStrictComparable;
20649
20650/**
20651 * Gets the property names, values, and compare flags of `object`.
20652 *
20653 * @private
20654 * @param {Object} object The object to query.
20655 * @returns {Array} Returns the match data of `object`.
20656 */
20657function getMatchData(object) {
20658 var result = keys_1(object),
20659 length = result.length;
20660
20661 while (length--) {
20662 var key = result[length],
20663 value = object[key];
20664
20665 result[length] = [key, value, _isStrictComparable(value)];
20666 }
20667 return result;
20668}
20669
20670var _getMatchData = getMatchData;
20671
20672/**
20673 * A specialized version of `matchesProperty` for source values suitable
20674 * for strict equality comparisons, i.e. `===`.
20675 *
20676 * @private
20677 * @param {string} key The key of the property to get.
20678 * @param {*} srcValue The value to match.
20679 * @returns {Function} Returns the new spec function.
20680 */
20681function matchesStrictComparable(key, srcValue) {
20682 return function(object) {
20683 if (object == null) {
20684 return false;
20685 }
20686 return object[key] === srcValue &&
20687 (srcValue !== undefined || (key in Object(object)));
20688 };
20689}
20690
20691var _matchesStrictComparable = matchesStrictComparable;
20692
20693/**
20694 * The base implementation of `_.matches` which doesn't clone `source`.
20695 *
20696 * @private
20697 * @param {Object} source The object of property values to match.
20698 * @returns {Function} Returns the new spec function.
20699 */
20700function baseMatches(source) {
20701 var matchData = _getMatchData(source);
20702 if (matchData.length == 1 && matchData[0][2]) {
20703 return _matchesStrictComparable(matchData[0][0], matchData[0][1]);
20704 }
20705 return function(object) {
20706 return object === source || _baseIsMatch(object, source, matchData);
20707 };
20708}
20709
20710var _baseMatches = baseMatches;
20711
20712/** `Object#toString` result references. */
20713var symbolTag$3 = '[object Symbol]';
20714
20715/**
20716 * Checks if `value` is classified as a `Symbol` primitive or object.
20717 *
20718 * @static
20719 * @memberOf _
20720 * @since 4.0.0
20721 * @category Lang
20722 * @param {*} value The value to check.
20723 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
20724 * @example
20725 *
20726 * _.isSymbol(Symbol.iterator);
20727 * // => true
20728 *
20729 * _.isSymbol('abc');
20730 * // => false
20731 */
20732function isSymbol(value) {
20733 return typeof value == 'symbol' ||
20734 (isObjectLike_1(value) && _baseGetTag(value) == symbolTag$3);
20735}
20736
20737var isSymbol_1 = isSymbol;
20738
20739/** Used to match property names within property paths. */
20740var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
20741 reIsPlainProp = /^\w*$/;
20742
20743/**
20744 * Checks if `value` is a property name and not a property path.
20745 *
20746 * @private
20747 * @param {*} value The value to check.
20748 * @param {Object} [object] The object to query keys on.
20749 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
20750 */
20751function isKey(value, object) {
20752 if (isArray_1(value)) {
20753 return false;
20754 }
20755 var type = typeof value;
20756 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
20757 value == null || isSymbol_1(value)) {
20758 return true;
20759 }
20760 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
20761 (object != null && value in Object(object));
20762}
20763
20764var _isKey = isKey;
20765
20766/** Error message constants. */
20767var FUNC_ERROR_TEXT = 'Expected a function';
20768
20769/**
20770 * Creates a function that memoizes the result of `func`. If `resolver` is
20771 * provided, it determines the cache key for storing the result based on the
20772 * arguments provided to the memoized function. By default, the first argument
20773 * provided to the memoized function is used as the map cache key. The `func`
20774 * is invoked with the `this` binding of the memoized function.
20775 *
20776 * **Note:** The cache is exposed as the `cache` property on the memoized
20777 * function. Its creation may be customized by replacing the `_.memoize.Cache`
20778 * constructor with one whose instances implement the
20779 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
20780 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
20781 *
20782 * @static
20783 * @memberOf _
20784 * @since 0.1.0
20785 * @category Function
20786 * @param {Function} func The function to have its output memoized.
20787 * @param {Function} [resolver] The function to resolve the cache key.
20788 * @returns {Function} Returns the new memoized function.
20789 * @example
20790 *
20791 * var object = { 'a': 1, 'b': 2 };
20792 * var other = { 'c': 3, 'd': 4 };
20793 *
20794 * var values = _.memoize(_.values);
20795 * values(object);
20796 * // => [1, 2]
20797 *
20798 * values(other);
20799 * // => [3, 4]
20800 *
20801 * object.a = 2;
20802 * values(object);
20803 * // => [1, 2]
20804 *
20805 * // Modify the result cache.
20806 * values.cache.set(object, ['a', 'b']);
20807 * values(object);
20808 * // => ['a', 'b']
20809 *
20810 * // Replace `_.memoize.Cache`.
20811 * _.memoize.Cache = WeakMap;
20812 */
20813function memoize(func, resolver) {
20814 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
20815 throw new TypeError(FUNC_ERROR_TEXT);
20816 }
20817 var memoized = function() {
20818 var args = arguments,
20819 key = resolver ? resolver.apply(this, args) : args[0],
20820 cache = memoized.cache;
20821
20822 if (cache.has(key)) {
20823 return cache.get(key);
20824 }
20825 var result = func.apply(this, args);
20826 memoized.cache = cache.set(key, result) || cache;
20827 return result;
20828 };
20829 memoized.cache = new (memoize.Cache || _MapCache);
20830 return memoized;
20831}
20832
20833// Expose `MapCache`.
20834memoize.Cache = _MapCache;
20835
20836var memoize_1 = memoize;
20837
20838/** Used as the maximum memoize cache size. */
20839var MAX_MEMOIZE_SIZE = 500;
20840
20841/**
20842 * A specialized version of `_.memoize` which clears the memoized function's
20843 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
20844 *
20845 * @private
20846 * @param {Function} func The function to have its output memoized.
20847 * @returns {Function} Returns the new memoized function.
20848 */
20849function memoizeCapped(func) {
20850 var result = memoize_1(func, function(key) {
20851 if (cache.size === MAX_MEMOIZE_SIZE) {
20852 cache.clear();
20853 }
20854 return key;
20855 });
20856
20857 var cache = result.cache;
20858 return result;
20859}
20860
20861var _memoizeCapped = memoizeCapped;
20862
20863/** Used to match property names within property paths. */
20864var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
20865
20866/** Used to match backslashes in property paths. */
20867var reEscapeChar = /\\(\\)?/g;
20868
20869/**
20870 * Converts `string` to a property path array.
20871 *
20872 * @private
20873 * @param {string} string The string to convert.
20874 * @returns {Array} Returns the property path array.
20875 */
20876var stringToPath = _memoizeCapped(function(string) {
20877 var result = [];
20878 if (string.charCodeAt(0) === 46 /* . */) {
20879 result.push('');
20880 }
20881 string.replace(rePropName, function(match, number, quote, subString) {
20882 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
20883 });
20884 return result;
20885});
20886
20887var _stringToPath = stringToPath;
20888
20889/**
20890 * A specialized version of `_.map` for arrays without support for iteratee
20891 * shorthands.
20892 *
20893 * @private
20894 * @param {Array} [array] The array to iterate over.
20895 * @param {Function} iteratee The function invoked per iteration.
20896 * @returns {Array} Returns the new mapped array.
20897 */
20898function arrayMap(array, iteratee) {
20899 var index = -1,
20900 length = array == null ? 0 : array.length,
20901 result = Array(length);
20902
20903 while (++index < length) {
20904 result[index] = iteratee(array[index], index, array);
20905 }
20906 return result;
20907}
20908
20909var _arrayMap = arrayMap;
20910
20911/** Used as references for various `Number` constants. */
20912var INFINITY = 1 / 0;
20913
20914/** Used to convert symbols to primitives and strings. */
20915var symbolProto$2 = _Symbol ? _Symbol.prototype : undefined,
20916 symbolToString = symbolProto$2 ? symbolProto$2.toString : undefined;
20917
20918/**
20919 * The base implementation of `_.toString` which doesn't convert nullish
20920 * values to empty strings.
20921 *
20922 * @private
20923 * @param {*} value The value to process.
20924 * @returns {string} Returns the string.
20925 */
20926function baseToString(value) {
20927 // Exit early for strings to avoid a performance hit in some environments.
20928 if (typeof value == 'string') {
20929 return value;
20930 }
20931 if (isArray_1(value)) {
20932 // Recursively convert values (susceptible to call stack limits).
20933 return _arrayMap(value, baseToString) + '';
20934 }
20935 if (isSymbol_1(value)) {
20936 return symbolToString ? symbolToString.call(value) : '';
20937 }
20938 var result = (value + '');
20939 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
20940}
20941
20942var _baseToString = baseToString;
20943
20944/**
20945 * Converts `value` to a string. An empty string is returned for `null`
20946 * and `undefined` values. The sign of `-0` is preserved.
20947 *
20948 * @static
20949 * @memberOf _
20950 * @since 4.0.0
20951 * @category Lang
20952 * @param {*} value The value to convert.
20953 * @returns {string} Returns the converted string.
20954 * @example
20955 *
20956 * _.toString(null);
20957 * // => ''
20958 *
20959 * _.toString(-0);
20960 * // => '-0'
20961 *
20962 * _.toString([1, 2, 3]);
20963 * // => '1,2,3'
20964 */
20965function toString(value) {
20966 return value == null ? '' : _baseToString(value);
20967}
20968
20969var toString_1 = toString;
20970
20971/**
20972 * Casts `value` to a path array if it's not one.
20973 *
20974 * @private
20975 * @param {*} value The value to inspect.
20976 * @param {Object} [object] The object to query keys on.
20977 * @returns {Array} Returns the cast property path array.
20978 */
20979function castPath(value, object) {
20980 if (isArray_1(value)) {
20981 return value;
20982 }
20983 return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
20984}
20985
20986var _castPath = castPath;
20987
20988/** Used as references for various `Number` constants. */
20989var INFINITY$1 = 1 / 0;
20990
20991/**
20992 * Converts `value` to a string key if it's not a string or symbol.
20993 *
20994 * @private
20995 * @param {*} value The value to inspect.
20996 * @returns {string|symbol} Returns the key.
20997 */
20998function toKey(value) {
20999 if (typeof value == 'string' || isSymbol_1(value)) {
21000 return value;
21001 }
21002 var result = (value + '');
21003 return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
21004}
21005
21006var _toKey = toKey;
21007
21008/**
21009 * The base implementation of `_.get` without support for default values.
21010 *
21011 * @private
21012 * @param {Object} object The object to query.
21013 * @param {Array|string} path The path of the property to get.
21014 * @returns {*} Returns the resolved value.
21015 */
21016function baseGet(object, path) {
21017 path = _castPath(path, object);
21018
21019 var index = 0,
21020 length = path.length;
21021
21022 while (object != null && index < length) {
21023 object = object[_toKey(path[index++])];
21024 }
21025 return (index && index == length) ? object : undefined;
21026}
21027
21028var _baseGet = baseGet;
21029
21030/**
21031 * Gets the value at `path` of `object`. If the resolved value is
21032 * `undefined`, the `defaultValue` is returned in its place.
21033 *
21034 * @static
21035 * @memberOf _
21036 * @since 3.7.0
21037 * @category Object
21038 * @param {Object} object The object to query.
21039 * @param {Array|string} path The path of the property to get.
21040 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
21041 * @returns {*} Returns the resolved value.
21042 * @example
21043 *
21044 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
21045 *
21046 * _.get(object, 'a[0].b.c');
21047 * // => 3
21048 *
21049 * _.get(object, ['a', '0', 'b', 'c']);
21050 * // => 3
21051 *
21052 * _.get(object, 'a.b.c', 'default');
21053 * // => 'default'
21054 */
21055function get(object, path, defaultValue) {
21056 var result = object == null ? undefined : _baseGet(object, path);
21057 return result === undefined ? defaultValue : result;
21058}
21059
21060var get_1 = get;
21061
21062/**
21063 * The base implementation of `_.hasIn` without support for deep paths.
21064 *
21065 * @private
21066 * @param {Object} [object] The object to query.
21067 * @param {Array|string} key The key to check.
21068 * @returns {boolean} Returns `true` if `key` exists, else `false`.
21069 */
21070function baseHasIn(object, key) {
21071 return object != null && key in Object(object);
21072}
21073
21074var _baseHasIn = baseHasIn;
21075
21076/**
21077 * Checks if `path` exists on `object`.
21078 *
21079 * @private
21080 * @param {Object} object The object to query.
21081 * @param {Array|string} path The path to check.
21082 * @param {Function} hasFunc The function to check properties.
21083 * @returns {boolean} Returns `true` if `path` exists, else `false`.
21084 */
21085function hasPath(object, path, hasFunc) {
21086 path = _castPath(path, object);
21087
21088 var index = -1,
21089 length = path.length,
21090 result = false;
21091
21092 while (++index < length) {
21093 var key = _toKey(path[index]);
21094 if (!(result = object != null && hasFunc(object, key))) {
21095 break;
21096 }
21097 object = object[key];
21098 }
21099 if (result || ++index != length) {
21100 return result;
21101 }
21102 length = object == null ? 0 : object.length;
21103 return !!length && isLength_1(length) && _isIndex(key, length) &&
21104 (isArray_1(object) || isArguments_1(object));
21105}
21106
21107var _hasPath = hasPath;
21108
21109/**
21110 * Checks if `path` is a direct or inherited property of `object`.
21111 *
21112 * @static
21113 * @memberOf _
21114 * @since 4.0.0
21115 * @category Object
21116 * @param {Object} object The object to query.
21117 * @param {Array|string} path The path to check.
21118 * @returns {boolean} Returns `true` if `path` exists, else `false`.
21119 * @example
21120 *
21121 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
21122 *
21123 * _.hasIn(object, 'a');
21124 * // => true
21125 *
21126 * _.hasIn(object, 'a.b');
21127 * // => true
21128 *
21129 * _.hasIn(object, ['a', 'b']);
21130 * // => true
21131 *
21132 * _.hasIn(object, 'b');
21133 * // => false
21134 */
21135function hasIn(object, path) {
21136 return object != null && _hasPath(object, path, _baseHasIn);
21137}
21138
21139var hasIn_1 = hasIn;
21140
21141/** Used to compose bitmasks for value comparisons. */
21142var COMPARE_PARTIAL_FLAG$5 = 1,
21143 COMPARE_UNORDERED_FLAG$3 = 2;
21144
21145/**
21146 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
21147 *
21148 * @private
21149 * @param {string} path The path of the property to get.
21150 * @param {*} srcValue The value to match.
21151 * @returns {Function} Returns the new spec function.
21152 */
21153function baseMatchesProperty(path, srcValue) {
21154 if (_isKey(path) && _isStrictComparable(srcValue)) {
21155 return _matchesStrictComparable(_toKey(path), srcValue);
21156 }
21157 return function(object) {
21158 var objValue = get_1(object, path);
21159 return (objValue === undefined && objValue === srcValue)
21160 ? hasIn_1(object, path)
21161 : _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$5 | COMPARE_UNORDERED_FLAG$3);
21162 };
21163}
21164
21165var _baseMatchesProperty = baseMatchesProperty;
21166
21167/**
21168 * The base implementation of `_.property` without support for deep paths.
21169 *
21170 * @private
21171 * @param {string} key The key of the property to get.
21172 * @returns {Function} Returns the new accessor function.
21173 */
21174function baseProperty(key) {
21175 return function(object) {
21176 return object == null ? undefined : object[key];
21177 };
21178}
21179
21180var _baseProperty = baseProperty;
21181
21182/**
21183 * A specialized version of `baseProperty` which supports deep paths.
21184 *
21185 * @private
21186 * @param {Array|string} path The path of the property to get.
21187 * @returns {Function} Returns the new accessor function.
21188 */
21189function basePropertyDeep(path) {
21190 return function(object) {
21191 return _baseGet(object, path);
21192 };
21193}
21194
21195var _basePropertyDeep = basePropertyDeep;
21196
21197/**
21198 * Creates a function that returns the value at `path` of a given object.
21199 *
21200 * @static
21201 * @memberOf _
21202 * @since 2.4.0
21203 * @category Util
21204 * @param {Array|string} path The path of the property to get.
21205 * @returns {Function} Returns the new accessor function.
21206 * @example
21207 *
21208 * var objects = [
21209 * { 'a': { 'b': 2 } },
21210 * { 'a': { 'b': 1 } }
21211 * ];
21212 *
21213 * _.map(objects, _.property('a.b'));
21214 * // => [2, 1]
21215 *
21216 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
21217 * // => [1, 2]
21218 */
21219function property(path) {
21220 return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
21221}
21222
21223var property_1 = property;
21224
21225/**
21226 * The base implementation of `_.iteratee`.
21227 *
21228 * @private
21229 * @param {*} [value=_.identity] The value to convert to an iteratee.
21230 * @returns {Function} Returns the iteratee.
21231 */
21232function baseIteratee(value) {
21233 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
21234 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
21235 if (typeof value == 'function') {
21236 return value;
21237 }
21238 if (value == null) {
21239 return identity_1;
21240 }
21241 if (typeof value == 'object') {
21242 return isArray_1(value)
21243 ? _baseMatchesProperty(value[0], value[1])
21244 : _baseMatches(value);
21245 }
21246 return property_1(value);
21247}
21248
21249var _baseIteratee = baseIteratee;
21250
21251/**
21252 * Iterates over elements of `collection`, returning an array of all elements
21253 * `predicate` returns truthy for. The predicate is invoked with three
21254 * arguments: (value, index|key, collection).
21255 *
21256 * **Note:** Unlike `_.remove`, this method returns a new array.
21257 *
21258 * @static
21259 * @memberOf _
21260 * @since 0.1.0
21261 * @category Collection
21262 * @param {Array|Object} collection The collection to iterate over.
21263 * @param {Function} [predicate=_.identity] The function invoked per iteration.
21264 * @returns {Array} Returns the new filtered array.
21265 * @see _.reject
21266 * @example
21267 *
21268 * var users = [
21269 * { 'user': 'barney', 'age': 36, 'active': true },
21270 * { 'user': 'fred', 'age': 40, 'active': false }
21271 * ];
21272 *
21273 * _.filter(users, function(o) { return !o.active; });
21274 * // => objects for ['fred']
21275 *
21276 * // The `_.matches` iteratee shorthand.
21277 * _.filter(users, { 'age': 36, 'active': true });
21278 * // => objects for ['barney']
21279 *
21280 * // The `_.matchesProperty` iteratee shorthand.
21281 * _.filter(users, ['active', false]);
21282 * // => objects for ['fred']
21283 *
21284 * // The `_.property` iteratee shorthand.
21285 * _.filter(users, 'active');
21286 * // => objects for ['barney']
21287 *
21288 * // Combining several predicates using `_.overEvery` or `_.overSome`.
21289 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
21290 * // => objects for ['fred', 'barney']
21291 */
21292function filter(collection, predicate) {
21293 var func = isArray_1(collection) ? _arrayFilter : _baseFilter;
21294 return func(collection, _baseIteratee(predicate));
21295}
21296
21297var filter_1 = filter;
21298
21299/** Used for built-in method references. */
21300var objectProto$f = Object.prototype;
21301
21302/** Used to check objects for own properties. */
21303var hasOwnProperty$c = objectProto$f.hasOwnProperty;
21304
21305/**
21306 * The base implementation of `_.has` without support for deep paths.
21307 *
21308 * @private
21309 * @param {Object} [object] The object to query.
21310 * @param {Array|string} key The key to check.
21311 * @returns {boolean} Returns `true` if `key` exists, else `false`.
21312 */
21313function baseHas(object, key) {
21314 return object != null && hasOwnProperty$c.call(object, key);
21315}
21316
21317var _baseHas = baseHas;
21318
21319/**
21320 * Checks if `path` is a direct property of `object`.
21321 *
21322 * @static
21323 * @since 0.1.0
21324 * @memberOf _
21325 * @category Object
21326 * @param {Object} object The object to query.
21327 * @param {Array|string} path The path to check.
21328 * @returns {boolean} Returns `true` if `path` exists, else `false`.
21329 * @example
21330 *
21331 * var object = { 'a': { 'b': 2 } };
21332 * var other = _.create({ 'a': _.create({ 'b': 2 }) });
21333 *
21334 * _.has(object, 'a');
21335 * // => true
21336 *
21337 * _.has(object, 'a.b');
21338 * // => true
21339 *
21340 * _.has(object, ['a', 'b']);
21341 * // => true
21342 *
21343 * _.has(other, 'a');
21344 * // => false
21345 */
21346function has(object, path) {
21347 return object != null && _hasPath(object, path, _baseHas);
21348}
21349
21350var has_1 = has;
21351
21352/** `Object#toString` result references. */
21353var mapTag$6 = '[object Map]',
21354 setTag$6 = '[object Set]';
21355
21356/** Used for built-in method references. */
21357var objectProto$g = Object.prototype;
21358
21359/** Used to check objects for own properties. */
21360var hasOwnProperty$d = objectProto$g.hasOwnProperty;
21361
21362/**
21363 * Checks if `value` is an empty object, collection, map, or set.
21364 *
21365 * Objects are considered empty if they have no own enumerable string keyed
21366 * properties.
21367 *
21368 * Array-like values such as `arguments` objects, arrays, buffers, strings, or
21369 * jQuery-like collections are considered empty if they have a `length` of `0`.
21370 * Similarly, maps and sets are considered empty if they have a `size` of `0`.
21371 *
21372 * @static
21373 * @memberOf _
21374 * @since 0.1.0
21375 * @category Lang
21376 * @param {*} value The value to check.
21377 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
21378 * @example
21379 *
21380 * _.isEmpty(null);
21381 * // => true
21382 *
21383 * _.isEmpty(true);
21384 * // => true
21385 *
21386 * _.isEmpty(1);
21387 * // => true
21388 *
21389 * _.isEmpty([1, 2, 3]);
21390 * // => false
21391 *
21392 * _.isEmpty({ 'a': 1 });
21393 * // => false
21394 */
21395function isEmpty(value) {
21396 if (value == null) {
21397 return true;
21398 }
21399 if (isArrayLike_1(value) &&
21400 (isArray_1(value) || typeof value == 'string' || typeof value.splice == 'function' ||
21401 isBuffer_1(value) || isTypedArray_1(value) || isArguments_1(value))) {
21402 return !value.length;
21403 }
21404 var tag = _getTag(value);
21405 if (tag == mapTag$6 || tag == setTag$6) {
21406 return !value.size;
21407 }
21408 if (_isPrototype(value)) {
21409 return !_baseKeys(value).length;
21410 }
21411 for (var key in value) {
21412 if (hasOwnProperty$d.call(value, key)) {
21413 return false;
21414 }
21415 }
21416 return true;
21417}
21418
21419var isEmpty_1 = isEmpty;
21420
21421/**
21422 * Checks if `value` is `undefined`.
21423 *
21424 * @static
21425 * @since 0.1.0
21426 * @memberOf _
21427 * @category Lang
21428 * @param {*} value The value to check.
21429 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
21430 * @example
21431 *
21432 * _.isUndefined(void 0);
21433 * // => true
21434 *
21435 * _.isUndefined(null);
21436 * // => false
21437 */
21438function isUndefined(value) {
21439 return value === undefined;
21440}
21441
21442var isUndefined_1 = isUndefined;
21443
21444/**
21445 * The base implementation of `_.map` without support for iteratee shorthands.
21446 *
21447 * @private
21448 * @param {Array|Object} collection The collection to iterate over.
21449 * @param {Function} iteratee The function invoked per iteration.
21450 * @returns {Array} Returns the new mapped array.
21451 */
21452function baseMap(collection, iteratee) {
21453 var index = -1,
21454 result = isArrayLike_1(collection) ? Array(collection.length) : [];
21455
21456 _baseEach(collection, function(value, key, collection) {
21457 result[++index] = iteratee(value, key, collection);
21458 });
21459 return result;
21460}
21461
21462var _baseMap = baseMap;
21463
21464/**
21465 * Creates an array of values by running each element in `collection` thru
21466 * `iteratee`. The iteratee is invoked with three arguments:
21467 * (value, index|key, collection).
21468 *
21469 * Many lodash methods are guarded to work as iteratees for methods like
21470 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
21471 *
21472 * The guarded methods are:
21473 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
21474 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
21475 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
21476 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
21477 *
21478 * @static
21479 * @memberOf _
21480 * @since 0.1.0
21481 * @category Collection
21482 * @param {Array|Object} collection The collection to iterate over.
21483 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
21484 * @returns {Array} Returns the new mapped array.
21485 * @example
21486 *
21487 * function square(n) {
21488 * return n * n;
21489 * }
21490 *
21491 * _.map([4, 8], square);
21492 * // => [16, 64]
21493 *
21494 * _.map({ 'a': 4, 'b': 8 }, square);
21495 * // => [16, 64] (iteration order is not guaranteed)
21496 *
21497 * var users = [
21498 * { 'user': 'barney' },
21499 * { 'user': 'fred' }
21500 * ];
21501 *
21502 * // The `_.property` iteratee shorthand.
21503 * _.map(users, 'user');
21504 * // => ['barney', 'fred']
21505 */
21506function map(collection, iteratee) {
21507 var func = isArray_1(collection) ? _arrayMap : _baseMap;
21508 return func(collection, _baseIteratee(iteratee));
21509}
21510
21511var map_1 = map;
21512
21513/**
21514 * A specialized version of `_.reduce` for arrays without support for
21515 * iteratee shorthands.
21516 *
21517 * @private
21518 * @param {Array} [array] The array to iterate over.
21519 * @param {Function} iteratee The function invoked per iteration.
21520 * @param {*} [accumulator] The initial value.
21521 * @param {boolean} [initAccum] Specify using the first element of `array` as
21522 * the initial value.
21523 * @returns {*} Returns the accumulated value.
21524 */
21525function arrayReduce(array, iteratee, accumulator, initAccum) {
21526 var index = -1,
21527 length = array == null ? 0 : array.length;
21528
21529 if (initAccum && length) {
21530 accumulator = array[++index];
21531 }
21532 while (++index < length) {
21533 accumulator = iteratee(accumulator, array[index], index, array);
21534 }
21535 return accumulator;
21536}
21537
21538var _arrayReduce = arrayReduce;
21539
21540/**
21541 * The base implementation of `_.reduce` and `_.reduceRight`, without support
21542 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
21543 *
21544 * @private
21545 * @param {Array|Object} collection The collection to iterate over.
21546 * @param {Function} iteratee The function invoked per iteration.
21547 * @param {*} accumulator The initial value.
21548 * @param {boolean} initAccum Specify using the first or last element of
21549 * `collection` as the initial value.
21550 * @param {Function} eachFunc The function to iterate over `collection`.
21551 * @returns {*} Returns the accumulated value.
21552 */
21553function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
21554 eachFunc(collection, function(value, index, collection) {
21555 accumulator = initAccum
21556 ? (initAccum = false, value)
21557 : iteratee(accumulator, value, index, collection);
21558 });
21559 return accumulator;
21560}
21561
21562var _baseReduce = baseReduce;
21563
21564/**
21565 * Reduces `collection` to a value which is the accumulated result of running
21566 * each element in `collection` thru `iteratee`, where each successive
21567 * invocation is supplied the return value of the previous. If `accumulator`
21568 * is not given, the first element of `collection` is used as the initial
21569 * value. The iteratee is invoked with four arguments:
21570 * (accumulator, value, index|key, collection).
21571 *
21572 * Many lodash methods are guarded to work as iteratees for methods like
21573 * `_.reduce`, `_.reduceRight`, and `_.transform`.
21574 *
21575 * The guarded methods are:
21576 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
21577 * and `sortBy`
21578 *
21579 * @static
21580 * @memberOf _
21581 * @since 0.1.0
21582 * @category Collection
21583 * @param {Array|Object} collection The collection to iterate over.
21584 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
21585 * @param {*} [accumulator] The initial value.
21586 * @returns {*} Returns the accumulated value.
21587 * @see _.reduceRight
21588 * @example
21589 *
21590 * _.reduce([1, 2], function(sum, n) {
21591 * return sum + n;
21592 * }, 0);
21593 * // => 3
21594 *
21595 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
21596 * (result[value] || (result[value] = [])).push(key);
21597 * return result;
21598 * }, {});
21599 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
21600 */
21601function reduce(collection, iteratee, accumulator) {
21602 var func = isArray_1(collection) ? _arrayReduce : _baseReduce,
21603 initAccum = arguments.length < 3;
21604
21605 return func(collection, _baseIteratee(iteratee), accumulator, initAccum, _baseEach);
21606}
21607
21608var reduce_1 = reduce;
21609
21610/** `Object#toString` result references. */
21611var stringTag$4 = '[object String]';
21612
21613/**
21614 * Checks if `value` is classified as a `String` primitive or object.
21615 *
21616 * @static
21617 * @since 0.1.0
21618 * @memberOf _
21619 * @category Lang
21620 * @param {*} value The value to check.
21621 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
21622 * @example
21623 *
21624 * _.isString('abc');
21625 * // => true
21626 *
21627 * _.isString(1);
21628 * // => false
21629 */
21630function isString(value) {
21631 return typeof value == 'string' ||
21632 (!isArray_1(value) && isObjectLike_1(value) && _baseGetTag(value) == stringTag$4);
21633}
21634
21635var isString_1 = isString;
21636
21637/**
21638 * Gets the size of an ASCII `string`.
21639 *
21640 * @private
21641 * @param {string} string The string inspect.
21642 * @returns {number} Returns the string size.
21643 */
21644var asciiSize = _baseProperty('length');
21645
21646var _asciiSize = asciiSize;
21647
21648/** Used to compose unicode character classes. */
21649var rsAstralRange = '\\ud800-\\udfff',
21650 rsComboMarksRange = '\\u0300-\\u036f',
21651 reComboHalfMarksRange = '\\ufe20-\\ufe2f',
21652 rsComboSymbolsRange = '\\u20d0-\\u20ff',
21653 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
21654 rsVarRange = '\\ufe0e\\ufe0f';
21655
21656/** Used to compose unicode capture groups. */
21657var rsZWJ = '\\u200d';
21658
21659/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
21660var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
21661
21662/**
21663 * Checks if `string` contains Unicode symbols.
21664 *
21665 * @private
21666 * @param {string} string The string to inspect.
21667 * @returns {boolean} Returns `true` if a symbol is found, else `false`.
21668 */
21669function hasUnicode(string) {
21670 return reHasUnicode.test(string);
21671}
21672
21673var _hasUnicode = hasUnicode;
21674
21675/** Used to compose unicode character classes. */
21676var rsAstralRange$1 = '\\ud800-\\udfff',
21677 rsComboMarksRange$1 = '\\u0300-\\u036f',
21678 reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
21679 rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
21680 rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
21681 rsVarRange$1 = '\\ufe0e\\ufe0f';
21682
21683/** Used to compose unicode capture groups. */
21684var rsAstral = '[' + rsAstralRange$1 + ']',
21685 rsCombo = '[' + rsComboRange$1 + ']',
21686 rsFitz = '\\ud83c[\\udffb-\\udfff]',
21687 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
21688 rsNonAstral = '[^' + rsAstralRange$1 + ']',
21689 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
21690 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
21691 rsZWJ$1 = '\\u200d';
21692
21693/** Used to compose unicode regexes. */
21694var reOptMod = rsModifier + '?',
21695 rsOptVar = '[' + rsVarRange$1 + ']?',
21696 rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
21697 rsSeq = rsOptVar + reOptMod + rsOptJoin,
21698 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
21699
21700/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
21701var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
21702
21703/**
21704 * Gets the size of a Unicode `string`.
21705 *
21706 * @private
21707 * @param {string} string The string inspect.
21708 * @returns {number} Returns the string size.
21709 */
21710function unicodeSize(string) {
21711 var result = reUnicode.lastIndex = 0;
21712 while (reUnicode.test(string)) {
21713 ++result;
21714 }
21715 return result;
21716}
21717
21718var _unicodeSize = unicodeSize;
21719
21720/**
21721 * Gets the number of symbols in `string`.
21722 *
21723 * @private
21724 * @param {string} string The string to inspect.
21725 * @returns {number} Returns the string size.
21726 */
21727function stringSize(string) {
21728 return _hasUnicode(string)
21729 ? _unicodeSize(string)
21730 : _asciiSize(string);
21731}
21732
21733var _stringSize = stringSize;
21734
21735/** `Object#toString` result references. */
21736var mapTag$7 = '[object Map]',
21737 setTag$7 = '[object Set]';
21738
21739/**
21740 * Gets the size of `collection` by returning its length for array-like
21741 * values or the number of own enumerable string keyed properties for objects.
21742 *
21743 * @static
21744 * @memberOf _
21745 * @since 0.1.0
21746 * @category Collection
21747 * @param {Array|Object|string} collection The collection to inspect.
21748 * @returns {number} Returns the collection size.
21749 * @example
21750 *
21751 * _.size([1, 2, 3]);
21752 * // => 3
21753 *
21754 * _.size({ 'a': 1, 'b': 2 });
21755 * // => 2
21756 *
21757 * _.size('pebbles');
21758 * // => 7
21759 */
21760function size(collection) {
21761 if (collection == null) {
21762 return 0;
21763 }
21764 if (isArrayLike_1(collection)) {
21765 return isString_1(collection) ? _stringSize(collection) : collection.length;
21766 }
21767 var tag = _getTag(collection);
21768 if (tag == mapTag$7 || tag == setTag$7) {
21769 return collection.size;
21770 }
21771 return _baseKeys(collection).length;
21772}
21773
21774var size_1 = size;
21775
21776/**
21777 * An alternative to `_.reduce`; this method transforms `object` to a new
21778 * `accumulator` object which is the result of running each of its own
21779 * enumerable string keyed properties thru `iteratee`, with each invocation
21780 * potentially mutating the `accumulator` object. If `accumulator` is not
21781 * provided, a new object with the same `[[Prototype]]` will be used. The
21782 * iteratee is invoked with four arguments: (accumulator, value, key, object).
21783 * Iteratee functions may exit iteration early by explicitly returning `false`.
21784 *
21785 * @static
21786 * @memberOf _
21787 * @since 1.3.0
21788 * @category Object
21789 * @param {Object} object The object to iterate over.
21790 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
21791 * @param {*} [accumulator] The custom accumulator value.
21792 * @returns {*} Returns the accumulated value.
21793 * @example
21794 *
21795 * _.transform([2, 3, 4], function(result, n) {
21796 * result.push(n *= n);
21797 * return n % 2 == 0;
21798 * }, []);
21799 * // => [4, 9]
21800 *
21801 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
21802 * (result[value] || (result[value] = [])).push(key);
21803 * }, {});
21804 * // => { '1': ['a', 'c'], '2': ['b'] }
21805 */
21806function transform(object, iteratee, accumulator) {
21807 var isArr = isArray_1(object),
21808 isArrLike = isArr || isBuffer_1(object) || isTypedArray_1(object);
21809
21810 iteratee = _baseIteratee(iteratee);
21811 if (accumulator == null) {
21812 var Ctor = object && object.constructor;
21813 if (isArrLike) {
21814 accumulator = isArr ? new Ctor : [];
21815 }
21816 else if (isObject_1(object)) {
21817 accumulator = isFunction_1(Ctor) ? _baseCreate(_getPrototype(object)) : {};
21818 }
21819 else {
21820 accumulator = {};
21821 }
21822 }
21823 (isArrLike ? _arrayEach : _baseForOwn)(object, function(value, index, object) {
21824 return iteratee(accumulator, value, index, object);
21825 });
21826 return accumulator;
21827}
21828
21829var transform_1 = transform;
21830
21831/** Built-in value references. */
21832var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
21833
21834/**
21835 * Checks if `value` is a flattenable `arguments` object or array.
21836 *
21837 * @private
21838 * @param {*} value The value to check.
21839 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
21840 */
21841function isFlattenable(value) {
21842 return isArray_1(value) || isArguments_1(value) ||
21843 !!(spreadableSymbol && value && value[spreadableSymbol]);
21844}
21845
21846var _isFlattenable = isFlattenable;
21847
21848/**
21849 * The base implementation of `_.flatten` with support for restricting flattening.
21850 *
21851 * @private
21852 * @param {Array} array The array to flatten.
21853 * @param {number} depth The maximum recursion depth.
21854 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
21855 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
21856 * @param {Array} [result=[]] The initial result value.
21857 * @returns {Array} Returns the new flattened array.
21858 */
21859function baseFlatten(array, depth, predicate, isStrict, result) {
21860 var index = -1,
21861 length = array.length;
21862
21863 predicate || (predicate = _isFlattenable);
21864 result || (result = []);
21865
21866 while (++index < length) {
21867 var value = array[index];
21868 if (depth > 0 && predicate(value)) {
21869 if (depth > 1) {
21870 // Recursively flatten arrays (susceptible to call stack limits).
21871 baseFlatten(value, depth - 1, predicate, isStrict, result);
21872 } else {
21873 _arrayPush(result, value);
21874 }
21875 } else if (!isStrict) {
21876 result[result.length] = value;
21877 }
21878 }
21879 return result;
21880}
21881
21882var _baseFlatten = baseFlatten;
21883
21884/**
21885 * A faster alternative to `Function#apply`, this function invokes `func`
21886 * with the `this` binding of `thisArg` and the arguments of `args`.
21887 *
21888 * @private
21889 * @param {Function} func The function to invoke.
21890 * @param {*} thisArg The `this` binding of `func`.
21891 * @param {Array} args The arguments to invoke `func` with.
21892 * @returns {*} Returns the result of `func`.
21893 */
21894function apply(func, thisArg, args) {
21895 switch (args.length) {
21896 case 0: return func.call(thisArg);
21897 case 1: return func.call(thisArg, args[0]);
21898 case 2: return func.call(thisArg, args[0], args[1]);
21899 case 3: return func.call(thisArg, args[0], args[1], args[2]);
21900 }
21901 return func.apply(thisArg, args);
21902}
21903
21904var _apply = apply;
21905
21906/* Built-in method references for those with the same name as other `lodash` methods. */
21907var nativeMax = Math.max;
21908
21909/**
21910 * A specialized version of `baseRest` which transforms the rest array.
21911 *
21912 * @private
21913 * @param {Function} func The function to apply a rest parameter to.
21914 * @param {number} [start=func.length-1] The start position of the rest parameter.
21915 * @param {Function} transform The rest array transform.
21916 * @returns {Function} Returns the new function.
21917 */
21918function overRest(func, start, transform) {
21919 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
21920 return function() {
21921 var args = arguments,
21922 index = -1,
21923 length = nativeMax(args.length - start, 0),
21924 array = Array(length);
21925
21926 while (++index < length) {
21927 array[index] = args[start + index];
21928 }
21929 index = -1;
21930 var otherArgs = Array(start + 1);
21931 while (++index < start) {
21932 otherArgs[index] = args[index];
21933 }
21934 otherArgs[start] = transform(array);
21935 return _apply(func, this, otherArgs);
21936 };
21937}
21938
21939var _overRest = overRest;
21940
21941/**
21942 * The base implementation of `setToString` without support for hot loop shorting.
21943 *
21944 * @private
21945 * @param {Function} func The function to modify.
21946 * @param {Function} string The `toString` result.
21947 * @returns {Function} Returns `func`.
21948 */
21949var baseSetToString = !_defineProperty ? identity_1 : function(func, string) {
21950 return _defineProperty(func, 'toString', {
21951 'configurable': true,
21952 'enumerable': false,
21953 'value': constant_1(string),
21954 'writable': true
21955 });
21956};
21957
21958var _baseSetToString = baseSetToString;
21959
21960/** Used to detect hot functions by number of calls within a span of milliseconds. */
21961var HOT_COUNT = 800,
21962 HOT_SPAN = 16;
21963
21964/* Built-in method references for those with the same name as other `lodash` methods. */
21965var nativeNow = Date.now;
21966
21967/**
21968 * Creates a function that'll short out and invoke `identity` instead
21969 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
21970 * milliseconds.
21971 *
21972 * @private
21973 * @param {Function} func The function to restrict.
21974 * @returns {Function} Returns the new shortable function.
21975 */
21976function shortOut(func) {
21977 var count = 0,
21978 lastCalled = 0;
21979
21980 return function() {
21981 var stamp = nativeNow(),
21982 remaining = HOT_SPAN - (stamp - lastCalled);
21983
21984 lastCalled = stamp;
21985 if (remaining > 0) {
21986 if (++count >= HOT_COUNT) {
21987 return arguments[0];
21988 }
21989 } else {
21990 count = 0;
21991 }
21992 return func.apply(undefined, arguments);
21993 };
21994}
21995
21996var _shortOut = shortOut;
21997
21998/**
21999 * Sets the `toString` method of `func` to return `string`.
22000 *
22001 * @private
22002 * @param {Function} func The function to modify.
22003 * @param {Function} string The `toString` result.
22004 * @returns {Function} Returns `func`.
22005 */
22006var setToString = _shortOut(_baseSetToString);
22007
22008var _setToString = setToString;
22009
22010/**
22011 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
22012 *
22013 * @private
22014 * @param {Function} func The function to apply a rest parameter to.
22015 * @param {number} [start=func.length-1] The start position of the rest parameter.
22016 * @returns {Function} Returns the new function.
22017 */
22018function baseRest(func, start) {
22019 return _setToString(_overRest(func, start, identity_1), func + '');
22020}
22021
22022var _baseRest = baseRest;
22023
22024/**
22025 * The base implementation of `_.findIndex` and `_.findLastIndex` without
22026 * support for iteratee shorthands.
22027 *
22028 * @private
22029 * @param {Array} array The array to inspect.
22030 * @param {Function} predicate The function invoked per iteration.
22031 * @param {number} fromIndex The index to search from.
22032 * @param {boolean} [fromRight] Specify iterating from right to left.
22033 * @returns {number} Returns the index of the matched value, else `-1`.
22034 */
22035function baseFindIndex(array, predicate, fromIndex, fromRight) {
22036 var length = array.length,
22037 index = fromIndex + (fromRight ? 1 : -1);
22038
22039 while ((fromRight ? index-- : ++index < length)) {
22040 if (predicate(array[index], index, array)) {
22041 return index;
22042 }
22043 }
22044 return -1;
22045}
22046
22047var _baseFindIndex = baseFindIndex;
22048
22049/**
22050 * The base implementation of `_.isNaN` without support for number objects.
22051 *
22052 * @private
22053 * @param {*} value The value to check.
22054 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
22055 */
22056function baseIsNaN(value) {
22057 return value !== value;
22058}
22059
22060var _baseIsNaN = baseIsNaN;
22061
22062/**
22063 * A specialized version of `_.indexOf` which performs strict equality
22064 * comparisons of values, i.e. `===`.
22065 *
22066 * @private
22067 * @param {Array} array The array to inspect.
22068 * @param {*} value The value to search for.
22069 * @param {number} fromIndex The index to search from.
22070 * @returns {number} Returns the index of the matched value, else `-1`.
22071 */
22072function strictIndexOf(array, value, fromIndex) {
22073 var index = fromIndex - 1,
22074 length = array.length;
22075
22076 while (++index < length) {
22077 if (array[index] === value) {
22078 return index;
22079 }
22080 }
22081 return -1;
22082}
22083
22084var _strictIndexOf = strictIndexOf;
22085
22086/**
22087 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
22088 *
22089 * @private
22090 * @param {Array} array The array to inspect.
22091 * @param {*} value The value to search for.
22092 * @param {number} fromIndex The index to search from.
22093 * @returns {number} Returns the index of the matched value, else `-1`.
22094 */
22095function baseIndexOf(array, value, fromIndex) {
22096 return value === value
22097 ? _strictIndexOf(array, value, fromIndex)
22098 : _baseFindIndex(array, _baseIsNaN, fromIndex);
22099}
22100
22101var _baseIndexOf = baseIndexOf;
22102
22103/**
22104 * A specialized version of `_.includes` for arrays without support for
22105 * specifying an index to search from.
22106 *
22107 * @private
22108 * @param {Array} [array] The array to inspect.
22109 * @param {*} target The value to search for.
22110 * @returns {boolean} Returns `true` if `target` is found, else `false`.
22111 */
22112function arrayIncludes(array, value) {
22113 var length = array == null ? 0 : array.length;
22114 return !!length && _baseIndexOf(array, value, 0) > -1;
22115}
22116
22117var _arrayIncludes = arrayIncludes;
22118
22119/**
22120 * This function is like `arrayIncludes` except that it accepts a comparator.
22121 *
22122 * @private
22123 * @param {Array} [array] The array to inspect.
22124 * @param {*} target The value to search for.
22125 * @param {Function} comparator The comparator invoked per element.
22126 * @returns {boolean} Returns `true` if `target` is found, else `false`.
22127 */
22128function arrayIncludesWith(array, value, comparator) {
22129 var index = -1,
22130 length = array == null ? 0 : array.length;
22131
22132 while (++index < length) {
22133 if (comparator(value, array[index])) {
22134 return true;
22135 }
22136 }
22137 return false;
22138}
22139
22140var _arrayIncludesWith = arrayIncludesWith;
22141
22142/**
22143 * This method returns `undefined`.
22144 *
22145 * @static
22146 * @memberOf _
22147 * @since 2.3.0
22148 * @category Util
22149 * @example
22150 *
22151 * _.times(2, _.noop);
22152 * // => [undefined, undefined]
22153 */
22154function noop() {
22155 // No operation performed.
22156}
22157
22158var noop_1 = noop;
22159
22160/** Used as references for various `Number` constants. */
22161var INFINITY$2 = 1 / 0;
22162
22163/**
22164 * Creates a set object of `values`.
22165 *
22166 * @private
22167 * @param {Array} values The values to add to the set.
22168 * @returns {Object} Returns the new set.
22169 */
22170var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY$2) ? noop_1 : function(values) {
22171 return new _Set(values);
22172};
22173
22174var _createSet = createSet;
22175
22176/** Used as the size to enable large array optimizations. */
22177var LARGE_ARRAY_SIZE$1 = 200;
22178
22179/**
22180 * The base implementation of `_.uniqBy` without support for iteratee shorthands.
22181 *
22182 * @private
22183 * @param {Array} array The array to inspect.
22184 * @param {Function} [iteratee] The iteratee invoked per element.
22185 * @param {Function} [comparator] The comparator invoked per element.
22186 * @returns {Array} Returns the new duplicate free array.
22187 */
22188function baseUniq(array, iteratee, comparator) {
22189 var index = -1,
22190 includes = _arrayIncludes,
22191 length = array.length,
22192 isCommon = true,
22193 result = [],
22194 seen = result;
22195
22196 if (comparator) {
22197 isCommon = false;
22198 includes = _arrayIncludesWith;
22199 }
22200 else if (length >= LARGE_ARRAY_SIZE$1) {
22201 var set = iteratee ? null : _createSet(array);
22202 if (set) {
22203 return _setToArray(set);
22204 }
22205 isCommon = false;
22206 includes = _cacheHas;
22207 seen = new _SetCache;
22208 }
22209 else {
22210 seen = iteratee ? [] : result;
22211 }
22212 outer:
22213 while (++index < length) {
22214 var value = array[index],
22215 computed = iteratee ? iteratee(value) : value;
22216
22217 value = (comparator || value !== 0) ? value : 0;
22218 if (isCommon && computed === computed) {
22219 var seenIndex = seen.length;
22220 while (seenIndex--) {
22221 if (seen[seenIndex] === computed) {
22222 continue outer;
22223 }
22224 }
22225 if (iteratee) {
22226 seen.push(computed);
22227 }
22228 result.push(value);
22229 }
22230 else if (!includes(seen, computed, comparator)) {
22231 if (seen !== result) {
22232 seen.push(computed);
22233 }
22234 result.push(value);
22235 }
22236 }
22237 return result;
22238}
22239
22240var _baseUniq = baseUniq;
22241
22242/**
22243 * This method is like `_.isArrayLike` except that it also checks if `value`
22244 * is an object.
22245 *
22246 * @static
22247 * @memberOf _
22248 * @since 4.0.0
22249 * @category Lang
22250 * @param {*} value The value to check.
22251 * @returns {boolean} Returns `true` if `value` is an array-like object,
22252 * else `false`.
22253 * @example
22254 *
22255 * _.isArrayLikeObject([1, 2, 3]);
22256 * // => true
22257 *
22258 * _.isArrayLikeObject(document.body.children);
22259 * // => true
22260 *
22261 * _.isArrayLikeObject('abc');
22262 * // => false
22263 *
22264 * _.isArrayLikeObject(_.noop);
22265 * // => false
22266 */
22267function isArrayLikeObject(value) {
22268 return isObjectLike_1(value) && isArrayLike_1(value);
22269}
22270
22271var isArrayLikeObject_1 = isArrayLikeObject;
22272
22273/**
22274 * Creates an array of unique values, in order, from all given arrays using
22275 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
22276 * for equality comparisons.
22277 *
22278 * @static
22279 * @memberOf _
22280 * @since 0.1.0
22281 * @category Array
22282 * @param {...Array} [arrays] The arrays to inspect.
22283 * @returns {Array} Returns the new array of combined values.
22284 * @example
22285 *
22286 * _.union([2], [1, 2]);
22287 * // => [2, 1]
22288 */
22289var union = _baseRest(function(arrays) {
22290 return _baseUniq(_baseFlatten(arrays, 1, isArrayLikeObject_1, true));
22291});
22292
22293var union_1 = union;
22294
22295/**
22296 * The base implementation of `_.values` and `_.valuesIn` which creates an
22297 * array of `object` property values corresponding to the property names
22298 * of `props`.
22299 *
22300 * @private
22301 * @param {Object} object The object to query.
22302 * @param {Array} props The property names to get values for.
22303 * @returns {Object} Returns the array of property values.
22304 */
22305function baseValues(object, props) {
22306 return _arrayMap(props, function(key) {
22307 return object[key];
22308 });
22309}
22310
22311var _baseValues = baseValues;
22312
22313/**
22314 * Creates an array of the own enumerable string keyed property values of `object`.
22315 *
22316 * **Note:** Non-object values are coerced to objects.
22317 *
22318 * @static
22319 * @since 0.1.0
22320 * @memberOf _
22321 * @category Object
22322 * @param {Object} object The object to query.
22323 * @returns {Array} Returns the array of property values.
22324 * @example
22325 *
22326 * function Foo() {
22327 * this.a = 1;
22328 * this.b = 2;
22329 * }
22330 *
22331 * Foo.prototype.c = 3;
22332 *
22333 * _.values(new Foo);
22334 * // => [1, 2] (iteration order is not guaranteed)
22335 *
22336 * _.values('hi');
22337 * // => ['h', 'i']
22338 */
22339function values(object) {
22340 return object == null ? [] : _baseValues(object, keys_1(object));
22341}
22342
22343var values_1 = values;
22344
22345/* global window */
22346
22347var lodash$1;
22348
22349if (typeof commonjsRequire === "function") {
22350 try {
22351 lodash$1 = {
22352 clone: clone_1,
22353 constant: constant_1,
22354 each: each,
22355 filter: filter_1,
22356 has: has_1,
22357 isArray: isArray_1,
22358 isEmpty: isEmpty_1,
22359 isFunction: isFunction_1,
22360 isUndefined: isUndefined_1,
22361 keys: keys_1,
22362 map: map_1,
22363 reduce: reduce_1,
22364 size: size_1,
22365 transform: transform_1,
22366 union: union_1,
22367 values: values_1
22368 };
22369 } catch (e) {
22370 // continue regardless of error
22371 }
22372}
22373
22374if (!lodash$1) {
22375 lodash$1 = window._;
22376}
22377
22378var lodash_1 = lodash$1;
22379
22380var graph = Graph;
22381
22382var DEFAULT_EDGE_NAME = "\x00";
22383var GRAPH_NODE = "\x00";
22384var EDGE_KEY_DELIM = "\x01";
22385
22386// Implementation notes:
22387//
22388// * Node id query functions should return string ids for the nodes
22389// * Edge id query functions should return an "edgeObj", edge object, that is
22390// composed of enough information to uniquely identify an edge: {v, w, name}.
22391// * Internally we use an "edgeId", a stringified form of the edgeObj, to
22392// reference edges. This is because we need a performant way to look these
22393// edges up and, object properties, which have string keys, are the closest
22394// we're going to get to a performant hashtable in JavaScript.
22395
22396function Graph(opts) {
22397 this._isDirected = lodash_1.has(opts, "directed") ? opts.directed : true;
22398 this._isMultigraph = lodash_1.has(opts, "multigraph") ? opts.multigraph : false;
22399 this._isCompound = lodash_1.has(opts, "compound") ? opts.compound : false;
22400
22401 // Label for the graph itself
22402 this._label = undefined;
22403
22404 // Defaults to be set when creating a new node
22405 this._defaultNodeLabelFn = lodash_1.constant(undefined);
22406
22407 // Defaults to be set when creating a new edge
22408 this._defaultEdgeLabelFn = lodash_1.constant(undefined);
22409
22410 // v -> label
22411 this._nodes = {};
22412
22413 if (this._isCompound) {
22414 // v -> parent
22415 this._parent = {};
22416
22417 // v -> children
22418 this._children = {};
22419 this._children[GRAPH_NODE] = {};
22420 }
22421
22422 // v -> edgeObj
22423 this._in = {};
22424
22425 // u -> v -> Number
22426 this._preds = {};
22427
22428 // v -> edgeObj
22429 this._out = {};
22430
22431 // v -> w -> Number
22432 this._sucs = {};
22433
22434 // e -> edgeObj
22435 this._edgeObjs = {};
22436
22437 // e -> label
22438 this._edgeLabels = {};
22439}
22440
22441/* Number of nodes in the graph. Should only be changed by the implementation. */
22442Graph.prototype._nodeCount = 0;
22443
22444/* Number of edges in the graph. Should only be changed by the implementation. */
22445Graph.prototype._edgeCount = 0;
22446
22447
22448/* === Graph functions ========= */
22449
22450Graph.prototype.isDirected = function() {
22451 return this._isDirected;
22452};
22453
22454Graph.prototype.isMultigraph = function() {
22455 return this._isMultigraph;
22456};
22457
22458Graph.prototype.isCompound = function() {
22459 return this._isCompound;
22460};
22461
22462Graph.prototype.setGraph = function(label) {
22463 this._label = label;
22464 return this;
22465};
22466
22467Graph.prototype.graph = function() {
22468 return this._label;
22469};
22470
22471
22472/* === Node functions ========== */
22473
22474Graph.prototype.setDefaultNodeLabel = function(newDefault) {
22475 if (!lodash_1.isFunction(newDefault)) {
22476 newDefault = lodash_1.constant(newDefault);
22477 }
22478 this._defaultNodeLabelFn = newDefault;
22479 return this;
22480};
22481
22482Graph.prototype.nodeCount = function() {
22483 return this._nodeCount;
22484};
22485
22486Graph.prototype.nodes = function() {
22487 return lodash_1.keys(this._nodes);
22488};
22489
22490Graph.prototype.sources = function() {
22491 var self = this;
22492 return lodash_1.filter(this.nodes(), function(v) {
22493 return lodash_1.isEmpty(self._in[v]);
22494 });
22495};
22496
22497Graph.prototype.sinks = function() {
22498 var self = this;
22499 return lodash_1.filter(this.nodes(), function(v) {
22500 return lodash_1.isEmpty(self._out[v]);
22501 });
22502};
22503
22504Graph.prototype.setNodes = function(vs, value) {
22505 var args = arguments;
22506 var self = this;
22507 lodash_1.each(vs, function(v) {
22508 if (args.length > 1) {
22509 self.setNode(v, value);
22510 } else {
22511 self.setNode(v);
22512 }
22513 });
22514 return this;
22515};
22516
22517Graph.prototype.setNode = function(v, value) {
22518 if (lodash_1.has(this._nodes, v)) {
22519 if (arguments.length > 1) {
22520 this._nodes[v] = value;
22521 }
22522 return this;
22523 }
22524
22525 this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v);
22526 if (this._isCompound) {
22527 this._parent[v] = GRAPH_NODE;
22528 this._children[v] = {};
22529 this._children[GRAPH_NODE][v] = true;
22530 }
22531 this._in[v] = {};
22532 this._preds[v] = {};
22533 this._out[v] = {};
22534 this._sucs[v] = {};
22535 ++this._nodeCount;
22536 return this;
22537};
22538
22539Graph.prototype.node = function(v) {
22540 return this._nodes[v];
22541};
22542
22543Graph.prototype.hasNode = function(v) {
22544 return lodash_1.has(this._nodes, v);
22545};
22546
22547Graph.prototype.removeNode = function(v) {
22548 var self = this;
22549 if (lodash_1.has(this._nodes, v)) {
22550 var removeEdge = function(e) { self.removeEdge(self._edgeObjs[e]); };
22551 delete this._nodes[v];
22552 if (this._isCompound) {
22553 this._removeFromParentsChildList(v);
22554 delete this._parent[v];
22555 lodash_1.each(this.children(v), function(child) {
22556 self.setParent(child);
22557 });
22558 delete this._children[v];
22559 }
22560 lodash_1.each(lodash_1.keys(this._in[v]), removeEdge);
22561 delete this._in[v];
22562 delete this._preds[v];
22563 lodash_1.each(lodash_1.keys(this._out[v]), removeEdge);
22564 delete this._out[v];
22565 delete this._sucs[v];
22566 --this._nodeCount;
22567 }
22568 return this;
22569};
22570
22571Graph.prototype.setParent = function(v, parent) {
22572 if (!this._isCompound) {
22573 throw new Error("Cannot set parent in a non-compound graph");
22574 }
22575
22576 if (lodash_1.isUndefined(parent)) {
22577 parent = GRAPH_NODE;
22578 } else {
22579 // Coerce parent to string
22580 parent += "";
22581 for (var ancestor = parent;
22582 !lodash_1.isUndefined(ancestor);
22583 ancestor = this.parent(ancestor)) {
22584 if (ancestor === v) {
22585 throw new Error("Setting " + parent+ " as parent of " + v +
22586 " would create a cycle");
22587 }
22588 }
22589
22590 this.setNode(parent);
22591 }
22592
22593 this.setNode(v);
22594 this._removeFromParentsChildList(v);
22595 this._parent[v] = parent;
22596 this._children[parent][v] = true;
22597 return this;
22598};
22599
22600Graph.prototype._removeFromParentsChildList = function(v) {
22601 delete this._children[this._parent[v]][v];
22602};
22603
22604Graph.prototype.parent = function(v) {
22605 if (this._isCompound) {
22606 var parent = this._parent[v];
22607 if (parent !== GRAPH_NODE) {
22608 return parent;
22609 }
22610 }
22611};
22612
22613Graph.prototype.children = function(v) {
22614 if (lodash_1.isUndefined(v)) {
22615 v = GRAPH_NODE;
22616 }
22617
22618 if (this._isCompound) {
22619 var children = this._children[v];
22620 if (children) {
22621 return lodash_1.keys(children);
22622 }
22623 } else if (v === GRAPH_NODE) {
22624 return this.nodes();
22625 } else if (this.hasNode(v)) {
22626 return [];
22627 }
22628};
22629
22630Graph.prototype.predecessors = function(v) {
22631 var predsV = this._preds[v];
22632 if (predsV) {
22633 return lodash_1.keys(predsV);
22634 }
22635};
22636
22637Graph.prototype.successors = function(v) {
22638 var sucsV = this._sucs[v];
22639 if (sucsV) {
22640 return lodash_1.keys(sucsV);
22641 }
22642};
22643
22644Graph.prototype.neighbors = function(v) {
22645 var preds = this.predecessors(v);
22646 if (preds) {
22647 return lodash_1.union(preds, this.successors(v));
22648 }
22649};
22650
22651Graph.prototype.isLeaf = function (v) {
22652 var neighbors;
22653 if (this.isDirected()) {
22654 neighbors = this.successors(v);
22655 } else {
22656 neighbors = this.neighbors(v);
22657 }
22658 return neighbors.length === 0;
22659};
22660
22661Graph.prototype.filterNodes = function(filter) {
22662 var copy = new this.constructor({
22663 directed: this._isDirected,
22664 multigraph: this._isMultigraph,
22665 compound: this._isCompound
22666 });
22667
22668 copy.setGraph(this.graph());
22669
22670 var self = this;
22671 lodash_1.each(this._nodes, function(value, v) {
22672 if (filter(v)) {
22673 copy.setNode(v, value);
22674 }
22675 });
22676
22677 lodash_1.each(this._edgeObjs, function(e) {
22678 if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
22679 copy.setEdge(e, self.edge(e));
22680 }
22681 });
22682
22683 var parents = {};
22684 function findParent(v) {
22685 var parent = self.parent(v);
22686 if (parent === undefined || copy.hasNode(parent)) {
22687 parents[v] = parent;
22688 return parent;
22689 } else if (parent in parents) {
22690 return parents[parent];
22691 } else {
22692 return findParent(parent);
22693 }
22694 }
22695
22696 if (this._isCompound) {
22697 lodash_1.each(copy.nodes(), function(v) {
22698 copy.setParent(v, findParent(v));
22699 });
22700 }
22701
22702 return copy;
22703};
22704
22705/* === Edge functions ========== */
22706
22707Graph.prototype.setDefaultEdgeLabel = function(newDefault) {
22708 if (!lodash_1.isFunction(newDefault)) {
22709 newDefault = lodash_1.constant(newDefault);
22710 }
22711 this._defaultEdgeLabelFn = newDefault;
22712 return this;
22713};
22714
22715Graph.prototype.edgeCount = function() {
22716 return this._edgeCount;
22717};
22718
22719Graph.prototype.edges = function() {
22720 return lodash_1.values(this._edgeObjs);
22721};
22722
22723Graph.prototype.setPath = function(vs, value) {
22724 var self = this;
22725 var args = arguments;
22726 lodash_1.reduce(vs, function(v, w) {
22727 if (args.length > 1) {
22728 self.setEdge(v, w, value);
22729 } else {
22730 self.setEdge(v, w);
22731 }
22732 return w;
22733 });
22734 return this;
22735};
22736
22737/*
22738 * setEdge(v, w, [value, [name]])
22739 * setEdge({ v, w, [name] }, [value])
22740 */
22741Graph.prototype.setEdge = function() {
22742 var v, w, name, value;
22743 var valueSpecified = false;
22744 var arg0 = arguments[0];
22745
22746 if (typeof arg0 === "object" && arg0 !== null && "v" in arg0) {
22747 v = arg0.v;
22748 w = arg0.w;
22749 name = arg0.name;
22750 if (arguments.length === 2) {
22751 value = arguments[1];
22752 valueSpecified = true;
22753 }
22754 } else {
22755 v = arg0;
22756 w = arguments[1];
22757 name = arguments[3];
22758 if (arguments.length > 2) {
22759 value = arguments[2];
22760 valueSpecified = true;
22761 }
22762 }
22763
22764 v = "" + v;
22765 w = "" + w;
22766 if (!lodash_1.isUndefined(name)) {
22767 name = "" + name;
22768 }
22769
22770 var e = edgeArgsToId(this._isDirected, v, w, name);
22771 if (lodash_1.has(this._edgeLabels, e)) {
22772 if (valueSpecified) {
22773 this._edgeLabels[e] = value;
22774 }
22775 return this;
22776 }
22777
22778 if (!lodash_1.isUndefined(name) && !this._isMultigraph) {
22779 throw new Error("Cannot set a named edge when isMultigraph = false");
22780 }
22781
22782 // It didn't exist, so we need to create it.
22783 // First ensure the nodes exist.
22784 this.setNode(v);
22785 this.setNode(w);
22786
22787 this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name);
22788
22789 var edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
22790 // Ensure we add undirected edges in a consistent way.
22791 v = edgeObj.v;
22792 w = edgeObj.w;
22793
22794 Object.freeze(edgeObj);
22795 this._edgeObjs[e] = edgeObj;
22796 incrementOrInitEntry(this._preds[w], v);
22797 incrementOrInitEntry(this._sucs[v], w);
22798 this._in[w][e] = edgeObj;
22799 this._out[v][e] = edgeObj;
22800 this._edgeCount++;
22801 return this;
22802};
22803
22804Graph.prototype.edge = function(v, w, name) {
22805 var e = (arguments.length === 1
22806 ? edgeObjToId(this._isDirected, arguments[0])
22807 : edgeArgsToId(this._isDirected, v, w, name));
22808 return this._edgeLabels[e];
22809};
22810
22811Graph.prototype.hasEdge = function(v, w, name) {
22812 var e = (arguments.length === 1
22813 ? edgeObjToId(this._isDirected, arguments[0])
22814 : edgeArgsToId(this._isDirected, v, w, name));
22815 return lodash_1.has(this._edgeLabels, e);
22816};
22817
22818Graph.prototype.removeEdge = function(v, w, name) {
22819 var e = (arguments.length === 1
22820 ? edgeObjToId(this._isDirected, arguments[0])
22821 : edgeArgsToId(this._isDirected, v, w, name));
22822 var edge = this._edgeObjs[e];
22823 if (edge) {
22824 v = edge.v;
22825 w = edge.w;
22826 delete this._edgeLabels[e];
22827 delete this._edgeObjs[e];
22828 decrementOrRemoveEntry(this._preds[w], v);
22829 decrementOrRemoveEntry(this._sucs[v], w);
22830 delete this._in[w][e];
22831 delete this._out[v][e];
22832 this._edgeCount--;
22833 }
22834 return this;
22835};
22836
22837Graph.prototype.inEdges = function(v, u) {
22838 var inV = this._in[v];
22839 if (inV) {
22840 var edges = lodash_1.values(inV);
22841 if (!u) {
22842 return edges;
22843 }
22844 return lodash_1.filter(edges, function(edge) { return edge.v === u; });
22845 }
22846};
22847
22848Graph.prototype.outEdges = function(v, w) {
22849 var outV = this._out[v];
22850 if (outV) {
22851 var edges = lodash_1.values(outV);
22852 if (!w) {
22853 return edges;
22854 }
22855 return lodash_1.filter(edges, function(edge) { return edge.w === w; });
22856 }
22857};
22858
22859Graph.prototype.nodeEdges = function(v, w) {
22860 var inEdges = this.inEdges(v, w);
22861 if (inEdges) {
22862 return inEdges.concat(this.outEdges(v, w));
22863 }
22864};
22865
22866function incrementOrInitEntry(map, k) {
22867 if (map[k]) {
22868 map[k]++;
22869 } else {
22870 map[k] = 1;
22871 }
22872}
22873
22874function decrementOrRemoveEntry(map, k) {
22875 if (!--map[k]) { delete map[k]; }
22876}
22877
22878function edgeArgsToId(isDirected, v_, w_, name) {
22879 var v = "" + v_;
22880 var w = "" + w_;
22881 if (!isDirected && v > w) {
22882 var tmp = v;
22883 v = w;
22884 w = tmp;
22885 }
22886 return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM +
22887 (lodash_1.isUndefined(name) ? DEFAULT_EDGE_NAME : name);
22888}
22889
22890function edgeArgsToObj(isDirected, v_, w_, name) {
22891 var v = "" + v_;
22892 var w = "" + w_;
22893 if (!isDirected && v > w) {
22894 var tmp = v;
22895 v = w;
22896 w = tmp;
22897 }
22898 var edgeObj = { v: v, w: w };
22899 if (name) {
22900 edgeObj.name = name;
22901 }
22902 return edgeObj;
22903}
22904
22905function edgeObjToId(isDirected, edgeObj) {
22906 return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);
22907}
22908
22909var version = '2.1.8';
22910
22911// Includes only the "core" of graphlib
22912var lib = {
22913 Graph: graph,
22914 version: version
22915};
22916
22917var json = {
22918 write: write,
22919 read: read
22920};
22921
22922function write(g) {
22923 var json = {
22924 options: {
22925 directed: g.isDirected(),
22926 multigraph: g.isMultigraph(),
22927 compound: g.isCompound()
22928 },
22929 nodes: writeNodes(g),
22930 edges: writeEdges(g)
22931 };
22932 if (!lodash_1.isUndefined(g.graph())) {
22933 json.value = lodash_1.clone(g.graph());
22934 }
22935 return json;
22936}
22937
22938function writeNodes(g) {
22939 return lodash_1.map(g.nodes(), function(v) {
22940 var nodeValue = g.node(v);
22941 var parent = g.parent(v);
22942 var node = { v: v };
22943 if (!lodash_1.isUndefined(nodeValue)) {
22944 node.value = nodeValue;
22945 }
22946 if (!lodash_1.isUndefined(parent)) {
22947 node.parent = parent;
22948 }
22949 return node;
22950 });
22951}
22952
22953function writeEdges(g) {
22954 return lodash_1.map(g.edges(), function(e) {
22955 var edgeValue = g.edge(e);
22956 var edge = { v: e.v, w: e.w };
22957 if (!lodash_1.isUndefined(e.name)) {
22958 edge.name = e.name;
22959 }
22960 if (!lodash_1.isUndefined(edgeValue)) {
22961 edge.value = edgeValue;
22962 }
22963 return edge;
22964 });
22965}
22966
22967function read(json) {
22968 var g = new graph(json.options).setGraph(json.value);
22969 lodash_1.each(json.nodes, function(entry) {
22970 g.setNode(entry.v, entry.value);
22971 if (entry.parent) {
22972 g.setParent(entry.v, entry.parent);
22973 }
22974 });
22975 lodash_1.each(json.edges, function(entry) {
22976 g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value);
22977 });
22978 return g;
22979}
22980
22981var components_1 = components;
22982
22983function components(g) {
22984 var visited = {};
22985 var cmpts = [];
22986 var cmpt;
22987
22988 function dfs(v) {
22989 if (lodash_1.has(visited, v)) return;
22990 visited[v] = true;
22991 cmpt.push(v);
22992 lodash_1.each(g.successors(v), dfs);
22993 lodash_1.each(g.predecessors(v), dfs);
22994 }
22995
22996 lodash_1.each(g.nodes(), function(v) {
22997 cmpt = [];
22998 dfs(v);
22999 if (cmpt.length) {
23000 cmpts.push(cmpt);
23001 }
23002 });
23003
23004 return cmpts;
23005}
23006
23007var priorityQueue = PriorityQueue;
23008
23009/**
23010 * A min-priority queue data structure. This algorithm is derived from Cormen,
23011 * et al., "Introduction to Algorithms". The basic idea of a min-priority
23012 * queue is that you can efficiently (in O(1) time) get the smallest key in
23013 * the queue. Adding and removing elements takes O(log n) time. A key can
23014 * have its priority decreased in O(log n) time.
23015 */
23016function PriorityQueue() {
23017 this._arr = [];
23018 this._keyIndices = {};
23019}
23020
23021/**
23022 * Returns the number of elements in the queue. Takes `O(1)` time.
23023 */
23024PriorityQueue.prototype.size = function() {
23025 return this._arr.length;
23026};
23027
23028/**
23029 * Returns the keys that are in the queue. Takes `O(n)` time.
23030 */
23031PriorityQueue.prototype.keys = function() {
23032 return this._arr.map(function(x) { return x.key; });
23033};
23034
23035/**
23036 * Returns `true` if **key** is in the queue and `false` if not.
23037 */
23038PriorityQueue.prototype.has = function(key) {
23039 return lodash_1.has(this._keyIndices, key);
23040};
23041
23042/**
23043 * Returns the priority for **key**. If **key** is not present in the queue
23044 * then this function returns `undefined`. Takes `O(1)` time.
23045 *
23046 * @param {Object} key
23047 */
23048PriorityQueue.prototype.priority = function(key) {
23049 var index = this._keyIndices[key];
23050 if (index !== undefined) {
23051 return this._arr[index].priority;
23052 }
23053};
23054
23055/**
23056 * Returns the key for the minimum element in this queue. If the queue is
23057 * empty this function throws an Error. Takes `O(1)` time.
23058 */
23059PriorityQueue.prototype.min = function() {
23060 if (this.size() === 0) {
23061 throw new Error("Queue underflow");
23062 }
23063 return this._arr[0].key;
23064};
23065
23066/**
23067 * Inserts a new key into the priority queue. If the key already exists in
23068 * the queue this function returns `false`; otherwise it will return `true`.
23069 * Takes `O(n)` time.
23070 *
23071 * @param {Object} key the key to add
23072 * @param {Number} priority the initial priority for the key
23073 */
23074PriorityQueue.prototype.add = function(key, priority) {
23075 var keyIndices = this._keyIndices;
23076 key = String(key);
23077 if (!lodash_1.has(keyIndices, key)) {
23078 var arr = this._arr;
23079 var index = arr.length;
23080 keyIndices[key] = index;
23081 arr.push({key: key, priority: priority});
23082 this._decrease(index);
23083 return true;
23084 }
23085 return false;
23086};
23087
23088/**
23089 * Removes and returns the smallest key in the queue. Takes `O(log n)` time.
23090 */
23091PriorityQueue.prototype.removeMin = function() {
23092 this._swap(0, this._arr.length - 1);
23093 var min = this._arr.pop();
23094 delete this._keyIndices[min.key];
23095 this._heapify(0);
23096 return min.key;
23097};
23098
23099/**
23100 * Decreases the priority for **key** to **priority**. If the new priority is
23101 * greater than the previous priority, this function will throw an Error.
23102 *
23103 * @param {Object} key the key for which to raise priority
23104 * @param {Number} priority the new priority for the key
23105 */
23106PriorityQueue.prototype.decrease = function(key, priority) {
23107 var index = this._keyIndices[key];
23108 if (priority > this._arr[index].priority) {
23109 throw new Error("New priority is greater than current priority. " +
23110 "Key: " + key + " Old: " + this._arr[index].priority + " New: " + priority);
23111 }
23112 this._arr[index].priority = priority;
23113 this._decrease(index);
23114};
23115
23116PriorityQueue.prototype._heapify = function(i) {
23117 var arr = this._arr;
23118 var l = 2 * i;
23119 var r = l + 1;
23120 var largest = i;
23121 if (l < arr.length) {
23122 largest = arr[l].priority < arr[largest].priority ? l : largest;
23123 if (r < arr.length) {
23124 largest = arr[r].priority < arr[largest].priority ? r : largest;
23125 }
23126 if (largest !== i) {
23127 this._swap(i, largest);
23128 this._heapify(largest);
23129 }
23130 }
23131};
23132
23133PriorityQueue.prototype._decrease = function(index) {
23134 var arr = this._arr;
23135 var priority = arr[index].priority;
23136 var parent;
23137 while (index !== 0) {
23138 parent = index >> 1;
23139 if (arr[parent].priority < priority) {
23140 break;
23141 }
23142 this._swap(index, parent);
23143 index = parent;
23144 }
23145};
23146
23147PriorityQueue.prototype._swap = function(i, j) {
23148 var arr = this._arr;
23149 var keyIndices = this._keyIndices;
23150 var origArrI = arr[i];
23151 var origArrJ = arr[j];
23152 arr[i] = origArrJ;
23153 arr[j] = origArrI;
23154 keyIndices[origArrJ.key] = i;
23155 keyIndices[origArrI.key] = j;
23156};
23157
23158var dijkstra_1 = dijkstra;
23159
23160var DEFAULT_WEIGHT_FUNC = lodash_1.constant(1);
23161
23162function dijkstra(g, source, weightFn, edgeFn) {
23163 return runDijkstra(g, String(source),
23164 weightFn || DEFAULT_WEIGHT_FUNC,
23165 edgeFn || function(v) { return g.outEdges(v); });
23166}
23167
23168function runDijkstra(g, source, weightFn, edgeFn) {
23169 var results = {};
23170 var pq = new priorityQueue();
23171 var v, vEntry;
23172
23173 var updateNeighbors = function(edge) {
23174 var w = edge.v !== v ? edge.v : edge.w;
23175 var wEntry = results[w];
23176 var weight = weightFn(edge);
23177 var distance = vEntry.distance + weight;
23178
23179 if (weight < 0) {
23180 throw new Error("dijkstra does not allow negative edge weights. " +
23181 "Bad edge: " + edge + " Weight: " + weight);
23182 }
23183
23184 if (distance < wEntry.distance) {
23185 wEntry.distance = distance;
23186 wEntry.predecessor = v;
23187 pq.decrease(w, distance);
23188 }
23189 };
23190
23191 g.nodes().forEach(function(v) {
23192 var distance = v === source ? 0 : Number.POSITIVE_INFINITY;
23193 results[v] = { distance: distance };
23194 pq.add(v, distance);
23195 });
23196
23197 while (pq.size() > 0) {
23198 v = pq.removeMin();
23199 vEntry = results[v];
23200 if (vEntry.distance === Number.POSITIVE_INFINITY) {
23201 break;
23202 }
23203
23204 edgeFn(v).forEach(updateNeighbors);
23205 }
23206
23207 return results;
23208}
23209
23210var dijkstraAll_1 = dijkstraAll;
23211
23212function dijkstraAll(g, weightFunc, edgeFunc) {
23213 return lodash_1.transform(g.nodes(), function(acc, v) {
23214 acc[v] = dijkstra_1(g, v, weightFunc, edgeFunc);
23215 }, {});
23216}
23217
23218var tarjan_1 = tarjan;
23219
23220function tarjan(g) {
23221 var index = 0;
23222 var stack = [];
23223 var visited = {}; // node id -> { onStack, lowlink, index }
23224 var results = [];
23225
23226 function dfs(v) {
23227 var entry = visited[v] = {
23228 onStack: true,
23229 lowlink: index,
23230 index: index++
23231 };
23232 stack.push(v);
23233
23234 g.successors(v).forEach(function(w) {
23235 if (!lodash_1.has(visited, w)) {
23236 dfs(w);
23237 entry.lowlink = Math.min(entry.lowlink, visited[w].lowlink);
23238 } else if (visited[w].onStack) {
23239 entry.lowlink = Math.min(entry.lowlink, visited[w].index);
23240 }
23241 });
23242
23243 if (entry.lowlink === entry.index) {
23244 var cmpt = [];
23245 var w;
23246 do {
23247 w = stack.pop();
23248 visited[w].onStack = false;
23249 cmpt.push(w);
23250 } while (v !== w);
23251 results.push(cmpt);
23252 }
23253 }
23254
23255 g.nodes().forEach(function(v) {
23256 if (!lodash_1.has(visited, v)) {
23257 dfs(v);
23258 }
23259 });
23260
23261 return results;
23262}
23263
23264var findCycles_1 = findCycles;
23265
23266function findCycles(g) {
23267 return lodash_1.filter(tarjan_1(g), function(cmpt) {
23268 return cmpt.length > 1 || (cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0]));
23269 });
23270}
23271
23272var floydWarshall_1 = floydWarshall;
23273
23274var DEFAULT_WEIGHT_FUNC$1 = lodash_1.constant(1);
23275
23276function floydWarshall(g, weightFn, edgeFn) {
23277 return runFloydWarshall(g,
23278 weightFn || DEFAULT_WEIGHT_FUNC$1,
23279 edgeFn || function(v) { return g.outEdges(v); });
23280}
23281
23282function runFloydWarshall(g, weightFn, edgeFn) {
23283 var results = {};
23284 var nodes = g.nodes();
23285
23286 nodes.forEach(function(v) {
23287 results[v] = {};
23288 results[v][v] = { distance: 0 };
23289 nodes.forEach(function(w) {
23290 if (v !== w) {
23291 results[v][w] = { distance: Number.POSITIVE_INFINITY };
23292 }
23293 });
23294 edgeFn(v).forEach(function(edge) {
23295 var w = edge.v === v ? edge.w : edge.v;
23296 var d = weightFn(edge);
23297 results[v][w] = { distance: d, predecessor: v };
23298 });
23299 });
23300
23301 nodes.forEach(function(k) {
23302 var rowK = results[k];
23303 nodes.forEach(function(i) {
23304 var rowI = results[i];
23305 nodes.forEach(function(j) {
23306 var ik = rowI[k];
23307 var kj = rowK[j];
23308 var ij = rowI[j];
23309 var altDistance = ik.distance + kj.distance;
23310 if (altDistance < ij.distance) {
23311 ij.distance = altDistance;
23312 ij.predecessor = kj.predecessor;
23313 }
23314 });
23315 });
23316 });
23317
23318 return results;
23319}
23320
23321var topsort_1 = topsort;
23322topsort.CycleException = CycleException;
23323
23324function topsort(g) {
23325 var visited = {};
23326 var stack = {};
23327 var results = [];
23328
23329 function visit(node) {
23330 if (lodash_1.has(stack, node)) {
23331 throw new CycleException();
23332 }
23333
23334 if (!lodash_1.has(visited, node)) {
23335 stack[node] = true;
23336 visited[node] = true;
23337 lodash_1.each(g.predecessors(node), visit);
23338 delete stack[node];
23339 results.push(node);
23340 }
23341 }
23342
23343 lodash_1.each(g.sinks(), visit);
23344
23345 if (lodash_1.size(visited) !== g.nodeCount()) {
23346 throw new CycleException();
23347 }
23348
23349 return results;
23350}
23351
23352function CycleException() {}
23353CycleException.prototype = new Error(); // must be an instance of Error to pass testing
23354
23355var isAcyclic_1 = isAcyclic;
23356
23357function isAcyclic(g) {
23358 try {
23359 topsort_1(g);
23360 } catch (e) {
23361 if (e instanceof topsort_1.CycleException) {
23362 return false;
23363 }
23364 throw e;
23365 }
23366 return true;
23367}
23368
23369var dfs_1 = dfs;
23370
23371/*
23372 * A helper that preforms a pre- or post-order traversal on the input graph
23373 * and returns the nodes in the order they were visited. If the graph is
23374 * undirected then this algorithm will navigate using neighbors. If the graph
23375 * is directed then this algorithm will navigate using successors.
23376 *
23377 * Order must be one of "pre" or "post".
23378 */
23379function dfs(g, vs, order) {
23380 if (!lodash_1.isArray(vs)) {
23381 vs = [vs];
23382 }
23383
23384 var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g);
23385
23386 var acc = [];
23387 var visited = {};
23388 lodash_1.each(vs, function(v) {
23389 if (!g.hasNode(v)) {
23390 throw new Error("Graph does not have node: " + v);
23391 }
23392
23393 doDfs(g, v, order === "post", visited, navigation, acc);
23394 });
23395 return acc;
23396}
23397
23398function doDfs(g, v, postorder, visited, navigation, acc) {
23399 if (!lodash_1.has(visited, v)) {
23400 visited[v] = true;
23401
23402 if (!postorder) { acc.push(v); }
23403 lodash_1.each(navigation(v), function(w) {
23404 doDfs(g, w, postorder, visited, navigation, acc);
23405 });
23406 if (postorder) { acc.push(v); }
23407 }
23408}
23409
23410var postorder_1 = postorder;
23411
23412function postorder(g, vs) {
23413 return dfs_1(g, vs, "post");
23414}
23415
23416var preorder_1 = preorder;
23417
23418function preorder(g, vs) {
23419 return dfs_1(g, vs, "pre");
23420}
23421
23422var prim_1 = prim;
23423
23424function prim(g, weightFunc) {
23425 var result = new graph();
23426 var parents = {};
23427 var pq = new priorityQueue();
23428 var v;
23429
23430 function updateNeighbors(edge) {
23431 var w = edge.v === v ? edge.w : edge.v;
23432 var pri = pq.priority(w);
23433 if (pri !== undefined) {
23434 var edgeWeight = weightFunc(edge);
23435 if (edgeWeight < pri) {
23436 parents[w] = v;
23437 pq.decrease(w, edgeWeight);
23438 }
23439 }
23440 }
23441
23442 if (g.nodeCount() === 0) {
23443 return result;
23444 }
23445
23446 lodash_1.each(g.nodes(), function(v) {
23447 pq.add(v, Number.POSITIVE_INFINITY);
23448 result.setNode(v);
23449 });
23450
23451 // Start from an arbitrary node
23452 pq.decrease(g.nodes()[0], 0);
23453
23454 var init = false;
23455 while (pq.size() > 0) {
23456 v = pq.removeMin();
23457 if (lodash_1.has(parents, v)) {
23458 result.setEdge(v, parents[v]);
23459 } else if (init) {
23460 throw new Error("Input graph is not connected: " + g);
23461 } else {
23462 init = true;
23463 }
23464
23465 g.nodeEdges(v).forEach(updateNeighbors);
23466 }
23467
23468 return result;
23469}
23470
23471var alg = {
23472 components: components_1,
23473 dijkstra: dijkstra_1,
23474 dijkstraAll: dijkstraAll_1,
23475 findCycles: findCycles_1,
23476 floydWarshall: floydWarshall_1,
23477 isAcyclic: isAcyclic_1,
23478 postorder: postorder_1,
23479 preorder: preorder_1,
23480 prim: prim_1,
23481 tarjan: tarjan_1,
23482 topsort: topsort_1
23483};
23484
23485/**
23486 * Copyright (c) 2014, Chris Pettitt
23487 * All rights reserved.
23488 *
23489 * Redistribution and use in source and binary forms, with or without
23490 * modification, are permitted provided that the following conditions are met:
23491 *
23492 * 1. Redistributions of source code must retain the above copyright notice, this
23493 * list of conditions and the following disclaimer.
23494 *
23495 * 2. Redistributions in binary form must reproduce the above copyright notice,
23496 * this list of conditions and the following disclaimer in the documentation
23497 * and/or other materials provided with the distribution.
23498 *
23499 * 3. Neither the name of the copyright holder nor the names of its contributors
23500 * may be used to endorse or promote products derived from this software without
23501 * specific prior written permission.
23502 *
23503 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23504 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23505 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23506 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23507 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23508 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23509 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23510 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23511 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23512 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23513 */
23514
23515var graphlib = {
23516 Graph: lib.Graph,
23517 json: json,
23518 alg: alg,
23519 version: lib.version
23520};
23521
23522var objectHash_1 = createCommonjsModule(function (module, exports) {
23523
23524
23525
23526/**
23527 * Exported function
23528 *
23529 * Options:
23530 *
23531 * - `algorithm` hash algo to be used by this instance: *'sha1', 'md5'
23532 * - `excludeValues` {true|*false} hash object keys, values ignored
23533 * - `encoding` hash encoding, supports 'buffer', '*hex', 'binary', 'base64'
23534 * - `ignoreUnknown` {true|*false} ignore unknown object types
23535 * - `replacer` optional function that replaces values before hashing
23536 * - `respectFunctionProperties` {*true|false} consider function properties when hashing
23537 * - `respectFunctionNames` {*true|false} consider 'name' property of functions for hashing
23538 * - `respectType` {*true|false} Respect special properties (prototype, constructor)
23539 * when hashing to distinguish between types
23540 * - `unorderedArrays` {true|*false} Sort all arrays before hashing
23541 * - `unorderedSets` {*true|false} Sort `Set` and `Map` instances before hashing
23542 * * = default
23543 *
23544 * @param {object} object value to hash
23545 * @param {object} options hashing options
23546 * @return {string} hash value
23547 * @api public
23548 */
23549exports = module.exports = objectHash;
23550
23551function objectHash(object, options){
23552 options = applyDefaults(object, options);
23553
23554 return hash(object, options);
23555}
23556
23557/**
23558 * Exported sugar methods
23559 *
23560 * @param {object} object value to hash
23561 * @return {string} hash value
23562 * @api public
23563 */
23564exports.sha1 = function(object){
23565 return objectHash(object);
23566};
23567exports.keys = function(object){
23568 return objectHash(object, {excludeValues: true, algorithm: 'sha1', encoding: 'hex'});
23569};
23570exports.MD5 = function(object){
23571 return objectHash(object, {algorithm: 'md5', encoding: 'hex'});
23572};
23573exports.keysMD5 = function(object){
23574 return objectHash(object, {algorithm: 'md5', encoding: 'hex', excludeValues: true});
23575};
23576
23577// Internals
23578var hashes = crypto.getHashes ? crypto.getHashes().slice() : ['sha1', 'md5'];
23579hashes.push('passthrough');
23580var encodings = ['buffer', 'hex', 'binary', 'base64'];
23581
23582function applyDefaults(object, sourceOptions){
23583 sourceOptions = sourceOptions || {};
23584
23585 // create a copy rather than mutating
23586 var options = {};
23587 options.algorithm = sourceOptions.algorithm || 'sha1';
23588 options.encoding = sourceOptions.encoding || 'hex';
23589 options.excludeValues = sourceOptions.excludeValues ? true : false;
23590 options.algorithm = options.algorithm.toLowerCase();
23591 options.encoding = options.encoding.toLowerCase();
23592 options.ignoreUnknown = sourceOptions.ignoreUnknown !== true ? false : true; // default to false
23593 options.respectType = sourceOptions.respectType === false ? false : true; // default to true
23594 options.respectFunctionNames = sourceOptions.respectFunctionNames === false ? false : true;
23595 options.respectFunctionProperties = sourceOptions.respectFunctionProperties === false ? false : true;
23596 options.unorderedArrays = sourceOptions.unorderedArrays !== true ? false : true; // default to false
23597 options.unorderedSets = sourceOptions.unorderedSets === false ? false : true; // default to false
23598 options.unorderedObjects = sourceOptions.unorderedObjects === false ? false : true; // default to true
23599 options.replacer = sourceOptions.replacer || undefined;
23600 options.excludeKeys = sourceOptions.excludeKeys || undefined;
23601
23602 if(typeof object === 'undefined') {
23603 throw new Error('Object argument required.');
23604 }
23605
23606 // if there is a case-insensitive match in the hashes list, accept it
23607 // (i.e. SHA256 for sha256)
23608 for (var i = 0; i < hashes.length; ++i) {
23609 if (hashes[i].toLowerCase() === options.algorithm.toLowerCase()) {
23610 options.algorithm = hashes[i];
23611 }
23612 }
23613
23614 if(hashes.indexOf(options.algorithm) === -1){
23615 throw new Error('Algorithm "' + options.algorithm + '" not supported. ' +
23616 'supported values: ' + hashes.join(', '));
23617 }
23618
23619 if(encodings.indexOf(options.encoding) === -1 &&
23620 options.algorithm !== 'passthrough'){
23621 throw new Error('Encoding "' + options.encoding + '" not supported. ' +
23622 'supported values: ' + encodings.join(', '));
23623 }
23624
23625 return options;
23626}
23627
23628/** Check if the given function is a native function */
23629function isNativeFunction(f) {
23630 if ((typeof f) !== 'function') {
23631 return false;
23632 }
23633 var exp = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i;
23634 return exp.exec(Function.prototype.toString.call(f)) != null;
23635}
23636
23637function hash(object, options) {
23638 var hashingStream;
23639
23640 if (options.algorithm !== 'passthrough') {
23641 hashingStream = crypto.createHash(options.algorithm);
23642 } else {
23643 hashingStream = new PassThrough();
23644 }
23645
23646 if (typeof hashingStream.write === 'undefined') {
23647 hashingStream.write = hashingStream.update;
23648 hashingStream.end = hashingStream.update;
23649 }
23650
23651 var hasher = typeHasher(options, hashingStream);
23652 hasher.dispatch(object);
23653 if (!hashingStream.update) {
23654 hashingStream.end('');
23655 }
23656
23657 if (hashingStream.digest) {
23658 return hashingStream.digest(options.encoding === 'buffer' ? undefined : options.encoding);
23659 }
23660
23661 var buf = hashingStream.read();
23662 if (options.encoding === 'buffer') {
23663 return buf;
23664 }
23665
23666 return buf.toString(options.encoding);
23667}
23668
23669/**
23670 * Expose streaming API
23671 *
23672 * @param {object} object Value to serialize
23673 * @param {object} options Options, as for hash()
23674 * @param {object} stream A stream to write the serializiation to
23675 * @api public
23676 */
23677exports.writeToStream = function(object, options, stream) {
23678 if (typeof stream === 'undefined') {
23679 stream = options;
23680 options = {};
23681 }
23682
23683 options = applyDefaults(object, options);
23684
23685 return typeHasher(options, stream).dispatch(object);
23686};
23687
23688function typeHasher(options, writeTo, context){
23689 context = context || [];
23690 var write = function(str) {
23691 if (writeTo.update) {
23692 return writeTo.update(str, 'utf8');
23693 } else {
23694 return writeTo.write(str, 'utf8');
23695 }
23696 };
23697
23698 return {
23699 dispatch: function(value){
23700 if (options.replacer) {
23701 value = options.replacer(value);
23702 }
23703
23704 var type = typeof value;
23705 if (value === null) {
23706 type = 'null';
23707 }
23708
23709 //console.log("[DEBUG] Dispatch: ", value, "->", type, " -> ", "_" + type);
23710
23711 return this['_' + type](value);
23712 },
23713 _object: function(object) {
23714 var pattern = (/\[object (.*)\]/i);
23715 var objString = Object.prototype.toString.call(object);
23716 var objType = pattern.exec(objString);
23717 if (!objType) { // object type did not match [object ...]
23718 objType = 'unknown:[' + objString + ']';
23719 } else {
23720 objType = objType[1]; // take only the class name
23721 }
23722
23723 objType = objType.toLowerCase();
23724
23725 var objectNumber = null;
23726
23727 if ((objectNumber = context.indexOf(object)) >= 0) {
23728 return this.dispatch('[CIRCULAR:' + objectNumber + ']');
23729 } else {
23730 context.push(object);
23731 }
23732
23733 if (typeof Buffer !== 'undefined' && Buffer.isBuffer && Buffer.isBuffer(object)) {
23734 write('buffer:');
23735 return write(object);
23736 }
23737
23738 if(objType !== 'object' && objType !== 'function' && objType !== 'asyncfunction') {
23739 if(this['_' + objType]) {
23740 this['_' + objType](object);
23741 } else if (options.ignoreUnknown) {
23742 return write('[' + objType + ']');
23743 } else {
23744 throw new Error('Unknown object type "' + objType + '"');
23745 }
23746 }else {
23747 var keys = Object.keys(object);
23748 if (options.unorderedObjects) {
23749 keys = keys.sort();
23750 }
23751 // Make sure to incorporate special properties, so
23752 // Types with different prototypes will produce
23753 // a different hash and objects derived from
23754 // different functions (`new Foo`, `new Bar`) will
23755 // produce different hashes.
23756 // We never do this for native functions since some
23757 // seem to break because of that.
23758 if (options.respectType !== false && !isNativeFunction(object)) {
23759 keys.splice(0, 0, 'prototype', '__proto__', 'constructor');
23760 }
23761
23762 if (options.excludeKeys) {
23763 keys = keys.filter(function(key) { return !options.excludeKeys(key); });
23764 }
23765
23766 write('object:' + keys.length + ':');
23767 var self = this;
23768 return keys.forEach(function(key){
23769 self.dispatch(key);
23770 write(':');
23771 if(!options.excludeValues) {
23772 self.dispatch(object[key]);
23773 }
23774 write(',');
23775 });
23776 }
23777 },
23778 _array: function(arr, unordered){
23779 unordered = typeof unordered !== 'undefined' ? unordered :
23780 options.unorderedArrays !== false; // default to options.unorderedArrays
23781
23782 var self = this;
23783 write('array:' + arr.length + ':');
23784 if (!unordered || arr.length <= 1) {
23785 return arr.forEach(function(entry) {
23786 return self.dispatch(entry);
23787 });
23788 }
23789
23790 // the unordered case is a little more complicated:
23791 // since there is no canonical ordering on objects,
23792 // i.e. {a:1} < {a:2} and {a:1} > {a:2} are both false,
23793 // we first serialize each entry using a PassThrough stream
23794 // before sorting.
23795 // also: we can’t use the same context array for all entries
23796 // since the order of hashing should *not* matter. instead,
23797 // we keep track of the additions to a copy of the context array
23798 // and add all of them to the global context array when we’re done
23799 var contextAdditions = [];
23800 var entries = arr.map(function(entry) {
23801 var strm = new PassThrough();
23802 var localContext = context.slice(); // make copy
23803 var hasher = typeHasher(options, strm, localContext);
23804 hasher.dispatch(entry);
23805 // take only what was added to localContext and append it to contextAdditions
23806 contextAdditions = contextAdditions.concat(localContext.slice(context.length));
23807 return strm.read().toString();
23808 });
23809 context = context.concat(contextAdditions);
23810 entries.sort();
23811 return this._array(entries, false);
23812 },
23813 _date: function(date){
23814 return write('date:' + date.toJSON());
23815 },
23816 _symbol: function(sym){
23817 return write('symbol:' + sym.toString());
23818 },
23819 _error: function(err){
23820 return write('error:' + err.toString());
23821 },
23822 _boolean: function(bool){
23823 return write('bool:' + bool.toString());
23824 },
23825 _string: function(string){
23826 write('string:' + string.length + ':');
23827 write(string.toString());
23828 },
23829 _function: function(fn){
23830 write('fn:');
23831 if (isNativeFunction(fn)) {
23832 this.dispatch('[native]');
23833 } else {
23834 this.dispatch(fn.toString());
23835 }
23836
23837 if (options.respectFunctionNames !== false) {
23838 // Make sure we can still distinguish native functions
23839 // by their name, otherwise String and Function will
23840 // have the same hash
23841 this.dispatch("function-name:" + String(fn.name));
23842 }
23843
23844 if (options.respectFunctionProperties) {
23845 this._object(fn);
23846 }
23847 },
23848 _number: function(number){
23849 return write('number:' + number.toString());
23850 },
23851 _xml: function(xml){
23852 return write('xml:' + xml.toString());
23853 },
23854 _null: function() {
23855 return write('Null');
23856 },
23857 _undefined: function() {
23858 return write('Undefined');
23859 },
23860 _regexp: function(regex){
23861 return write('regex:' + regex.toString());
23862 },
23863 _uint8array: function(arr){
23864 write('uint8array:');
23865 return this.dispatch(Array.prototype.slice.call(arr));
23866 },
23867 _uint8clampedarray: function(arr){
23868 write('uint8clampedarray:');
23869 return this.dispatch(Array.prototype.slice.call(arr));
23870 },
23871 _int8array: function(arr){
23872 write('uint8array:');
23873 return this.dispatch(Array.prototype.slice.call(arr));
23874 },
23875 _uint16array: function(arr){
23876 write('uint16array:');
23877 return this.dispatch(Array.prototype.slice.call(arr));
23878 },
23879 _int16array: function(arr){
23880 write('uint16array:');
23881 return this.dispatch(Array.prototype.slice.call(arr));
23882 },
23883 _uint32array: function(arr){
23884 write('uint32array:');
23885 return this.dispatch(Array.prototype.slice.call(arr));
23886 },
23887 _int32array: function(arr){
23888 write('uint32array:');
23889 return this.dispatch(Array.prototype.slice.call(arr));
23890 },
23891 _float32array: function(arr){
23892 write('float32array:');
23893 return this.dispatch(Array.prototype.slice.call(arr));
23894 },
23895 _float64array: function(arr){
23896 write('float64array:');
23897 return this.dispatch(Array.prototype.slice.call(arr));
23898 },
23899 _arraybuffer: function(arr){
23900 write('arraybuffer:');
23901 return this.dispatch(new Uint8Array(arr));
23902 },
23903 _url: function(url) {
23904 return write('url:' + url.toString());
23905 },
23906 _map: function(map) {
23907 write('map:');
23908 var arr = Array.from(map);
23909 return this._array(arr, options.unorderedSets !== false);
23910 },
23911 _set: function(set) {
23912 write('set:');
23913 var arr = Array.from(set);
23914 return this._array(arr, options.unorderedSets !== false);
23915 },
23916 _blob: function() {
23917 if (options.ignoreUnknown) {
23918 return write('[blob]');
23919 }
23920
23921 throw Error('Hashing Blob objects is currently not supported\n' +
23922 '(see https://github.com/puleos/object-hash/issues/26)\n' +
23923 'Use "options.replacer" or "options.ignoreUnknown"\n');
23924 },
23925 _domwindow: function() { return write('domwindow'); },
23926 /* Node.js standard native objects */
23927 _process: function() { return write('process'); },
23928 _timer: function() { return write('timer'); },
23929 _pipe: function() { return write('pipe'); },
23930 _tcp: function() { return write('tcp'); },
23931 _udp: function() { return write('udp'); },
23932 _tty: function() { return write('tty'); },
23933 _statwatcher: function() { return write('statwatcher'); },
23934 _securecontext: function() { return write('securecontext'); },
23935 _connection: function() { return write('connection'); },
23936 _zlib: function() { return write('zlib'); },
23937 _context: function() { return write('context'); },
23938 _nodescript: function() { return write('nodescript'); },
23939 _httpparser: function() { return write('httpparser'); },
23940 _dataview: function() { return write('dataview'); },
23941 _signal: function() { return write('signal'); },
23942 _fsevent: function() { return write('fsevent'); },
23943 _tlswrap: function() { return write('tlswrap'); }
23944 };
23945}
23946
23947// Mini-implementation of stream.PassThrough
23948// We are far from having need for the full implementation, and we can
23949// make assumptions like "many writes, then only one final read"
23950// and we can ignore encoding specifics
23951function PassThrough() {
23952 return {
23953 buf: '',
23954
23955 write: function(b) {
23956 this.buf += b;
23957 },
23958
23959 end: function(b) {
23960 this.buf += b;
23961 },
23962
23963 read: function() {
23964 return this.buf;
23965 }
23966 };
23967}
23968});
23969
23970/**
23971 * Saves data in new cache folder or reads it from old one.
23972 * Avoids perpetually growing cache and situations when things need to consider changed and then reverted data to be changed.
23973 */
23974class RollingCache {
23975 /**
23976 * @param cacheRoot: root folder for the cache
23977 * @param checkNewCache: whether to also look in new cache when reading from cache
23978 */
23979 constructor(cacheRoot, checkNewCache) {
23980 this.cacheRoot = cacheRoot;
23981 this.checkNewCache = checkNewCache;
23982 this.rolled = false;
23983 this.oldCacheRoot = `${this.cacheRoot}/cache`;
23984 this.newCacheRoot = `${this.cacheRoot}/cache_`;
23985 emptyDirSync(this.newCacheRoot);
23986 }
23987 /**
23988 * @returns true if name exist in old cache (or either old of new cache if checkNewCache is true)
23989 */
23990 exists(name) {
23991 if (this.rolled)
23992 return false;
23993 if (this.checkNewCache && existsSync(`${this.newCacheRoot}/${name}`))
23994 return true;
23995 return existsSync(`${this.oldCacheRoot}/${name}`);
23996 }
23997 path(name) {
23998 return `${this.oldCacheRoot}/${name}`;
23999 }
24000 /**
24001 * @returns true if old cache contains all names and nothing more
24002 */
24003 match(names) {
24004 if (this.rolled)
24005 return false;
24006 if (!existsSync(this.oldCacheRoot))
24007 return names.length === 0; // empty folder matches
24008 return lodash.isEqual(readdirSync(this.oldCacheRoot).sort(), names.sort());
24009 }
24010 /**
24011 * @returns data for name, must exist in old cache (or either old of new cache if checkNewCache is true)
24012 */
24013 read(name) {
24014 if (this.checkNewCache && existsSync(`${this.newCacheRoot}/${name}`))
24015 return readJsonSync(`${this.newCacheRoot}/${name}`, { encoding: "utf8", throws: false });
24016 return readJsonSync(`${this.oldCacheRoot}/${name}`, { encoding: "utf8", throws: false });
24017 }
24018 write(name, data) {
24019 if (this.rolled)
24020 return;
24021 if (data === undefined)
24022 return;
24023 writeJsonSync(`${this.newCacheRoot}/${name}`, data);
24024 }
24025 touch(name) {
24026 if (this.rolled)
24027 return;
24028 ensureFileSync(`${this.newCacheRoot}/${name}`);
24029 }
24030 /**
24031 * clears old cache and moves new in its place
24032 */
24033 roll() {
24034 if (this.rolled)
24035 return;
24036 this.rolled = true;
24037 removeSync(this.oldCacheRoot);
24038 if (existsSync(this.newCacheRoot)) {
24039 renameSync(this.newCacheRoot, this.oldCacheRoot);
24040 }
24041 }
24042}
24043
24044/*
24045The MIT License (MIT)
24046
24047Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
24048
24049Permission is hereby granted, free of charge, to any person obtaining a copy
24050of this software and associated documentation files (the "Software"), to deal
24051in the Software without restriction, including without limitation the rights
24052to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24053copies of the Software, and to permit persons to whom the Software is
24054furnished to do so, subject to the following conditions:
24055
24056The above copyright notice and this permission notice shall be included in
24057all copies or substantial portions of the Software.
24058
24059THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24060IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24061FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24062AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24063LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24064OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24065THE SOFTWARE.
24066
24067*/
24068
24069var styles_1 = createCommonjsModule(function (module) {
24070var styles = {};
24071module['exports'] = styles;
24072
24073var codes = {
24074 reset: [0, 0],
24075
24076 bold: [1, 22],
24077 dim: [2, 22],
24078 italic: [3, 23],
24079 underline: [4, 24],
24080 inverse: [7, 27],
24081 hidden: [8, 28],
24082 strikethrough: [9, 29],
24083
24084 black: [30, 39],
24085 red: [31, 39],
24086 green: [32, 39],
24087 yellow: [33, 39],
24088 blue: [34, 39],
24089 magenta: [35, 39],
24090 cyan: [36, 39],
24091 white: [37, 39],
24092 gray: [90, 39],
24093 grey: [90, 39],
24094
24095 brightRed: [91, 39],
24096 brightGreen: [92, 39],
24097 brightYellow: [93, 39],
24098 brightBlue: [94, 39],
24099 brightMagenta: [95, 39],
24100 brightCyan: [96, 39],
24101 brightWhite: [97, 39],
24102
24103 bgBlack: [40, 49],
24104 bgRed: [41, 49],
24105 bgGreen: [42, 49],
24106 bgYellow: [43, 49],
24107 bgBlue: [44, 49],
24108 bgMagenta: [45, 49],
24109 bgCyan: [46, 49],
24110 bgWhite: [47, 49],
24111 bgGray: [100, 49],
24112 bgGrey: [100, 49],
24113
24114 bgBrightRed: [101, 49],
24115 bgBrightGreen: [102, 49],
24116 bgBrightYellow: [103, 49],
24117 bgBrightBlue: [104, 49],
24118 bgBrightMagenta: [105, 49],
24119 bgBrightCyan: [106, 49],
24120 bgBrightWhite: [107, 49],
24121
24122 // legacy styles for colors pre v1.0.0
24123 blackBG: [40, 49],
24124 redBG: [41, 49],
24125 greenBG: [42, 49],
24126 yellowBG: [43, 49],
24127 blueBG: [44, 49],
24128 magentaBG: [45, 49],
24129 cyanBG: [46, 49],
24130 whiteBG: [47, 49],
24131
24132};
24133
24134Object.keys(codes).forEach(function(key) {
24135 var val = codes[key];
24136 var style = styles[key] = [];
24137 style.open = '\u001b[' + val[0] + 'm';
24138 style.close = '\u001b[' + val[1] + 'm';
24139});
24140});
24141
24142/*
24143MIT License
24144
24145Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
24146
24147Permission is hereby granted, free of charge, to any person obtaining a copy of
24148this software and associated documentation files (the "Software"), to deal in
24149the Software without restriction, including without limitation the rights to
24150use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
24151of the Software, and to permit persons to whom the Software is furnished to do
24152so, subject to the following conditions:
24153
24154The above copyright notice and this permission notice shall be included in all
24155copies or substantial portions of the Software.
24156
24157THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24158IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24159FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24160AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24161LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24162OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24163SOFTWARE.
24164*/
24165
24166var hasFlag = function(flag, argv) {
24167 argv = argv || process.argv;
24168
24169 var terminatorPos = argv.indexOf('--');
24170 var prefix = /^-{1,2}/.test(flag) ? '' : '--';
24171 var pos = argv.indexOf(prefix + flag);
24172
24173 return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
24174};
24175
24176/*
24177The MIT License (MIT)
24178
24179Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
24180
24181Permission is hereby granted, free of charge, to any person obtaining a copy
24182of this software and associated documentation files (the "Software"), to deal
24183in the Software without restriction, including without limitation the rights
24184to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24185copies of the Software, and to permit persons to whom the Software is
24186furnished to do so, subject to the following conditions:
24187
24188The above copyright notice and this permission notice shall be included in
24189all copies or substantial portions of the Software.
24190
24191THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24192IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24193FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24194AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24195LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24196OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24197THE SOFTWARE.
24198
24199*/
24200
24201
24202
24203
24204var env = process.env;
24205
24206var forceColor = void 0;
24207if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
24208 forceColor = false;
24209} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true')
24210 || hasFlag('color=always')) {
24211 forceColor = true;
24212}
24213if ('FORCE_COLOR' in env) {
24214 forceColor = env.FORCE_COLOR.length === 0
24215 || parseInt(env.FORCE_COLOR, 10) !== 0;
24216}
24217
24218function translateLevel(level) {
24219 if (level === 0) {
24220 return false;
24221 }
24222
24223 return {
24224 level: level,
24225 hasBasic: true,
24226 has256: level >= 2,
24227 has16m: level >= 3,
24228 };
24229}
24230
24231function supportsColor(stream) {
24232 if (forceColor === false) {
24233 return 0;
24234 }
24235
24236 if (hasFlag('color=16m') || hasFlag('color=full')
24237 || hasFlag('color=truecolor')) {
24238 return 3;
24239 }
24240
24241 if (hasFlag('color=256')) {
24242 return 2;
24243 }
24244
24245 if (stream && !stream.isTTY && forceColor !== true) {
24246 return 0;
24247 }
24248
24249 var min = forceColor ? 1 : 0;
24250
24251 if (process.platform === 'win32') {
24252 // Node.js 7.5.0 is the first version of Node.js to include a patch to
24253 // libuv that enables 256 color output on Windows. Anything earlier and it
24254 // won't work. However, here we target Node.js 8 at minimum as it is an LTS
24255 // release, and Node.js 7 is not. Windows 10 build 10586 is the first
24256 // Windows release that supports 256 colors. Windows 10 build 14931 is the
24257 // first release that supports 16m/TrueColor.
24258 var osRelease = os.release().split('.');
24259 if (Number(process.versions.node.split('.')[0]) >= 8
24260 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
24261 return Number(osRelease[2]) >= 14931 ? 3 : 2;
24262 }
24263
24264 return 1;
24265 }
24266
24267 if ('CI' in env) {
24268 if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function(sign) {
24269 return sign in env;
24270 }) || env.CI_NAME === 'codeship') {
24271 return 1;
24272 }
24273
24274 return min;
24275 }
24276
24277 if ('TEAMCITY_VERSION' in env) {
24278 return (/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0
24279 );
24280 }
24281
24282 if ('TERM_PROGRAM' in env) {
24283 var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
24284
24285 switch (env.TERM_PROGRAM) {
24286 case 'iTerm.app':
24287 return version >= 3 ? 3 : 2;
24288 case 'Hyper':
24289 return 3;
24290 case 'Apple_Terminal':
24291 return 2;
24292 // No default
24293 }
24294 }
24295
24296 if (/-256(color)?$/i.test(env.TERM)) {
24297 return 2;
24298 }
24299
24300 if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
24301 return 1;
24302 }
24303
24304 if ('COLORTERM' in env) {
24305 return 1;
24306 }
24307
24308 if (env.TERM === 'dumb') {
24309 return min;
24310 }
24311
24312 return min;
24313}
24314
24315function getSupportLevel(stream) {
24316 var level = supportsColor(stream);
24317 return translateLevel(level);
24318}
24319
24320var supportsColors = {
24321 supportsColor: getSupportLevel,
24322 stdout: getSupportLevel(process.stdout),
24323 stderr: getSupportLevel(process.stderr),
24324};
24325
24326var trap = createCommonjsModule(function (module) {
24327module['exports'] = function runTheTrap(text, options) {
24328 var result = '';
24329 text = text || 'Run the trap, drop the bass';
24330 text = text.split('');
24331 var trap = {
24332 a: ['\u0040', '\u0104', '\u023a', '\u0245', '\u0394', '\u039b', '\u0414'],
24333 b: ['\u00df', '\u0181', '\u0243', '\u026e', '\u03b2', '\u0e3f'],
24334 c: ['\u00a9', '\u023b', '\u03fe'],
24335 d: ['\u00d0', '\u018a', '\u0500', '\u0501', '\u0502', '\u0503'],
24336 e: ['\u00cb', '\u0115', '\u018e', '\u0258', '\u03a3', '\u03be', '\u04bc',
24337 '\u0a6c'],
24338 f: ['\u04fa'],
24339 g: ['\u0262'],
24340 h: ['\u0126', '\u0195', '\u04a2', '\u04ba', '\u04c7', '\u050a'],
24341 i: ['\u0f0f'],
24342 j: ['\u0134'],
24343 k: ['\u0138', '\u04a0', '\u04c3', '\u051e'],
24344 l: ['\u0139'],
24345 m: ['\u028d', '\u04cd', '\u04ce', '\u0520', '\u0521', '\u0d69'],
24346 n: ['\u00d1', '\u014b', '\u019d', '\u0376', '\u03a0', '\u048a'],
24347 o: ['\u00d8', '\u00f5', '\u00f8', '\u01fe', '\u0298', '\u047a', '\u05dd',
24348 '\u06dd', '\u0e4f'],
24349 p: ['\u01f7', '\u048e'],
24350 q: ['\u09cd'],
24351 r: ['\u00ae', '\u01a6', '\u0210', '\u024c', '\u0280', '\u042f'],
24352 s: ['\u00a7', '\u03de', '\u03df', '\u03e8'],
24353 t: ['\u0141', '\u0166', '\u0373'],
24354 u: ['\u01b1', '\u054d'],
24355 v: ['\u05d8'],
24356 w: ['\u0428', '\u0460', '\u047c', '\u0d70'],
24357 x: ['\u04b2', '\u04fe', '\u04fc', '\u04fd'],
24358 y: ['\u00a5', '\u04b0', '\u04cb'],
24359 z: ['\u01b5', '\u0240'],
24360 };
24361 text.forEach(function(c) {
24362 c = c.toLowerCase();
24363 var chars = trap[c] || [' '];
24364 var rand = Math.floor(Math.random() * chars.length);
24365 if (typeof trap[c] !== 'undefined') {
24366 result += trap[c][rand];
24367 } else {
24368 result += c;
24369 }
24370 });
24371 return result;
24372};
24373});
24374
24375var zalgo = createCommonjsModule(function (module) {
24376// please no
24377module['exports'] = function zalgo(text, options) {
24378 text = text || ' he is here ';
24379 var soul = {
24380 'up': [
24381 '̍', '̎', '̄', '̅',
24382 '̿', '̑', '̆', '̐',
24383 '͒', '͗', '͑', '̇',
24384 '̈', '̊', '͂', '̓',
24385 '̈', '͊', '͋', '͌',
24386 '̃', '̂', '̌', '͐',
24387 '̀', '́', '̋', '̏',
24388 '̒', '̓', '̔', '̽',
24389 '̉', 'ͣ', 'ͤ', 'ͥ',
24390 'ͦ', 'ͧ', 'ͨ', 'ͩ',
24391 'ͪ', 'ͫ', 'ͬ', 'ͭ',
24392 'ͮ', 'ͯ', '̾', '͛',
24393 '͆', '̚',
24394 ],
24395 'down': [
24396 '̖', '̗', '̘', '̙',
24397 '̜', '̝', '̞', '̟',
24398 '̠', '̤', '̥', '̦',
24399 '̩', '̪', '̫', '̬',
24400 '̭', '̮', '̯', '̰',
24401 '̱', '̲', '̳', '̹',
24402 '̺', '̻', '̼', 'ͅ',
24403 '͇', '͈', '͉', '͍',
24404 '͎', '͓', '͔', '͕',
24405 '͖', '͙', '͚', '̣',
24406 ],
24407 'mid': [
24408 '̕', '̛', '̀', '́',
24409 '͘', '̡', '̢', '̧',
24410 '̨', '̴', '̵', '̶',
24411 '͜', '͝', '͞',
24412 '͟', '͠', '͢', '̸',
24413 '̷', '͡', ' ҉',
24414 ],
24415 };
24416 var all = [].concat(soul.up, soul.down, soul.mid);
24417
24418 function randomNumber(range) {
24419 var r = Math.floor(Math.random() * range);
24420 return r;
24421 }
24422
24423 function isChar(character) {
24424 var bool = false;
24425 all.filter(function(i) {
24426 bool = (i === character);
24427 });
24428 return bool;
24429 }
24430
24431
24432 function heComes(text, options) {
24433 var result = '';
24434 var counts;
24435 var l;
24436 options = options || {};
24437 options['up'] =
24438 typeof options['up'] !== 'undefined' ? options['up'] : true;
24439 options['mid'] =
24440 typeof options['mid'] !== 'undefined' ? options['mid'] : true;
24441 options['down'] =
24442 typeof options['down'] !== 'undefined' ? options['down'] : true;
24443 options['size'] =
24444 typeof options['size'] !== 'undefined' ? options['size'] : 'maxi';
24445 text = text.split('');
24446 for (l in text) {
24447 if (isChar(l)) {
24448 continue;
24449 }
24450 result = result + text[l];
24451 counts = {'up': 0, 'down': 0, 'mid': 0};
24452 switch (options.size) {
24453 case 'mini':
24454 counts.up = randomNumber(8);
24455 counts.mid = randomNumber(2);
24456 counts.down = randomNumber(8);
24457 break;
24458 case 'maxi':
24459 counts.up = randomNumber(16) + 3;
24460 counts.mid = randomNumber(4) + 1;
24461 counts.down = randomNumber(64) + 3;
24462 break;
24463 default:
24464 counts.up = randomNumber(8) + 1;
24465 counts.mid = randomNumber(6) / 2;
24466 counts.down = randomNumber(8) + 1;
24467 break;
24468 }
24469
24470 var arr = ['up', 'mid', 'down'];
24471 for (var d in arr) {
24472 var index = arr[d];
24473 for (var i = 0; i <= counts[index]; i++) {
24474 if (options[index]) {
24475 result = result + soul[index][randomNumber(soul[index].length)];
24476 }
24477 }
24478 }
24479 }
24480 return result;
24481 }
24482 // don't summon him
24483 return heComes(text, options);
24484};
24485});
24486
24487var america = createCommonjsModule(function (module) {
24488module['exports'] = function(colors) {
24489 return function(letter, i, exploded) {
24490 if (letter === ' ') return letter;
24491 switch (i%3) {
24492 case 0: return colors.red(letter);
24493 case 1: return colors.white(letter);
24494 case 2: return colors.blue(letter);
24495 }
24496 };
24497};
24498});
24499
24500var zebra = createCommonjsModule(function (module) {
24501module['exports'] = function(colors) {
24502 return function(letter, i, exploded) {
24503 return i % 2 === 0 ? letter : colors.inverse(letter);
24504 };
24505};
24506});
24507
24508var rainbow = createCommonjsModule(function (module) {
24509module['exports'] = function(colors) {
24510 // RoY G BiV
24511 var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta'];
24512 return function(letter, i, exploded) {
24513 if (letter === ' ') {
24514 return letter;
24515 } else {
24516 return colors[rainbowColors[i++ % rainbowColors.length]](letter);
24517 }
24518 };
24519};
24520});
24521
24522var random = createCommonjsModule(function (module) {
24523module['exports'] = function(colors) {
24524 var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
24525 'blue', 'white', 'cyan', 'magenta', 'brightYellow', 'brightRed',
24526 'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan', 'brightMagenta'];
24527 return function(letter, i, exploded) {
24528 return letter === ' ' ? letter :
24529 colors[
24530 available[Math.round(Math.random() * (available.length - 2))]
24531 ](letter);
24532 };
24533};
24534});
24535
24536/*
24537
24538The MIT License (MIT)
24539
24540Original Library
24541 - Copyright (c) Marak Squires
24542
24543Additional functionality
24544 - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
24545
24546Permission is hereby granted, free of charge, to any person obtaining a copy
24547of this software and associated documentation files (the "Software"), to deal
24548in the Software without restriction, including without limitation the rights
24549to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24550copies of the Software, and to permit persons to whom the Software is
24551furnished to do so, subject to the following conditions:
24552
24553The above copyright notice and this permission notice shall be included in
24554all copies or substantial portions of the Software.
24555
24556THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24557IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24558FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24559AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24560LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24561OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24562THE SOFTWARE.
24563
24564*/
24565
24566var colors_1 = createCommonjsModule(function (module) {
24567var colors = {};
24568module['exports'] = colors;
24569
24570colors.themes = {};
24571
24572
24573var ansiStyles = colors.styles = styles_1;
24574var defineProps = Object.defineProperties;
24575var newLineRegex = new RegExp(/[\r\n]+/g);
24576
24577colors.supportsColor = supportsColors.supportsColor;
24578
24579if (typeof colors.enabled === 'undefined') {
24580 colors.enabled = colors.supportsColor() !== false;
24581}
24582
24583colors.enable = function() {
24584 colors.enabled = true;
24585};
24586
24587colors.disable = function() {
24588 colors.enabled = false;
24589};
24590
24591colors.stripColors = colors.strip = function(str) {
24592 return ('' + str).replace(/\x1B\[\d+m/g, '');
24593};
24594
24595// eslint-disable-next-line no-unused-vars
24596colors.stylize = function stylize(str, style) {
24597 if (!colors.enabled) {
24598 return str+'';
24599 }
24600
24601 var styleMap = ansiStyles[style];
24602
24603 // Stylize should work for non-ANSI styles, too
24604 if(!styleMap && style in colors){
24605 // Style maps like trap operate as functions on strings;
24606 // they don't have properties like open or close.
24607 return colors[style](str);
24608 }
24609
24610 return styleMap.open + str + styleMap.close;
24611};
24612
24613var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
24614var escapeStringRegexp = function(str) {
24615 if (typeof str !== 'string') {
24616 throw new TypeError('Expected a string');
24617 }
24618 return str.replace(matchOperatorsRe, '\\$&');
24619};
24620
24621function build(_styles) {
24622 var builder = function builder() {
24623 return applyStyle.apply(builder, arguments);
24624 };
24625 builder._styles = _styles;
24626 // __proto__ is used because we must return a function, but there is
24627 // no way to create a function with a different prototype.
24628 builder.__proto__ = proto;
24629 return builder;
24630}
24631
24632var styles = (function() {
24633 var ret = {};
24634 ansiStyles.grey = ansiStyles.gray;
24635 Object.keys(ansiStyles).forEach(function(key) {
24636 ansiStyles[key].closeRe =
24637 new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
24638 ret[key] = {
24639 get: function() {
24640 return build(this._styles.concat(key));
24641 },
24642 };
24643 });
24644 return ret;
24645})();
24646
24647var proto = defineProps(function colors() {}, styles);
24648
24649function applyStyle() {
24650 var args = Array.prototype.slice.call(arguments);
24651
24652 var str = args.map(function(arg) {
24653 // Use weak equality check so we can colorize null/undefined in safe mode
24654 if (arg != null && arg.constructor === String) {
24655 return arg;
24656 } else {
24657 return require$$0.inspect(arg);
24658 }
24659 }).join(' ');
24660
24661 if (!colors.enabled || !str) {
24662 return str;
24663 }
24664
24665 var newLinesPresent = str.indexOf('\n') != -1;
24666
24667 var nestedStyles = this._styles;
24668
24669 var i = nestedStyles.length;
24670 while (i--) {
24671 var code = ansiStyles[nestedStyles[i]];
24672 str = code.open + str.replace(code.closeRe, code.open) + code.close;
24673 if (newLinesPresent) {
24674 str = str.replace(newLineRegex, function(match) {
24675 return code.close + match + code.open;
24676 });
24677 }
24678 }
24679
24680 return str;
24681}
24682
24683colors.setTheme = function(theme) {
24684 if (typeof theme === 'string') {
24685 console.log('colors.setTheme now only accepts an object, not a string. ' +
24686 'If you are trying to set a theme from a file, it is now your (the ' +
24687 'caller\'s) responsibility to require the file. The old syntax ' +
24688 'looked like colors.setTheme(__dirname + ' +
24689 '\'/../themes/generic-logging.js\'); The new syntax looks like '+
24690 'colors.setTheme(require(__dirname + ' +
24691 '\'/../themes/generic-logging.js\'));');
24692 return;
24693 }
24694 for (var style in theme) {
24695 (function(style) {
24696 colors[style] = function(str) {
24697 if (typeof theme[style] === 'object') {
24698 var out = str;
24699 for (var i in theme[style]) {
24700 out = colors[theme[style][i]](out);
24701 }
24702 return out;
24703 }
24704 return colors[theme[style]](str);
24705 };
24706 })(style);
24707 }
24708};
24709
24710function init() {
24711 var ret = {};
24712 Object.keys(styles).forEach(function(name) {
24713 ret[name] = {
24714 get: function() {
24715 return build([name]);
24716 },
24717 };
24718 });
24719 return ret;
24720}
24721
24722var sequencer = function sequencer(map, str) {
24723 var exploded = str.split('');
24724 exploded = exploded.map(map);
24725 return exploded.join('');
24726};
24727
24728// custom formatter methods
24729colors.trap = trap;
24730colors.zalgo = zalgo;
24731
24732// maps
24733colors.maps = {};
24734colors.maps.america = america(colors);
24735colors.maps.zebra = zebra(colors);
24736colors.maps.rainbow = rainbow(colors);
24737colors.maps.random = random(colors);
24738
24739for (var map in colors.maps) {
24740 (function(map) {
24741 colors[map] = function(str) {
24742 return sequencer(colors.maps[map], str);
24743 };
24744 })(map);
24745}
24746
24747defineProps(colors, init());
24748});
24749
24750var safe = createCommonjsModule(function (module) {
24751//
24752// Remark: Requiring this file will use the "safe" colors API,
24753// which will not touch String.prototype.
24754//
24755// var colors = require('colors/safe');
24756// colors.red("foo")
24757//
24758//
24759
24760module['exports'] = colors_1;
24761});
24762
24763class FormatHost {
24764 getCurrentDirectory() {
24765 return tsModule.sys.getCurrentDirectory();
24766 }
24767 getCanonicalFileName(fileName) {
24768 return normalize$1(fileName);
24769 }
24770 getNewLine() {
24771 return tsModule.sys.newLine;
24772 }
24773}
24774const formatHost = new FormatHost();
24775
24776class NoCache {
24777 exists(_name) {
24778 return false;
24779 }
24780 path(name) {
24781 return name;
24782 }
24783 match(_names) {
24784 return false;
24785 }
24786 read(_name) {
24787 return undefined;
24788 }
24789 write(_name, _data) {
24790 return;
24791 }
24792 touch(_name) {
24793 return;
24794 }
24795 roll() {
24796 return;
24797 }
24798}
24799
24800function convertEmitOutput(output, references) {
24801 const out = { code: "", references };
24802 output.outputFiles.forEach((e) => {
24803 if (lodash.endsWith(e.name, ".d.ts"))
24804 out.dts = e;
24805 else if (lodash.endsWith(e.name, ".d.ts.map"))
24806 out.dtsmap = e;
24807 else if (lodash.endsWith(e.name, ".map"))
24808 out.map = e.text;
24809 else
24810 out.code = e.text;
24811 });
24812 return out;
24813}
24814function getAllReferences(importer, snapshot, options) {
24815 if (!snapshot)
24816 return [];
24817 const info = tsModule.preProcessFile(snapshot.getText(0, snapshot.getLength()), true, true);
24818 return lodash.compact(lodash.concat(info.referencedFiles, info.importedFiles).map((reference) => {
24819 const resolved = tsModule.nodeModuleNameResolver(reference.fileName, importer, options, tsModule.sys);
24820 return resolved.resolvedModule ? resolved.resolvedModule.resolvedFileName : undefined;
24821 }));
24822}
24823function convertDiagnostic(type, data) {
24824 return lodash.map(data, (diagnostic) => {
24825 const entry = {
24826 flatMessage: tsModule.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
24827 formatted: tsModule.formatDiagnosticsWithColorAndContext(data, formatHost),
24828 category: diagnostic.category,
24829 code: diagnostic.code,
24830 type,
24831 };
24832 if (diagnostic.file && diagnostic.start !== undefined) {
24833 const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
24834 entry.fileLine = `${diagnostic.file.fileName}(${line + 1},${character + 1})`;
24835 }
24836 return entry;
24837 });
24838}
24839class TsCache {
24840 constructor(noCache, hashIgnoreUnknown, host, cacheRoot, options, rollupConfig, rootFilenames, context) {
24841 this.noCache = noCache;
24842 this.host = host;
24843 this.cacheRoot = cacheRoot;
24844 this.options = options;
24845 this.rollupConfig = rollupConfig;
24846 this.context = context;
24847 this.cacheVersion = "9";
24848 this.cachePrefix = "rpt2_";
24849 this.ambientTypesDirty = false;
24850 this.hashOptions = { algorithm: "sha1", ignoreUnknown: false };
24851 this.hashOptions.ignoreUnknown = hashIgnoreUnknown;
24852 if (!noCache) {
24853 this.cacheDir = `${this.cacheRoot}/${this.cachePrefix}${objectHash_1({
24854 version: this.cacheVersion,
24855 rootFilenames,
24856 options: this.options,
24857 rollupConfig: this.rollupConfig,
24858 tsVersion: tsModule.version,
24859 }, this.hashOptions)}`;
24860 }
24861 this.dependencyTree = new graphlib.Graph({ directed: true });
24862 this.dependencyTree.setDefaultNodeLabel((_node) => ({ dirty: false }));
24863 const automaticTypes = lodash.map(tsModule.getAutomaticTypeDirectiveNames(options, tsModule.sys), (entry) => tsModule.resolveTypeReferenceDirective(entry, undefined, options, tsModule.sys))
24864 .filter((entry) => entry.resolvedTypeReferenceDirective && entry.resolvedTypeReferenceDirective.resolvedFileName)
24865 .map((entry) => entry.resolvedTypeReferenceDirective.resolvedFileName);
24866 this.ambientTypes = lodash.filter(rootFilenames, (file) => lodash.endsWith(file, ".d.ts"))
24867 .concat(automaticTypes)
24868 .map((id) => ({ id, snapshot: this.host.getScriptSnapshot(id) }));
24869 this.init();
24870 this.checkAmbientTypes();
24871 }
24872 clean() {
24873 if (pathExistsSync(this.cacheRoot)) {
24874 const entries = readdirSync$1(this.cacheRoot);
24875 entries.forEach((e) => {
24876 const dir = `${this.cacheRoot}/${e}`;
24877 if (e.startsWith(this.cachePrefix) && statSync(dir).isDirectory) {
24878 this.context.info(safe.blue(`cleaning cache: ${dir}`));
24879 emptyDirSync(`${dir}`);
24880 removeSync(`${dir}`);
24881 }
24882 else
24883 this.context.debug(`not cleaning ${dir}`);
24884 });
24885 }
24886 this.init();
24887 }
24888 setDependency(importee, importer) {
24889 // importee -> importer
24890 this.context.debug(`${safe.blue("dependency")} '${importee}'`);
24891 this.context.debug(` imported by '${importer}'`);
24892 this.dependencyTree.setEdge(importer, importee);
24893 }
24894 walkTree(cb) {
24895 const acyclic = graphlib.alg.isAcyclic(this.dependencyTree);
24896 if (acyclic) {
24897 lodash.each(graphlib.alg.topsort(this.dependencyTree), (id) => cb(id));
24898 return;
24899 }
24900 this.context.info(safe.yellow("import tree has cycles"));
24901 lodash.each(this.dependencyTree.nodes(), (id) => cb(id));
24902 }
24903 done() {
24904 this.context.info(safe.blue("rolling caches"));
24905 this.codeCache.roll();
24906 this.semanticDiagnosticsCache.roll();
24907 this.syntacticDiagnosticsCache.roll();
24908 this.typesCache.roll();
24909 }
24910 getCompiled(id, snapshot, transform) {
24911 if (this.noCache) {
24912 this.context.info(`${safe.blue("transpiling")} '${id}'`);
24913 this.markAsDirty(id);
24914 return transform();
24915 }
24916 const name = this.makeName(id, snapshot);
24917 this.context.info(`${safe.blue("transpiling")} '${id}'`);
24918 this.context.debug(` cache: '${this.codeCache.path(name)}'`);
24919 if (this.codeCache.exists(name) && !this.isDirty(id, false)) {
24920 this.context.debug(safe.green(" cache hit"));
24921 const data = this.codeCache.read(name);
24922 if (data) {
24923 this.codeCache.write(name, data);
24924 return data;
24925 }
24926 else
24927 this.context.warn(safe.yellow(" cache broken, discarding"));
24928 }
24929 this.context.debug(safe.yellow(" cache miss"));
24930 const transformedData = transform();
24931 this.codeCache.write(name, transformedData);
24932 this.markAsDirty(id);
24933 return transformedData;
24934 }
24935 getSyntacticDiagnostics(id, snapshot, check) {
24936 return this.getDiagnostics("syntax", this.syntacticDiagnosticsCache, id, snapshot, check);
24937 }
24938 getSemanticDiagnostics(id, snapshot, check) {
24939 return this.getDiagnostics("semantic", this.semanticDiagnosticsCache, id, snapshot, check);
24940 }
24941 checkAmbientTypes() {
24942 if (this.noCache) {
24943 this.ambientTypesDirty = true;
24944 return;
24945 }
24946 this.context.debug(safe.blue("Ambient types:"));
24947 const typeNames = lodash.filter(this.ambientTypes, (snapshot) => snapshot.snapshot !== undefined)
24948 .map((snapshot) => {
24949 this.context.debug(` ${snapshot.id}`);
24950 return this.makeName(snapshot.id, snapshot.snapshot);
24951 });
24952 // types dirty if any d.ts changed, added or removed
24953 this.ambientTypesDirty = !this.typesCache.match(typeNames);
24954 if (this.ambientTypesDirty)
24955 this.context.info(safe.yellow("ambient types changed, redoing all semantic diagnostics"));
24956 lodash.each(typeNames, (name) => this.typesCache.touch(name));
24957 }
24958 getDiagnostics(type, cache, id, snapshot, check) {
24959 if (this.noCache) {
24960 this.markAsDirty(id);
24961 return convertDiagnostic(type, check());
24962 }
24963 const name = this.makeName(id, snapshot);
24964 this.context.debug(` cache: '${cache.path(name)}'`);
24965 if (cache.exists(name) && !this.isDirty(id, true)) {
24966 this.context.debug(safe.green(" cache hit"));
24967 const data = cache.read(name);
24968 if (data) {
24969 cache.write(name, data);
24970 return data;
24971 }
24972 else
24973 this.context.warn(safe.yellow(" cache broken, discarding"));
24974 }
24975 this.context.debug(safe.yellow(" cache miss"));
24976 const convertedData = convertDiagnostic(type, check());
24977 cache.write(name, convertedData);
24978 this.markAsDirty(id);
24979 return convertedData;
24980 }
24981 init() {
24982 if (this.noCache) {
24983 this.codeCache = new NoCache();
24984 this.typesCache = new NoCache();
24985 this.syntacticDiagnosticsCache = new NoCache();
24986 this.semanticDiagnosticsCache = new NoCache();
24987 }
24988 else {
24989 if (this.cacheDir === undefined)
24990 throw new Error(`this.cacheDir undefined`);
24991 this.codeCache = new RollingCache(`${this.cacheDir}/code`, true);
24992 this.typesCache = new RollingCache(`${this.cacheDir}/types`, true);
24993 this.syntacticDiagnosticsCache = new RollingCache(`${this.cacheDir}/syntacticDiagnostics`, true);
24994 this.semanticDiagnosticsCache = new RollingCache(`${this.cacheDir}/semanticDiagnostics`, true);
24995 }
24996 }
24997 markAsDirty(id) {
24998 this.dependencyTree.setNode(id, { dirty: true });
24999 }
25000 // returns true if node or any of its imports or any of global types changed
25001 isDirty(id, checkImports) {
25002 const label = this.dependencyTree.node(id);
25003 if (!label)
25004 return false;
25005 if (!checkImports || label.dirty)
25006 return label.dirty;
25007 if (this.ambientTypesDirty)
25008 return true;
25009 const dependencies = graphlib.alg.dijkstra(this.dependencyTree, id);
25010 return lodash.some(dependencies, (dependency, node) => {
25011 if (!node || dependency.distance === Infinity)
25012 return false;
25013 const l = this.dependencyTree.node(node);
25014 const dirty = l === undefined ? true : l.dirty;
25015 if (dirty)
25016 this.context.debug(` import changed: ${node}`);
25017 return dirty;
25018 });
25019 }
25020 makeName(id, snapshot) {
25021 const data = snapshot.getText(0, snapshot.getLength());
25022 return objectHash_1({ data, id }, this.hashOptions);
25023 }
25024}
25025
25026function printDiagnostics(context, diagnostics, pretty) {
25027 lodash.each(diagnostics, (diagnostic) => {
25028 let print;
25029 let color;
25030 let category;
25031 switch (diagnostic.category) {
25032 case tsModule.DiagnosticCategory.Message:
25033 print = context.info;
25034 color = safe.white;
25035 category = "";
25036 break;
25037 case tsModule.DiagnosticCategory.Error:
25038 print = context.error;
25039 color = safe.red;
25040 category = "error";
25041 break;
25042 case tsModule.DiagnosticCategory.Warning:
25043 default:
25044 print = context.warn;
25045 color = safe.yellow;
25046 category = "warning";
25047 break;
25048 }
25049 const type = diagnostic.type + " ";
25050 if (pretty)
25051 print.call(context, `${diagnostic.formatted}`);
25052 else {
25053 if (diagnostic.fileLine !== undefined)
25054 print.call(context, `${diagnostic.fileLine}: ${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
25055 else
25056 print.call(context, `${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
25057 }
25058 });
25059}
25060
25061function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsedTsconfig) {
25062 const overrides = {
25063 noEmitHelpers: false,
25064 importHelpers: true,
25065 noResolve: false,
25066 noEmit: false,
25067 inlineSourceMap: false,
25068 outDir: `${cacheRoot}/placeholder`,
25069 moduleResolution: tsModule.ModuleResolutionKind.NodeJs,
25070 allowNonTsExtensions: true,
25071 };
25072 if (preParsedTsconfig) {
25073 if (preParsedTsconfig.options.module === undefined)
25074 overrides.module = tsModule.ModuleKind.ES2015;
25075 // only set declarationDir if useTsconfigDeclarationDir is enabled
25076 if (!useTsconfigDeclarationDir)
25077 overrides.declarationDir = undefined;
25078 // unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
25079 const sourceMap = preParsedTsconfig.options.sourceMap;
25080 if (!sourceMap)
25081 overrides.sourceRoot = undefined;
25082 }
25083 return overrides;
25084}
25085function expandIncludeWithDirs(include, dirs) {
25086 return lodash.chain(dirs)
25087 .flatMap((root) => {
25088 if (include instanceof Array)
25089 return include.map((x) => join(root, x));
25090 else
25091 return join(root, include);
25092 })
25093 .uniq()
25094 .value();
25095}
25096function createFilter(context, pluginOptions, parsedConfig) {
25097 let included = pluginOptions.include;
25098 let excluded = pluginOptions.exclude;
25099 if (parsedConfig.options.rootDirs) {
25100 included = expandIncludeWithDirs(included, parsedConfig.options.rootDirs);
25101 excluded = expandIncludeWithDirs(excluded, parsedConfig.options.rootDirs);
25102 }
25103 if (parsedConfig.projectReferences) {
25104 included = lodash.concat(included, expandIncludeWithDirs(included, parsedConfig.projectReferences.map((x) => x.path)));
25105 excluded = lodash.concat(excluded, expandIncludeWithDirs(excluded, parsedConfig.projectReferences.map((x) => x.path)));
25106 }
25107 context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
25108 context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
25109 return createFilter$1(included, excluded, { resolve: parsedConfig.options.rootDir });
25110}
25111
25112function checkTsConfig(parsedConfig) {
25113 const module = parsedConfig.options.module;
25114 if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ESNext && module !== tsModule.ModuleKind.ES2020)
25115 throw new Error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.`);
25116}
25117
25118function parseTsConfig(context, pluginOptions) {
25119 const fileName = tsModule.findConfigFile(pluginOptions.cwd, tsModule.sys.fileExists, pluginOptions.tsconfig);
25120 // if the value was provided, but no file, fail hard
25121 if (pluginOptions.tsconfig !== undefined && !fileName)
25122 throw new Error(`failed to open '${fileName}'`);
25123 let loadedConfig = {};
25124 let baseDir = pluginOptions.cwd;
25125 let configFileName;
25126 let pretty = false;
25127 if (fileName) {
25128 const text = tsModule.sys.readFile(fileName);
25129 if (text === undefined)
25130 throw new Error(`failed to read '${fileName}'`);
25131 const result = tsModule.parseConfigFileTextToJson(fileName, text);
25132 pretty = lodash.get(result.config, "pretty", pretty);
25133 if (result.error !== undefined) {
25134 printDiagnostics(context, convertDiagnostic("config", [result.error]), pretty);
25135 throw new Error(`failed to parse '${fileName}'`);
25136 }
25137 loadedConfig = result.config;
25138 baseDir = dirname(fileName);
25139 configFileName = fileName;
25140 }
25141 const mergedConfig = {};
25142 lodash.merge(mergedConfig, pluginOptions.tsconfigDefaults, loadedConfig, pluginOptions.tsconfigOverride);
25143 const preParsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, getOptionsOverrides(pluginOptions), configFileName);
25144 const compilerOptionsOverride = getOptionsOverrides(pluginOptions, preParsedTsConfig);
25145 const parsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, compilerOptionsOverride, configFileName);
25146 checkTsConfig(parsedTsConfig);
25147 printDiagnostics(context, convertDiagnostic("config", parsedTsConfig.errors), pretty);
25148 context.debug(`built-in options overrides: ${JSON.stringify(compilerOptionsOverride, undefined, 4)}`);
25149 context.debug(`parsed tsconfig: ${JSON.stringify(parsedTsConfig, undefined, 4)}`);
25150 return { parsedTsConfig, fileName };
25151}
25152
25153// The injected id for helpers.
25154const TSLIB = "tslib";
25155const TSLIB_VIRTUAL = "\0tslib.js";
25156let tslibSource;
25157let tslibVersion;
25158try {
25159 // tslint:disable-next-line:no-string-literal no-var-requires
25160 const tslibPackage = require("tslib/package.json");
25161 const tslibPath = require.resolve("tslib/" + tslibPackage.module);
25162 tslibSource = readFileSync(tslibPath, "utf8");
25163 tslibVersion = tslibPackage.version;
25164}
25165catch (e) {
25166 console.warn("Error loading `tslib` helper library.");
25167 throw e;
25168}
25169
25170// Note: this is the semver.org version of the spec that it implements
25171// Not necessarily the package version of this code.
25172const SEMVER_SPEC_VERSION = '2.0.0';
25173
25174const MAX_LENGTH = 256;
25175const MAX_SAFE_INTEGER$2 = Number.MAX_SAFE_INTEGER ||
25176 /* istanbul ignore next */ 9007199254740991;
25177
25178// Max safe segment length for coercion.
25179const MAX_SAFE_COMPONENT_LENGTH = 16;
25180
25181var constants = {
25182 SEMVER_SPEC_VERSION,
25183 MAX_LENGTH,
25184 MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$2,
25185 MAX_SAFE_COMPONENT_LENGTH
25186};
25187
25188const debug = (
25189 typeof process === 'object' &&
25190 process.env &&
25191 process.env.NODE_DEBUG &&
25192 /\bsemver\b/i.test(process.env.NODE_DEBUG)
25193) ? (...args) => console.error('SEMVER', ...args)
25194 : () => {};
25195
25196var debug_1 = debug;
25197
25198var re_1 = createCommonjsModule(function (module, exports) {
25199const { MAX_SAFE_COMPONENT_LENGTH } = constants;
25200
25201exports = module.exports = {};
25202
25203// The actual regexps go on exports.re
25204const re = exports.re = [];
25205const src = exports.src = [];
25206const t = exports.t = {};
25207let R = 0;
25208
25209const createToken = (name, value, isGlobal) => {
25210 const index = R++;
25211 debug_1(index, value);
25212 t[name] = index;
25213 src[index] = value;
25214 re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
25215};
25216
25217// The following Regular Expressions can be used for tokenizing,
25218// validating, and parsing SemVer version strings.
25219
25220// ## Numeric Identifier
25221// A single `0`, or a non-zero digit followed by zero or more digits.
25222
25223createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
25224createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
25225
25226// ## Non-numeric Identifier
25227// Zero or more digits, followed by a letter or hyphen, and then zero or
25228// more letters, digits, or hyphens.
25229
25230createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
25231
25232// ## Main Version
25233// Three dot-separated numeric identifiers.
25234
25235createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
25236 `(${src[t.NUMERICIDENTIFIER]})\\.` +
25237 `(${src[t.NUMERICIDENTIFIER]})`);
25238
25239createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
25240 `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
25241 `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
25242
25243// ## Pre-release Version Identifier
25244// A numeric identifier, or a non-numeric identifier.
25245
25246createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
25247}|${src[t.NONNUMERICIDENTIFIER]})`);
25248
25249createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
25250}|${src[t.NONNUMERICIDENTIFIER]})`);
25251
25252// ## Pre-release Version
25253// Hyphen, followed by one or more dot-separated pre-release version
25254// identifiers.
25255
25256createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
25257}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
25258
25259createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
25260}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
25261
25262// ## Build Metadata Identifier
25263// Any combination of digits, letters, or hyphens.
25264
25265createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
25266
25267// ## Build Metadata
25268// Plus sign, followed by one or more period-separated build metadata
25269// identifiers.
25270
25271createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
25272}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
25273
25274// ## Full Version String
25275// A main version, followed optionally by a pre-release version and
25276// build metadata.
25277
25278// Note that the only major, minor, patch, and pre-release sections of
25279// the version string are capturing groups. The build metadata is not a
25280// capturing group, because it should not ever be used in version
25281// comparison.
25282
25283createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
25284}${src[t.PRERELEASE]}?${
25285 src[t.BUILD]}?`);
25286
25287createToken('FULL', `^${src[t.FULLPLAIN]}$`);
25288
25289// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
25290// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
25291// common in the npm registry.
25292createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
25293}${src[t.PRERELEASELOOSE]}?${
25294 src[t.BUILD]}?`);
25295
25296createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
25297
25298createToken('GTLT', '((?:<|>)?=?)');
25299
25300// Something like "2.*" or "1.2.x".
25301// Note that "x.x" is a valid xRange identifer, meaning "any version"
25302// Only the first item is strictly required.
25303createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
25304createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
25305
25306createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
25307 `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
25308 `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
25309 `(?:${src[t.PRERELEASE]})?${
25310 src[t.BUILD]}?` +
25311 `)?)?`);
25312
25313createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
25314 `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
25315 `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
25316 `(?:${src[t.PRERELEASELOOSE]})?${
25317 src[t.BUILD]}?` +
25318 `)?)?`);
25319
25320createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
25321createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
25322
25323// Coercion.
25324// Extract anything that could conceivably be a part of a valid semver
25325createToken('COERCE', `${'(^|[^\\d])' +
25326 '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
25327 `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
25328 `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
25329 `(?:$|[^\\d])`);
25330createToken('COERCERTL', src[t.COERCE], true);
25331
25332// Tilde ranges.
25333// Meaning is "reasonably at or greater than"
25334createToken('LONETILDE', '(?:~>?)');
25335
25336createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
25337exports.tildeTrimReplace = '$1~';
25338
25339createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
25340createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
25341
25342// Caret ranges.
25343// Meaning is "at least and backwards compatible with"
25344createToken('LONECARET', '(?:\\^)');
25345
25346createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
25347exports.caretTrimReplace = '$1^';
25348
25349createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
25350createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
25351
25352// A simple gt/lt/eq thing, or just "" to indicate "any version"
25353createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
25354createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
25355
25356// An expression to strip any whitespace between the gtlt and the thing
25357// it modifies, so that `> 1.2.3` ==> `>1.2.3`
25358createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
25359}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
25360exports.comparatorTrimReplace = '$1$2$3';
25361
25362// Something like `1.2.3 - 1.2.4`
25363// Note that these all use the loose form, because they'll be
25364// checked against either the strict or loose comparator form
25365// later.
25366createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
25367 `\\s+-\\s+` +
25368 `(${src[t.XRANGEPLAIN]})` +
25369 `\\s*$`);
25370
25371createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
25372 `\\s+-\\s+` +
25373 `(${src[t.XRANGEPLAINLOOSE]})` +
25374 `\\s*$`);
25375
25376// Star ranges basically just allow anything at all.
25377createToken('STAR', '(<|>)?=?\\s*\\*');
25378// >=0.0.0 is like a star
25379createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
25380createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
25381});
25382
25383// parse out just the options we care about so we always get a consistent
25384// obj with keys in a consistent order.
25385const opts = ['includePrerelease', 'loose', 'rtl'];
25386const parseOptions = options =>
25387 !options ? {}
25388 : typeof options !== 'object' ? { loose: true }
25389 : opts.filter(k => options[k]).reduce((options, k) => {
25390 options[k] = true;
25391 return options
25392 }, {});
25393var parseOptions_1 = parseOptions;
25394
25395const numeric = /^[0-9]+$/;
25396const compareIdentifiers = (a, b) => {
25397 const anum = numeric.test(a);
25398 const bnum = numeric.test(b);
25399
25400 if (anum && bnum) {
25401 a = +a;
25402 b = +b;
25403 }
25404
25405 return a === b ? 0
25406 : (anum && !bnum) ? -1
25407 : (bnum && !anum) ? 1
25408 : a < b ? -1
25409 : 1
25410};
25411
25412const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
25413
25414var identifiers = {
25415 compareIdentifiers,
25416 rcompareIdentifiers
25417};
25418
25419const { MAX_LENGTH: MAX_LENGTH$1, MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$3 } = constants;
25420const { re, t } = re_1;
25421
25422
25423const { compareIdentifiers: compareIdentifiers$1 } = identifiers;
25424class SemVer {
25425 constructor (version, options) {
25426 options = parseOptions_1(options);
25427
25428 if (version instanceof SemVer) {
25429 if (version.loose === !!options.loose &&
25430 version.includePrerelease === !!options.includePrerelease) {
25431 return version
25432 } else {
25433 version = version.version;
25434 }
25435 } else if (typeof version !== 'string') {
25436 throw new TypeError(`Invalid Version: ${version}`)
25437 }
25438
25439 if (version.length > MAX_LENGTH$1) {
25440 throw new TypeError(
25441 `version is longer than ${MAX_LENGTH$1} characters`
25442 )
25443 }
25444
25445 debug_1('SemVer', version, options);
25446 this.options = options;
25447 this.loose = !!options.loose;
25448 // this isn't actually relevant for versions, but keep it so that we
25449 // don't run into trouble passing this.options around.
25450 this.includePrerelease = !!options.includePrerelease;
25451
25452 const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
25453
25454 if (!m) {
25455 throw new TypeError(`Invalid Version: ${version}`)
25456 }
25457
25458 this.raw = version;
25459
25460 // these are actually numbers
25461 this.major = +m[1];
25462 this.minor = +m[2];
25463 this.patch = +m[3];
25464
25465 if (this.major > MAX_SAFE_INTEGER$3 || this.major < 0) {
25466 throw new TypeError('Invalid major version')
25467 }
25468
25469 if (this.minor > MAX_SAFE_INTEGER$3 || this.minor < 0) {
25470 throw new TypeError('Invalid minor version')
25471 }
25472
25473 if (this.patch > MAX_SAFE_INTEGER$3 || this.patch < 0) {
25474 throw new TypeError('Invalid patch version')
25475 }
25476
25477 // numberify any prerelease numeric ids
25478 if (!m[4]) {
25479 this.prerelease = [];
25480 } else {
25481 this.prerelease = m[4].split('.').map((id) => {
25482 if (/^[0-9]+$/.test(id)) {
25483 const num = +id;
25484 if (num >= 0 && num < MAX_SAFE_INTEGER$3) {
25485 return num
25486 }
25487 }
25488 return id
25489 });
25490 }
25491
25492 this.build = m[5] ? m[5].split('.') : [];
25493 this.format();
25494 }
25495
25496 format () {
25497 this.version = `${this.major}.${this.minor}.${this.patch}`;
25498 if (this.prerelease.length) {
25499 this.version += `-${this.prerelease.join('.')}`;
25500 }
25501 return this.version
25502 }
25503
25504 toString () {
25505 return this.version
25506 }
25507
25508 compare (other) {
25509 debug_1('SemVer.compare', this.version, this.options, other);
25510 if (!(other instanceof SemVer)) {
25511 if (typeof other === 'string' && other === this.version) {
25512 return 0
25513 }
25514 other = new SemVer(other, this.options);
25515 }
25516
25517 if (other.version === this.version) {
25518 return 0
25519 }
25520
25521 return this.compareMain(other) || this.comparePre(other)
25522 }
25523
25524 compareMain (other) {
25525 if (!(other instanceof SemVer)) {
25526 other = new SemVer(other, this.options);
25527 }
25528
25529 return (
25530 compareIdentifiers$1(this.major, other.major) ||
25531 compareIdentifiers$1(this.minor, other.minor) ||
25532 compareIdentifiers$1(this.patch, other.patch)
25533 )
25534 }
25535
25536 comparePre (other) {
25537 if (!(other instanceof SemVer)) {
25538 other = new SemVer(other, this.options);
25539 }
25540
25541 // NOT having a prerelease is > having one
25542 if (this.prerelease.length && !other.prerelease.length) {
25543 return -1
25544 } else if (!this.prerelease.length && other.prerelease.length) {
25545 return 1
25546 } else if (!this.prerelease.length && !other.prerelease.length) {
25547 return 0
25548 }
25549
25550 let i = 0;
25551 do {
25552 const a = this.prerelease[i];
25553 const b = other.prerelease[i];
25554 debug_1('prerelease compare', i, a, b);
25555 if (a === undefined && b === undefined) {
25556 return 0
25557 } else if (b === undefined) {
25558 return 1
25559 } else if (a === undefined) {
25560 return -1
25561 } else if (a === b) {
25562 continue
25563 } else {
25564 return compareIdentifiers$1(a, b)
25565 }
25566 } while (++i)
25567 }
25568
25569 compareBuild (other) {
25570 if (!(other instanceof SemVer)) {
25571 other = new SemVer(other, this.options);
25572 }
25573
25574 let i = 0;
25575 do {
25576 const a = this.build[i];
25577 const b = other.build[i];
25578 debug_1('prerelease compare', i, a, b);
25579 if (a === undefined && b === undefined) {
25580 return 0
25581 } else if (b === undefined) {
25582 return 1
25583 } else if (a === undefined) {
25584 return -1
25585 } else if (a === b) {
25586 continue
25587 } else {
25588 return compareIdentifiers$1(a, b)
25589 }
25590 } while (++i)
25591 }
25592
25593 // preminor will bump the version up to the next minor release, and immediately
25594 // down to pre-release. premajor and prepatch work the same way.
25595 inc (release, identifier) {
25596 switch (release) {
25597 case 'premajor':
25598 this.prerelease.length = 0;
25599 this.patch = 0;
25600 this.minor = 0;
25601 this.major++;
25602 this.inc('pre', identifier);
25603 break
25604 case 'preminor':
25605 this.prerelease.length = 0;
25606 this.patch = 0;
25607 this.minor++;
25608 this.inc('pre', identifier);
25609 break
25610 case 'prepatch':
25611 // If this is already a prerelease, it will bump to the next version
25612 // drop any prereleases that might already exist, since they are not
25613 // relevant at this point.
25614 this.prerelease.length = 0;
25615 this.inc('patch', identifier);
25616 this.inc('pre', identifier);
25617 break
25618 // If the input is a non-prerelease version, this acts the same as
25619 // prepatch.
25620 case 'prerelease':
25621 if (this.prerelease.length === 0) {
25622 this.inc('patch', identifier);
25623 }
25624 this.inc('pre', identifier);
25625 break
25626
25627 case 'major':
25628 // If this is a pre-major version, bump up to the same major version.
25629 // Otherwise increment major.
25630 // 1.0.0-5 bumps to 1.0.0
25631 // 1.1.0 bumps to 2.0.0
25632 if (
25633 this.minor !== 0 ||
25634 this.patch !== 0 ||
25635 this.prerelease.length === 0
25636 ) {
25637 this.major++;
25638 }
25639 this.minor = 0;
25640 this.patch = 0;
25641 this.prerelease = [];
25642 break
25643 case 'minor':
25644 // If this is a pre-minor version, bump up to the same minor version.
25645 // Otherwise increment minor.
25646 // 1.2.0-5 bumps to 1.2.0
25647 // 1.2.1 bumps to 1.3.0
25648 if (this.patch !== 0 || this.prerelease.length === 0) {
25649 this.minor++;
25650 }
25651 this.patch = 0;
25652 this.prerelease = [];
25653 break
25654 case 'patch':
25655 // If this is not a pre-release version, it will increment the patch.
25656 // If it is a pre-release it will bump up to the same patch version.
25657 // 1.2.0-5 patches to 1.2.0
25658 // 1.2.0 patches to 1.2.1
25659 if (this.prerelease.length === 0) {
25660 this.patch++;
25661 }
25662 this.prerelease = [];
25663 break
25664 // This probably shouldn't be used publicly.
25665 // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
25666 case 'pre':
25667 if (this.prerelease.length === 0) {
25668 this.prerelease = [0];
25669 } else {
25670 let i = this.prerelease.length;
25671 while (--i >= 0) {
25672 if (typeof this.prerelease[i] === 'number') {
25673 this.prerelease[i]++;
25674 i = -2;
25675 }
25676 }
25677 if (i === -1) {
25678 // didn't increment anything
25679 this.prerelease.push(0);
25680 }
25681 }
25682 if (identifier) {
25683 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
25684 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
25685 if (this.prerelease[0] === identifier) {
25686 if (isNaN(this.prerelease[1])) {
25687 this.prerelease = [identifier, 0];
25688 }
25689 } else {
25690 this.prerelease = [identifier, 0];
25691 }
25692 }
25693 break
25694
25695 default:
25696 throw new Error(`invalid increment argument: ${release}`)
25697 }
25698 this.format();
25699 this.raw = this.version;
25700 return this
25701 }
25702}
25703
25704var semver = SemVer;
25705
25706const {MAX_LENGTH: MAX_LENGTH$2} = constants;
25707const { re: re$1, t: t$1 } = re_1;
25708
25709
25710
25711const parse = (version, options) => {
25712 options = parseOptions_1(options);
25713
25714 if (version instanceof semver) {
25715 return version
25716 }
25717
25718 if (typeof version !== 'string') {
25719 return null
25720 }
25721
25722 if (version.length > MAX_LENGTH$2) {
25723 return null
25724 }
25725
25726 const r = options.loose ? re$1[t$1.LOOSE] : re$1[t$1.FULL];
25727 if (!r.test(version)) {
25728 return null
25729 }
25730
25731 try {
25732 return new semver(version, options)
25733 } catch (er) {
25734 return null
25735 }
25736};
25737
25738var parse_1 = parse;
25739
25740const valid = (version, options) => {
25741 const v = parse_1(version, options);
25742 return v ? v.version : null
25743};
25744var valid_1 = valid;
25745
25746const clean = (version, options) => {
25747 const s = parse_1(version.trim().replace(/^[=v]+/, ''), options);
25748 return s ? s.version : null
25749};
25750var clean_1 = clean;
25751
25752const inc = (version, release, options, identifier) => {
25753 if (typeof (options) === 'string') {
25754 identifier = options;
25755 options = undefined;
25756 }
25757
25758 try {
25759 return new semver(version, options).inc(release, identifier).version
25760 } catch (er) {
25761 return null
25762 }
25763};
25764var inc_1 = inc;
25765
25766const compare = (a, b, loose) =>
25767 new semver(a, loose).compare(new semver(b, loose));
25768
25769var compare_1 = compare;
25770
25771const eq$1 = (a, b, loose) => compare_1(a, b, loose) === 0;
25772var eq_1$1 = eq$1;
25773
25774const diff = (version1, version2) => {
25775 if (eq_1$1(version1, version2)) {
25776 return null
25777 } else {
25778 const v1 = parse_1(version1);
25779 const v2 = parse_1(version2);
25780 const hasPre = v1.prerelease.length || v2.prerelease.length;
25781 const prefix = hasPre ? 'pre' : '';
25782 const defaultResult = hasPre ? 'prerelease' : '';
25783 for (const key in v1) {
25784 if (key === 'major' || key === 'minor' || key === 'patch') {
25785 if (v1[key] !== v2[key]) {
25786 return prefix + key
25787 }
25788 }
25789 }
25790 return defaultResult // may be undefined
25791 }
25792};
25793var diff_1 = diff;
25794
25795const major = (a, loose) => new semver(a, loose).major;
25796var major_1 = major;
25797
25798const minor = (a, loose) => new semver(a, loose).minor;
25799var minor_1 = minor;
25800
25801const patch = (a, loose) => new semver(a, loose).patch;
25802var patch_1 = patch;
25803
25804const prerelease = (version, options) => {
25805 const parsed = parse_1(version, options);
25806 return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
25807};
25808var prerelease_1 = prerelease;
25809
25810const rcompare = (a, b, loose) => compare_1(b, a, loose);
25811var rcompare_1 = rcompare;
25812
25813const compareLoose = (a, b) => compare_1(a, b, true);
25814var compareLoose_1 = compareLoose;
25815
25816const compareBuild = (a, b, loose) => {
25817 const versionA = new semver(a, loose);
25818 const versionB = new semver(b, loose);
25819 return versionA.compare(versionB) || versionA.compareBuild(versionB)
25820};
25821var compareBuild_1 = compareBuild;
25822
25823const sort = (list, loose) => list.sort((a, b) => compareBuild_1(a, b, loose));
25824var sort_1 = sort;
25825
25826const rsort = (list, loose) => list.sort((a, b) => compareBuild_1(b, a, loose));
25827var rsort_1 = rsort;
25828
25829const gt = (a, b, loose) => compare_1(a, b, loose) > 0;
25830var gt_1 = gt;
25831
25832const lt = (a, b, loose) => compare_1(a, b, loose) < 0;
25833var lt_1 = lt;
25834
25835const neq = (a, b, loose) => compare_1(a, b, loose) !== 0;
25836var neq_1 = neq;
25837
25838const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
25839var gte_1 = gte;
25840
25841const lte = (a, b, loose) => compare_1(a, b, loose) <= 0;
25842var lte_1 = lte;
25843
25844const cmp = (a, op, b, loose) => {
25845 switch (op) {
25846 case '===':
25847 if (typeof a === 'object')
25848 a = a.version;
25849 if (typeof b === 'object')
25850 b = b.version;
25851 return a === b
25852
25853 case '!==':
25854 if (typeof a === 'object')
25855 a = a.version;
25856 if (typeof b === 'object')
25857 b = b.version;
25858 return a !== b
25859
25860 case '':
25861 case '=':
25862 case '==':
25863 return eq_1$1(a, b, loose)
25864
25865 case '!=':
25866 return neq_1(a, b, loose)
25867
25868 case '>':
25869 return gt_1(a, b, loose)
25870
25871 case '>=':
25872 return gte_1(a, b, loose)
25873
25874 case '<':
25875 return lt_1(a, b, loose)
25876
25877 case '<=':
25878 return lte_1(a, b, loose)
25879
25880 default:
25881 throw new TypeError(`Invalid operator: ${op}`)
25882 }
25883};
25884var cmp_1 = cmp;
25885
25886const {re: re$2, t: t$2} = re_1;
25887
25888const coerce = (version, options) => {
25889 if (version instanceof semver) {
25890 return version
25891 }
25892
25893 if (typeof version === 'number') {
25894 version = String(version);
25895 }
25896
25897 if (typeof version !== 'string') {
25898 return null
25899 }
25900
25901 options = options || {};
25902
25903 let match = null;
25904 if (!options.rtl) {
25905 match = version.match(re$2[t$2.COERCE]);
25906 } else {
25907 // Find the right-most coercible string that does not share
25908 // a terminus with a more left-ward coercible string.
25909 // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
25910 //
25911 // Walk through the string checking with a /g regexp
25912 // Manually set the index so as to pick up overlapping matches.
25913 // Stop when we get a match that ends at the string end, since no
25914 // coercible string can be more right-ward without the same terminus.
25915 let next;
25916 while ((next = re$2[t$2.COERCERTL].exec(version)) &&
25917 (!match || match.index + match[0].length !== version.length)
25918 ) {
25919 if (!match ||
25920 next.index + next[0].length !== match.index + match[0].length) {
25921 match = next;
25922 }
25923 re$2[t$2.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
25924 }
25925 // leave it in a clean state
25926 re$2[t$2.COERCERTL].lastIndex = -1;
25927 }
25928
25929 if (match === null)
25930 return null
25931
25932 return parse_1(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
25933};
25934var coerce_1 = coerce;
25935
25936var iterator = function (Yallist) {
25937 Yallist.prototype[Symbol.iterator] = function* () {
25938 for (let walker = this.head; walker; walker = walker.next) {
25939 yield walker.value;
25940 }
25941 };
25942};
25943
25944var yallist = Yallist;
25945
25946Yallist.Node = Node;
25947Yallist.create = Yallist;
25948
25949function Yallist (list) {
25950 var self = this;
25951 if (!(self instanceof Yallist)) {
25952 self = new Yallist();
25953 }
25954
25955 self.tail = null;
25956 self.head = null;
25957 self.length = 0;
25958
25959 if (list && typeof list.forEach === 'function') {
25960 list.forEach(function (item) {
25961 self.push(item);
25962 });
25963 } else if (arguments.length > 0) {
25964 for (var i = 0, l = arguments.length; i < l; i++) {
25965 self.push(arguments[i]);
25966 }
25967 }
25968
25969 return self
25970}
25971
25972Yallist.prototype.removeNode = function (node) {
25973 if (node.list !== this) {
25974 throw new Error('removing node which does not belong to this list')
25975 }
25976
25977 var next = node.next;
25978 var prev = node.prev;
25979
25980 if (next) {
25981 next.prev = prev;
25982 }
25983
25984 if (prev) {
25985 prev.next = next;
25986 }
25987
25988 if (node === this.head) {
25989 this.head = next;
25990 }
25991 if (node === this.tail) {
25992 this.tail = prev;
25993 }
25994
25995 node.list.length--;
25996 node.next = null;
25997 node.prev = null;
25998 node.list = null;
25999
26000 return next
26001};
26002
26003Yallist.prototype.unshiftNode = function (node) {
26004 if (node === this.head) {
26005 return
26006 }
26007
26008 if (node.list) {
26009 node.list.removeNode(node);
26010 }
26011
26012 var head = this.head;
26013 node.list = this;
26014 node.next = head;
26015 if (head) {
26016 head.prev = node;
26017 }
26018
26019 this.head = node;
26020 if (!this.tail) {
26021 this.tail = node;
26022 }
26023 this.length++;
26024};
26025
26026Yallist.prototype.pushNode = function (node) {
26027 if (node === this.tail) {
26028 return
26029 }
26030
26031 if (node.list) {
26032 node.list.removeNode(node);
26033 }
26034
26035 var tail = this.tail;
26036 node.list = this;
26037 node.prev = tail;
26038 if (tail) {
26039 tail.next = node;
26040 }
26041
26042 this.tail = node;
26043 if (!this.head) {
26044 this.head = node;
26045 }
26046 this.length++;
26047};
26048
26049Yallist.prototype.push = function () {
26050 for (var i = 0, l = arguments.length; i < l; i++) {
26051 push(this, arguments[i]);
26052 }
26053 return this.length
26054};
26055
26056Yallist.prototype.unshift = function () {
26057 for (var i = 0, l = arguments.length; i < l; i++) {
26058 unshift(this, arguments[i]);
26059 }
26060 return this.length
26061};
26062
26063Yallist.prototype.pop = function () {
26064 if (!this.tail) {
26065 return undefined
26066 }
26067
26068 var res = this.tail.value;
26069 this.tail = this.tail.prev;
26070 if (this.tail) {
26071 this.tail.next = null;
26072 } else {
26073 this.head = null;
26074 }
26075 this.length--;
26076 return res
26077};
26078
26079Yallist.prototype.shift = function () {
26080 if (!this.head) {
26081 return undefined
26082 }
26083
26084 var res = this.head.value;
26085 this.head = this.head.next;
26086 if (this.head) {
26087 this.head.prev = null;
26088 } else {
26089 this.tail = null;
26090 }
26091 this.length--;
26092 return res
26093};
26094
26095Yallist.prototype.forEach = function (fn, thisp) {
26096 thisp = thisp || this;
26097 for (var walker = this.head, i = 0; walker !== null; i++) {
26098 fn.call(thisp, walker.value, i, this);
26099 walker = walker.next;
26100 }
26101};
26102
26103Yallist.prototype.forEachReverse = function (fn, thisp) {
26104 thisp = thisp || this;
26105 for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
26106 fn.call(thisp, walker.value, i, this);
26107 walker = walker.prev;
26108 }
26109};
26110
26111Yallist.prototype.get = function (n) {
26112 for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
26113 // abort out of the list early if we hit a cycle
26114 walker = walker.next;
26115 }
26116 if (i === n && walker !== null) {
26117 return walker.value
26118 }
26119};
26120
26121Yallist.prototype.getReverse = function (n) {
26122 for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
26123 // abort out of the list early if we hit a cycle
26124 walker = walker.prev;
26125 }
26126 if (i === n && walker !== null) {
26127 return walker.value
26128 }
26129};
26130
26131Yallist.prototype.map = function (fn, thisp) {
26132 thisp = thisp || this;
26133 var res = new Yallist();
26134 for (var walker = this.head; walker !== null;) {
26135 res.push(fn.call(thisp, walker.value, this));
26136 walker = walker.next;
26137 }
26138 return res
26139};
26140
26141Yallist.prototype.mapReverse = function (fn, thisp) {
26142 thisp = thisp || this;
26143 var res = new Yallist();
26144 for (var walker = this.tail; walker !== null;) {
26145 res.push(fn.call(thisp, walker.value, this));
26146 walker = walker.prev;
26147 }
26148 return res
26149};
26150
26151Yallist.prototype.reduce = function (fn, initial) {
26152 var acc;
26153 var walker = this.head;
26154 if (arguments.length > 1) {
26155 acc = initial;
26156 } else if (this.head) {
26157 walker = this.head.next;
26158 acc = this.head.value;
26159 } else {
26160 throw new TypeError('Reduce of empty list with no initial value')
26161 }
26162
26163 for (var i = 0; walker !== null; i++) {
26164 acc = fn(acc, walker.value, i);
26165 walker = walker.next;
26166 }
26167
26168 return acc
26169};
26170
26171Yallist.prototype.reduceReverse = function (fn, initial) {
26172 var acc;
26173 var walker = this.tail;
26174 if (arguments.length > 1) {
26175 acc = initial;
26176 } else if (this.tail) {
26177 walker = this.tail.prev;
26178 acc = this.tail.value;
26179 } else {
26180 throw new TypeError('Reduce of empty list with no initial value')
26181 }
26182
26183 for (var i = this.length - 1; walker !== null; i--) {
26184 acc = fn(acc, walker.value, i);
26185 walker = walker.prev;
26186 }
26187
26188 return acc
26189};
26190
26191Yallist.prototype.toArray = function () {
26192 var arr = new Array(this.length);
26193 for (var i = 0, walker = this.head; walker !== null; i++) {
26194 arr[i] = walker.value;
26195 walker = walker.next;
26196 }
26197 return arr
26198};
26199
26200Yallist.prototype.toArrayReverse = function () {
26201 var arr = new Array(this.length);
26202 for (var i = 0, walker = this.tail; walker !== null; i++) {
26203 arr[i] = walker.value;
26204 walker = walker.prev;
26205 }
26206 return arr
26207};
26208
26209Yallist.prototype.slice = function (from, to) {
26210 to = to || this.length;
26211 if (to < 0) {
26212 to += this.length;
26213 }
26214 from = from || 0;
26215 if (from < 0) {
26216 from += this.length;
26217 }
26218 var ret = new Yallist();
26219 if (to < from || to < 0) {
26220 return ret
26221 }
26222 if (from < 0) {
26223 from = 0;
26224 }
26225 if (to > this.length) {
26226 to = this.length;
26227 }
26228 for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
26229 walker = walker.next;
26230 }
26231 for (; walker !== null && i < to; i++, walker = walker.next) {
26232 ret.push(walker.value);
26233 }
26234 return ret
26235};
26236
26237Yallist.prototype.sliceReverse = function (from, to) {
26238 to = to || this.length;
26239 if (to < 0) {
26240 to += this.length;
26241 }
26242 from = from || 0;
26243 if (from < 0) {
26244 from += this.length;
26245 }
26246 var ret = new Yallist();
26247 if (to < from || to < 0) {
26248 return ret
26249 }
26250 if (from < 0) {
26251 from = 0;
26252 }
26253 if (to > this.length) {
26254 to = this.length;
26255 }
26256 for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
26257 walker = walker.prev;
26258 }
26259 for (; walker !== null && i > from; i--, walker = walker.prev) {
26260 ret.push(walker.value);
26261 }
26262 return ret
26263};
26264
26265Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
26266 if (start > this.length) {
26267 start = this.length - 1;
26268 }
26269 if (start < 0) {
26270 start = this.length + start;
26271 }
26272
26273 for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
26274 walker = walker.next;
26275 }
26276
26277 var ret = [];
26278 for (var i = 0; walker && i < deleteCount; i++) {
26279 ret.push(walker.value);
26280 walker = this.removeNode(walker);
26281 }
26282 if (walker === null) {
26283 walker = this.tail;
26284 }
26285
26286 if (walker !== this.head && walker !== this.tail) {
26287 walker = walker.prev;
26288 }
26289
26290 for (var i = 0; i < nodes.length; i++) {
26291 walker = insert(this, walker, nodes[i]);
26292 }
26293 return ret;
26294};
26295
26296Yallist.prototype.reverse = function () {
26297 var head = this.head;
26298 var tail = this.tail;
26299 for (var walker = head; walker !== null; walker = walker.prev) {
26300 var p = walker.prev;
26301 walker.prev = walker.next;
26302 walker.next = p;
26303 }
26304 this.head = tail;
26305 this.tail = head;
26306 return this
26307};
26308
26309function insert (self, node, value) {
26310 var inserted = node === self.head ?
26311 new Node(value, null, node, self) :
26312 new Node(value, node, node.next, self);
26313
26314 if (inserted.next === null) {
26315 self.tail = inserted;
26316 }
26317 if (inserted.prev === null) {
26318 self.head = inserted;
26319 }
26320
26321 self.length++;
26322
26323 return inserted
26324}
26325
26326function push (self, item) {
26327 self.tail = new Node(item, self.tail, null, self);
26328 if (!self.head) {
26329 self.head = self.tail;
26330 }
26331 self.length++;
26332}
26333
26334function unshift (self, item) {
26335 self.head = new Node(item, null, self.head, self);
26336 if (!self.tail) {
26337 self.tail = self.head;
26338 }
26339 self.length++;
26340}
26341
26342function Node (value, prev, next, list) {
26343 if (!(this instanceof Node)) {
26344 return new Node(value, prev, next, list)
26345 }
26346
26347 this.list = list;
26348 this.value = value;
26349
26350 if (prev) {
26351 prev.next = this;
26352 this.prev = prev;
26353 } else {
26354 this.prev = null;
26355 }
26356
26357 if (next) {
26358 next.prev = this;
26359 this.next = next;
26360 } else {
26361 this.next = null;
26362 }
26363}
26364
26365try {
26366 // add if support for Symbol.iterator is present
26367 iterator(Yallist);
26368} catch (er) {}
26369
26370// A linked list to keep track of recently-used-ness
26371
26372
26373const MAX = Symbol('max');
26374const LENGTH = Symbol('length');
26375const LENGTH_CALCULATOR = Symbol('lengthCalculator');
26376const ALLOW_STALE = Symbol('allowStale');
26377const MAX_AGE = Symbol('maxAge');
26378const DISPOSE = Symbol('dispose');
26379const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
26380const LRU_LIST = Symbol('lruList');
26381const CACHE = Symbol('cache');
26382const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
26383
26384const naiveLength = () => 1;
26385
26386// lruList is a yallist where the head is the youngest
26387// item, and the tail is the oldest. the list contains the Hit
26388// objects as the entries.
26389// Each Hit object has a reference to its Yallist.Node. This
26390// never changes.
26391//
26392// cache is a Map (or PseudoMap) that matches the keys to
26393// the Yallist.Node object.
26394class LRUCache {
26395 constructor (options) {
26396 if (typeof options === 'number')
26397 options = { max: options };
26398
26399 if (!options)
26400 options = {};
26401
26402 if (options.max && (typeof options.max !== 'number' || options.max < 0))
26403 throw new TypeError('max must be a non-negative number')
26404 // Kind of weird to have a default max of Infinity, but oh well.
26405 this[MAX] = options.max || Infinity;
26406
26407 const lc = options.length || naiveLength;
26408 this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
26409 this[ALLOW_STALE] = options.stale || false;
26410 if (options.maxAge && typeof options.maxAge !== 'number')
26411 throw new TypeError('maxAge must be a number')
26412 this[MAX_AGE] = options.maxAge || 0;
26413 this[DISPOSE] = options.dispose;
26414 this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
26415 this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
26416 this.reset();
26417 }
26418
26419 // resize the cache when the max changes.
26420 set max (mL) {
26421 if (typeof mL !== 'number' || mL < 0)
26422 throw new TypeError('max must be a non-negative number')
26423
26424 this[MAX] = mL || Infinity;
26425 trim(this);
26426 }
26427 get max () {
26428 return this[MAX]
26429 }
26430
26431 set allowStale (allowStale) {
26432 this[ALLOW_STALE] = !!allowStale;
26433 }
26434 get allowStale () {
26435 return this[ALLOW_STALE]
26436 }
26437
26438 set maxAge (mA) {
26439 if (typeof mA !== 'number')
26440 throw new TypeError('maxAge must be a non-negative number')
26441
26442 this[MAX_AGE] = mA;
26443 trim(this);
26444 }
26445 get maxAge () {
26446 return this[MAX_AGE]
26447 }
26448
26449 // resize the cache when the lengthCalculator changes.
26450 set lengthCalculator (lC) {
26451 if (typeof lC !== 'function')
26452 lC = naiveLength;
26453
26454 if (lC !== this[LENGTH_CALCULATOR]) {
26455 this[LENGTH_CALCULATOR] = lC;
26456 this[LENGTH] = 0;
26457 this[LRU_LIST].forEach(hit => {
26458 hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
26459 this[LENGTH] += hit.length;
26460 });
26461 }
26462 trim(this);
26463 }
26464 get lengthCalculator () { return this[LENGTH_CALCULATOR] }
26465
26466 get length () { return this[LENGTH] }
26467 get itemCount () { return this[LRU_LIST].length }
26468
26469 rforEach (fn, thisp) {
26470 thisp = thisp || this;
26471 for (let walker = this[LRU_LIST].tail; walker !== null;) {
26472 const prev = walker.prev;
26473 forEachStep(this, fn, walker, thisp);
26474 walker = prev;
26475 }
26476 }
26477
26478 forEach (fn, thisp) {
26479 thisp = thisp || this;
26480 for (let walker = this[LRU_LIST].head; walker !== null;) {
26481 const next = walker.next;
26482 forEachStep(this, fn, walker, thisp);
26483 walker = next;
26484 }
26485 }
26486
26487 keys () {
26488 return this[LRU_LIST].toArray().map(k => k.key)
26489 }
26490
26491 values () {
26492 return this[LRU_LIST].toArray().map(k => k.value)
26493 }
26494
26495 reset () {
26496 if (this[DISPOSE] &&
26497 this[LRU_LIST] &&
26498 this[LRU_LIST].length) {
26499 this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
26500 }
26501
26502 this[CACHE] = new Map(); // hash of items by key
26503 this[LRU_LIST] = new yallist(); // list of items in order of use recency
26504 this[LENGTH] = 0; // length of items in the list
26505 }
26506
26507 dump () {
26508 return this[LRU_LIST].map(hit =>
26509 isStale(this, hit) ? false : {
26510 k: hit.key,
26511 v: hit.value,
26512 e: hit.now + (hit.maxAge || 0)
26513 }).toArray().filter(h => h)
26514 }
26515
26516 dumpLru () {
26517 return this[LRU_LIST]
26518 }
26519
26520 set (key, value, maxAge) {
26521 maxAge = maxAge || this[MAX_AGE];
26522
26523 if (maxAge && typeof maxAge !== 'number')
26524 throw new TypeError('maxAge must be a number')
26525
26526 const now = maxAge ? Date.now() : 0;
26527 const len = this[LENGTH_CALCULATOR](value, key);
26528
26529 if (this[CACHE].has(key)) {
26530 if (len > this[MAX]) {
26531 del(this, this[CACHE].get(key));
26532 return false
26533 }
26534
26535 const node = this[CACHE].get(key);
26536 const item = node.value;
26537
26538 // dispose of the old one before overwriting
26539 // split out into 2 ifs for better coverage tracking
26540 if (this[DISPOSE]) {
26541 if (!this[NO_DISPOSE_ON_SET])
26542 this[DISPOSE](key, item.value);
26543 }
26544
26545 item.now = now;
26546 item.maxAge = maxAge;
26547 item.value = value;
26548 this[LENGTH] += len - item.length;
26549 item.length = len;
26550 this.get(key);
26551 trim(this);
26552 return true
26553 }
26554
26555 const hit = new Entry(key, value, len, now, maxAge);
26556
26557 // oversized objects fall out of cache automatically.
26558 if (hit.length > this[MAX]) {
26559 if (this[DISPOSE])
26560 this[DISPOSE](key, value);
26561
26562 return false
26563 }
26564
26565 this[LENGTH] += hit.length;
26566 this[LRU_LIST].unshift(hit);
26567 this[CACHE].set(key, this[LRU_LIST].head);
26568 trim(this);
26569 return true
26570 }
26571
26572 has (key) {
26573 if (!this[CACHE].has(key)) return false
26574 const hit = this[CACHE].get(key).value;
26575 return !isStale(this, hit)
26576 }
26577
26578 get (key) {
26579 return get$1(this, key, true)
26580 }
26581
26582 peek (key) {
26583 return get$1(this, key, false)
26584 }
26585
26586 pop () {
26587 const node = this[LRU_LIST].tail;
26588 if (!node)
26589 return null
26590
26591 del(this, node);
26592 return node.value
26593 }
26594
26595 del (key) {
26596 del(this, this[CACHE].get(key));
26597 }
26598
26599 load (arr) {
26600 // reset the cache
26601 this.reset();
26602
26603 const now = Date.now();
26604 // A previous serialized cache has the most recent items first
26605 for (let l = arr.length - 1; l >= 0; l--) {
26606 const hit = arr[l];
26607 const expiresAt = hit.e || 0;
26608 if (expiresAt === 0)
26609 // the item was created without expiration in a non aged cache
26610 this.set(hit.k, hit.v);
26611 else {
26612 const maxAge = expiresAt - now;
26613 // dont add already expired items
26614 if (maxAge > 0) {
26615 this.set(hit.k, hit.v, maxAge);
26616 }
26617 }
26618 }
26619 }
26620
26621 prune () {
26622 this[CACHE].forEach((value, key) => get$1(this, key, false));
26623 }
26624}
26625
26626const get$1 = (self, key, doUse) => {
26627 const node = self[CACHE].get(key);
26628 if (node) {
26629 const hit = node.value;
26630 if (isStale(self, hit)) {
26631 del(self, node);
26632 if (!self[ALLOW_STALE])
26633 return undefined
26634 } else {
26635 if (doUse) {
26636 if (self[UPDATE_AGE_ON_GET])
26637 node.value.now = Date.now();
26638 self[LRU_LIST].unshiftNode(node);
26639 }
26640 }
26641 return hit.value
26642 }
26643};
26644
26645const isStale = (self, hit) => {
26646 if (!hit || (!hit.maxAge && !self[MAX_AGE]))
26647 return false
26648
26649 const diff = Date.now() - hit.now;
26650 return hit.maxAge ? diff > hit.maxAge
26651 : self[MAX_AGE] && (diff > self[MAX_AGE])
26652};
26653
26654const trim = self => {
26655 if (self[LENGTH] > self[MAX]) {
26656 for (let walker = self[LRU_LIST].tail;
26657 self[LENGTH] > self[MAX] && walker !== null;) {
26658 // We know that we're about to delete this one, and also
26659 // what the next least recently used key will be, so just
26660 // go ahead and set it now.
26661 const prev = walker.prev;
26662 del(self, walker);
26663 walker = prev;
26664 }
26665 }
26666};
26667
26668const del = (self, node) => {
26669 if (node) {
26670 const hit = node.value;
26671 if (self[DISPOSE])
26672 self[DISPOSE](hit.key, hit.value);
26673
26674 self[LENGTH] -= hit.length;
26675 self[CACHE].delete(hit.key);
26676 self[LRU_LIST].removeNode(node);
26677 }
26678};
26679
26680class Entry {
26681 constructor (key, value, length, now, maxAge) {
26682 this.key = key;
26683 this.value = value;
26684 this.length = length;
26685 this.now = now;
26686 this.maxAge = maxAge || 0;
26687 }
26688}
26689
26690const forEachStep = (self, fn, node, thisp) => {
26691 let hit = node.value;
26692 if (isStale(self, hit)) {
26693 del(self, node);
26694 if (!self[ALLOW_STALE])
26695 hit = undefined;
26696 }
26697 if (hit)
26698 fn.call(thisp, hit.value, hit.key, self);
26699};
26700
26701var lruCache = LRUCache;
26702
26703// hoisted class for cyclic dependency
26704class Range {
26705 constructor (range, options) {
26706 options = parseOptions_1(options);
26707
26708 if (range instanceof Range) {
26709 if (
26710 range.loose === !!options.loose &&
26711 range.includePrerelease === !!options.includePrerelease
26712 ) {
26713 return range
26714 } else {
26715 return new Range(range.raw, options)
26716 }
26717 }
26718
26719 if (range instanceof comparator) {
26720 // just put it in the set and return
26721 this.raw = range.value;
26722 this.set = [[range]];
26723 this.format();
26724 return this
26725 }
26726
26727 this.options = options;
26728 this.loose = !!options.loose;
26729 this.includePrerelease = !!options.includePrerelease;
26730
26731 // First, split based on boolean or ||
26732 this.raw = range;
26733 this.set = range
26734 .split(/\s*\|\|\s*/)
26735 // map the range to a 2d array of comparators
26736 .map(range => this.parseRange(range.trim()))
26737 // throw out any comparator lists that are empty
26738 // this generally means that it was not a valid range, which is allowed
26739 // in loose mode, but will still throw if the WHOLE range is invalid.
26740 .filter(c => c.length);
26741
26742 if (!this.set.length) {
26743 throw new TypeError(`Invalid SemVer Range: ${range}`)
26744 }
26745
26746 // if we have any that are not the null set, throw out null sets.
26747 if (this.set.length > 1) {
26748 // keep the first one, in case they're all null sets
26749 const first = this.set[0];
26750 this.set = this.set.filter(c => !isNullSet(c[0]));
26751 if (this.set.length === 0)
26752 this.set = [first];
26753 else if (this.set.length > 1) {
26754 // if we have any that are *, then the range is just *
26755 for (const c of this.set) {
26756 if (c.length === 1 && isAny(c[0])) {
26757 this.set = [c];
26758 break
26759 }
26760 }
26761 }
26762 }
26763
26764 this.format();
26765 }
26766
26767 format () {
26768 this.range = this.set
26769 .map((comps) => {
26770 return comps.join(' ').trim()
26771 })
26772 .join('||')
26773 .trim();
26774 return this.range
26775 }
26776
26777 toString () {
26778 return this.range
26779 }
26780
26781 parseRange (range) {
26782 range = range.trim();
26783
26784 // memoize range parsing for performance.
26785 // this is a very hot path, and fully deterministic.
26786 const memoOpts = Object.keys(this.options).join(',');
26787 const memoKey = `parseRange:${memoOpts}:${range}`;
26788 const cached = cache.get(memoKey);
26789 if (cached)
26790 return cached
26791
26792 const loose = this.options.loose;
26793 // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
26794 const hr = loose ? re$3[t$3.HYPHENRANGELOOSE] : re$3[t$3.HYPHENRANGE];
26795 range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
26796 debug_1('hyphen replace', range);
26797 // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
26798 range = range.replace(re$3[t$3.COMPARATORTRIM], comparatorTrimReplace);
26799 debug_1('comparator trim', range, re$3[t$3.COMPARATORTRIM]);
26800
26801 // `~ 1.2.3` => `~1.2.3`
26802 range = range.replace(re$3[t$3.TILDETRIM], tildeTrimReplace);
26803
26804 // `^ 1.2.3` => `^1.2.3`
26805 range = range.replace(re$3[t$3.CARETTRIM], caretTrimReplace);
26806
26807 // normalize spaces
26808 range = range.split(/\s+/).join(' ');
26809
26810 // At this point, the range is completely trimmed and
26811 // ready to be split into comparators.
26812
26813 const compRe = loose ? re$3[t$3.COMPARATORLOOSE] : re$3[t$3.COMPARATOR];
26814 const rangeList = range
26815 .split(' ')
26816 .map(comp => parseComparator(comp, this.options))
26817 .join(' ')
26818 .split(/\s+/)
26819 // >=0.0.0 is equivalent to *
26820 .map(comp => replaceGTE0(comp, this.options))
26821 // in loose mode, throw out any that are not valid comparators
26822 .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true)
26823 .map(comp => new comparator(comp, this.options));
26824
26825 // if any comparators are the null set, then replace with JUST null set
26826 // if more than one comparator, remove any * comparators
26827 // also, don't include the same comparator more than once
26828 rangeList.length;
26829 const rangeMap = new Map();
26830 for (const comp of rangeList) {
26831 if (isNullSet(comp))
26832 return [comp]
26833 rangeMap.set(comp.value, comp);
26834 }
26835 if (rangeMap.size > 1 && rangeMap.has(''))
26836 rangeMap.delete('');
26837
26838 const result = [...rangeMap.values()];
26839 cache.set(memoKey, result);
26840 return result
26841 }
26842
26843 intersects (range, options) {
26844 if (!(range instanceof Range)) {
26845 throw new TypeError('a Range is required')
26846 }
26847
26848 return this.set.some((thisComparators) => {
26849 return (
26850 isSatisfiable(thisComparators, options) &&
26851 range.set.some((rangeComparators) => {
26852 return (
26853 isSatisfiable(rangeComparators, options) &&
26854 thisComparators.every((thisComparator) => {
26855 return rangeComparators.every((rangeComparator) => {
26856 return thisComparator.intersects(rangeComparator, options)
26857 })
26858 })
26859 )
26860 })
26861 )
26862 })
26863 }
26864
26865 // if ANY of the sets match ALL of its comparators, then pass
26866 test (version) {
26867 if (!version) {
26868 return false
26869 }
26870
26871 if (typeof version === 'string') {
26872 try {
26873 version = new semver(version, this.options);
26874 } catch (er) {
26875 return false
26876 }
26877 }
26878
26879 for (let i = 0; i < this.set.length; i++) {
26880 if (testSet(this.set[i], version, this.options)) {
26881 return true
26882 }
26883 }
26884 return false
26885 }
26886}
26887var range = Range;
26888
26889
26890const cache = new lruCache({ max: 1000 });
26891
26892
26893
26894
26895
26896const {
26897 re: re$3,
26898 t: t$3,
26899 comparatorTrimReplace,
26900 tildeTrimReplace,
26901 caretTrimReplace
26902} = re_1;
26903
26904const isNullSet = c => c.value === '<0.0.0-0';
26905const isAny = c => c.value === '';
26906
26907// take a set of comparators and determine whether there
26908// exists a version which can satisfy it
26909const isSatisfiable = (comparators, options) => {
26910 let result = true;
26911 const remainingComparators = comparators.slice();
26912 let testComparator = remainingComparators.pop();
26913
26914 while (result && remainingComparators.length) {
26915 result = remainingComparators.every((otherComparator) => {
26916 return testComparator.intersects(otherComparator, options)
26917 });
26918
26919 testComparator = remainingComparators.pop();
26920 }
26921
26922 return result
26923};
26924
26925// comprised of xranges, tildes, stars, and gtlt's at this point.
26926// already replaced the hyphen ranges
26927// turn into a set of JUST comparators.
26928const parseComparator = (comp, options) => {
26929 debug_1('comp', comp, options);
26930 comp = replaceCarets(comp, options);
26931 debug_1('caret', comp);
26932 comp = replaceTildes(comp, options);
26933 debug_1('tildes', comp);
26934 comp = replaceXRanges(comp, options);
26935 debug_1('xrange', comp);
26936 comp = replaceStars(comp, options);
26937 debug_1('stars', comp);
26938 return comp
26939};
26940
26941const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
26942
26943// ~, ~> --> * (any, kinda silly)
26944// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
26945// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
26946// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
26947// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
26948// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
26949const replaceTildes = (comp, options) =>
26950 comp.trim().split(/\s+/).map((comp) => {
26951 return replaceTilde(comp, options)
26952 }).join(' ');
26953
26954const replaceTilde = (comp, options) => {
26955 const r = options.loose ? re$3[t$3.TILDELOOSE] : re$3[t$3.TILDE];
26956 return comp.replace(r, (_, M, m, p, pr) => {
26957 debug_1('tilde', comp, _, M, m, p, pr);
26958 let ret;
26959
26960 if (isX(M)) {
26961 ret = '';
26962 } else if (isX(m)) {
26963 ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
26964 } else if (isX(p)) {
26965 // ~1.2 == >=1.2.0 <1.3.0-0
26966 ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
26967 } else if (pr) {
26968 debug_1('replaceTilde pr', pr);
26969 ret = `>=${M}.${m}.${p}-${pr
26970 } <${M}.${+m + 1}.0-0`;
26971 } else {
26972 // ~1.2.3 == >=1.2.3 <1.3.0-0
26973 ret = `>=${M}.${m}.${p
26974 } <${M}.${+m + 1}.0-0`;
26975 }
26976
26977 debug_1('tilde return', ret);
26978 return ret
26979 })
26980};
26981
26982// ^ --> * (any, kinda silly)
26983// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
26984// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
26985// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
26986// ^1.2.3 --> >=1.2.3 <2.0.0-0
26987// ^1.2.0 --> >=1.2.0 <2.0.0-0
26988const replaceCarets = (comp, options) =>
26989 comp.trim().split(/\s+/).map((comp) => {
26990 return replaceCaret(comp, options)
26991 }).join(' ');
26992
26993const replaceCaret = (comp, options) => {
26994 debug_1('caret', comp, options);
26995 const r = options.loose ? re$3[t$3.CARETLOOSE] : re$3[t$3.CARET];
26996 const z = options.includePrerelease ? '-0' : '';
26997 return comp.replace(r, (_, M, m, p, pr) => {
26998 debug_1('caret', comp, _, M, m, p, pr);
26999 let ret;
27000
27001 if (isX(M)) {
27002 ret = '';
27003 } else if (isX(m)) {
27004 ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
27005 } else if (isX(p)) {
27006 if (M === '0') {
27007 ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
27008 } else {
27009 ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
27010 }
27011 } else if (pr) {
27012 debug_1('replaceCaret pr', pr);
27013 if (M === '0') {
27014 if (m === '0') {
27015 ret = `>=${M}.${m}.${p}-${pr
27016 } <${M}.${m}.${+p + 1}-0`;
27017 } else {
27018 ret = `>=${M}.${m}.${p}-${pr
27019 } <${M}.${+m + 1}.0-0`;
27020 }
27021 } else {
27022 ret = `>=${M}.${m}.${p}-${pr
27023 } <${+M + 1}.0.0-0`;
27024 }
27025 } else {
27026 debug_1('no pr');
27027 if (M === '0') {
27028 if (m === '0') {
27029 ret = `>=${M}.${m}.${p
27030 }${z} <${M}.${m}.${+p + 1}-0`;
27031 } else {
27032 ret = `>=${M}.${m}.${p
27033 }${z} <${M}.${+m + 1}.0-0`;
27034 }
27035 } else {
27036 ret = `>=${M}.${m}.${p
27037 } <${+M + 1}.0.0-0`;
27038 }
27039 }
27040
27041 debug_1('caret return', ret);
27042 return ret
27043 })
27044};
27045
27046const replaceXRanges = (comp, options) => {
27047 debug_1('replaceXRanges', comp, options);
27048 return comp.split(/\s+/).map((comp) => {
27049 return replaceXRange(comp, options)
27050 }).join(' ')
27051};
27052
27053const replaceXRange = (comp, options) => {
27054 comp = comp.trim();
27055 const r = options.loose ? re$3[t$3.XRANGELOOSE] : re$3[t$3.XRANGE];
27056 return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
27057 debug_1('xRange', comp, ret, gtlt, M, m, p, pr);
27058 const xM = isX(M);
27059 const xm = xM || isX(m);
27060 const xp = xm || isX(p);
27061 const anyX = xp;
27062
27063 if (gtlt === '=' && anyX) {
27064 gtlt = '';
27065 }
27066
27067 // if we're including prereleases in the match, then we need
27068 // to fix this to -0, the lowest possible prerelease value
27069 pr = options.includePrerelease ? '-0' : '';
27070
27071 if (xM) {
27072 if (gtlt === '>' || gtlt === '<') {
27073 // nothing is allowed
27074 ret = '<0.0.0-0';
27075 } else {
27076 // nothing is forbidden
27077 ret = '*';
27078 }
27079 } else if (gtlt && anyX) {
27080 // we know patch is an x, because we have any x at all.
27081 // replace X with 0
27082 if (xm) {
27083 m = 0;
27084 }
27085 p = 0;
27086
27087 if (gtlt === '>') {
27088 // >1 => >=2.0.0
27089 // >1.2 => >=1.3.0
27090 gtlt = '>=';
27091 if (xm) {
27092 M = +M + 1;
27093 m = 0;
27094 p = 0;
27095 } else {
27096 m = +m + 1;
27097 p = 0;
27098 }
27099 } else if (gtlt === '<=') {
27100 // <=0.7.x is actually <0.8.0, since any 0.7.x should
27101 // pass. Similarly, <=7.x is actually <8.0.0, etc.
27102 gtlt = '<';
27103 if (xm) {
27104 M = +M + 1;
27105 } else {
27106 m = +m + 1;
27107 }
27108 }
27109
27110 if (gtlt === '<')
27111 pr = '-0';
27112
27113 ret = `${gtlt + M}.${m}.${p}${pr}`;
27114 } else if (xm) {
27115 ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
27116 } else if (xp) {
27117 ret = `>=${M}.${m}.0${pr
27118 } <${M}.${+m + 1}.0-0`;
27119 }
27120
27121 debug_1('xRange return', ret);
27122
27123 return ret
27124 })
27125};
27126
27127// Because * is AND-ed with everything else in the comparator,
27128// and '' means "any version", just remove the *s entirely.
27129const replaceStars = (comp, options) => {
27130 debug_1('replaceStars', comp, options);
27131 // Looseness is ignored here. star is always as loose as it gets!
27132 return comp.trim().replace(re$3[t$3.STAR], '')
27133};
27134
27135const replaceGTE0 = (comp, options) => {
27136 debug_1('replaceGTE0', comp, options);
27137 return comp.trim()
27138 .replace(re$3[options.includePrerelease ? t$3.GTE0PRE : t$3.GTE0], '')
27139};
27140
27141// This function is passed to string.replace(re[t.HYPHENRANGE])
27142// M, m, patch, prerelease, build
27143// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
27144// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
27145// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
27146const hyphenReplace = incPr => ($0,
27147 from, fM, fm, fp, fpr, fb,
27148 to, tM, tm, tp, tpr, tb) => {
27149 if (isX(fM)) {
27150 from = '';
27151 } else if (isX(fm)) {
27152 from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
27153 } else if (isX(fp)) {
27154 from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
27155 } else if (fpr) {
27156 from = `>=${from}`;
27157 } else {
27158 from = `>=${from}${incPr ? '-0' : ''}`;
27159 }
27160
27161 if (isX(tM)) {
27162 to = '';
27163 } else if (isX(tm)) {
27164 to = `<${+tM + 1}.0.0-0`;
27165 } else if (isX(tp)) {
27166 to = `<${tM}.${+tm + 1}.0-0`;
27167 } else if (tpr) {
27168 to = `<=${tM}.${tm}.${tp}-${tpr}`;
27169 } else if (incPr) {
27170 to = `<${tM}.${tm}.${+tp + 1}-0`;
27171 } else {
27172 to = `<=${to}`;
27173 }
27174
27175 return (`${from} ${to}`).trim()
27176};
27177
27178const testSet = (set, version, options) => {
27179 for (let i = 0; i < set.length; i++) {
27180 if (!set[i].test(version)) {
27181 return false
27182 }
27183 }
27184
27185 if (version.prerelease.length && !options.includePrerelease) {
27186 // Find the set of versions that are allowed to have prereleases
27187 // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
27188 // That should allow `1.2.3-pr.2` to pass.
27189 // However, `1.2.4-alpha.notready` should NOT be allowed,
27190 // even though it's within the range set by the comparators.
27191 for (let i = 0; i < set.length; i++) {
27192 debug_1(set[i].semver);
27193 if (set[i].semver === comparator.ANY) {
27194 continue
27195 }
27196
27197 if (set[i].semver.prerelease.length > 0) {
27198 const allowed = set[i].semver;
27199 if (allowed.major === version.major &&
27200 allowed.minor === version.minor &&
27201 allowed.patch === version.patch) {
27202 return true
27203 }
27204 }
27205 }
27206
27207 // Version has a -pre, but it's not one of the ones we like.
27208 return false
27209 }
27210
27211 return true
27212};
27213
27214const ANY = Symbol('SemVer ANY');
27215// hoisted class for cyclic dependency
27216class Comparator {
27217 static get ANY () {
27218 return ANY
27219 }
27220 constructor (comp, options) {
27221 options = parseOptions_1(options);
27222
27223 if (comp instanceof Comparator) {
27224 if (comp.loose === !!options.loose) {
27225 return comp
27226 } else {
27227 comp = comp.value;
27228 }
27229 }
27230
27231 debug_1('comparator', comp, options);
27232 this.options = options;
27233 this.loose = !!options.loose;
27234 this.parse(comp);
27235
27236 if (this.semver === ANY) {
27237 this.value = '';
27238 } else {
27239 this.value = this.operator + this.semver.version;
27240 }
27241
27242 debug_1('comp', this);
27243 }
27244
27245 parse (comp) {
27246 const r = this.options.loose ? re$4[t$4.COMPARATORLOOSE] : re$4[t$4.COMPARATOR];
27247 const m = comp.match(r);
27248
27249 if (!m) {
27250 throw new TypeError(`Invalid comparator: ${comp}`)
27251 }
27252
27253 this.operator = m[1] !== undefined ? m[1] : '';
27254 if (this.operator === '=') {
27255 this.operator = '';
27256 }
27257
27258 // if it literally is just '>' or '' then allow anything.
27259 if (!m[2]) {
27260 this.semver = ANY;
27261 } else {
27262 this.semver = new semver(m[2], this.options.loose);
27263 }
27264 }
27265
27266 toString () {
27267 return this.value
27268 }
27269
27270 test (version) {
27271 debug_1('Comparator.test', version, this.options.loose);
27272
27273 if (this.semver === ANY || version === ANY) {
27274 return true
27275 }
27276
27277 if (typeof version === 'string') {
27278 try {
27279 version = new semver(version, this.options);
27280 } catch (er) {
27281 return false
27282 }
27283 }
27284
27285 return cmp_1(version, this.operator, this.semver, this.options)
27286 }
27287
27288 intersects (comp, options) {
27289 if (!(comp instanceof Comparator)) {
27290 throw new TypeError('a Comparator is required')
27291 }
27292
27293 if (!options || typeof options !== 'object') {
27294 options = {
27295 loose: !!options,
27296 includePrerelease: false
27297 };
27298 }
27299
27300 if (this.operator === '') {
27301 if (this.value === '') {
27302 return true
27303 }
27304 return new range(comp.value, options).test(this.value)
27305 } else if (comp.operator === '') {
27306 if (comp.value === '') {
27307 return true
27308 }
27309 return new range(this.value, options).test(comp.semver)
27310 }
27311
27312 const sameDirectionIncreasing =
27313 (this.operator === '>=' || this.operator === '>') &&
27314 (comp.operator === '>=' || comp.operator === '>');
27315 const sameDirectionDecreasing =
27316 (this.operator === '<=' || this.operator === '<') &&
27317 (comp.operator === '<=' || comp.operator === '<');
27318 const sameSemVer = this.semver.version === comp.semver.version;
27319 const differentDirectionsInclusive =
27320 (this.operator === '>=' || this.operator === '<=') &&
27321 (comp.operator === '>=' || comp.operator === '<=');
27322 const oppositeDirectionsLessThan =
27323 cmp_1(this.semver, '<', comp.semver, options) &&
27324 (this.operator === '>=' || this.operator === '>') &&
27325 (comp.operator === '<=' || comp.operator === '<');
27326 const oppositeDirectionsGreaterThan =
27327 cmp_1(this.semver, '>', comp.semver, options) &&
27328 (this.operator === '<=' || this.operator === '<') &&
27329 (comp.operator === '>=' || comp.operator === '>');
27330
27331 return (
27332 sameDirectionIncreasing ||
27333 sameDirectionDecreasing ||
27334 (sameSemVer && differentDirectionsInclusive) ||
27335 oppositeDirectionsLessThan ||
27336 oppositeDirectionsGreaterThan
27337 )
27338 }
27339}
27340
27341var comparator = Comparator;
27342
27343
27344const {re: re$4, t: t$4} = re_1;
27345
27346const satisfies = (version, range$1, options) => {
27347 try {
27348 range$1 = new range(range$1, options);
27349 } catch (er) {
27350 return false
27351 }
27352 return range$1.test(version)
27353};
27354var satisfies_1 = satisfies;
27355
27356// Mostly just for testing and legacy API reasons
27357const toComparators = (range$1, options) =>
27358 new range(range$1, options).set
27359 .map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
27360
27361var toComparators_1 = toComparators;
27362
27363const maxSatisfying = (versions, range$1, options) => {
27364 let max = null;
27365 let maxSV = null;
27366 let rangeObj = null;
27367 try {
27368 rangeObj = new range(range$1, options);
27369 } catch (er) {
27370 return null
27371 }
27372 versions.forEach((v) => {
27373 if (rangeObj.test(v)) {
27374 // satisfies(v, range, options)
27375 if (!max || maxSV.compare(v) === -1) {
27376 // compare(max, v, true)
27377 max = v;
27378 maxSV = new semver(max, options);
27379 }
27380 }
27381 });
27382 return max
27383};
27384var maxSatisfying_1 = maxSatisfying;
27385
27386const minSatisfying = (versions, range$1, options) => {
27387 let min = null;
27388 let minSV = null;
27389 let rangeObj = null;
27390 try {
27391 rangeObj = new range(range$1, options);
27392 } catch (er) {
27393 return null
27394 }
27395 versions.forEach((v) => {
27396 if (rangeObj.test(v)) {
27397 // satisfies(v, range, options)
27398 if (!min || minSV.compare(v) === 1) {
27399 // compare(min, v, true)
27400 min = v;
27401 minSV = new semver(min, options);
27402 }
27403 }
27404 });
27405 return min
27406};
27407var minSatisfying_1 = minSatisfying;
27408
27409const minVersion = (range$1, loose) => {
27410 range$1 = new range(range$1, loose);
27411
27412 let minver = new semver('0.0.0');
27413 if (range$1.test(minver)) {
27414 return minver
27415 }
27416
27417 minver = new semver('0.0.0-0');
27418 if (range$1.test(minver)) {
27419 return minver
27420 }
27421
27422 minver = null;
27423 for (let i = 0; i < range$1.set.length; ++i) {
27424 const comparators = range$1.set[i];
27425
27426 let setMin = null;
27427 comparators.forEach((comparator) => {
27428 // Clone to avoid manipulating the comparator's semver object.
27429 const compver = new semver(comparator.semver.version);
27430 switch (comparator.operator) {
27431 case '>':
27432 if (compver.prerelease.length === 0) {
27433 compver.patch++;
27434 } else {
27435 compver.prerelease.push(0);
27436 }
27437 compver.raw = compver.format();
27438 /* fallthrough */
27439 case '':
27440 case '>=':
27441 if (!setMin || gt_1(compver, setMin)) {
27442 setMin = compver;
27443 }
27444 break
27445 case '<':
27446 case '<=':
27447 /* Ignore maximum versions */
27448 break
27449 /* istanbul ignore next */
27450 default:
27451 throw new Error(`Unexpected operation: ${comparator.operator}`)
27452 }
27453 });
27454 if (setMin && (!minver || gt_1(minver, setMin)))
27455 minver = setMin;
27456 }
27457
27458 if (minver && range$1.test(minver)) {
27459 return minver
27460 }
27461
27462 return null
27463};
27464var minVersion_1 = minVersion;
27465
27466const validRange = (range$1, options) => {
27467 try {
27468 // Return '*' instead of '' so that truthiness works.
27469 // This will throw if it's invalid anyway
27470 return new range(range$1, options).range || '*'
27471 } catch (er) {
27472 return null
27473 }
27474};
27475var valid$1 = validRange;
27476
27477const {ANY: ANY$1} = comparator;
27478
27479
27480
27481
27482
27483
27484
27485const outside = (version, range$1, hilo, options) => {
27486 version = new semver(version, options);
27487 range$1 = new range(range$1, options);
27488
27489 let gtfn, ltefn, ltfn, comp, ecomp;
27490 switch (hilo) {
27491 case '>':
27492 gtfn = gt_1;
27493 ltefn = lte_1;
27494 ltfn = lt_1;
27495 comp = '>';
27496 ecomp = '>=';
27497 break
27498 case '<':
27499 gtfn = lt_1;
27500 ltefn = gte_1;
27501 ltfn = gt_1;
27502 comp = '<';
27503 ecomp = '<=';
27504 break
27505 default:
27506 throw new TypeError('Must provide a hilo val of "<" or ">"')
27507 }
27508
27509 // If it satisfies the range it is not outside
27510 if (satisfies_1(version, range$1, options)) {
27511 return false
27512 }
27513
27514 // From now on, variable terms are as if we're in "gtr" mode.
27515 // but note that everything is flipped for the "ltr" function.
27516
27517 for (let i = 0; i < range$1.set.length; ++i) {
27518 const comparators = range$1.set[i];
27519
27520 let high = null;
27521 let low = null;
27522
27523 comparators.forEach((comparator$1) => {
27524 if (comparator$1.semver === ANY$1) {
27525 comparator$1 = new comparator('>=0.0.0');
27526 }
27527 high = high || comparator$1;
27528 low = low || comparator$1;
27529 if (gtfn(comparator$1.semver, high.semver, options)) {
27530 high = comparator$1;
27531 } else if (ltfn(comparator$1.semver, low.semver, options)) {
27532 low = comparator$1;
27533 }
27534 });
27535
27536 // If the edge version comparator has a operator then our version
27537 // isn't outside it
27538 if (high.operator === comp || high.operator === ecomp) {
27539 return false
27540 }
27541
27542 // If the lowest version comparator has an operator and our version
27543 // is less than it then it isn't higher than the range
27544 if ((!low.operator || low.operator === comp) &&
27545 ltefn(version, low.semver)) {
27546 return false
27547 } else if (low.operator === ecomp && ltfn(version, low.semver)) {
27548 return false
27549 }
27550 }
27551 return true
27552};
27553
27554var outside_1 = outside;
27555
27556// Determine if version is greater than all the versions possible in the range.
27557
27558const gtr = (version, range, options) => outside_1(version, range, '>', options);
27559var gtr_1 = gtr;
27560
27561// Determine if version is less than all the versions possible in the range
27562const ltr = (version, range, options) => outside_1(version, range, '<', options);
27563var ltr_1 = ltr;
27564
27565const intersects = (r1, r2, options) => {
27566 r1 = new range(r1, options);
27567 r2 = new range(r2, options);
27568 return r1.intersects(r2)
27569};
27570var intersects_1 = intersects;
27571
27572// given a set of versions and a range, create a "simplified" range
27573// that includes the same versions that the original range does
27574// If the original range is shorter than the simplified one, return that.
27575
27576
27577var simplify = (versions, range, options) => {
27578 const set = [];
27579 let min = null;
27580 let prev = null;
27581 const v = versions.sort((a, b) => compare_1(a, b, options));
27582 for (const version of v) {
27583 const included = satisfies_1(version, range, options);
27584 if (included) {
27585 prev = version;
27586 if (!min)
27587 min = version;
27588 } else {
27589 if (prev) {
27590 set.push([min, prev]);
27591 }
27592 prev = null;
27593 min = null;
27594 }
27595 }
27596 if (min)
27597 set.push([min, null]);
27598
27599 const ranges = [];
27600 for (const [min, max] of set) {
27601 if (min === max)
27602 ranges.push(min);
27603 else if (!max && min === v[0])
27604 ranges.push('*');
27605 else if (!max)
27606 ranges.push(`>=${min}`);
27607 else if (min === v[0])
27608 ranges.push(`<=${max}`);
27609 else
27610 ranges.push(`${min} - ${max}`);
27611 }
27612 const simplified = ranges.join(' || ');
27613 const original = typeof range.raw === 'string' ? range.raw : String(range);
27614 return simplified.length < original.length ? simplified : range
27615};
27616
27617const { ANY: ANY$2 } = comparator;
27618
27619
27620
27621// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
27622// - Every simple range `r1, r2, ...` is a subset of some `R1, R2, ...`
27623//
27624// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
27625// - If c is only the ANY comparator
27626// - If C is only the ANY comparator, return true
27627// - Else return false
27628// - Let EQ be the set of = comparators in c
27629// - If EQ is more than one, return true (null set)
27630// - Let GT be the highest > or >= comparator in c
27631// - Let LT be the lowest < or <= comparator in c
27632// - If GT and LT, and GT.semver > LT.semver, return true (null set)
27633// - If EQ
27634// - If GT, and EQ does not satisfy GT, return true (null set)
27635// - If LT, and EQ does not satisfy LT, return true (null set)
27636// - If EQ satisfies every C, return true
27637// - Else return false
27638// - If GT
27639// - If GT.semver is lower than any > or >= comp in C, return false
27640// - If GT is >=, and GT.semver does not satisfy every C, return false
27641// - If LT
27642// - If LT.semver is greater than any < or <= comp in C, return false
27643// - If LT is <=, and LT.semver does not satisfy every C, return false
27644// - If any C is a = range, and GT or LT are set, return false
27645// - Else return true
27646
27647const subset = (sub, dom, options) => {
27648 if (sub === dom)
27649 return true
27650
27651 sub = new range(sub, options);
27652 dom = new range(dom, options);
27653 let sawNonNull = false;
27654
27655 OUTER: for (const simpleSub of sub.set) {
27656 for (const simpleDom of dom.set) {
27657 const isSub = simpleSubset(simpleSub, simpleDom, options);
27658 sawNonNull = sawNonNull || isSub !== null;
27659 if (isSub)
27660 continue OUTER
27661 }
27662 // the null set is a subset of everything, but null simple ranges in
27663 // a complex range should be ignored. so if we saw a non-null range,
27664 // then we know this isn't a subset, but if EVERY simple range was null,
27665 // then it is a subset.
27666 if (sawNonNull)
27667 return false
27668 }
27669 return true
27670};
27671
27672const simpleSubset = (sub, dom, options) => {
27673 if (sub === dom)
27674 return true
27675
27676 if (sub.length === 1 && sub[0].semver === ANY$2)
27677 return dom.length === 1 && dom[0].semver === ANY$2
27678
27679 const eqSet = new Set();
27680 let gt, lt;
27681 for (const c of sub) {
27682 if (c.operator === '>' || c.operator === '>=')
27683 gt = higherGT(gt, c, options);
27684 else if (c.operator === '<' || c.operator === '<=')
27685 lt = lowerLT(lt, c, options);
27686 else
27687 eqSet.add(c.semver);
27688 }
27689
27690 if (eqSet.size > 1)
27691 return null
27692
27693 let gtltComp;
27694 if (gt && lt) {
27695 gtltComp = compare_1(gt.semver, lt.semver, options);
27696 if (gtltComp > 0)
27697 return null
27698 else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<='))
27699 return null
27700 }
27701
27702 // will iterate one or zero times
27703 for (const eq of eqSet) {
27704 if (gt && !satisfies_1(eq, String(gt), options))
27705 return null
27706
27707 if (lt && !satisfies_1(eq, String(lt), options))
27708 return null
27709
27710 for (const c of dom) {
27711 if (!satisfies_1(eq, String(c), options))
27712 return false
27713 }
27714
27715 return true
27716 }
27717
27718 let higher, lower;
27719 let hasDomLT, hasDomGT;
27720 for (const c of dom) {
27721 hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
27722 hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
27723 if (gt) {
27724 if (c.operator === '>' || c.operator === '>=') {
27725 higher = higherGT(gt, c, options);
27726 if (higher === c && higher !== gt)
27727 return false
27728 } else if (gt.operator === '>=' && !satisfies_1(gt.semver, String(c), options))
27729 return false
27730 }
27731 if (lt) {
27732 if (c.operator === '<' || c.operator === '<=') {
27733 lower = lowerLT(lt, c, options);
27734 if (lower === c && lower !== lt)
27735 return false
27736 } else if (lt.operator === '<=' && !satisfies_1(lt.semver, String(c), options))
27737 return false
27738 }
27739 if (!c.operator && (lt || gt) && gtltComp !== 0)
27740 return false
27741 }
27742
27743 // if there was a < or >, and nothing in the dom, then must be false
27744 // UNLESS it was limited by another range in the other direction.
27745 // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
27746 if (gt && hasDomLT && !lt && gtltComp !== 0)
27747 return false
27748
27749 if (lt && hasDomGT && !gt && gtltComp !== 0)
27750 return false
27751
27752 return true
27753};
27754
27755// >=1.2.3 is lower than >1.2.3
27756const higherGT = (a, b, options) => {
27757 if (!a)
27758 return b
27759 const comp = compare_1(a.semver, b.semver, options);
27760 return comp > 0 ? a
27761 : comp < 0 ? b
27762 : b.operator === '>' && a.operator === '>=' ? b
27763 : a
27764};
27765
27766// <=1.2.3 is higher than <1.2.3
27767const lowerLT = (a, b, options) => {
27768 if (!a)
27769 return b
27770 const comp = compare_1(a.semver, b.semver, options);
27771 return comp < 0 ? a
27772 : comp > 0 ? b
27773 : b.operator === '<' && a.operator === '<=' ? b
27774 : a
27775};
27776
27777var subset_1 = subset;
27778
27779// just pre-load all the stuff that index.js lazily exports
27780
27781var semver$1 = {
27782 re: re_1.re,
27783 src: re_1.src,
27784 tokens: re_1.t,
27785 SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
27786 SemVer: semver,
27787 compareIdentifiers: identifiers.compareIdentifiers,
27788 rcompareIdentifiers: identifiers.rcompareIdentifiers,
27789 parse: parse_1,
27790 valid: valid_1,
27791 clean: clean_1,
27792 inc: inc_1,
27793 diff: diff_1,
27794 major: major_1,
27795 minor: minor_1,
27796 patch: patch_1,
27797 prerelease: prerelease_1,
27798 compare: compare_1,
27799 rcompare: rcompare_1,
27800 compareLoose: compareLoose_1,
27801 compareBuild: compareBuild_1,
27802 sort: sort_1,
27803 rsort: rsort_1,
27804 gt: gt_1,
27805 lt: lt_1,
27806 eq: eq_1$1,
27807 neq: neq_1,
27808 gte: gte_1,
27809 lte: lte_1,
27810 cmp: cmp_1,
27811 coerce: coerce_1,
27812 Comparator: comparator,
27813 Range: range,
27814 satisfies: satisfies_1,
27815 toComparators: toComparators_1,
27816 maxSatisfying: maxSatisfying_1,
27817 minSatisfying: minSatisfying_1,
27818 minVersion: minVersion_1,
27819 validRange: valid$1,
27820 outside: outside_1,
27821 gtr: gtr_1,
27822 ltr: ltr_1,
27823 intersects: intersects_1,
27824 simplifyRange: simplify,
27825 subset: subset_1,
27826};
27827
27828var commondir = function (basedir, relfiles) {
27829 if (relfiles) {
27830 var files = relfiles.map(function (r) {
27831 return path.resolve(basedir, r);
27832 });
27833 }
27834 else {
27835 var files = basedir;
27836 }
27837
27838 var res = files.slice(1).reduce(function (ps, file) {
27839 if (!file.match(/^([A-Za-z]:)?\/|\\/)) {
27840 throw new Error('relative path without a basedir');
27841 }
27842
27843 var xs = file.split(/\/+|\\+/);
27844 for (
27845 var i = 0;
27846 ps[i] === xs[i] && i < Math.min(ps.length, xs.length);
27847 i++
27848 );
27849 return ps.slice(0, i);
27850 }, files[0].split(/\/+|\\+/));
27851
27852 // Windows correctly handles paths with forward-slashes
27853 return res.length > 1 ? res.join('/') : '/'
27854};
27855
27856const pTry = (fn, ...arguments_) => new Promise(resolve => {
27857 resolve(fn(...arguments_));
27858});
27859
27860var pTry_1 = pTry;
27861// TODO: remove this in the next major version
27862var _default = pTry;
27863pTry_1.default = _default;
27864
27865const pLimit = concurrency => {
27866 if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
27867 return Promise.reject(new TypeError('Expected `concurrency` to be a number from 1 and up'));
27868 }
27869
27870 const queue = [];
27871 let activeCount = 0;
27872
27873 const next = () => {
27874 activeCount--;
27875
27876 if (queue.length > 0) {
27877 queue.shift()();
27878 }
27879 };
27880
27881 const run = (fn, resolve, ...args) => {
27882 activeCount++;
27883
27884 const result = pTry_1(fn, ...args);
27885
27886 resolve(result);
27887
27888 result.then(next, next);
27889 };
27890
27891 const enqueue = (fn, resolve, ...args) => {
27892 if (activeCount < concurrency) {
27893 run(fn, resolve, ...args);
27894 } else {
27895 queue.push(run.bind(null, fn, resolve, ...args));
27896 }
27897 };
27898
27899 const generator = (fn, ...args) => new Promise(resolve => enqueue(fn, resolve, ...args));
27900 Object.defineProperties(generator, {
27901 activeCount: {
27902 get: () => activeCount
27903 },
27904 pendingCount: {
27905 get: () => queue.length
27906 }
27907 });
27908
27909 return generator;
27910};
27911
27912var pLimit_1 = pLimit;
27913var _default$1 = pLimit;
27914pLimit_1.default = _default$1;
27915
27916class EndError extends Error {
27917 constructor(value) {
27918 super();
27919 this.value = value;
27920 }
27921}
27922
27923// The input can also be a promise, so we await it
27924const testElement = async (element, tester) => tester(await element);
27925
27926// The input can also be a promise, so we `Promise.all()` them both
27927const finder = async element => {
27928 const values = await Promise.all(element);
27929 if (values[1] === true) {
27930 throw new EndError(values[0]);
27931 }
27932
27933 return false;
27934};
27935
27936const pLocate = async (iterable, tester, options) => {
27937 options = {
27938 concurrency: Infinity,
27939 preserveOrder: true,
27940 ...options
27941 };
27942
27943 const limit = pLimit_1(options.concurrency);
27944
27945 // Start all the promises concurrently with optional limit
27946 const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
27947
27948 // Check the promises either serially or concurrently
27949 const checkLimit = pLimit_1(options.preserveOrder ? 1 : Infinity);
27950
27951 try {
27952 await Promise.all(items.map(element => checkLimit(finder, element)));
27953 } catch (error) {
27954 if (error instanceof EndError) {
27955 return error.value;
27956 }
27957
27958 throw error;
27959 }
27960};
27961
27962var pLocate_1 = pLocate;
27963// TODO: Remove this for the next major release
27964var _default$2 = pLocate;
27965pLocate_1.default = _default$2;
27966
27967const {promisify} = require$$0;
27968
27969
27970const fsStat = promisify(fs.stat);
27971const fsLStat = promisify(fs.lstat);
27972
27973const typeMappings = {
27974 directory: 'isDirectory',
27975 file: 'isFile'
27976};
27977
27978function checkType({type}) {
27979 if (type in typeMappings) {
27980 return;
27981 }
27982
27983 throw new Error(`Invalid type specified: ${type}`);
27984}
27985
27986const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
27987
27988var locatePath = async (paths, options) => {
27989 options = {
27990 cwd: process.cwd(),
27991 type: 'file',
27992 allowSymlinks: true,
27993 ...options
27994 };
27995 checkType(options);
27996 const statFn = options.allowSymlinks ? fsStat : fsLStat;
27997
27998 return pLocate_1(paths, async path_ => {
27999 try {
28000 const stat = await statFn(path.resolve(options.cwd, path_));
28001 return matchType(options.type, stat);
28002 } catch (_) {
28003 return false;
28004 }
28005 }, options);
28006};
28007
28008var sync = (paths, options) => {
28009 options = {
28010 cwd: process.cwd(),
28011 allowSymlinks: true,
28012 type: 'file',
28013 ...options
28014 };
28015 checkType(options);
28016 const statFn = options.allowSymlinks ? fs.statSync : fs.lstatSync;
28017
28018 for (const path_ of paths) {
28019 try {
28020 const stat = statFn(path.resolve(options.cwd, path_));
28021
28022 if (matchType(options.type, stat)) {
28023 return path_;
28024 }
28025 } catch (_) {
28026 }
28027 }
28028};
28029locatePath.sync = sync;
28030
28031const {promisify: promisify$1} = require$$0;
28032
28033const pAccess = promisify$1(fs.access);
28034
28035var pathExists = async path => {
28036 try {
28037 await pAccess(path);
28038 return true;
28039 } catch (_) {
28040 return false;
28041 }
28042};
28043
28044var sync$1 = path => {
28045 try {
28046 fs.accessSync(path);
28047 return true;
28048 } catch (_) {
28049 return false;
28050 }
28051};
28052pathExists.sync = sync$1;
28053
28054var findUp = createCommonjsModule(function (module) {
28055
28056
28057
28058
28059const stop = Symbol('findUp.stop');
28060
28061module.exports = async (name, options = {}) => {
28062 let directory = path.resolve(options.cwd || '');
28063 const {root} = path.parse(directory);
28064 const paths = [].concat(name);
28065
28066 const runMatcher = async locateOptions => {
28067 if (typeof name !== 'function') {
28068 return locatePath(paths, locateOptions);
28069 }
28070
28071 const foundPath = await name(locateOptions.cwd);
28072 if (typeof foundPath === 'string') {
28073 return locatePath([foundPath], locateOptions);
28074 }
28075
28076 return foundPath;
28077 };
28078
28079 // eslint-disable-next-line no-constant-condition
28080 while (true) {
28081 // eslint-disable-next-line no-await-in-loop
28082 const foundPath = await runMatcher({...options, cwd: directory});
28083
28084 if (foundPath === stop) {
28085 return;
28086 }
28087
28088 if (foundPath) {
28089 return path.resolve(directory, foundPath);
28090 }
28091
28092 if (directory === root) {
28093 return;
28094 }
28095
28096 directory = path.dirname(directory);
28097 }
28098};
28099
28100module.exports.sync = (name, options = {}) => {
28101 let directory = path.resolve(options.cwd || '');
28102 const {root} = path.parse(directory);
28103 const paths = [].concat(name);
28104
28105 const runMatcher = locateOptions => {
28106 if (typeof name !== 'function') {
28107 return locatePath.sync(paths, locateOptions);
28108 }
28109
28110 const foundPath = name(locateOptions.cwd);
28111 if (typeof foundPath === 'string') {
28112 return locatePath.sync([foundPath], locateOptions);
28113 }
28114
28115 return foundPath;
28116 };
28117
28118 // eslint-disable-next-line no-constant-condition
28119 while (true) {
28120 const foundPath = runMatcher({...options, cwd: directory});
28121
28122 if (foundPath === stop) {
28123 return;
28124 }
28125
28126 if (foundPath) {
28127 return path.resolve(directory, foundPath);
28128 }
28129
28130 if (directory === root) {
28131 return;
28132 }
28133
28134 directory = path.dirname(directory);
28135 }
28136};
28137
28138module.exports.exists = pathExists;
28139
28140module.exports.sync.exists = pathExists.sync;
28141
28142module.exports.stop = stop;
28143});
28144
28145const pkgDir = async cwd => {
28146 const filePath = await findUp('package.json', {cwd});
28147 return filePath && path.dirname(filePath);
28148};
28149
28150var pkgDir_1 = pkgDir;
28151// TODO: Remove this for the next major release
28152var _default$3 = pkgDir;
28153
28154var sync$2 = cwd => {
28155 const filePath = findUp.sync('package.json', {cwd});
28156 return filePath && path.dirname(filePath);
28157};
28158pkgDir_1.default = _default$3;
28159pkgDir_1.sync = sync$2;
28160
28161var semver$2 = createCommonjsModule(function (module, exports) {
28162exports = module.exports = SemVer;
28163
28164var debug;
28165/* istanbul ignore next */
28166if (typeof process === 'object' &&
28167 process.env &&
28168 process.env.NODE_DEBUG &&
28169 /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
28170 debug = function () {
28171 var args = Array.prototype.slice.call(arguments, 0);
28172 args.unshift('SEMVER');
28173 console.log.apply(console, args);
28174 };
28175} else {
28176 debug = function () {};
28177}
28178
28179// Note: this is the semver.org version of the spec that it implements
28180// Not necessarily the package version of this code.
28181exports.SEMVER_SPEC_VERSION = '2.0.0';
28182
28183var MAX_LENGTH = 256;
28184var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
28185 /* istanbul ignore next */ 9007199254740991;
28186
28187// Max safe segment length for coercion.
28188var MAX_SAFE_COMPONENT_LENGTH = 16;
28189
28190// The actual regexps go on exports.re
28191var re = exports.re = [];
28192var src = exports.src = [];
28193var t = exports.tokens = {};
28194var R = 0;
28195
28196function tok (n) {
28197 t[n] = R++;
28198}
28199
28200// The following Regular Expressions can be used for tokenizing,
28201// validating, and parsing SemVer version strings.
28202
28203// ## Numeric Identifier
28204// A single `0`, or a non-zero digit followed by zero or more digits.
28205
28206tok('NUMERICIDENTIFIER');
28207src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
28208tok('NUMERICIDENTIFIERLOOSE');
28209src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
28210
28211// ## Non-numeric Identifier
28212// Zero or more digits, followed by a letter or hyphen, and then zero or
28213// more letters, digits, or hyphens.
28214
28215tok('NONNUMERICIDENTIFIER');
28216src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
28217
28218// ## Main Version
28219// Three dot-separated numeric identifiers.
28220
28221tok('MAINVERSION');
28222src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
28223 '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
28224 '(' + src[t.NUMERICIDENTIFIER] + ')';
28225
28226tok('MAINVERSIONLOOSE');
28227src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
28228 '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
28229 '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
28230
28231// ## Pre-release Version Identifier
28232// A numeric identifier, or a non-numeric identifier.
28233
28234tok('PRERELEASEIDENTIFIER');
28235src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
28236 '|' + src[t.NONNUMERICIDENTIFIER] + ')';
28237
28238tok('PRERELEASEIDENTIFIERLOOSE');
28239src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
28240 '|' + src[t.NONNUMERICIDENTIFIER] + ')';
28241
28242// ## Pre-release Version
28243// Hyphen, followed by one or more dot-separated pre-release version
28244// identifiers.
28245
28246tok('PRERELEASE');
28247src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
28248 '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
28249
28250tok('PRERELEASELOOSE');
28251src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
28252 '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
28253
28254// ## Build Metadata Identifier
28255// Any combination of digits, letters, or hyphens.
28256
28257tok('BUILDIDENTIFIER');
28258src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
28259
28260// ## Build Metadata
28261// Plus sign, followed by one or more period-separated build metadata
28262// identifiers.
28263
28264tok('BUILD');
28265src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
28266 '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
28267
28268// ## Full Version String
28269// A main version, followed optionally by a pre-release version and
28270// build metadata.
28271
28272// Note that the only major, minor, patch, and pre-release sections of
28273// the version string are capturing groups. The build metadata is not a
28274// capturing group, because it should not ever be used in version
28275// comparison.
28276
28277tok('FULL');
28278tok('FULLPLAIN');
28279src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
28280 src[t.PRERELEASE] + '?' +
28281 src[t.BUILD] + '?';
28282
28283src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
28284
28285// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
28286// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
28287// common in the npm registry.
28288tok('LOOSEPLAIN');
28289src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
28290 src[t.PRERELEASELOOSE] + '?' +
28291 src[t.BUILD] + '?';
28292
28293tok('LOOSE');
28294src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
28295
28296tok('GTLT');
28297src[t.GTLT] = '((?:<|>)?=?)';
28298
28299// Something like "2.*" or "1.2.x".
28300// Note that "x.x" is a valid xRange identifer, meaning "any version"
28301// Only the first item is strictly required.
28302tok('XRANGEIDENTIFIERLOOSE');
28303src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
28304tok('XRANGEIDENTIFIER');
28305src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
28306
28307tok('XRANGEPLAIN');
28308src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
28309 '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
28310 '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
28311 '(?:' + src[t.PRERELEASE] + ')?' +
28312 src[t.BUILD] + '?' +
28313 ')?)?';
28314
28315tok('XRANGEPLAINLOOSE');
28316src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
28317 '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
28318 '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
28319 '(?:' + src[t.PRERELEASELOOSE] + ')?' +
28320 src[t.BUILD] + '?' +
28321 ')?)?';
28322
28323tok('XRANGE');
28324src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
28325tok('XRANGELOOSE');
28326src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
28327
28328// Coercion.
28329// Extract anything that could conceivably be a part of a valid semver
28330tok('COERCE');
28331src[t.COERCE] = '(^|[^\\d])' +
28332 '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
28333 '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
28334 '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
28335 '(?:$|[^\\d])';
28336tok('COERCERTL');
28337re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
28338
28339// Tilde ranges.
28340// Meaning is "reasonably at or greater than"
28341tok('LONETILDE');
28342src[t.LONETILDE] = '(?:~>?)';
28343
28344tok('TILDETRIM');
28345src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
28346re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
28347var tildeTrimReplace = '$1~';
28348
28349tok('TILDE');
28350src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
28351tok('TILDELOOSE');
28352src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
28353
28354// Caret ranges.
28355// Meaning is "at least and backwards compatible with"
28356tok('LONECARET');
28357src[t.LONECARET] = '(?:\\^)';
28358
28359tok('CARETTRIM');
28360src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
28361re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
28362var caretTrimReplace = '$1^';
28363
28364tok('CARET');
28365src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
28366tok('CARETLOOSE');
28367src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
28368
28369// A simple gt/lt/eq thing, or just "" to indicate "any version"
28370tok('COMPARATORLOOSE');
28371src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
28372tok('COMPARATOR');
28373src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
28374
28375// An expression to strip any whitespace between the gtlt and the thing
28376// it modifies, so that `> 1.2.3` ==> `>1.2.3`
28377tok('COMPARATORTRIM');
28378src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
28379 '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
28380
28381// this one has to use the /g flag
28382re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
28383var comparatorTrimReplace = '$1$2$3';
28384
28385// Something like `1.2.3 - 1.2.4`
28386// Note that these all use the loose form, because they'll be
28387// checked against either the strict or loose comparator form
28388// later.
28389tok('HYPHENRANGE');
28390src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
28391 '\\s+-\\s+' +
28392 '(' + src[t.XRANGEPLAIN] + ')' +
28393 '\\s*$';
28394
28395tok('HYPHENRANGELOOSE');
28396src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
28397 '\\s+-\\s+' +
28398 '(' + src[t.XRANGEPLAINLOOSE] + ')' +
28399 '\\s*$';
28400
28401// Star ranges basically just allow anything at all.
28402tok('STAR');
28403src[t.STAR] = '(<|>)?=?\\s*\\*';
28404
28405// Compile to actual regexp objects.
28406// All are flag-free, unless they were created above with a flag.
28407for (var i = 0; i < R; i++) {
28408 debug(i, src[i]);
28409 if (!re[i]) {
28410 re[i] = new RegExp(src[i]);
28411 }
28412}
28413
28414exports.parse = parse;
28415function parse (version, options) {
28416 if (!options || typeof options !== 'object') {
28417 options = {
28418 loose: !!options,
28419 includePrerelease: false
28420 };
28421 }
28422
28423 if (version instanceof SemVer) {
28424 return version
28425 }
28426
28427 if (typeof version !== 'string') {
28428 return null
28429 }
28430
28431 if (version.length > MAX_LENGTH) {
28432 return null
28433 }
28434
28435 var r = options.loose ? re[t.LOOSE] : re[t.FULL];
28436 if (!r.test(version)) {
28437 return null
28438 }
28439
28440 try {
28441 return new SemVer(version, options)
28442 } catch (er) {
28443 return null
28444 }
28445}
28446
28447exports.valid = valid;
28448function valid (version, options) {
28449 var v = parse(version, options);
28450 return v ? v.version : null
28451}
28452
28453exports.clean = clean;
28454function clean (version, options) {
28455 var s = parse(version.trim().replace(/^[=v]+/, ''), options);
28456 return s ? s.version : null
28457}
28458
28459exports.SemVer = SemVer;
28460
28461function SemVer (version, options) {
28462 if (!options || typeof options !== 'object') {
28463 options = {
28464 loose: !!options,
28465 includePrerelease: false
28466 };
28467 }
28468 if (version instanceof SemVer) {
28469 if (version.loose === options.loose) {
28470 return version
28471 } else {
28472 version = version.version;
28473 }
28474 } else if (typeof version !== 'string') {
28475 throw new TypeError('Invalid Version: ' + version)
28476 }
28477
28478 if (version.length > MAX_LENGTH) {
28479 throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
28480 }
28481
28482 if (!(this instanceof SemVer)) {
28483 return new SemVer(version, options)
28484 }
28485
28486 debug('SemVer', version, options);
28487 this.options = options;
28488 this.loose = !!options.loose;
28489
28490 var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
28491
28492 if (!m) {
28493 throw new TypeError('Invalid Version: ' + version)
28494 }
28495
28496 this.raw = version;
28497
28498 // these are actually numbers
28499 this.major = +m[1];
28500 this.minor = +m[2];
28501 this.patch = +m[3];
28502
28503 if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
28504 throw new TypeError('Invalid major version')
28505 }
28506
28507 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
28508 throw new TypeError('Invalid minor version')
28509 }
28510
28511 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
28512 throw new TypeError('Invalid patch version')
28513 }
28514
28515 // numberify any prerelease numeric ids
28516 if (!m[4]) {
28517 this.prerelease = [];
28518 } else {
28519 this.prerelease = m[4].split('.').map(function (id) {
28520 if (/^[0-9]+$/.test(id)) {
28521 var num = +id;
28522 if (num >= 0 && num < MAX_SAFE_INTEGER) {
28523 return num
28524 }
28525 }
28526 return id
28527 });
28528 }
28529
28530 this.build = m[5] ? m[5].split('.') : [];
28531 this.format();
28532}
28533
28534SemVer.prototype.format = function () {
28535 this.version = this.major + '.' + this.minor + '.' + this.patch;
28536 if (this.prerelease.length) {
28537 this.version += '-' + this.prerelease.join('.');
28538 }
28539 return this.version
28540};
28541
28542SemVer.prototype.toString = function () {
28543 return this.version
28544};
28545
28546SemVer.prototype.compare = function (other) {
28547 debug('SemVer.compare', this.version, this.options, other);
28548 if (!(other instanceof SemVer)) {
28549 other = new SemVer(other, this.options);
28550 }
28551
28552 return this.compareMain(other) || this.comparePre(other)
28553};
28554
28555SemVer.prototype.compareMain = function (other) {
28556 if (!(other instanceof SemVer)) {
28557 other = new SemVer(other, this.options);
28558 }
28559
28560 return compareIdentifiers(this.major, other.major) ||
28561 compareIdentifiers(this.minor, other.minor) ||
28562 compareIdentifiers(this.patch, other.patch)
28563};
28564
28565SemVer.prototype.comparePre = function (other) {
28566 if (!(other instanceof SemVer)) {
28567 other = new SemVer(other, this.options);
28568 }
28569
28570 // NOT having a prerelease is > having one
28571 if (this.prerelease.length && !other.prerelease.length) {
28572 return -1
28573 } else if (!this.prerelease.length && other.prerelease.length) {
28574 return 1
28575 } else if (!this.prerelease.length && !other.prerelease.length) {
28576 return 0
28577 }
28578
28579 var i = 0;
28580 do {
28581 var a = this.prerelease[i];
28582 var b = other.prerelease[i];
28583 debug('prerelease compare', i, a, b);
28584 if (a === undefined && b === undefined) {
28585 return 0
28586 } else if (b === undefined) {
28587 return 1
28588 } else if (a === undefined) {
28589 return -1
28590 } else if (a === b) {
28591 continue
28592 } else {
28593 return compareIdentifiers(a, b)
28594 }
28595 } while (++i)
28596};
28597
28598SemVer.prototype.compareBuild = function (other) {
28599 if (!(other instanceof SemVer)) {
28600 other = new SemVer(other, this.options);
28601 }
28602
28603 var i = 0;
28604 do {
28605 var a = this.build[i];
28606 var b = other.build[i];
28607 debug('prerelease compare', i, a, b);
28608 if (a === undefined && b === undefined) {
28609 return 0
28610 } else if (b === undefined) {
28611 return 1
28612 } else if (a === undefined) {
28613 return -1
28614 } else if (a === b) {
28615 continue
28616 } else {
28617 return compareIdentifiers(a, b)
28618 }
28619 } while (++i)
28620};
28621
28622// preminor will bump the version up to the next minor release, and immediately
28623// down to pre-release. premajor and prepatch work the same way.
28624SemVer.prototype.inc = function (release, identifier) {
28625 switch (release) {
28626 case 'premajor':
28627 this.prerelease.length = 0;
28628 this.patch = 0;
28629 this.minor = 0;
28630 this.major++;
28631 this.inc('pre', identifier);
28632 break
28633 case 'preminor':
28634 this.prerelease.length = 0;
28635 this.patch = 0;
28636 this.minor++;
28637 this.inc('pre', identifier);
28638 break
28639 case 'prepatch':
28640 // If this is already a prerelease, it will bump to the next version
28641 // drop any prereleases that might already exist, since they are not
28642 // relevant at this point.
28643 this.prerelease.length = 0;
28644 this.inc('patch', identifier);
28645 this.inc('pre', identifier);
28646 break
28647 // If the input is a non-prerelease version, this acts the same as
28648 // prepatch.
28649 case 'prerelease':
28650 if (this.prerelease.length === 0) {
28651 this.inc('patch', identifier);
28652 }
28653 this.inc('pre', identifier);
28654 break
28655
28656 case 'major':
28657 // If this is a pre-major version, bump up to the same major version.
28658 // Otherwise increment major.
28659 // 1.0.0-5 bumps to 1.0.0
28660 // 1.1.0 bumps to 2.0.0
28661 if (this.minor !== 0 ||
28662 this.patch !== 0 ||
28663 this.prerelease.length === 0) {
28664 this.major++;
28665 }
28666 this.minor = 0;
28667 this.patch = 0;
28668 this.prerelease = [];
28669 break
28670 case 'minor':
28671 // If this is a pre-minor version, bump up to the same minor version.
28672 // Otherwise increment minor.
28673 // 1.2.0-5 bumps to 1.2.0
28674 // 1.2.1 bumps to 1.3.0
28675 if (this.patch !== 0 || this.prerelease.length === 0) {
28676 this.minor++;
28677 }
28678 this.patch = 0;
28679 this.prerelease = [];
28680 break
28681 case 'patch':
28682 // If this is not a pre-release version, it will increment the patch.
28683 // If it is a pre-release it will bump up to the same patch version.
28684 // 1.2.0-5 patches to 1.2.0
28685 // 1.2.0 patches to 1.2.1
28686 if (this.prerelease.length === 0) {
28687 this.patch++;
28688 }
28689 this.prerelease = [];
28690 break
28691 // This probably shouldn't be used publicly.
28692 // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
28693 case 'pre':
28694 if (this.prerelease.length === 0) {
28695 this.prerelease = [0];
28696 } else {
28697 var i = this.prerelease.length;
28698 while (--i >= 0) {
28699 if (typeof this.prerelease[i] === 'number') {
28700 this.prerelease[i]++;
28701 i = -2;
28702 }
28703 }
28704 if (i === -1) {
28705 // didn't increment anything
28706 this.prerelease.push(0);
28707 }
28708 }
28709 if (identifier) {
28710 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
28711 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
28712 if (this.prerelease[0] === identifier) {
28713 if (isNaN(this.prerelease[1])) {
28714 this.prerelease = [identifier, 0];
28715 }
28716 } else {
28717 this.prerelease = [identifier, 0];
28718 }
28719 }
28720 break
28721
28722 default:
28723 throw new Error('invalid increment argument: ' + release)
28724 }
28725 this.format();
28726 this.raw = this.version;
28727 return this
28728};
28729
28730exports.inc = inc;
28731function inc (version, release, loose, identifier) {
28732 if (typeof (loose) === 'string') {
28733 identifier = loose;
28734 loose = undefined;
28735 }
28736
28737 try {
28738 return new SemVer(version, loose).inc(release, identifier).version
28739 } catch (er) {
28740 return null
28741 }
28742}
28743
28744exports.diff = diff;
28745function diff (version1, version2) {
28746 if (eq(version1, version2)) {
28747 return null
28748 } else {
28749 var v1 = parse(version1);
28750 var v2 = parse(version2);
28751 var prefix = '';
28752 if (v1.prerelease.length || v2.prerelease.length) {
28753 prefix = 'pre';
28754 var defaultResult = 'prerelease';
28755 }
28756 for (var key in v1) {
28757 if (key === 'major' || key === 'minor' || key === 'patch') {
28758 if (v1[key] !== v2[key]) {
28759 return prefix + key
28760 }
28761 }
28762 }
28763 return defaultResult // may be undefined
28764 }
28765}
28766
28767exports.compareIdentifiers = compareIdentifiers;
28768
28769var numeric = /^[0-9]+$/;
28770function compareIdentifiers (a, b) {
28771 var anum = numeric.test(a);
28772 var bnum = numeric.test(b);
28773
28774 if (anum && bnum) {
28775 a = +a;
28776 b = +b;
28777 }
28778
28779 return a === b ? 0
28780 : (anum && !bnum) ? -1
28781 : (bnum && !anum) ? 1
28782 : a < b ? -1
28783 : 1
28784}
28785
28786exports.rcompareIdentifiers = rcompareIdentifiers;
28787function rcompareIdentifiers (a, b) {
28788 return compareIdentifiers(b, a)
28789}
28790
28791exports.major = major;
28792function major (a, loose) {
28793 return new SemVer(a, loose).major
28794}
28795
28796exports.minor = minor;
28797function minor (a, loose) {
28798 return new SemVer(a, loose).minor
28799}
28800
28801exports.patch = patch;
28802function patch (a, loose) {
28803 return new SemVer(a, loose).patch
28804}
28805
28806exports.compare = compare;
28807function compare (a, b, loose) {
28808 return new SemVer(a, loose).compare(new SemVer(b, loose))
28809}
28810
28811exports.compareLoose = compareLoose;
28812function compareLoose (a, b) {
28813 return compare(a, b, true)
28814}
28815
28816exports.compareBuild = compareBuild;
28817function compareBuild (a, b, loose) {
28818 var versionA = new SemVer(a, loose);
28819 var versionB = new SemVer(b, loose);
28820 return versionA.compare(versionB) || versionA.compareBuild(versionB)
28821}
28822
28823exports.rcompare = rcompare;
28824function rcompare (a, b, loose) {
28825 return compare(b, a, loose)
28826}
28827
28828exports.sort = sort;
28829function sort (list, loose) {
28830 return list.sort(function (a, b) {
28831 return exports.compareBuild(a, b, loose)
28832 })
28833}
28834
28835exports.rsort = rsort;
28836function rsort (list, loose) {
28837 return list.sort(function (a, b) {
28838 return exports.compareBuild(b, a, loose)
28839 })
28840}
28841
28842exports.gt = gt;
28843function gt (a, b, loose) {
28844 return compare(a, b, loose) > 0
28845}
28846
28847exports.lt = lt;
28848function lt (a, b, loose) {
28849 return compare(a, b, loose) < 0
28850}
28851
28852exports.eq = eq;
28853function eq (a, b, loose) {
28854 return compare(a, b, loose) === 0
28855}
28856
28857exports.neq = neq;
28858function neq (a, b, loose) {
28859 return compare(a, b, loose) !== 0
28860}
28861
28862exports.gte = gte;
28863function gte (a, b, loose) {
28864 return compare(a, b, loose) >= 0
28865}
28866
28867exports.lte = lte;
28868function lte (a, b, loose) {
28869 return compare(a, b, loose) <= 0
28870}
28871
28872exports.cmp = cmp;
28873function cmp (a, op, b, loose) {
28874 switch (op) {
28875 case '===':
28876 if (typeof a === 'object')
28877 a = a.version;
28878 if (typeof b === 'object')
28879 b = b.version;
28880 return a === b
28881
28882 case '!==':
28883 if (typeof a === 'object')
28884 a = a.version;
28885 if (typeof b === 'object')
28886 b = b.version;
28887 return a !== b
28888
28889 case '':
28890 case '=':
28891 case '==':
28892 return eq(a, b, loose)
28893
28894 case '!=':
28895 return neq(a, b, loose)
28896
28897 case '>':
28898 return gt(a, b, loose)
28899
28900 case '>=':
28901 return gte(a, b, loose)
28902
28903 case '<':
28904 return lt(a, b, loose)
28905
28906 case '<=':
28907 return lte(a, b, loose)
28908
28909 default:
28910 throw new TypeError('Invalid operator: ' + op)
28911 }
28912}
28913
28914exports.Comparator = Comparator;
28915function Comparator (comp, options) {
28916 if (!options || typeof options !== 'object') {
28917 options = {
28918 loose: !!options,
28919 includePrerelease: false
28920 };
28921 }
28922
28923 if (comp instanceof Comparator) {
28924 if (comp.loose === !!options.loose) {
28925 return comp
28926 } else {
28927 comp = comp.value;
28928 }
28929 }
28930
28931 if (!(this instanceof Comparator)) {
28932 return new Comparator(comp, options)
28933 }
28934
28935 debug('comparator', comp, options);
28936 this.options = options;
28937 this.loose = !!options.loose;
28938 this.parse(comp);
28939
28940 if (this.semver === ANY) {
28941 this.value = '';
28942 } else {
28943 this.value = this.operator + this.semver.version;
28944 }
28945
28946 debug('comp', this);
28947}
28948
28949var ANY = {};
28950Comparator.prototype.parse = function (comp) {
28951 var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
28952 var m = comp.match(r);
28953
28954 if (!m) {
28955 throw new TypeError('Invalid comparator: ' + comp)
28956 }
28957
28958 this.operator = m[1] !== undefined ? m[1] : '';
28959 if (this.operator === '=') {
28960 this.operator = '';
28961 }
28962
28963 // if it literally is just '>' or '' then allow anything.
28964 if (!m[2]) {
28965 this.semver = ANY;
28966 } else {
28967 this.semver = new SemVer(m[2], this.options.loose);
28968 }
28969};
28970
28971Comparator.prototype.toString = function () {
28972 return this.value
28973};
28974
28975Comparator.prototype.test = function (version) {
28976 debug('Comparator.test', version, this.options.loose);
28977
28978 if (this.semver === ANY || version === ANY) {
28979 return true
28980 }
28981
28982 if (typeof version === 'string') {
28983 try {
28984 version = new SemVer(version, this.options);
28985 } catch (er) {
28986 return false
28987 }
28988 }
28989
28990 return cmp(version, this.operator, this.semver, this.options)
28991};
28992
28993Comparator.prototype.intersects = function (comp, options) {
28994 if (!(comp instanceof Comparator)) {
28995 throw new TypeError('a Comparator is required')
28996 }
28997
28998 if (!options || typeof options !== 'object') {
28999 options = {
29000 loose: !!options,
29001 includePrerelease: false
29002 };
29003 }
29004
29005 var rangeTmp;
29006
29007 if (this.operator === '') {
29008 if (this.value === '') {
29009 return true
29010 }
29011 rangeTmp = new Range(comp.value, options);
29012 return satisfies(this.value, rangeTmp, options)
29013 } else if (comp.operator === '') {
29014 if (comp.value === '') {
29015 return true
29016 }
29017 rangeTmp = new Range(this.value, options);
29018 return satisfies(comp.semver, rangeTmp, options)
29019 }
29020
29021 var sameDirectionIncreasing =
29022 (this.operator === '>=' || this.operator === '>') &&
29023 (comp.operator === '>=' || comp.operator === '>');
29024 var sameDirectionDecreasing =
29025 (this.operator === '<=' || this.operator === '<') &&
29026 (comp.operator === '<=' || comp.operator === '<');
29027 var sameSemVer = this.semver.version === comp.semver.version;
29028 var differentDirectionsInclusive =
29029 (this.operator === '>=' || this.operator === '<=') &&
29030 (comp.operator === '>=' || comp.operator === '<=');
29031 var oppositeDirectionsLessThan =
29032 cmp(this.semver, '<', comp.semver, options) &&
29033 ((this.operator === '>=' || this.operator === '>') &&
29034 (comp.operator === '<=' || comp.operator === '<'));
29035 var oppositeDirectionsGreaterThan =
29036 cmp(this.semver, '>', comp.semver, options) &&
29037 ((this.operator === '<=' || this.operator === '<') &&
29038 (comp.operator === '>=' || comp.operator === '>'));
29039
29040 return sameDirectionIncreasing || sameDirectionDecreasing ||
29041 (sameSemVer && differentDirectionsInclusive) ||
29042 oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
29043};
29044
29045exports.Range = Range;
29046function Range (range, options) {
29047 if (!options || typeof options !== 'object') {
29048 options = {
29049 loose: !!options,
29050 includePrerelease: false
29051 };
29052 }
29053
29054 if (range instanceof Range) {
29055 if (range.loose === !!options.loose &&
29056 range.includePrerelease === !!options.includePrerelease) {
29057 return range
29058 } else {
29059 return new Range(range.raw, options)
29060 }
29061 }
29062
29063 if (range instanceof Comparator) {
29064 return new Range(range.value, options)
29065 }
29066
29067 if (!(this instanceof Range)) {
29068 return new Range(range, options)
29069 }
29070
29071 this.options = options;
29072 this.loose = !!options.loose;
29073 this.includePrerelease = !!options.includePrerelease;
29074
29075 // First, split based on boolean or ||
29076 this.raw = range;
29077 this.set = range.split(/\s*\|\|\s*/).map(function (range) {
29078 return this.parseRange(range.trim())
29079 }, this).filter(function (c) {
29080 // throw out any that are not relevant for whatever reason
29081 return c.length
29082 });
29083
29084 if (!this.set.length) {
29085 throw new TypeError('Invalid SemVer Range: ' + range)
29086 }
29087
29088 this.format();
29089}
29090
29091Range.prototype.format = function () {
29092 this.range = this.set.map(function (comps) {
29093 return comps.join(' ').trim()
29094 }).join('||').trim();
29095 return this.range
29096};
29097
29098Range.prototype.toString = function () {
29099 return this.range
29100};
29101
29102Range.prototype.parseRange = function (range) {
29103 var loose = this.options.loose;
29104 range = range.trim();
29105 // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
29106 var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
29107 range = range.replace(hr, hyphenReplace);
29108 debug('hyphen replace', range);
29109 // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
29110 range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
29111 debug('comparator trim', range, re[t.COMPARATORTRIM]);
29112
29113 // `~ 1.2.3` => `~1.2.3`
29114 range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
29115
29116 // `^ 1.2.3` => `^1.2.3`
29117 range = range.replace(re[t.CARETTRIM], caretTrimReplace);
29118
29119 // normalize spaces
29120 range = range.split(/\s+/).join(' ');
29121
29122 // At this point, the range is completely trimmed and
29123 // ready to be split into comparators.
29124
29125 var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
29126 var set = range.split(' ').map(function (comp) {
29127 return parseComparator(comp, this.options)
29128 }, this).join(' ').split(/\s+/);
29129 if (this.options.loose) {
29130 // in loose mode, throw out any that are not valid comparators
29131 set = set.filter(function (comp) {
29132 return !!comp.match(compRe)
29133 });
29134 }
29135 set = set.map(function (comp) {
29136 return new Comparator(comp, this.options)
29137 }, this);
29138
29139 return set
29140};
29141
29142Range.prototype.intersects = function (range, options) {
29143 if (!(range instanceof Range)) {
29144 throw new TypeError('a Range is required')
29145 }
29146
29147 return this.set.some(function (thisComparators) {
29148 return (
29149 isSatisfiable(thisComparators, options) &&
29150 range.set.some(function (rangeComparators) {
29151 return (
29152 isSatisfiable(rangeComparators, options) &&
29153 thisComparators.every(function (thisComparator) {
29154 return rangeComparators.every(function (rangeComparator) {
29155 return thisComparator.intersects(rangeComparator, options)
29156 })
29157 })
29158 )
29159 })
29160 )
29161 })
29162};
29163
29164// take a set of comparators and determine whether there
29165// exists a version which can satisfy it
29166function isSatisfiable (comparators, options) {
29167 var result = true;
29168 var remainingComparators = comparators.slice();
29169 var testComparator = remainingComparators.pop();
29170
29171 while (result && remainingComparators.length) {
29172 result = remainingComparators.every(function (otherComparator) {
29173 return testComparator.intersects(otherComparator, options)
29174 });
29175
29176 testComparator = remainingComparators.pop();
29177 }
29178
29179 return result
29180}
29181
29182// Mostly just for testing and legacy API reasons
29183exports.toComparators = toComparators;
29184function toComparators (range, options) {
29185 return new Range(range, options).set.map(function (comp) {
29186 return comp.map(function (c) {
29187 return c.value
29188 }).join(' ').trim().split(' ')
29189 })
29190}
29191
29192// comprised of xranges, tildes, stars, and gtlt's at this point.
29193// already replaced the hyphen ranges
29194// turn into a set of JUST comparators.
29195function parseComparator (comp, options) {
29196 debug('comp', comp, options);
29197 comp = replaceCarets(comp, options);
29198 debug('caret', comp);
29199 comp = replaceTildes(comp, options);
29200 debug('tildes', comp);
29201 comp = replaceXRanges(comp, options);
29202 debug('xrange', comp);
29203 comp = replaceStars(comp, options);
29204 debug('stars', comp);
29205 return comp
29206}
29207
29208function isX (id) {
29209 return !id || id.toLowerCase() === 'x' || id === '*'
29210}
29211
29212// ~, ~> --> * (any, kinda silly)
29213// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
29214// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
29215// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
29216// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
29217// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
29218function replaceTildes (comp, options) {
29219 return comp.trim().split(/\s+/).map(function (comp) {
29220 return replaceTilde(comp, options)
29221 }).join(' ')
29222}
29223
29224function replaceTilde (comp, options) {
29225 var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
29226 return comp.replace(r, function (_, M, m, p, pr) {
29227 debug('tilde', comp, _, M, m, p, pr);
29228 var ret;
29229
29230 if (isX(M)) {
29231 ret = '';
29232 } else if (isX(m)) {
29233 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
29234 } else if (isX(p)) {
29235 // ~1.2 == >=1.2.0 <1.3.0
29236 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
29237 } else if (pr) {
29238 debug('replaceTilde pr', pr);
29239 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
29240 ' <' + M + '.' + (+m + 1) + '.0';
29241 } else {
29242 // ~1.2.3 == >=1.2.3 <1.3.0
29243 ret = '>=' + M + '.' + m + '.' + p +
29244 ' <' + M + '.' + (+m + 1) + '.0';
29245 }
29246
29247 debug('tilde return', ret);
29248 return ret
29249 })
29250}
29251
29252// ^ --> * (any, kinda silly)
29253// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
29254// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
29255// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
29256// ^1.2.3 --> >=1.2.3 <2.0.0
29257// ^1.2.0 --> >=1.2.0 <2.0.0
29258function replaceCarets (comp, options) {
29259 return comp.trim().split(/\s+/).map(function (comp) {
29260 return replaceCaret(comp, options)
29261 }).join(' ')
29262}
29263
29264function replaceCaret (comp, options) {
29265 debug('caret', comp, options);
29266 var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
29267 return comp.replace(r, function (_, M, m, p, pr) {
29268 debug('caret', comp, _, M, m, p, pr);
29269 var ret;
29270
29271 if (isX(M)) {
29272 ret = '';
29273 } else if (isX(m)) {
29274 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
29275 } else if (isX(p)) {
29276 if (M === '0') {
29277 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
29278 } else {
29279 ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
29280 }
29281 } else if (pr) {
29282 debug('replaceCaret pr', pr);
29283 if (M === '0') {
29284 if (m === '0') {
29285 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
29286 ' <' + M + '.' + m + '.' + (+p + 1);
29287 } else {
29288 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
29289 ' <' + M + '.' + (+m + 1) + '.0';
29290 }
29291 } else {
29292 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
29293 ' <' + (+M + 1) + '.0.0';
29294 }
29295 } else {
29296 debug('no pr');
29297 if (M === '0') {
29298 if (m === '0') {
29299 ret = '>=' + M + '.' + m + '.' + p +
29300 ' <' + M + '.' + m + '.' + (+p + 1);
29301 } else {
29302 ret = '>=' + M + '.' + m + '.' + p +
29303 ' <' + M + '.' + (+m + 1) + '.0';
29304 }
29305 } else {
29306 ret = '>=' + M + '.' + m + '.' + p +
29307 ' <' + (+M + 1) + '.0.0';
29308 }
29309 }
29310
29311 debug('caret return', ret);
29312 return ret
29313 })
29314}
29315
29316function replaceXRanges (comp, options) {
29317 debug('replaceXRanges', comp, options);
29318 return comp.split(/\s+/).map(function (comp) {
29319 return replaceXRange(comp, options)
29320 }).join(' ')
29321}
29322
29323function replaceXRange (comp, options) {
29324 comp = comp.trim();
29325 var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
29326 return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
29327 debug('xRange', comp, ret, gtlt, M, m, p, pr);
29328 var xM = isX(M);
29329 var xm = xM || isX(m);
29330 var xp = xm || isX(p);
29331 var anyX = xp;
29332
29333 if (gtlt === '=' && anyX) {
29334 gtlt = '';
29335 }
29336
29337 // if we're including prereleases in the match, then we need
29338 // to fix this to -0, the lowest possible prerelease value
29339 pr = options.includePrerelease ? '-0' : '';
29340
29341 if (xM) {
29342 if (gtlt === '>' || gtlt === '<') {
29343 // nothing is allowed
29344 ret = '<0.0.0-0';
29345 } else {
29346 // nothing is forbidden
29347 ret = '*';
29348 }
29349 } else if (gtlt && anyX) {
29350 // we know patch is an x, because we have any x at all.
29351 // replace X with 0
29352 if (xm) {
29353 m = 0;
29354 }
29355 p = 0;
29356
29357 if (gtlt === '>') {
29358 // >1 => >=2.0.0
29359 // >1.2 => >=1.3.0
29360 // >1.2.3 => >= 1.2.4
29361 gtlt = '>=';
29362 if (xm) {
29363 M = +M + 1;
29364 m = 0;
29365 p = 0;
29366 } else {
29367 m = +m + 1;
29368 p = 0;
29369 }
29370 } else if (gtlt === '<=') {
29371 // <=0.7.x is actually <0.8.0, since any 0.7.x should
29372 // pass. Similarly, <=7.x is actually <8.0.0, etc.
29373 gtlt = '<';
29374 if (xm) {
29375 M = +M + 1;
29376 } else {
29377 m = +m + 1;
29378 }
29379 }
29380
29381 ret = gtlt + M + '.' + m + '.' + p + pr;
29382 } else if (xm) {
29383 ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
29384 } else if (xp) {
29385 ret = '>=' + M + '.' + m + '.0' + pr +
29386 ' <' + M + '.' + (+m + 1) + '.0' + pr;
29387 }
29388
29389 debug('xRange return', ret);
29390
29391 return ret
29392 })
29393}
29394
29395// Because * is AND-ed with everything else in the comparator,
29396// and '' means "any version", just remove the *s entirely.
29397function replaceStars (comp, options) {
29398 debug('replaceStars', comp, options);
29399 // Looseness is ignored here. star is always as loose as it gets!
29400 return comp.trim().replace(re[t.STAR], '')
29401}
29402
29403// This function is passed to string.replace(re[t.HYPHENRANGE])
29404// M, m, patch, prerelease, build
29405// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
29406// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
29407// 1.2 - 3.4 => >=1.2.0 <3.5.0
29408function hyphenReplace ($0,
29409 from, fM, fm, fp, fpr, fb,
29410 to, tM, tm, tp, tpr, tb) {
29411 if (isX(fM)) {
29412 from = '';
29413 } else if (isX(fm)) {
29414 from = '>=' + fM + '.0.0';
29415 } else if (isX(fp)) {
29416 from = '>=' + fM + '.' + fm + '.0';
29417 } else {
29418 from = '>=' + from;
29419 }
29420
29421 if (isX(tM)) {
29422 to = '';
29423 } else if (isX(tm)) {
29424 to = '<' + (+tM + 1) + '.0.0';
29425 } else if (isX(tp)) {
29426 to = '<' + tM + '.' + (+tm + 1) + '.0';
29427 } else if (tpr) {
29428 to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
29429 } else {
29430 to = '<=' + to;
29431 }
29432
29433 return (from + ' ' + to).trim()
29434}
29435
29436// if ANY of the sets match ALL of its comparators, then pass
29437Range.prototype.test = function (version) {
29438 if (!version) {
29439 return false
29440 }
29441
29442 if (typeof version === 'string') {
29443 try {
29444 version = new SemVer(version, this.options);
29445 } catch (er) {
29446 return false
29447 }
29448 }
29449
29450 for (var i = 0; i < this.set.length; i++) {
29451 if (testSet(this.set[i], version, this.options)) {
29452 return true
29453 }
29454 }
29455 return false
29456};
29457
29458function testSet (set, version, options) {
29459 for (var i = 0; i < set.length; i++) {
29460 if (!set[i].test(version)) {
29461 return false
29462 }
29463 }
29464
29465 if (version.prerelease.length && !options.includePrerelease) {
29466 // Find the set of versions that are allowed to have prereleases
29467 // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
29468 // That should allow `1.2.3-pr.2` to pass.
29469 // However, `1.2.4-alpha.notready` should NOT be allowed,
29470 // even though it's within the range set by the comparators.
29471 for (i = 0; i < set.length; i++) {
29472 debug(set[i].semver);
29473 if (set[i].semver === ANY) {
29474 continue
29475 }
29476
29477 if (set[i].semver.prerelease.length > 0) {
29478 var allowed = set[i].semver;
29479 if (allowed.major === version.major &&
29480 allowed.minor === version.minor &&
29481 allowed.patch === version.patch) {
29482 return true
29483 }
29484 }
29485 }
29486
29487 // Version has a -pre, but it's not one of the ones we like.
29488 return false
29489 }
29490
29491 return true
29492}
29493
29494exports.satisfies = satisfies;
29495function satisfies (version, range, options) {
29496 try {
29497 range = new Range(range, options);
29498 } catch (er) {
29499 return false
29500 }
29501 return range.test(version)
29502}
29503
29504exports.maxSatisfying = maxSatisfying;
29505function maxSatisfying (versions, range, options) {
29506 var max = null;
29507 var maxSV = null;
29508 try {
29509 var rangeObj = new Range(range, options);
29510 } catch (er) {
29511 return null
29512 }
29513 versions.forEach(function (v) {
29514 if (rangeObj.test(v)) {
29515 // satisfies(v, range, options)
29516 if (!max || maxSV.compare(v) === -1) {
29517 // compare(max, v, true)
29518 max = v;
29519 maxSV = new SemVer(max, options);
29520 }
29521 }
29522 });
29523 return max
29524}
29525
29526exports.minSatisfying = minSatisfying;
29527function minSatisfying (versions, range, options) {
29528 var min = null;
29529 var minSV = null;
29530 try {
29531 var rangeObj = new Range(range, options);
29532 } catch (er) {
29533 return null
29534 }
29535 versions.forEach(function (v) {
29536 if (rangeObj.test(v)) {
29537 // satisfies(v, range, options)
29538 if (!min || minSV.compare(v) === 1) {
29539 // compare(min, v, true)
29540 min = v;
29541 minSV = new SemVer(min, options);
29542 }
29543 }
29544 });
29545 return min
29546}
29547
29548exports.minVersion = minVersion;
29549function minVersion (range, loose) {
29550 range = new Range(range, loose);
29551
29552 var minver = new SemVer('0.0.0');
29553 if (range.test(minver)) {
29554 return minver
29555 }
29556
29557 minver = new SemVer('0.0.0-0');
29558 if (range.test(minver)) {
29559 return minver
29560 }
29561
29562 minver = null;
29563 for (var i = 0; i < range.set.length; ++i) {
29564 var comparators = range.set[i];
29565
29566 comparators.forEach(function (comparator) {
29567 // Clone to avoid manipulating the comparator's semver object.
29568 var compver = new SemVer(comparator.semver.version);
29569 switch (comparator.operator) {
29570 case '>':
29571 if (compver.prerelease.length === 0) {
29572 compver.patch++;
29573 } else {
29574 compver.prerelease.push(0);
29575 }
29576 compver.raw = compver.format();
29577 /* fallthrough */
29578 case '':
29579 case '>=':
29580 if (!minver || gt(minver, compver)) {
29581 minver = compver;
29582 }
29583 break
29584 case '<':
29585 case '<=':
29586 /* Ignore maximum versions */
29587 break
29588 /* istanbul ignore next */
29589 default:
29590 throw new Error('Unexpected operation: ' + comparator.operator)
29591 }
29592 });
29593 }
29594
29595 if (minver && range.test(minver)) {
29596 return minver
29597 }
29598
29599 return null
29600}
29601
29602exports.validRange = validRange;
29603function validRange (range, options) {
29604 try {
29605 // Return '*' instead of '' so that truthiness works.
29606 // This will throw if it's invalid anyway
29607 return new Range(range, options).range || '*'
29608 } catch (er) {
29609 return null
29610 }
29611}
29612
29613// Determine if version is less than all the versions possible in the range
29614exports.ltr = ltr;
29615function ltr (version, range, options) {
29616 return outside(version, range, '<', options)
29617}
29618
29619// Determine if version is greater than all the versions possible in the range.
29620exports.gtr = gtr;
29621function gtr (version, range, options) {
29622 return outside(version, range, '>', options)
29623}
29624
29625exports.outside = outside;
29626function outside (version, range, hilo, options) {
29627 version = new SemVer(version, options);
29628 range = new Range(range, options);
29629
29630 var gtfn, ltefn, ltfn, comp, ecomp;
29631 switch (hilo) {
29632 case '>':
29633 gtfn = gt;
29634 ltefn = lte;
29635 ltfn = lt;
29636 comp = '>';
29637 ecomp = '>=';
29638 break
29639 case '<':
29640 gtfn = lt;
29641 ltefn = gte;
29642 ltfn = gt;
29643 comp = '<';
29644 ecomp = '<=';
29645 break
29646 default:
29647 throw new TypeError('Must provide a hilo val of "<" or ">"')
29648 }
29649
29650 // If it satisifes the range it is not outside
29651 if (satisfies(version, range, options)) {
29652 return false
29653 }
29654
29655 // From now on, variable terms are as if we're in "gtr" mode.
29656 // but note that everything is flipped for the "ltr" function.
29657
29658 for (var i = 0; i < range.set.length; ++i) {
29659 var comparators = range.set[i];
29660
29661 var high = null;
29662 var low = null;
29663
29664 comparators.forEach(function (comparator) {
29665 if (comparator.semver === ANY) {
29666 comparator = new Comparator('>=0.0.0');
29667 }
29668 high = high || comparator;
29669 low = low || comparator;
29670 if (gtfn(comparator.semver, high.semver, options)) {
29671 high = comparator;
29672 } else if (ltfn(comparator.semver, low.semver, options)) {
29673 low = comparator;
29674 }
29675 });
29676
29677 // If the edge version comparator has a operator then our version
29678 // isn't outside it
29679 if (high.operator === comp || high.operator === ecomp) {
29680 return false
29681 }
29682
29683 // If the lowest version comparator has an operator and our version
29684 // is less than it then it isn't higher than the range
29685 if ((!low.operator || low.operator === comp) &&
29686 ltefn(version, low.semver)) {
29687 return false
29688 } else if (low.operator === ecomp && ltfn(version, low.semver)) {
29689 return false
29690 }
29691 }
29692 return true
29693}
29694
29695exports.prerelease = prerelease;
29696function prerelease (version, options) {
29697 var parsed = parse(version, options);
29698 return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
29699}
29700
29701exports.intersects = intersects;
29702function intersects (r1, r2, options) {
29703 r1 = new Range(r1, options);
29704 r2 = new Range(r2, options);
29705 return r1.intersects(r2)
29706}
29707
29708exports.coerce = coerce;
29709function coerce (version, options) {
29710 if (version instanceof SemVer) {
29711 return version
29712 }
29713
29714 if (typeof version === 'number') {
29715 version = String(version);
29716 }
29717
29718 if (typeof version !== 'string') {
29719 return null
29720 }
29721
29722 options = options || {};
29723
29724 var match = null;
29725 if (!options.rtl) {
29726 match = version.match(re[t.COERCE]);
29727 } else {
29728 // Find the right-most coercible string that does not share
29729 // a terminus with a more left-ward coercible string.
29730 // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
29731 //
29732 // Walk through the string checking with a /g regexp
29733 // Manually set the index so as to pick up overlapping matches.
29734 // Stop when we get a match that ends at the string end, since no
29735 // coercible string can be more right-ward without the same terminus.
29736 var next;
29737 while ((next = re[t.COERCERTL].exec(version)) &&
29738 (!match || match.index + match[0].length !== version.length)
29739 ) {
29740 if (!match ||
29741 next.index + next[0].length !== match.index + match[0].length) {
29742 match = next;
29743 }
29744 re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
29745 }
29746 // leave it in a clean state
29747 re[t.COERCERTL].lastIndex = -1;
29748 }
29749
29750 if (match === null) {
29751 return null
29752 }
29753
29754 return parse(match[2] +
29755 '.' + (match[3] || '0') +
29756 '.' + (match[4] || '0'), options)
29757}
29758});
29759
29760const {promisify: promisify$2} = require$$0;
29761
29762
29763const useNativeRecursiveOption = semver$2.satisfies(process.version, '>=10.12.0');
29764
29765// https://github.com/nodejs/node/issues/8987
29766// https://github.com/libuv/libuv/pull/1088
29767const checkPath = pth => {
29768 if (process.platform === 'win32') {
29769 const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
29770
29771 if (pathHasInvalidWinCharacters) {
29772 const error = new Error(`Path contains invalid characters: ${pth}`);
29773 error.code = 'EINVAL';
29774 throw error;
29775 }
29776 }
29777};
29778
29779const processOptions = options => {
29780 // https://github.com/sindresorhus/make-dir/issues/18
29781 const defaults = {
29782 mode: 0o777 & (~process.umask()),
29783 fs
29784 };
29785
29786 return {
29787 ...defaults,
29788 ...options
29789 };
29790};
29791
29792const permissionError = pth => {
29793 // This replicates the exception of `fs.mkdir` with native the
29794 // `recusive` option when run on an invalid drive under Windows.
29795 const error = new Error(`operation not permitted, mkdir '${pth}'`);
29796 error.code = 'EPERM';
29797 error.errno = -4048;
29798 error.path = pth;
29799 error.syscall = 'mkdir';
29800 return error;
29801};
29802
29803const makeDir = async (input, options) => {
29804 checkPath(input);
29805 options = processOptions(options);
29806
29807 const mkdir = promisify$2(options.fs.mkdir);
29808 const stat = promisify$2(options.fs.stat);
29809
29810 if (useNativeRecursiveOption && options.fs.mkdir === fs.mkdir) {
29811 const pth = path.resolve(input);
29812
29813 await mkdir(pth, {
29814 mode: options.mode,
29815 recursive: true
29816 });
29817
29818 return pth;
29819 }
29820
29821 const make = async pth => {
29822 try {
29823 await mkdir(pth, options.mode);
29824
29825 return pth;
29826 } catch (error) {
29827 if (error.code === 'EPERM') {
29828 throw error;
29829 }
29830
29831 if (error.code === 'ENOENT') {
29832 if (path.dirname(pth) === pth) {
29833 throw permissionError(pth);
29834 }
29835
29836 if (error.message.includes('null bytes')) {
29837 throw error;
29838 }
29839
29840 await make(path.dirname(pth));
29841
29842 return make(pth);
29843 }
29844
29845 try {
29846 const stats = await stat(pth);
29847 if (!stats.isDirectory()) {
29848 throw new Error('The path is not a directory');
29849 }
29850 } catch (_) {
29851 throw error;
29852 }
29853
29854 return pth;
29855 }
29856 };
29857
29858 return make(path.resolve(input));
29859};
29860
29861var makeDir_1 = makeDir;
29862
29863var sync$3 = (input, options) => {
29864 checkPath(input);
29865 options = processOptions(options);
29866
29867 if (useNativeRecursiveOption && options.fs.mkdirSync === fs.mkdirSync) {
29868 const pth = path.resolve(input);
29869
29870 fs.mkdirSync(pth, {
29871 mode: options.mode,
29872 recursive: true
29873 });
29874
29875 return pth;
29876 }
29877
29878 const make = pth => {
29879 try {
29880 options.fs.mkdirSync(pth, options.mode);
29881 } catch (error) {
29882 if (error.code === 'EPERM') {
29883 throw error;
29884 }
29885
29886 if (error.code === 'ENOENT') {
29887 if (path.dirname(pth) === pth) {
29888 throw permissionError(pth);
29889 }
29890
29891 if (error.message.includes('null bytes')) {
29892 throw error;
29893 }
29894
29895 make(path.dirname(pth));
29896 return make(pth);
29897 }
29898
29899 try {
29900 if (!options.fs.statSync(pth).isDirectory()) {
29901 throw new Error('The path is not a directory');
29902 }
29903 } catch (_) {
29904 throw error;
29905 }
29906 }
29907
29908 return pth;
29909 };
29910
29911 return make(path.resolve(input));
29912};
29913makeDir_1.sync = sync$3;
29914
29915const {env: env$1, cwd} = process;
29916
29917const isWritable = path => {
29918 try {
29919 fs.accessSync(path, fs.constants.W_OK);
29920 return true;
29921 } catch (_) {
29922 return false;
29923 }
29924};
29925
29926function useDirectory(directory, options) {
29927 if (options.create) {
29928 makeDir_1.sync(directory);
29929 }
29930
29931 if (options.thunk) {
29932 return (...arguments_) => path.join(directory, ...arguments_);
29933 }
29934
29935 return directory;
29936}
29937
29938function getNodeModuleDirectory(directory) {
29939 const nodeModules = path.join(directory, 'node_modules');
29940
29941 if (
29942 !isWritable(nodeModules) &&
29943 (fs.existsSync(nodeModules) || !isWritable(path.join(directory)))
29944 ) {
29945 return;
29946 }
29947
29948 return nodeModules;
29949}
29950
29951var findCacheDir = (options = {}) => {
29952 if (env$1.CACHE_DIR && !['true', 'false', '1', '0'].includes(env$1.CACHE_DIR)) {
29953 return useDirectory(path.join(env$1.CACHE_DIR, 'find-cache-dir'), options);
29954 }
29955
29956 let {cwd: directory = cwd()} = options;
29957
29958 if (options.files) {
29959 directory = commondir(directory, options.files);
29960 }
29961
29962 directory = pkgDir_1.sync(directory);
29963
29964 if (!directory) {
29965 return;
29966 }
29967
29968 const nodeModules = getNodeModuleDirectory(directory);
29969 if (!nodeModules) {
29970 return undefined;
29971 }
29972
29973 return useDirectory(path.join(directory, 'node_modules', '.cache', options.name), options);
29974};
29975
29976const typescript = (options) => {
29977 let watchMode = false;
29978 let generateRound = 0;
29979 let rollupOptions;
29980 let context;
29981 let filter;
29982 let parsedConfig;
29983 let tsConfigPath;
29984 let servicesHost;
29985 let service;
29986 let noErrors = true;
29987 const declarations = {};
29988 const allImportedFiles = new Set();
29989 let _cache;
29990 const cache = () => {
29991 if (!_cache)
29992 _cache = new TsCache(pluginOptions.clean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
29993 return _cache;
29994 };
29995 const pluginOptions = Object.assign({}, options);
29996 lodash.defaults(pluginOptions, {
29997 check: true,
29998 verbosity: VerbosityLevel.Warning,
29999 clean: false,
30000 cacheRoot: findCacheDir({ name: "rollup-plugin-typescript2" }),
30001 include: ["*.ts+(|x)", "**/*.ts+(|x)"],
30002 exclude: ["*.d.ts", "**/*.d.ts"],
30003 abortOnError: true,
30004 rollupCommonJSResolveHack: false,
30005 tsconfig: undefined,
30006 useTsconfigDeclarationDir: false,
30007 tsconfigOverride: {},
30008 transformers: [],
30009 tsconfigDefaults: {},
30010 objectHashIgnoreUnknownHack: false,
30011 cwd: process.cwd(),
30012 });
30013 if (!pluginOptions.typescript) {
30014 pluginOptions.typescript = require("typescript");
30015 }
30016 setTypescriptModule(pluginOptions.typescript);
30017 const self = {
30018 name: "rpt2",
30019 options(config) {
30020 rollupOptions = Object.assign({}, config);
30021 context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
30022 watchMode = process.env.ROLLUP_WATCH === "true";
30023 ({ parsedTsConfig: parsedConfig, fileName: tsConfigPath } = parseTsConfig(context, pluginOptions));
30024 if (generateRound === 0) {
30025 parsedConfig.fileNames.forEach((fileName) => { allImportedFiles.add(fileName); });
30026 context.info(`typescript version: ${tsModule.version}`);
30027 context.info(`tslib version: ${tslibVersion}`);
30028 if (this.meta)
30029 context.info(`rollup version: ${this.meta.rollupVersion}`);
30030 if (!semver$1.satisfies(tsModule.version, ">=2.4.0", { includePrerelease: true }))
30031 throw new Error(`Installed typescript version '${tsModule.version}' is outside of supported range '>=2.4.0'`);
30032 context.info(`rollup-plugin-typescript2 version: 0.30.0`);
30033 context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${value.version}` : value, 4)}`);
30034 context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
30035 context.debug(() => `tsconfig path: ${tsConfigPath}`);
30036 if (pluginOptions.objectHashIgnoreUnknownHack)
30037 context.warn(() => `${safe.yellow("You are using 'objectHashIgnoreUnknownHack' option")}. If you enabled it because of async functions, try disabling it now.`);
30038 if (watchMode)
30039 context.info(`running in watch mode`);
30040 }
30041 filter = createFilter(context, pluginOptions, parsedConfig);
30042 servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
30043 service = tsModule.createLanguageService(servicesHost, tsModule.createDocumentRegistry());
30044 servicesHost.setLanguageService(service);
30045 // printing compiler option errors
30046 if (pluginOptions.check)
30047 printDiagnostics(context, convertDiagnostic("options", service.getCompilerOptionsDiagnostics()), parsedConfig.options.pretty === true);
30048 if (pluginOptions.clean)
30049 cache().clean();
30050 return config;
30051 },
30052 watchChange(id) {
30053 const key = normalize(id);
30054 delete declarations[key];
30055 },
30056 resolveId(importee, importer) {
30057 if (importee === TSLIB)
30058 return TSLIB_VIRTUAL;
30059 if (!importer)
30060 return;
30061 importer = normalize(importer);
30062 // avoiding trying to resolve ids for things imported from files unrelated to this plugin
30063 if (!allImportedFiles.has(importer))
30064 return;
30065 // TODO: use module resolution cache
30066 const result = tsModule.nodeModuleNameResolver(importee, importer, parsedConfig.options, tsModule.sys);
30067 if (result.resolvedModule && result.resolvedModule.resolvedFileName) {
30068 if (filter(result.resolvedModule.resolvedFileName))
30069 cache().setDependency(result.resolvedModule.resolvedFileName, importer);
30070 if (lodash.endsWith(result.resolvedModule.resolvedFileName, ".d.ts"))
30071 return;
30072 const resolved = pluginOptions.rollupCommonJSResolveHack
30073 ? sync$4(result.resolvedModule.resolvedFileName)
30074 : result.resolvedModule.resolvedFileName;
30075 context.debug(() => `${safe.blue("resolving")} '${importee}' imported by '${importer}'`);
30076 context.debug(() => ` to '${resolved}'`);
30077 return normalize$1(resolved);
30078 }
30079 return;
30080 },
30081 load(id) {
30082 if (id === TSLIB_VIRTUAL)
30083 return tslibSource;
30084 return null;
30085 },
30086 transform(code, id) {
30087 generateRound = 0; // in watch mode transform call resets generate count (used to avoid printing too many copies of the same error messages)
30088 if (!filter(id))
30089 return undefined;
30090 allImportedFiles.add(normalize(id));
30091 const contextWrapper = new RollupContext(pluginOptions.verbosity, pluginOptions.abortOnError, this, "rpt2: ");
30092 const snapshot = servicesHost.setSnapshot(id, code);
30093 // getting compiled file from cache or from ts
30094 const result = cache().getCompiled(id, snapshot, () => {
30095 const output = service.getEmitOutput(id);
30096 if (output.emitSkipped) {
30097 noErrors = false;
30098 // always checking on fatal errors, even if options.check is set to false
30099 const diagnostics = lodash.concat(cache().getSyntacticDiagnostics(id, snapshot, () => {
30100 return service.getSyntacticDiagnostics(id);
30101 }), cache().getSemanticDiagnostics(id, snapshot, () => {
30102 return service.getSemanticDiagnostics(id);
30103 }));
30104 printDiagnostics(contextWrapper, diagnostics, parsedConfig.options.pretty === true);
30105 // since no output was generated, aborting compilation
30106 cache().done();
30107 if (lodash.isFunction(this.error))
30108 this.error(safe.red(`failed to transpile '${id}'`));
30109 }
30110 const references = getAllReferences(id, servicesHost.getScriptSnapshot(id), parsedConfig.options);
30111 return convertEmitOutput(output, references);
30112 });
30113 if (pluginOptions.check) {
30114 const diagnostics = lodash.concat(cache().getSyntacticDiagnostics(id, snapshot, () => {
30115 return service.getSyntacticDiagnostics(id);
30116 }), cache().getSemanticDiagnostics(id, snapshot, () => {
30117 return service.getSemanticDiagnostics(id);
30118 }));
30119 if (diagnostics.length > 0)
30120 noErrors = false;
30121 printDiagnostics(contextWrapper, diagnostics, parsedConfig.options.pretty === true);
30122 }
30123 if (result) {
30124 if (result.references)
30125 result.references.map(normalize).map(allImportedFiles.add, allImportedFiles);
30126 if (watchMode && this.addWatchFile && result.references) {
30127 if (tsConfigPath)
30128 this.addWatchFile(tsConfigPath);
30129 result.references.map(this.addWatchFile, this);
30130 context.debug(() => `${safe.green(" watching")}: ${result.references.join("\nrpt2: ")}`);
30131 }
30132 if (result.dts) {
30133 const key = normalize(id);
30134 declarations[key] = { type: result.dts, map: result.dtsmap };
30135 context.debug(() => `${safe.blue("generated declarations")} for '${key}'`);
30136 }
30137 const transformResult = { code: result.code, map: { mappings: "" } };
30138 if (result.map) {
30139 if (pluginOptions.sourceMapCallback)
30140 pluginOptions.sourceMapCallback(id, result.map);
30141 transformResult.map = JSON.parse(result.map);
30142 }
30143 return transformResult;
30144 }
30145 return undefined;
30146 },
30147 generateBundle(bundleOptions) {
30148 self._ongenerate();
30149 self._onwrite.call(this, bundleOptions);
30150 },
30151 _ongenerate() {
30152 context.debug(() => `generating target ${generateRound + 1}`);
30153 if (pluginOptions.check && watchMode && generateRound === 0) {
30154 cache().walkTree((id) => {
30155 if (!filter(id))
30156 return;
30157 const snapshot = servicesHost.getScriptSnapshot(id);
30158 if (!snapshot)
30159 return;
30160 const diagnostics = lodash.concat(cache().getSyntacticDiagnostics(id, snapshot, () => {
30161 return service.getSyntacticDiagnostics(id);
30162 }), cache().getSemanticDiagnostics(id, snapshot, () => {
30163 return service.getSemanticDiagnostics(id);
30164 }));
30165 printDiagnostics(context, diagnostics, parsedConfig.options.pretty === true);
30166 });
30167 }
30168 if (!watchMode && !noErrors)
30169 context.info(safe.yellow("there were errors or warnings."));
30170 cache().done();
30171 generateRound++;
30172 },
30173 _onwrite(_output) {
30174 if (!parsedConfig.options.declaration)
30175 return;
30176 lodash.each(parsedConfig.fileNames, (name) => {
30177 const key = normalize(name);
30178 if (lodash.has(declarations, key))
30179 return;
30180 if (!allImportedFiles.has(key)) {
30181 context.debug(() => `skipping declarations for unused '${key}'`);
30182 return;
30183 }
30184 context.debug(() => `generating missed declarations for '${key}'`);
30185 const output = service.getEmitOutput(key, true);
30186 const out = convertEmitOutput(output);
30187 if (out.dts)
30188 declarations[key] = { type: out.dts, map: out.dtsmap };
30189 });
30190 const emitDeclaration = (key, extension, entry) => {
30191 if (!entry)
30192 return;
30193 let fileName = entry.name;
30194 if (fileName.includes("?")) // HACK for rollup-plugin-vue, it creates virtual modules in form 'file.vue?rollup-plugin-vue=script.ts'
30195 fileName = fileName.split("?", 1) + extension;
30196 // If 'useTsconfigDeclarationDir' is given in the
30197 // plugin options, directly write to the path provided
30198 // by Typescript's LanguageService (which may not be
30199 // under Rollup's output directory, and thus can't be
30200 // emitted as an asset).
30201 if (pluginOptions.useTsconfigDeclarationDir) {
30202 context.debug(() => `${safe.blue("emitting declarations")} for '${key}' to '${fileName}'`);
30203 tsModule.sys.writeFile(fileName, entry.text, entry.writeByteOrderMark);
30204 }
30205 else {
30206 // don't mutate the entry because generateBundle gets called multiple times
30207 let entryText = entry.text;
30208 const declarationDir = (_output.file ? dirname(_output.file) : _output.dir);
30209 const cachePlaceholder = `${pluginOptions.cacheRoot}/placeholder`;
30210 // modify declaration map sources to correct relative path
30211 if (extension === ".d.ts.map") {
30212 const parsedText = JSON.parse(entryText);
30213 // invert back to absolute, then make relative to declarationDir
30214 parsedText.sources = parsedText.sources.map(source => {
30215 const absolutePath = resolve(cachePlaceholder, source);
30216 return normalize(relative(declarationDir, absolutePath));
30217 });
30218 entryText = JSON.stringify(parsedText);
30219 }
30220 const relativePath = normalize(relative(cachePlaceholder, fileName));
30221 context.debug(() => `${safe.blue("emitting declarations")} for '${key}' to '${relativePath}'`);
30222 this.emitFile({
30223 type: "asset",
30224 source: entryText,
30225 fileName: relativePath,
30226 });
30227 }
30228 };
30229 lodash.each(declarations, ({ type, map }, key) => {
30230 emitDeclaration(key, ".d.ts", type);
30231 emitDeclaration(key, ".d.ts.map", map);
30232 });
30233 },
30234 };
30235 return self;
30236};
30237
30238export default typescript;
30239//# sourceMappingURL=rollup-plugin-typescript2.es.js.map