1/******/ (() => { // webpackBootstrap 2/******/ var __webpack_modules__ = ({ 3
vendor: 3,394 bytes, lines 4-114
4/***/ "./node_modules/@alpinejs/collapse/dist/module.esm.js": 5/*!************************************************************!*\ 6 !*** ./node_modules/@alpinejs/collapse/dist/module.esm.js ***! 7 \************************************************************/ 8/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 9 10"use strict"; 11__webpack_require__.r(__webpack_exports__); 12/* harmony export */ __webpack_require__.d(__webpack_exports__, { 13/* harmony export */ "default": () => (/* binding */ module_default) 14/* harmony export */ }); 15// packages/collapse/src/index.js 16function src_default(Alpine) { 17 Alpine.directive("collapse", collapse); 18 collapse.inline = (el, {modifiers}) => { 19 if (!modifiers.includes("min")) 20 return; 21 el._x_doShow = () => { 22 }; 23 el._x_doHide = () => { 24 }; 25 }; 26 function collapse(el, {modifiers}) { 27 let duration = modifierValue(modifiers, "duration", 250) / 1e3; 28 let floor = modifierValue(modifiers, "min", 0); 29 let fullyHide = !modifiers.includes("min"); 30 if (!el._x_isShown) 31 el.style.height = `${floor}px`; 32 if (!el._x_isShown && fullyHide) 33 el.hidden = true; 34 if (!el._x_isShown) 35 el.style.overflow = "hidden"; 36 let setFunction = (el2, styles) => { 37 let revertFunction = Alpine.setStyles(el2, styles); 38 return styles.height ? () => { 39 } : revertFunction; 40 }; 41 let transitionStyles = { 42 transitionProperty: "height", 43 transitionDuration: `${duration}s`, 44 transitionTimingFunction: "cubic-bezier(0.4, 0.0, 0.2, 1)" 45 }; 46 el._x_transition = { 47 in(before = () => { 48 }, after = () => { 49 }) { 50 if (fullyHide) 51 el.hidden = false; 52 if (fullyHide) 53 el.style.display = null; 54 let current = el.getBoundingClientRect().height; 55 el.style.height = "auto"; 56 let full = el.getBoundingClientRect().height; 57 if (current === full) { 58 current = floor; 59 } 60 Alpine.transition(el, Alpine.setStyles, { 61 during: transitionStyles, 62 start: {height: current + "px"}, 63 end: {height: full + "px"} 64 }, () => el._x_isShown = true, () => { 65 if (el.style.height == `${full}px`) { 66 el.style.overflow = null; 67 } 68 }); 69 }, 70 out(before = () => { 71 }, after = () => { 72 }) { 73 let full = el.getBoundingClientRect().height; 74 Alpine.transition(el, setFunction, { 75 during: transitionStyles, 76 start: {height: full + "px"}, 77 end: {height: floor + "px"} 78 }, () => el.style.overflow = "hidden", () => { 79 el._x_isShown = false; 80 if (el.style.height == `${floor}px` && fullyHide) { 81 el.style.display = "none"; 82 el.hidden = true; 83 } 84 }); 85 } 86 }; 87 } 88} 89function modifierValue(modifiers, key, fallback) { 90 if (modifiers.indexOf(key) === -1) 91 return fallback; 92 const rawValue = modifiers[modifiers.indexOf(key) + 1]; 93 if (!rawValue) 94 return fallback; 95 if (key === "duration") { 96 let match = rawValue.match(/([0-9]+)ms/); 97 if (match) 98 return match[1]; 99 } 100 if (key === "min") { 101 let match = rawValue.match(/([0-9]+)px/); 102 if (match) 103 return match[1]; 104 } 105 return rawValue; 106} 107 108// packages/collapse/builds/module.js 109var module_default = src_default; 110 111 112 113/***/ }), 114
vendor: 88,425 bytes, lines 115-3025
115/***/ "./node_modules/alpinejs/dist/module.esm.js": 116/*!**************************************************!*\ 117 !*** ./node_modules/alpinejs/dist/module.esm.js ***! 118 \**************************************************/ 119/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 120 121"use strict"; 122__webpack_require__.r(__webpack_exports__); 123/* harmony export */ __webpack_require__.d(__webpack_exports__, { 124/* harmony export */ "default": () => (/* binding */ module_default) 125/* harmony export */ }); 126// packages/alpinejs/src/scheduler.js 127var flushPending = false; 128var flushing = false; 129var queue = []; 130function scheduler(callback) { 131 queueJob(callback); 132} 133function queueJob(job) { 134 if (!queue.includes(job)) 135 queue.push(job); 136 queueFlush(); 137} 138function dequeueJob(job) { 139 let index = queue.indexOf(job); 140 if (index !== -1) 141 queue.splice(index, 1); 142} 143function queueFlush() { 144 if (!flushing && !flushPending) { 145 flushPending = true; 146 queueMicrotask(flushJobs); 147 } 148} 149function flushJobs() { 150 flushPending = false; 151 flushing = true; 152 for (let i = 0; i < queue.length; i++) { 153 queue[i](); 154 } 155 queue.length = 0; 156 flushing = false; 157} 158 159// packages/alpinejs/src/reactivity.js 160var reactive; 161var effect; 162var release; 163var raw; 164var shouldSchedule = true; 165function disableEffectScheduling(callback) { 166 shouldSchedule = false; 167 callback(); 168 shouldSchedule = true; 169} 170function setReactivityEngine(engine) { 171 reactive = engine.reactive; 172 release = engine.release; 173 effect = (callback) => engine.effect(callback, {scheduler: (task) => { 174 if (shouldSchedule) { 175 scheduler(task); 176 } else { 177 task(); 178 } 179 }}); 180 raw = engine.raw; 181} 182function overrideEffect(override) { 183 effect = override; 184} 185function elementBoundEffect(el) { 186 let cleanup2 = () => { 187 }; 188 let wrappedEffect = (callback) => { 189 let effectReference = effect(callback); 190 if (!el._x_effects) { 191 el._x_effects = new Set(); 192 el._x_runEffects = () => { 193 el._x_effects.forEach((i) => i()); 194 }; 195 } 196 el._x_effects.add(effectReference); 197 cleanup2 = () => { 198 if (effectReference === void 0) 199 return; 200 el._x_effects.delete(effectReference); 201 release(effectReference); 202 }; 203 return effectReference; 204 }; 205 return [wrappedEffect, () => { 206 cleanup2(); 207 }]; 208} 209 210// packages/alpinejs/src/mutation.js 211var onAttributeAddeds = []; 212var onElRemoveds = []; 213var onElAddeds = []; 214function onElAdded(callback) { 215 onElAddeds.push(callback); 216} 217function onElRemoved(el, callback) { 218 if (typeof callback === "function") { 219 if (!el._x_cleanups) 220 el._x_cleanups = []; 221 el._x_cleanups.push(callback); 222 } else { 223 callback = el; 224 onElRemoveds.push(callback); 225 } 226} 227function onAttributesAdded(callback) { 228 onAttributeAddeds.push(callback); 229} 230function onAttributeRemoved(el, name, callback) { 231 if (!el._x_attributeCleanups) 232 el._x_attributeCleanups = {}; 233 if (!el._x_attributeCleanups[name]) 234 el._x_attributeCleanups[name] = []; 235 el._x_attributeCleanups[name].push(callback); 236} 237function cleanupAttributes(el, names) { 238 if (!el._x_attributeCleanups) 239 return; 240 Object.entries(el._x_attributeCleanups).forEach(([name, value]) => { 241 if (names === void 0 || names.includes(name)) { 242 value.forEach((i) => i()); 243 delete el._x_attributeCleanups[name]; 244 } 245 }); 246} 247var observer = new MutationObserver(onMutate); 248var currentlyObserving = false; 249function startObservingMutations() { 250 observer.observe(document, {subtree: true, childList: true, attributes: true, attributeOldValue: true}); 251 currentlyObserving = true; 252} 253function stopObservingMutations() { 254 flushObserver(); 255 observer.disconnect(); 256 currentlyObserving = false; 257} 258var recordQueue = []; 259var willProcessRecordQueue = false; 260function flushObserver() { 261 recordQueue = recordQueue.concat(observer.takeRecords()); 262 if (recordQueue.length && !willProcessRecordQueue) { 263 willProcessRecordQueue = true; 264 queueMicrotask(() => { 265 processRecordQueue(); 266 willProcessRecordQueue = false; 267 }); 268 } 269} 270function processRecordQueue() { 271 onMutate(recordQueue); 272 recordQueue.length = 0; 273} 274function mutateDom(callback) { 275 if (!currentlyObserving) 276 return callback(); 277 stopObservingMutations(); 278 let result = callback(); 279 startObservingMutations(); 280 return result; 281} 282var isCollecting = false; 283var deferredMutations = []; 284function deferMutations() { 285 isCollecting = true; 286} 287function flushAndStopDeferringMutations() { 288 isCollecting = false; 289 onMutate(deferredMutations); 290 deferredMutations = []; 291} 292function onMutate(mutations) { 293 if (isCollecting) { 294 deferredMutations = deferredMutations.concat(mutations); 295 return; 296 } 297 let addedNodes = []; 298 let removedNodes = []; 299 let addedAttributes = new Map(); 300 let removedAttributes = new Map(); 301 for (let i = 0; i < mutations.length; i++) { 302 if (mutations[i].target._x_ignoreMutationObserver) 303 continue; 304 if (mutations[i].type === "childList") { 305 mutations[i].addedNodes.forEach((node) => node.nodeType === 1 && addedNodes.push(node)); 306 mutations[i].removedNodes.forEach((node) => node.nodeType === 1 && removedNodes.push(node)); 307 } 308 if (mutations[i].type === "attributes") { 309 let el = mutations[i].target; 310 let name = mutations[i].attributeName; 311 let oldValue = mutations[i].oldValue; 312 let add2 = () => { 313 if (!addedAttributes.has(el)) 314 addedAttributes.set(el, []); 315 addedAttributes.get(el).push({name, value: el.getAttribute(name)}); 316 }; 317 let remove = () => { 318 if (!removedAttributes.has(el)) 319 removedAttributes.set(el, []); 320 removedAttributes.get(el).push(name); 321 }; 322 if (el.hasAttribute(name) && oldValue === null) { 323 add2(); 324 } else if (el.hasAttribute(name)) { 325 remove(); 326 add2(); 327 } else { 328 remove(); 329 } 330 } 331 } 332 removedAttributes.forEach((attrs, el) => { 333 cleanupAttributes(el, attrs); 334 }); 335 addedAttributes.forEach((attrs, el) => { 336 onAttributeAddeds.forEach((i) => i(el, attrs)); 337 }); 338 for (let node of removedNodes) { 339 if (addedNodes.includes(node)) 340 continue; 341 onElRemoveds.forEach((i) => i(node)); 342 if (node._x_cleanups) { 343 while (node._x_cleanups.length) 344 node._x_cleanups.pop()(); 345 } 346 } 347 addedNodes.forEach((node) => { 348 node._x_ignoreSelf = true; 349 node._x_ignore = true; 350 }); 351 for (let node of addedNodes) { 352 if (removedNodes.includes(node)) 353 continue; 354 if (!node.isConnected) 355 continue; 356 delete node._x_ignoreSelf; 357 delete node._x_ignore; 358 onElAddeds.forEach((i) => i(node)); 359 node._x_ignore = true; 360 node._x_ignoreSelf = true; 361 } 362 addedNodes.forEach((node) => { 363 delete node._x_ignoreSelf; 364 delete node._x_ignore; 365 }); 366 addedNodes = null; 367 removedNodes = null; 368 addedAttributes = null; 369 removedAttributes = null; 370} 371 372// packages/alpinejs/src/scope.js 373function scope(node) { 374 return mergeProxies(closestDataStack(node)); 375} 376function addScopeToNode(node, data2, referenceNode) { 377 node._x_dataStack = [data2, ...closestDataStack(referenceNode || node)]; 378 return () => { 379 node._x_dataStack = node._x_dataStack.filter((i) => i !== data2); 380 }; 381} 382function refreshScope(element, scope2) { 383 let existingScope = element._x_dataStack[0]; 384 Object.entries(scope2).forEach(([key, value]) => { 385 existingScope[key] = value; 386 }); 387} 388function closestDataStack(node) { 389 if (node._x_dataStack) 390 return node._x_dataStack; 391 if (typeof ShadowRoot === "function" && node instanceof ShadowRoot) { 392 return closestDataStack(node.host); 393 } 394 if (!node.parentNode) { 395 return []; 396 } 397 return closestDataStack(node.parentNode); 398} 399function mergeProxies(objects) { 400 let thisProxy = new Proxy({}, { 401 ownKeys: () => { 402 return Array.from(new Set(objects.flatMap((i) => Object.keys(i)))); 403 }, 404 has: (target, name) => { 405 return objects.some((obj) => obj.hasOwnProperty(name)); 406 }, 407 get: (target, name) => { 408 return (objects.find((obj) => { 409 if (obj.hasOwnProperty(name)) { 410 let descriptor = Object.getOwnPropertyDescriptor(obj, name); 411 if (descriptor.get && descriptor.get._x_alreadyBound || descriptor.set && descriptor.set._x_alreadyBound) { 412 return true; 413 } 414 if ((descriptor.get || descriptor.set) && descriptor.enumerable) { 415 let getter = descriptor.get; 416 let setter = descriptor.set; 417 let property = descriptor; 418 getter = getter && getter.bind(thisProxy); 419 setter = setter && setter.bind(thisProxy); 420 if (getter) 421 getter._x_alreadyBound = true; 422 if (setter) 423 setter._x_alreadyBound = true; 424 Object.defineProperty(obj, name, { 425 ...property, 426 get: getter, 427 set: setter 428 }); 429 } 430 return true; 431 } 432 return false; 433 }) || {})[name]; 434 }, 435 set: (target, name, value) => { 436 let closestObjectWithKey = objects.find((obj) => obj.hasOwnProperty(name)); 437 if (closestObjectWithKey) { 438 closestObjectWithKey[name] = value; 439 } else { 440 objects[objects.length - 1][name] = value; 441 } 442 return true; 443 } 444 }); 445 return thisProxy; 446} 447 448// packages/alpinejs/src/interceptor.js 449function initInterceptors(data2) { 450 let isObject2 = (val) => typeof val === "object" && !Array.isArray(val) && val !== null; 451 let recurse = (obj, basePath = "") => { 452 Object.entries(Object.getOwnPropertyDescriptors(obj)).forEach(([key, {value, enumerable}]) => { 453 if (enumerable === false || value === void 0) 454 return; 455 let path = basePath === "" ? key : `${basePath}.${key}`; 456 if (typeof value === "object" && value !== null && value._x_interceptor) { 457 obj[key] = value.initialize(data2, path, key); 458 } else { 459 if (isObject2(value) && value !== obj && !(value instanceof Element)) { 460 recurse(value, path); 461 } 462 } 463 }); 464 }; 465 return recurse(data2); 466} 467function interceptor(callback, mutateObj = () => { 468}) { 469 let obj = { 470 initialValue: void 0, 471 _x_interceptor: true, 472 initialize(data2, path, key) { 473 return callback(this.initialValue, () => get(data2, path), (value) => set(data2, path, value), path, key); 474 } 475 }; 476 mutateObj(obj); 477 return (initialValue) => { 478 if (typeof initialValue === "object" && initialValue !== null && initialValue._x_interceptor) { 479 let initialize = obj.initialize.bind(obj); 480 obj.initialize = (data2, path, key) => { 481 let innerValue = initialValue.initialize(data2, path, key); 482 obj.initialValue = innerValue; 483 return initialize(data2, path, key); 484 }; 485 } else { 486 obj.initialValue = initialValue; 487 } 488 return obj; 489 }; 490} 491function get(obj, path) { 492 return path.split(".").reduce((carry, segment) => carry[segment], obj); 493} 494function set(obj, path, value) { 495 if (typeof path === "string") 496 path = path.split("."); 497 if (path.length === 1) 498 obj[path[0]] = value; 499 else if (path.length === 0) 500 throw error; 501 else { 502 if (obj[path[0]]) 503 return set(obj[path[0]], path.slice(1), value); 504 else { 505 obj[path[0]] = {}; 506 return set(obj[path[0]], path.slice(1), value); 507 } 508 } 509} 510 511// packages/alpinejs/src/magics.js 512var magics = {}; 513function magic(name, callback) { 514 magics[name] = callback; 515} 516function injectMagics(obj, el) { 517 Object.entries(magics).forEach(([name, callback]) => { 518 Object.defineProperty(obj, `$${name}`, { 519 get() { 520 let [utilities, cleanup2] = getElementBoundUtilities(el); 521 utilities = {interceptor, ...utilities}; 522 onElRemoved(el, cleanup2); 523 return callback(el, utilities); 524 }, 525 enumerable: false 526 }); 527 }); 528 return obj; 529} 530 531// packages/alpinejs/src/utils/error.js 532function tryCatch(el, expression, callback, ...args) { 533 try { 534 return callback(...args); 535 } catch (e) { 536 handleError(e, el, expression); 537 } 538} 539function handleError(error2, el, expression = void 0) { 540 Object.assign(error2, {el, expression}); 541 console.warn(`Alpine Expression Error: ${error2.message} 542 543${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); 544 setTimeout(() => { 545 throw error2; 546 }, 0); 547} 548 549// packages/alpinejs/src/evaluator.js 550var shouldAutoEvaluateFunctions = true; 551function dontAutoEvaluateFunctions(callback) { 552 let cache = shouldAutoEvaluateFunctions; 553 shouldAutoEvaluateFunctions = false; 554 callback(); 555 shouldAutoEvaluateFunctions = cache; 556} 557function evaluate(el, expression, extras = {}) { 558 let result; 559 evaluateLater(el, expression)((value) => result = value, extras); 560 return result; 561} 562function evaluateLater(...args) { 563 return theEvaluatorFunction(...args); 564} 565var theEvaluatorFunction = normalEvaluator; 566function setEvaluator(newEvaluator) { 567 theEvaluatorFunction = newEvaluator; 568} 569function normalEvaluator(el, expression) { 570 let overriddenMagics = {}; 571 injectMagics(overriddenMagics, el); 572 let dataStack = [overriddenMagics, ...closestDataStack(el)]; 573 if (typeof expression === "function") { 574 return generateEvaluatorFromFunction(dataStack, expression); 575 } 576 let evaluator = generateEvaluatorFromString(dataStack, expression, el); 577 return tryCatch.bind(null, el, expression, evaluator); 578} 579function generateEvaluatorFromFunction(dataStack, func) { 580 return (receiver = () => { 581 }, {scope: scope2 = {}, params = []} = {}) => { 582 let result = func.apply(mergeProxies([scope2, ...dataStack]), params); 583 runIfTypeOfFunction(receiver, result); 584 }; 585} 586var evaluatorMemo = {}; 587function generateFunctionFromString(expression, el) { 588 if (evaluatorMemo[expression]) { 589 return evaluatorMemo[expression]; 590 } 591 let AsyncFunction = Object.getPrototypeOf(async function() { 592 }).constructor; 593 let rightSideSafeExpression = /^[\n\s]*if.*\(.*\)/.test(expression) || /^(let|const)\s/.test(expression) ? `(() => { ${expression} })()` : expression; 594 const safeAsyncFunction = () => { 595 try { 596 return new AsyncFunction(["__self", "scope"], `with (scope) { __self.result = ${rightSideSafeExpression} }; __self.finished = true; return __self.result;`); 597 } catch (error2) { 598 handleError(error2, el, expression); 599 return Promise.resolve(); 600 } 601 }; 602 let func = safeAsyncFunction(); 603 evaluatorMemo[expression] = func; 604 return func; 605} 606function generateEvaluatorFromString(dataStack, expression, el) { 607 let func = generateFunctionFromString(expression, el); 608 return (receiver = () => { 609 }, {scope: scope2 = {}, params = []} = {}) => { 610 func.result = void 0; 611 func.finished = false; 612 let completeScope = mergeProxies([scope2, ...dataStack]); 613 if (typeof func === "function") { 614 let promise = func(func, completeScope).catch((error2) => handleError(error2, el, expression)); 615 if (func.finished) { 616 runIfTypeOfFunction(receiver, func.result, completeScope, params, el); 617 func.result = void 0; 618 } else { 619 promise.then((result) => { 620 runIfTypeOfFunction(receiver, result, completeScope, params, el); 621 }).catch((error2) => handleError(error2, el, expression)).finally(() => func.result = void 0); 622 } 623 } 624 }; 625} 626function runIfTypeOfFunction(receiver, value, scope2, params, el) { 627 if (shouldAutoEvaluateFunctions && typeof value === "function") { 628 let result = value.apply(scope2, params); 629 if (result instanceof Promise) { 630 result.then((i) => runIfTypeOfFunction(receiver, i, scope2, params)).catch((error2) => handleError(error2, el, value)); 631 } else { 632 receiver(result); 633 } 634 } else { 635 receiver(value); 636 } 637} 638 639// packages/alpinejs/src/directives.js 640var prefixAsString = "x-"; 641function prefix(subject = "") { 642 return prefixAsString + subject; 643} 644function setPrefix(newPrefix) { 645 prefixAsString = newPrefix; 646} 647var directiveHandlers = {}; 648function directive(name, callback) { 649 directiveHandlers[name] = callback; 650} 651function directives(el, attributes, originalAttributeOverride) { 652 let transformedAttributeMap = {}; 653 let directives2 = Array.from(attributes).map(toTransformedAttributes((newName, oldName) => transformedAttributeMap[newName] = oldName)).filter(outNonAlpineAttributes).map(toParsedDirectives(transformedAttributeMap, originalAttributeOverride)).sort(byPriority); 654 return directives2.map((directive2) => { 655 return getDirectiveHandler(el, directive2); 656 }); 657} 658function attributesOnly(attributes) { 659 return Array.from(attributes).map(toTransformedAttributes()).filter((attr) => !outNonAlpineAttributes(attr)); 660} 661var isDeferringHandlers = false; 662var directiveHandlerStacks = new Map(); 663var currentHandlerStackKey = Symbol(); 664function deferHandlingDirectives(callback) { 665 isDeferringHandlers = true; 666 let key = Symbol(); 667 currentHandlerStackKey = key; 668 directiveHandlerStacks.set(key, []); 669 let flushHandlers = () => { 670 while (directiveHandlerStacks.get(key).length) 671 directiveHandlerStacks.get(key).shift()(); 672 directiveHandlerStacks.delete(key); 673 }; 674 let stopDeferring = () => { 675 isDeferringHandlers = false; 676 flushHandlers(); 677 }; 678 callback(flushHandlers); 679 stopDeferring(); 680} 681function getElementBoundUtilities(el) { 682 let cleanups = []; 683 let cleanup2 = (callback) => cleanups.push(callback); 684 let [effect3, cleanupEffect] = elementBoundEffect(el); 685 cleanups.push(cleanupEffect); 686 let utilities = { 687 Alpine: alpine_default, 688 effect: effect3, 689 cleanup: cleanup2, 690 evaluateLater: evaluateLater.bind(evaluateLater, el), 691 evaluate: evaluate.bind(evaluate, el) 692 }; 693 let doCleanup = () => cleanups.forEach((i) => i()); 694 return [utilities, doCleanup]; 695} 696function getDirectiveHandler(el, directive2) { 697 let noop = () => { 698 }; 699 let handler3 = directiveHandlers[directive2.type] || noop; 700 let [utilities, cleanup2] = getElementBoundUtilities(el); 701 onAttributeRemoved(el, directive2.original, cleanup2); 702 let fullHandler = () => { 703 if (el._x_ignore || el._x_ignoreSelf) 704 return; 705 handler3.inline && handler3.inline(el, directive2, utilities); 706 handler3 = handler3.bind(handler3, el, directive2, utilities); 707 isDeferringHandlers ? directiveHandlerStacks.get(currentHandlerStackKey).push(handler3) : handler3(); 708 }; 709 fullHandler.runCleanups = cleanup2; 710 return fullHandler; 711} 712var startingWith = (subject, replacement) => ({name, value}) => { 713 if (name.startsWith(subject)) 714 name = name.replace(subject, replacement); 715 return {name, value}; 716}; 717var into = (i) => i; 718function toTransformedAttributes(callback = () => { 719}) { 720 return ({name, value}) => { 721 let {name: newName, value: newValue} = attributeTransformers.reduce((carry, transform) => { 722 return transform(carry); 723 }, {name, value}); 724 if (newName !== name) 725 callback(newName, name); 726 return {name: newName, value: newValue}; 727 }; 728} 729var attributeTransformers = []; 730function mapAttributes(callback) { 731 attributeTransformers.push(callback); 732} 733function outNonAlpineAttributes({name}) { 734 return alpineAttributeRegex().test(name); 735} 736var alpineAttributeRegex = () => new RegExp(`^${prefixAsString}([^:^.]+)\\b`); 737function toParsedDirectives(transformedAttributeMap, originalAttributeOverride) { 738 return ({name, value}) => { 739 let typeMatch = name.match(alpineAttributeRegex()); 740 let valueMatch = name.match(/:([a-zA-Z0-9\-:]+)/); 741 let modifiers = name.match(/\.[^.\]]+(?=[^\]]*$)/g) || []; 742 let original = originalAttributeOverride || transformedAttributeMap[name] || name; 743 return { 744 type: typeMatch ? typeMatch[1] : null, 745 value: valueMatch ? valueMatch[1] : null, 746 modifiers: modifiers.map((i) => i.replace(".", "")), 747 expression: value, 748 original 749 }; 750 }; 751} 752var DEFAULT = "DEFAULT"; 753var directiveOrder = [ 754 "ignore", 755 "ref", 756 "data", 757 "id", 758 "bind", 759 "init", 760 "for", 761 "mask", 762 "model", 763 "modelable", 764 "transition", 765 "show", 766 "if", 767 DEFAULT, 768 "teleport", 769 "element" 770]; 771function byPriority(a, b) { 772 let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type; 773 let typeB = directiveOrder.indexOf(b.type) === -1 ? DEFAULT : b.type; 774 return directiveOrder.indexOf(typeA) - directiveOrder.indexOf(typeB); 775} 776 777// packages/alpinejs/src/utils/dispatch.js 778function dispatch(el, name, detail = {}) { 779 el.dispatchEvent(new CustomEvent(name, { 780 detail, 781 bubbles: true, 782 composed: true, 783 cancelable: true 784 })); 785} 786 787// packages/alpinejs/src/nextTick.js 788var tickStack = []; 789var isHolding = false; 790function nextTick(callback = () => { 791}) { 792 queueMicrotask(() => { 793 isHolding || setTimeout(() => { 794 releaseNextTicks(); 795 }); 796 }); 797 return new Promise((res) => { 798 tickStack.push(() => { 799 callback(); 800 res(); 801 }); 802 }); 803} 804function releaseNextTicks() { 805 isHolding = false; 806 while (tickStack.length) 807 tickStack.shift()(); 808} 809function holdNextTicks() { 810 isHolding = true; 811} 812 813// packages/alpinejs/src/utils/walk.js 814function walk(el, callback) { 815 if (typeof ShadowRoot === "function" && el instanceof ShadowRoot) { 816 Array.from(el.children).forEach((el2) => walk(el2, callback)); 817 return; 818 } 819 let skip = false; 820 callback(el, () => skip = true); 821 if (skip) 822 return; 823 let node = el.firstElementChild; 824 while (node) { 825 walk(node, callback, false); 826 node = node.nextElementSibling; 827 } 828} 829 830// packages/alpinejs/src/utils/warn.js 831function warn(message, ...args) { 832 console.warn(`Alpine Warning: ${message}`, ...args); 833} 834 835// packages/alpinejs/src/lifecycle.js 836function start() { 837 if (!document.body) 838 warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"); 839 dispatch(document, "alpine:init"); 840 dispatch(document, "alpine:initializing"); 841 startObservingMutations(); 842 onElAdded((el) => initTree(el, walk)); 843 onElRemoved((el) => destroyTree(el)); 844 onAttributesAdded((el, attrs) => { 845 directives(el, attrs).forEach((handle) => handle()); 846 }); 847 let outNestedComponents = (el) => !closestRoot(el.parentElement, true); 848 Array.from(document.querySelectorAll(allSelectors())).filter(outNestedComponents).forEach((el) => { 849 initTree(el); 850 }); 851 dispatch(document, "alpine:initialized"); 852} 853var rootSelectorCallbacks = []; 854var initSelectorCallbacks = []; 855function rootSelectors() { 856 return rootSelectorCallbacks.map((fn) => fn()); 857} 858function allSelectors() { 859 return rootSelectorCallbacks.concat(initSelectorCallbacks).map((fn) => fn()); 860} 861function addRootSelector(selectorCallback) { 862 rootSelectorCallbacks.push(selectorCallback); 863} 864function addInitSelector(selectorCallback) { 865 initSelectorCallbacks.push(selectorCallback); 866} 867function closestRoot(el, includeInitSelectors = false) { 868 return findClosest(el, (element) => { 869 const selectors = includeInitSelectors ? allSelectors() : rootSelectors(); 870 if (selectors.some((selector) => element.matches(selector))) 871 return true; 872 }); 873} 874function findClosest(el, callback) { 875 if (!el) 876 return; 877 if (callback(el)) 878 return el; 879 if (el._x_teleportBack) 880 el = el._x_teleportBack; 881 if (!el.parentElement) 882 return; 883 return findClosest(el.parentElement, callback); 884} 885function isRoot(el) { 886 return rootSelectors().some((selector) => el.matches(selector)); 887} 888function initTree(el, walker = walk) { 889 deferHandlingDirectives(() => { 890 walker(el, (el2, skip) => { 891 directives(el2, el2.attributes).forEach((handle) => handle()); 892 el2._x_ignore && skip(); 893 }); 894 }); 895} 896function destroyTree(root) { 897 walk(root, (el) => cleanupAttributes(el)); 898} 899 900// packages/alpinejs/src/utils/classes.js 901function setClasses(el, value) { 902 if (Array.isArray(value)) { 903 return setClassesFromString(el, value.join(" ")); 904 } else if (typeof value === "object" && value !== null) { 905 return setClassesFromObject(el, value); 906 } else if (typeof value === "function") { 907 return setClasses(el, value()); 908 } 909 return setClassesFromString(el, value); 910} 911function setClassesFromString(el, classString) { 912 let split = (classString2) => classString2.split(" ").filter(Boolean); 913 let missingClasses = (classString2) => classString2.split(" ").filter((i) => !el.classList.contains(i)).filter(Boolean); 914 let addClassesAndReturnUndo = (classes) => { 915 el.classList.add(...classes); 916 return () => { 917 el.classList.remove(...classes); 918 }; 919 }; 920 classString = classString === true ? classString = "" : classString || ""; 921 return addClassesAndReturnUndo(missingClasses(classString)); 922} 923function setClassesFromObject(el, classObject) { 924 let split = (classString) => classString.split(" ").filter(Boolean); 925 let forAdd = Object.entries(classObject).flatMap(([classString, bool]) => bool ? split(classString) : false).filter(Boolean); 926 let forRemove = Object.entries(classObject).flatMap(([classString, bool]) => !bool ? split(classString) : false).filter(Boolean); 927 let added = []; 928 let removed = []; 929 forRemove.forEach((i) => { 930 if (el.classList.contains(i)) { 931 el.classList.remove(i); 932 removed.push(i); 933 } 934 }); 935 forAdd.forEach((i) => { 936 if (!el.classList.contains(i)) { 937 el.classList.add(i); 938 added.push(i); 939 } 940 }); 941 return () => { 942 removed.forEach((i) => el.classList.add(i)); 943 added.forEach((i) => el.classList.remove(i)); 944 }; 945} 946 947// packages/alpinejs/src/utils/styles.js 948function setStyles(el, value) { 949 if (typeof value === "object" && value !== null) { 950 return setStylesFromObject(el, value); 951 } 952 return setStylesFromString(el, value); 953} 954function setStylesFromObject(el, value) { 955 let previousStyles = {}; 956 Object.entries(value).forEach(([key, value2]) => { 957 previousStyles[key] = el.style[key]; 958 if (!key.startsWith("--")) { 959 key = kebabCase(key); 960 } 961 el.style.setProperty(key, value2); 962 }); 963 setTimeout(() => { 964 if (el.style.length === 0) { 965 el.removeAttribute("style"); 966 } 967 }); 968 return () => { 969 setStyles(el, previousStyles); 970 }; 971} 972function setStylesFromString(el, value) { 973 let cache = el.getAttribute("style", value); 974 el.setAttribute("style", value); 975 return () => { 976 el.setAttribute("style", cache || ""); 977 }; 978} 979function kebabCase(subject) { 980 return subject.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); 981} 982 983// packages/alpinejs/src/utils/once.js 984function once(callback, fallback = () => { 985}) { 986 let called = false; 987 return function() { 988 if (!called) { 989 called = true; 990 callback.apply(this, arguments); 991 } else { 992 fallback.apply(this, arguments); 993 } 994 }; 995} 996 997// packages/alpinejs/src/directives/x-transition.js 998directive("transition", (el, {value, modifiers, expression}, {evaluate: evaluate2}) => { 999 if (typeof expression === "function") 1000 expression = evaluate2(expression); 1001 if (!expression) { 1002 registerTransitionsFromHelper(el, modifiers, value); 1003 } else { 1004 registerTransitionsFromClassString(el, expression, value); 1005 } 1006}); 1007function registerTransitionsFromClassString(el, classString, stage) { 1008 registerTransitionObject(el, setClasses, ""); 1009 let directiveStorageMap = { 1010 enter: (classes) => { 1011 el._x_transition.enter.during = classes; 1012 }, 1013 "enter-start": (classes) => { 1014 el._x_transition.enter.start = classes; 1015 }, 1016 "enter-end": (classes) => { 1017 el._x_transition.enter.end = classes; 1018 }, 1019 leave: (classes) => { 1020 el._x_transition.leave.during = classes; 1021 }, 1022 "leave-start": (classes) => { 1023 el._x_transition.leave.start = classes; 1024 }, 1025 "leave-end": (classes) => { 1026 el._x_transition.leave.end = classes; 1027 } 1028 }; 1029 directiveStorageMap[stage](classString); 1030} 1031function registerTransitionsFromHelper(el, modifiers, stage) { 1032 registerTransitionObject(el, setStyles); 1033 let doesntSpecify = !modifiers.includes("in") && !modifiers.includes("out") && !stage; 1034 let transitioningIn = doesntSpecify || modifiers.includes("in") || ["enter"].includes(stage); 1035 let transitioningOut = doesntSpecify || modifiers.includes("out") || ["leave"].includes(stage); 1036 if (modifiers.includes("in") && !doesntSpecify) { 1037 modifiers = modifiers.filter((i, index) => index < modifiers.indexOf("out")); 1038 } 1039 if (modifiers.includes("out") && !doesntSpecify) { 1040 modifiers = modifiers.filter((i, index) => index > modifiers.indexOf("out")); 1041 } 1042 let wantsAll = !modifiers.includes("opacity") && !modifiers.includes("scale"); 1043 let wantsOpacity = wantsAll || modifiers.includes("opacity"); 1044 let wantsScale = wantsAll || modifiers.includes("scale"); 1045 let opacityValue = wantsOpacity ? 0 : 1; 1046 let scaleValue = wantsScale ? modifierValue(modifiers, "scale", 95) / 100 : 1; 1047 let delay = modifierValue(modifiers, "delay", 0); 1048 let origin = modifierValue(modifiers, "origin", "center"); 1049 let property = "opacity, transform"; 1050 let durationIn = modifierValue(modifiers, "duration", 150) / 1e3; 1051 let durationOut = modifierValue(modifiers, "duration", 75) / 1e3; 1052 let easing = `cubic-bezier(0.4, 0.0, 0.2, 1)`; 1053 if (transitioningIn) { 1054 el._x_transition.enter.during = { 1055 transformOrigin: origin, 1056 transitionDelay: delay, 1057 transitionProperty: property, 1058 transitionDuration: `${durationIn}s`, 1059 transitionTimingFunction: easing 1060 }; 1061 el._x_transition.enter.start = { 1062 opacity: opacityValue, 1063 transform: `scale(${scaleValue})` 1064 }; 1065 el._x_transition.enter.end = { 1066 opacity: 1, 1067 transform: `scale(1)` 1068 }; 1069 } 1070 if (transitioningOut) { 1071 el._x_transition.leave.during = { 1072 transformOrigin: origin, 1073 transitionDelay: delay, 1074 transitionProperty: property, 1075 transitionDuration: `${durationOut}s`, 1076 transitionTimingFunction: easing 1077 }; 1078 el._x_transition.leave.start = { 1079 opacity: 1, 1080 transform: `scale(1)` 1081 }; 1082 el._x_transition.leave.end = { 1083 opacity: opacityValue, 1084 transform: `scale(${scaleValue})` 1085 }; 1086 } 1087} 1088function registerTransitionObject(el, setFunction, defaultValue = {}) { 1089 if (!el._x_transition) 1090 el._x_transition = { 1091 enter: {during: defaultValue, start: defaultValue, end: defaultValue}, 1092 leave: {during: defaultValue, start: defaultValue, end: defaultValue}, 1093 in(before = () => { 1094 }, after = () => { 1095 }) { 1096 transition(el, setFunction, { 1097 during: this.enter.during, 1098 start: this.enter.start, 1099 end: this.enter.end 1100 }, before, after); 1101 }, 1102 out(before = () => { 1103 }, after = () => { 1104 }) { 1105 transition(el, setFunction, { 1106 during: this.leave.during, 1107 start: this.leave.start, 1108 end: this.leave.end 1109 }, before, after); 1110 } 1111 }; 1112} 1113window.Element.prototype._x_toggleAndCascadeWithTransitions = function(el, value, show, hide) { 1114 let clickAwayCompatibleShow = () => { 1115 document.visibilityState === "visible" ? requestAnimationFrame(show) : setTimeout(show); 1116 }; 1117 if (value) { 1118 if (el._x_transition && (el._x_transition.enter || el._x_transition.leave)) { 1119 el._x_transition.enter && (Object.entries(el._x_transition.enter.during).length || Object.entries(el._x_transition.enter.start).length || Object.entries(el._x_transition.enter.end).length) ? el._x_transition.in(show) : clickAwayCompatibleShow(); 1120 } else { 1121 el._x_transition ? el._x_transition.in(show) : clickAwayCompatibleShow(); 1122 } 1123 return; 1124 } 1125 el._x_hidePromise = el._x_transition ? new Promise((resolve, reject) => { 1126 el._x_transition.out(() => { 1127 }, () => resolve(hide)); 1128 el._x_transitioning.beforeCancel(() => reject({isFromCancelledTransition: true})); 1129 }) : Promise.resolve(hide); 1130 queueMicrotask(() => { 1131 let closest = closestHide(el); 1132 if (closest) { 1133 if (!closest._x_hideChildren) 1134 closest._x_hideChildren = []; 1135 closest._x_hideChildren.push(el); 1136 } else { 1137 queueMicrotask(() => { 1138 let hideAfterChildren = (el2) => { 1139 let carry = Promise.all([ 1140 el2._x_hidePromise, 1141 ...(el2._x_hideChildren || []).map(hideAfterChildren) 1142 ]).then(([i]) => i()); 1143 delete el2._x_hidePromise; 1144 delete el2._x_hideChildren; 1145 return carry; 1146 }; 1147 hideAfterChildren(el).catch((e) => { 1148 if (!e.isFromCancelledTransition) 1149 throw e; 1150 }); 1151 }); 1152 } 1153 }); 1154}; 1155function closestHide(el) { 1156 let parent = el.parentNode; 1157 if (!parent) 1158 return; 1159 return parent._x_hidePromise ? parent : closestHide(parent); 1160} 1161function transition(el, setFunction, {during, start: start2, end} = {}, before = () => { 1162}, after = () => { 1163}) { 1164 if (el._x_transitioning) 1165 el._x_transitioning.cancel(); 1166 if (Object.keys(during).length === 0 && Object.keys(start2).length === 0 && Object.keys(end).length === 0) { 1167 before(); 1168 after(); 1169 return; 1170 } 1171 let undoStart, undoDuring, undoEnd; 1172 performTransition(el, { 1173 start() { 1174 undoStart = setFunction(el, start2); 1175 }, 1176 during() { 1177 undoDuring = setFunction(el, during); 1178 }, 1179 before, 1180 end() { 1181 undoStart(); 1182 undoEnd = setFunction(el, end); 1183 }, 1184 after, 1185 cleanup() { 1186 undoDuring(); 1187 undoEnd(); 1188 } 1189 }); 1190} 1191function performTransition(el, stages) { 1192 let interrupted, reachedBefore, reachedEnd; 1193 let finish = once(() => { 1194 mutateDom(() => { 1195 interrupted = true; 1196 if (!reachedBefore) 1197 stages.before(); 1198 if (!reachedEnd) { 1199 stages.end(); 1200 releaseNextTicks(); 1201 } 1202 stages.after(); 1203 if (el.isConnected) 1204 stages.cleanup(); 1205 delete el._x_transitioning; 1206 }); 1207 }); 1208 el._x_transitioning = { 1209 beforeCancels: [], 1210 beforeCancel(callback) { 1211 this.beforeCancels.push(callback); 1212 }, 1213 cancel: once(function() { 1214 while (this.beforeCancels.length) { 1215 this.beforeCancels.shift()(); 1216 } 1217 ; 1218 finish(); 1219 }), 1220 finish 1221 }; 1222 mutateDom(() => { 1223 stages.start(); 1224 stages.during(); 1225 }); 1226 holdNextTicks(); 1227 requestAnimationFrame(() => { 1228 if (interrupted) 1229 return; 1230 let duration = Number(getComputedStyle(el).transitionDuration.replace(/,.*/, "").replace("s", "")) * 1e3; 1231 let delay = Number(getComputedStyle(el).transitionDelay.replace(/,.*/, "").replace("s", "")) * 1e3; 1232 if (duration === 0) 1233 duration = Number(getComputedStyle(el).animationDuration.replace("s", "")) * 1e3; 1234 mutateDom(() => { 1235 stages.before(); 1236 }); 1237 reachedBefore = true; 1238 requestAnimationFrame(() => { 1239 if (interrupted) 1240 return; 1241 mutateDom(() => { 1242 stages.end(); 1243 }); 1244 releaseNextTicks(); 1245 setTimeout(el._x_transitioning.finish, duration + delay); 1246 reachedEnd = true; 1247 }); 1248 }); 1249} 1250function modifierValue(modifiers, key, fallback) { 1251 if (modifiers.indexOf(key) === -1) 1252 return fallback; 1253 const rawValue = modifiers[modifiers.indexOf(key) + 1]; 1254 if (!rawValue) 1255 return fallback; 1256 if (key === "scale") { 1257 if (isNaN(rawValue)) 1258 return fallback; 1259 } 1260 if (key === "duration") { 1261 let match = rawValue.match(/([0-9]+)ms/); 1262 if (match) 1263 return match[1]; 1264 } 1265 if (key === "origin") { 1266 if (["top", "right", "left", "center", "bottom"].includes(modifiers[modifiers.indexOf(key) + 2])) { 1267 return [rawValue, modifiers[modifiers.indexOf(key) + 2]].join(" "); 1268 } 1269 } 1270 return rawValue; 1271} 1272 1273// packages/alpinejs/src/clone.js 1274var isCloning = false; 1275function skipDuringClone(callback, fallback = () => { 1276}) { 1277 return (...args) => isCloning ? fallback(...args) : callback(...args); 1278} 1279function clone(oldEl, newEl) { 1280 if (!newEl._x_dataStack) 1281 newEl._x_dataStack = oldEl._x_dataStack; 1282 isCloning = true; 1283 dontRegisterReactiveSideEffects(() => { 1284 cloneTree(newEl); 1285 }); 1286 isCloning = false; 1287} 1288function cloneTree(el) { 1289 let hasRunThroughFirstEl = false; 1290 let shallowWalker = (el2, callback) => { 1291 walk(el2, (el3, skip) => { 1292 if (hasRunThroughFirstEl && isRoot(el3)) 1293 return skip(); 1294 hasRunThroughFirstEl = true; 1295 callback(el3, skip); 1296 }); 1297 }; 1298 initTree(el, shallowWalker); 1299} 1300function dontRegisterReactiveSideEffects(callback) { 1301 let cache = effect; 1302 overrideEffect((callback2, el) => { 1303 let storedEffect = cache(callback2); 1304 release(storedEffect); 1305 return () => { 1306 }; 1307 }); 1308 callback(); 1309 overrideEffect(cache); 1310} 1311 1312// packages/alpinejs/src/utils/bind.js 1313function bind(el, name, value, modifiers = []) { 1314 if (!el._x_bindings) 1315 el._x_bindings = reactive({}); 1316 el._x_bindings[name] = value; 1317 name = modifiers.includes("camel") ? camelCase(name) : name; 1318 switch (name) { 1319 case "value": 1320 bindInputValue(el, value); 1321 break; 1322 case "style": 1323 bindStyles(el, value); 1324 break; 1325 case "class": 1326 bindClasses(el, value); 1327 break; 1328 default: 1329 bindAttribute(el, name, value); 1330 break; 1331 } 1332} 1333function bindInputValue(el, value) { 1334 if (el.type === "radio") { 1335 if (el.attributes.value === void 0) { 1336 el.value = value; 1337 } 1338 if (window.fromModel) { 1339 el.checked = checkedAttrLooseCompare(el.value, value); 1340 } 1341 } else if (el.type === "checkbox") { 1342 if (Number.isInteger(value)) { 1343 el.value = value; 1344 } else if (!Number.isInteger(value) && !Array.isArray(value) && typeof value !== "boolean" && ![null, void 0].includes(value)) { 1345 el.value = String(value); 1346 } else { 1347 if (Array.isArray(value)) { 1348 el.checked = value.some((val) => checkedAttrLooseCompare(val, el.value)); 1349 } else { 1350 el.checked = !!value; 1351 } 1352 } 1353 } else if (el.tagName === "SELECT") { 1354 updateSelect(el, value); 1355 } else { 1356 if (el.value === value) 1357 return; 1358 el.value = value; 1359 } 1360} 1361function bindClasses(el, value) { 1362 if (el._x_undoAddedClasses) 1363 el._x_undoAddedClasses(); 1364 el._x_undoAddedClasses = setClasses(el, value); 1365} 1366function bindStyles(el, value) { 1367 if (el._x_undoAddedStyles) 1368 el._x_undoAddedStyles(); 1369 el._x_undoAddedStyles = setStyles(el, value); 1370} 1371function bindAttribute(el, name, value) { 1372 if ([null, void 0, false].includes(value) && attributeShouldntBePreservedIfFalsy(name)) { 1373 el.removeAttribute(name); 1374 } else { 1375 if (isBooleanAttr(name)) 1376 value = name; 1377 setIfChanged(el, name, value); 1378 } 1379} 1380function setIfChanged(el, attrName, value) { 1381 if (el.getAttribute(attrName) != value) { 1382 el.setAttribute(attrName, value); 1383 } 1384} 1385function updateSelect(el, value) { 1386 const arrayWrappedValue = [].concat(value).map((value2) => { 1387 return value2 + ""; 1388 }); 1389 Array.from(el.options).forEach((option) => { 1390 option.selected = arrayWrappedValue.includes(option.value); 1391 }); 1392} 1393function camelCase(subject) { 1394 return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); 1395} 1396function checkedAttrLooseCompare(valueA, valueB) { 1397 return valueA == valueB; 1398} 1399function isBooleanAttr(attrName) { 1400 const booleanAttributes = [ 1401 "disabled", 1402 "checked", 1403 "required", 1404 "readonly", 1405 "hidden", 1406 "open", 1407 "selected", 1408 "autofocus", 1409 "itemscope", 1410 "multiple", 1411 "novalidate", 1412 "allowfullscreen", 1413 "allowpaymentrequest", 1414 "formnovalidate", 1415 "autoplay", 1416 "controls", 1417 "loop", 1418 "muted", 1419 "playsinline", 1420 "default", 1421 "ismap", 1422 "reversed", 1423 "async", 1424 "defer", 1425 "nomodule" 1426 ]; 1427 return booleanAttributes.includes(attrName); 1428} 1429function attributeShouldntBePreservedIfFalsy(name) { 1430 return !["aria-pressed", "aria-checked", "aria-expanded", "aria-selected"].includes(name); 1431} 1432function getBinding(el, name, fallback) { 1433 if (el._x_bindings && el._x_bindings[name] !== void 0) 1434 return el._x_bindings[name]; 1435 let attr = el.getAttribute(name); 1436 if (attr === null) 1437 return typeof fallback === "function" ? fallback() : fallback; 1438 if (isBooleanAttr(name)) { 1439 return !![name, "true"].includes(attr); 1440 } 1441 if (attr === "") 1442 return true; 1443 return attr; 1444} 1445 1446// packages/alpinejs/src/utils/debounce.js 1447function debounce(func, wait) { 1448 var timeout; 1449 return function() { 1450 var context = this, args = arguments; 1451 var later = function() { 1452 timeout = null; 1453 func.apply(context, args); 1454 }; 1455 clearTimeout(timeout); 1456 timeout = setTimeout(later, wait); 1457 }; 1458} 1459 1460// packages/alpinejs/src/utils/throttle.js 1461function throttle(func, limit) { 1462 let inThrottle; 1463 return function() { 1464 let context = this, args = arguments; 1465 if (!inThrottle) { 1466 func.apply(context, args); 1467 inThrottle = true; 1468 setTimeout(() => inThrottle = false, limit); 1469 } 1470 }; 1471} 1472 1473// packages/alpinejs/src/plugin.js 1474function plugin(callback) { 1475 callback(alpine_default); 1476} 1477 1478// packages/alpinejs/src/store.js 1479var stores = {}; 1480var isReactive = false; 1481function store(name, value) { 1482 if (!isReactive) { 1483 stores = reactive(stores); 1484 isReactive = true; 1485 } 1486 if (value === void 0) { 1487 return stores[name]; 1488 } 1489 stores[name] = value; 1490 if (typeof value === "object" && value !== null && value.hasOwnProperty("init") && typeof value.init === "function") { 1491 stores[name].init(); 1492 } 1493 initInterceptors(stores[name]); 1494} 1495function getStores() { 1496 return stores; 1497} 1498 1499// packages/alpinejs/src/binds.js 1500var binds = {}; 1501function bind2(name, object) { 1502 binds[name] = typeof object !== "function" ? () => object : object; 1503} 1504function injectBindingProviders(obj) { 1505 Object.entries(binds).forEach(([name, callback]) => { 1506 Object.defineProperty(obj, name, { 1507 get() { 1508 return (...args) => { 1509 return callback(...args); 1510 }; 1511 } 1512 }); 1513 }); 1514 return obj; 1515} 1516 1517// packages/alpinejs/src/datas.js 1518var datas = {}; 1519function data(name, callback) { 1520 datas[name] = callback; 1521} 1522function injectDataProviders(obj, context) { 1523 Object.entries(datas).forEach(([name, callback]) => { 1524 Object.defineProperty(obj, name, { 1525 get() { 1526 return (...args) => { 1527 return callback.bind(context)(...args); 1528 }; 1529 }, 1530 enumerable: false 1531 }); 1532 }); 1533 return obj; 1534} 1535 1536// packages/alpinejs/src/alpine.js 1537var Alpine = { 1538 get reactive() { 1539 return reactive; 1540 }, 1541 get release() { 1542 return release; 1543 }, 1544 get effect() { 1545 return effect; 1546 }, 1547 get raw() { 1548 return raw; 1549 }, 1550 version: "3.10.0", 1551 flushAndStopDeferringMutations, 1552 dontAutoEvaluateFunctions, 1553 disableEffectScheduling, 1554 setReactivityEngine, 1555 closestDataStack, 1556 skipDuringClone, 1557 addRootSelector, 1558 addInitSelector, 1559 addScopeToNode, 1560 deferMutations, 1561 mapAttributes, 1562 evaluateLater, 1563 setEvaluator, 1564 mergeProxies, 1565 findClosest, 1566 closestRoot, 1567 interceptor, 1568 transition, 1569 setStyles, 1570 mutateDom, 1571 directive, 1572 throttle, 1573 debounce, 1574 evaluate, 1575 initTree, 1576 nextTick, 1577 prefixed: prefix, 1578 prefix: setPrefix, 1579 plugin, 1580 magic, 1581 store, 1582 start, 1583 clone, 1584 bound: getBinding, 1585 $data: scope, 1586 data, 1587 bind: bind2 1588}; 1589var alpine_default = Alpine; 1590 1591// node_modules/@vue/shared/dist/shared.esm-bundler.js 1592function makeMap(str, expectsLowerCase) { 1593 const map = Object.create(null); 1594 const list = str.split(","); 1595 for (let i = 0; i < list.length; i++) { 1596 map[list[i]] = true; 1597 } 1598 return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val]; 1599} 1600var PatchFlagNames = { 1601 [1]: `TEXT`, 1602 [2]: `CLASS`, 1603 [4]: `STYLE`, 1604 [8]: `PROPS`, 1605 [16]: `FULL_PROPS`, 1606 [32]: `HYDRATE_EVENTS`, 1607 [64]: `STABLE_FRAGMENT`, 1608 [128]: `KEYED_FRAGMENT`, 1609 [256]: `UNKEYED_FRAGMENT`, 1610 [512]: `NEED_PATCH`, 1611 [1024]: `DYNAMIC_SLOTS`, 1612 [2048]: `DEV_ROOT_FRAGMENT`, 1613 [-1]: `HOISTED`, 1614 [-2]: `BAIL` 1615}; 1616var slotFlagsText = { 1617 [1]: "STABLE", 1618 [2]: "DYNAMIC", 1619 [3]: "FORWARDED" 1620}; 1621var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; 1622var isBooleanAttr2 = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`); 1623var EMPTY_OBJ = false ? 0 : {}; 1624var EMPTY_ARR = false ? 0 : []; 1625var extend = Object.assign; 1626var hasOwnProperty = Object.prototype.hasOwnProperty; 1627var hasOwn = (val, key) => hasOwnProperty.call(val, key); 1628var isArray = Array.isArray; 1629var isMap = (val) => toTypeString(val) === "[object Map]"; 1630var isString = (val) => typeof val === "string"; 1631var isSymbol = (val) => typeof val === "symbol"; 1632var isObject = (val) => val !== null && typeof val === "object"; 1633var objectToString = Object.prototype.toString; 1634var toTypeString = (value) => objectToString.call(value); 1635var toRawType = (value) => { 1636 return toTypeString(value).slice(8, -1); 1637}; 1638var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key; 1639var cacheStringFunction = (fn) => { 1640 const cache = Object.create(null); 1641 return (str) => { 1642 const hit = cache[str]; 1643 return hit || (cache[str] = fn(str)); 1644 }; 1645}; 1646var camelizeRE = /-(\w)/g; 1647var camelize = cacheStringFunction((str) => { 1648 return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); 1649}); 1650var hyphenateRE = /\B([A-Z])/g; 1651var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); 1652var capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1)); 1653var toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``); 1654var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue); 1655 1656// node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js 1657var targetMap = new WeakMap(); 1658var effectStack = []; 1659var activeEffect; 1660var ITERATE_KEY = Symbol( false ? 0 : ""); 1661var MAP_KEY_ITERATE_KEY = Symbol( false ? 0 : ""); 1662function isEffect(fn) { 1663 return fn && fn._isEffect === true; 1664} 1665function effect2(fn, options = EMPTY_OBJ) { 1666 if (isEffect(fn)) { 1667 fn = fn.raw; 1668 } 1669 const effect3 = createReactiveEffect(fn, options); 1670 if (!options.lazy) { 1671 effect3(); 1672 } 1673 return effect3; 1674} 1675function stop(effect3) { 1676 if (effect3.active) { 1677 cleanup(effect3); 1678 if (effect3.options.onStop) { 1679 effect3.options.onStop(); 1680 } 1681 effect3.active = false; 1682 } 1683} 1684var uid = 0; 1685function createReactiveEffect(fn, options) { 1686 const effect3 = function reactiveEffect() { 1687 if (!effect3.active) { 1688 return fn(); 1689 } 1690 if (!effectStack.includes(effect3)) { 1691 cleanup(effect3); 1692 try { 1693 enableTracking(); 1694 effectStack.push(effect3); 1695 activeEffect = effect3; 1696 return fn(); 1697 } finally { 1698 effectStack.pop(); 1699 resetTracking(); 1700 activeEffect = effectStack[effectStack.length - 1]; 1701 } 1702 } 1703 }; 1704 effect3.id = uid++; 1705 effect3.allowRecurse = !!options.allowRecurse; 1706 effect3._isEffect = true; 1707 effect3.active = true; 1708 effect3.raw = fn; 1709 effect3.deps = []; 1710 effect3.options = options; 1711 return effect3; 1712} 1713function cleanup(effect3) { 1714 const {deps} = effect3; 1715 if (deps.length) { 1716 for (let i = 0; i < deps.length; i++) { 1717 deps[i].delete(effect3); 1718 } 1719 deps.length = 0; 1720 } 1721} 1722var shouldTrack = true; 1723var trackStack = []; 1724function pauseTracking() { 1725 trackStack.push(shouldTrack); 1726 shouldTrack = false; 1727} 1728function enableTracking() { 1729 trackStack.push(shouldTrack); 1730 shouldTrack = true; 1731} 1732function resetTracking() { 1733 const last = trackStack.pop(); 1734 shouldTrack = last === void 0 ? true : last; 1735} 1736function track(target, type, key) { 1737 if (!shouldTrack || activeEffect === void 0) { 1738 return; 1739 } 1740 let depsMap = targetMap.get(target); 1741 if (!depsMap) { 1742 targetMap.set(target, depsMap = new Map()); 1743 } 1744 let dep = depsMap.get(key); 1745 if (!dep) { 1746 depsMap.set(key, dep = new Set()); 1747 } 1748 if (!dep.has(activeEffect)) { 1749 dep.add(activeEffect); 1750 activeEffect.deps.push(dep); 1751 if (false) {} 1752 } 1753} 1754function trigger(target, type, key, newValue, oldValue, oldTarget) { 1755 const depsMap = targetMap.get(target); 1756 if (!depsMap) { 1757 return; 1758 } 1759 const effects = new Set(); 1760 const add2 = (effectsToAdd) => { 1761 if (effectsToAdd) { 1762 effectsToAdd.forEach((effect3) => { 1763 if (effect3 !== activeEffect || effect3.allowRecurse) { 1764 effects.add(effect3); 1765 } 1766 }); 1767 } 1768 }; 1769 if (type === "clear") { 1770 depsMap.forEach(add2); 1771 } else if (key === "length" && isArray(target)) { 1772 depsMap.forEach((dep, key2) => { 1773 if (key2 === "length" || key2 >= newValue) { 1774 add2(dep); 1775 } 1776 }); 1777 } else { 1778 if (key !== void 0) { 1779 add2(depsMap.get(key)); 1780 } 1781 switch (type) { 1782 case "add": 1783 if (!isArray(target)) { 1784 add2(depsMap.get(ITERATE_KEY)); 1785 if (isMap(target)) { 1786 add2(depsMap.get(MAP_KEY_ITERATE_KEY)); 1787 } 1788 } else if (isIntegerKey(key)) { 1789 add2(depsMap.get("length")); 1790 } 1791 break; 1792 case "delete": 1793 if (!isArray(target)) { 1794 add2(depsMap.get(ITERATE_KEY)); 1795 if (isMap(target)) { 1796 add2(depsMap.get(MAP_KEY_ITERATE_KEY)); 1797 } 1798 } 1799 break; 1800 case "set": 1801 if (isMap(target)) { 1802 add2(depsMap.get(ITERATE_KEY)); 1803 } 1804 break; 1805 } 1806 } 1807 const run = (effect3) => { 1808 if (false) {} 1809 if (effect3.options.scheduler) { 1810 effect3.options.scheduler(effect3); 1811 } else { 1812 effect3(); 1813 } 1814 }; 1815 effects.forEach(run); 1816} 1817var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); 1818var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol)); 1819var get2 = /* @__PURE__ */ createGetter(); 1820var shallowGet = /* @__PURE__ */ createGetter(false, true); 1821var readonlyGet = /* @__PURE__ */ createGetter(true); 1822var shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true); 1823var arrayInstrumentations = {}; 1824["includes", "indexOf", "lastIndexOf"].forEach((key) => { 1825 const method = Array.prototype[key]; 1826 arrayInstrumentations[key] = function(...args) { 1827 const arr = toRaw(this); 1828 for (let i = 0, l = this.length; i < l; i++) { 1829 track(arr, "get", i + ""); 1830 } 1831 const res = method.apply(arr, args); 1832 if (res === -1 || res === false) { 1833 return method.apply(arr, args.map(toRaw)); 1834 } else { 1835 return res; 1836 } 1837 }; 1838}); 1839["push", "pop", "shift", "unshift", "splice"].forEach((key) => { 1840 const method = Array.prototype[key]; 1841 arrayInstrumentations[key] = function(...args) { 1842 pauseTracking(); 1843 const res = method.apply(this, args); 1844 resetTracking(); 1845 return res; 1846 }; 1847}); 1848function createGetter(isReadonly = false, shallow = false) { 1849 return function get3(target, key, receiver) { 1850 if (key === "__v_isReactive") { 1851 return !isReadonly; 1852 } else if (key === "__v_isReadonly") { 1853 return isReadonly; 1854 } else if (key === "__v_raw" && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { 1855 return target; 1856 } 1857 const targetIsArray = isArray(target); 1858 if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) { 1859 return Reflect.get(arrayInstrumentations, key, receiver); 1860 } 1861 const res = Reflect.get(target, key, receiver); 1862 if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { 1863 return res; 1864 } 1865 if (!isReadonly) { 1866 track(target, "get", key); 1867 } 1868 if (shallow) { 1869 return res; 1870 } 1871 if (isRef(res)) { 1872 const shouldUnwrap = !targetIsArray || !isIntegerKey(key); 1873 return shouldUnwrap ? res.value : res; 1874 } 1875 if (isObject(res)) { 1876 return isReadonly ? readonly(res) : reactive2(res); 1877 } 1878 return res; 1879 }; 1880} 1881var set2 = /* @__PURE__ */ createSetter(); 1882var shallowSet = /* @__PURE__ */ createSetter(true); 1883function createSetter(shallow = false) { 1884 return function set3(target, key, value, receiver) { 1885 let oldValue = target[key]; 1886 if (!shallow) { 1887 value = toRaw(value); 1888 oldValue = toRaw(oldValue); 1889 if (!isArray(target) && isRef(oldValue) && !isRef(value)) { 1890 oldValue.value = value; 1891 return true; 1892 } 1893 } 1894 const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); 1895 const result = Reflect.set(target, key, value, receiver); 1896 if (target === toRaw(receiver)) { 1897 if (!hadKey) { 1898 trigger(target, "add", key, value); 1899 } else if (hasChanged(value, oldValue)) { 1900 trigger(target, "set", key, value, oldValue); 1901 } 1902 } 1903 return result; 1904 }; 1905} 1906function deleteProperty(target, key) { 1907 const hadKey = hasOwn(target, key); 1908 const oldValue = target[key]; 1909 const result = Reflect.deleteProperty(target, key); 1910 if (result && hadKey) { 1911 trigger(target, "delete", key, void 0, oldValue); 1912 } 1913 return result; 1914} 1915function has(target, key) { 1916 const result = Reflect.has(target, key); 1917 if (!isSymbol(key) || !builtInSymbols.has(key)) { 1918 track(target, "has", key); 1919 } 1920 return result; 1921} 1922function ownKeys(target) { 1923 track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY); 1924 return Reflect.ownKeys(target); 1925} 1926var mutableHandlers = { 1927 get: get2, 1928 set: set2, 1929 deleteProperty, 1930 has, 1931 ownKeys 1932}; 1933var readonlyHandlers = { 1934 get: readonlyGet, 1935 set(target, key) { 1936 if (false) {} 1937 return true; 1938 }, 1939 deleteProperty(target, key) { 1940 if (false) {} 1941 return true; 1942 } 1943}; 1944var shallowReactiveHandlers = extend({}, mutableHandlers, { 1945 get: shallowGet, 1946 set: shallowSet 1947}); 1948var shallowReadonlyHandlers = extend({}, readonlyHandlers, { 1949 get: shallowReadonlyGet 1950}); 1951var toReactive = (value) => isObject(value) ? reactive2(value) : value; 1952var toReadonly = (value) => isObject(value) ? readonly(value) : value; 1953var toShallow = (value) => value; 1954var getProto = (v) => Reflect.getPrototypeOf(v); 1955function get$1(target, key, isReadonly = false, isShallow = false) { 1956 target = target["__v_raw"]; 1957 const rawTarget = toRaw(target); 1958 const rawKey = toRaw(key); 1959 if (key !== rawKey) { 1960 !isReadonly && track(rawTarget, "get", key); 1961 } 1962 !isReadonly && track(rawTarget, "get", rawKey); 1963 const {has: has2} = getProto(rawTarget); 1964 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 1965 if (has2.call(rawTarget, key)) { 1966 return wrap(target.get(key)); 1967 } else if (has2.call(rawTarget, rawKey)) { 1968 return wrap(target.get(rawKey)); 1969 } else if (target !== rawTarget) { 1970 target.get(key); 1971 } 1972} 1973function has$1(key, isReadonly = false) { 1974 const target = this["__v_raw"]; 1975 const rawTarget = toRaw(target); 1976 const rawKey = toRaw(key); 1977 if (key !== rawKey) { 1978 !isReadonly && track(rawTarget, "has", key); 1979 } 1980 !isReadonly && track(rawTarget, "has", rawKey); 1981 return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); 1982} 1983function size(target, isReadonly = false) { 1984 target = target["__v_raw"]; 1985 !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY); 1986 return Reflect.get(target, "size", target); 1987} 1988function add(value) { 1989 value = toRaw(value); 1990 const target = toRaw(this); 1991 const proto = getProto(target); 1992 const hadKey = proto.has.call(target, value); 1993 if (!hadKey) { 1994 target.add(value); 1995 trigger(target, "add", value, value); 1996 } 1997 return this; 1998} 1999function set$1(key, value) { 2000 value = toRaw(value); 2001 const target = toRaw(this); 2002 const {has: has2, get: get3} = getProto(target); 2003 let hadKey = has2.call(target, key); 2004 if (!hadKey) { 2005 key = toRaw(key); 2006 hadKey = has2.call(target, key); 2007 } else if (false) {} 2008 const oldValue = get3.call(target, key); 2009 target.set(key, value); 2010 if (!hadKey) { 2011 trigger(target, "add", key, value); 2012 } else if (hasChanged(value, oldValue)) { 2013 trigger(target, "set", key, value, oldValue); 2014 } 2015 return this; 2016} 2017function deleteEntry(key) { 2018 const target = toRaw(this); 2019 const {has: has2, get: get3} = getProto(target); 2020 let hadKey = has2.call(target, key); 2021 if (!hadKey) { 2022 key = toRaw(key); 2023 hadKey = has2.call(target, key); 2024 } else if (false) {} 2025 const oldValue = get3 ? get3.call(target, key) : void 0; 2026 const result = target.delete(key); 2027 if (hadKey) { 2028 trigger(target, "delete", key, void 0, oldValue); 2029 } 2030 return result; 2031} 2032function clear() { 2033 const target = toRaw(this); 2034 const hadItems = target.size !== 0; 2035 const oldTarget = false ? 0 : void 0; 2036 const result = target.clear(); 2037 if (hadItems) { 2038 trigger(target, "clear", void 0, void 0, oldTarget); 2039 } 2040 return result; 2041} 2042function createForEach(isReadonly, isShallow) { 2043 return function forEach(callback, thisArg) { 2044 const observed = this; 2045 const target = observed["__v_raw"]; 2046 const rawTarget = toRaw(target); 2047 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 2048 !isReadonly && track(rawTarget, "iterate", ITERATE_KEY); 2049 return target.forEach((value, key) => { 2050 return callback.call(thisArg, wrap(value), wrap(key), observed); 2051 }); 2052 }; 2053} 2054function createIterableMethod(method, isReadonly, isShallow) { 2055 return function(...args) { 2056 const target = this["__v_raw"]; 2057 const rawTarget = toRaw(target); 2058 const targetIsMap = isMap(rawTarget); 2059 const isPair = method === "entries" || method === Symbol.iterator && targetIsMap; 2060 const isKeyOnly = method === "keys" && targetIsMap; 2061 const innerIterator = target[method](...args); 2062 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 2063 !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); 2064 return { 2065 next() { 2066 const {value, done} = innerIterator.next(); 2067 return done ? {value, done} : { 2068 value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), 2069 done 2070 }; 2071 }, 2072 [Symbol.iterator]() { 2073 return this; 2074 } 2075 }; 2076 }; 2077} 2078function createReadonlyMethod(type) { 2079 return function(...args) { 2080 if (false) {} 2081 return type === "delete" ? false : this; 2082 }; 2083} 2084var mutableInstrumentations = { 2085 get(key) { 2086 return get$1(this, key); 2087 }, 2088 get size() { 2089 return size(this); 2090 }, 2091 has: has$1, 2092 add, 2093 set: set$1, 2094 delete: deleteEntry, 2095 clear, 2096 forEach: createForEach(false, false) 2097}; 2098var shallowInstrumentations = { 2099 get(key) { 2100 return get$1(this, key, false, true); 2101 }, 2102 get size() { 2103 return size(this); 2104 }, 2105 has: has$1, 2106 add, 2107 set: set$1, 2108 delete: deleteEntry, 2109 clear, 2110 forEach: createForEach(false, true) 2111}; 2112var readonlyInstrumentations = { 2113 get(key) { 2114 return get$1(this, key, true); 2115 }, 2116 get size() { 2117 return size(this, true); 2118 }, 2119 has(key) { 2120 return has$1.call(this, key, true); 2121 }, 2122 add: createReadonlyMethod("add"), 2123 set: createReadonlyMethod("set"), 2124 delete: createReadonlyMethod("delete"), 2125 clear: createReadonlyMethod("clear"), 2126 forEach: createForEach(true, false) 2127}; 2128var shallowReadonlyInstrumentations = { 2129 get(key) { 2130 return get$1(this, key, true, true); 2131 }, 2132 get size() { 2133 return size(this, true); 2134 }, 2135 has(key) { 2136 return has$1.call(this, key, true); 2137 }, 2138 add: createReadonlyMethod("add"), 2139 set: createReadonlyMethod("set"), 2140 delete: createReadonlyMethod("delete"), 2141 clear: createReadonlyMethod("clear"), 2142 forEach: createForEach(true, true) 2143}; 2144var iteratorMethods = ["keys", "values", "entries", Symbol.iterator]; 2145iteratorMethods.forEach((method) => { 2146 mutableInstrumentations[method] = createIterableMethod(method, false, false); 2147 readonlyInstrumentations[method] = createIterableMethod(method, true, false); 2148 shallowInstrumentations[method] = createIterableMethod(method, false, true); 2149 shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true); 2150}); 2151function createInstrumentationGetter(isReadonly, shallow) { 2152 const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; 2153 return (target, key, receiver) => { 2154 if (key === "__v_isReactive") { 2155 return !isReadonly; 2156 } else if (key === "__v_isReadonly") { 2157 return isReadonly; 2158 } else if (key === "__v_raw") { 2159 return target; 2160 } 2161 return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); 2162 }; 2163} 2164var mutableCollectionHandlers = { 2165 get: createInstrumentationGetter(false, false) 2166}; 2167var shallowCollectionHandlers = { 2168 get: createInstrumentationGetter(false, true) 2169}; 2170var readonlyCollectionHandlers = { 2171 get: createInstrumentationGetter(true, false) 2172}; 2173var shallowReadonlyCollectionHandlers = { 2174 get: createInstrumentationGetter(true, true) 2175}; 2176var reactiveMap = new WeakMap(); 2177var shallowReactiveMap = new WeakMap(); 2178var readonlyMap = new WeakMap(); 2179var shallowReadonlyMap = new WeakMap(); 2180function targetTypeMap(rawType) { 2181 switch (rawType) { 2182 case "Object": 2183 case "Array": 2184 return 1; 2185 case "Map": 2186 case "Set": 2187 case "WeakMap": 2188 case "WeakSet": 2189 return 2; 2190 default: 2191 return 0; 2192 } 2193} 2194function getTargetType(value) { 2195 return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value)); 2196} 2197function reactive2(target) { 2198 if (target && target["__v_isReadonly"]) { 2199 return target; 2200 } 2201 return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); 2202} 2203function readonly(target) { 2204 return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); 2205} 2206function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { 2207 if (!isObject(target)) { 2208 if (false) {} 2209 return target; 2210 } 2211 if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) { 2212 return target; 2213 } 2214 const existingProxy = proxyMap.get(target); 2215 if (existingProxy) { 2216 return existingProxy; 2217 } 2218 const targetType = getTargetType(target); 2219 if (targetType === 0) { 2220 return target; 2221 } 2222 const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers); 2223 proxyMap.set(target, proxy); 2224 return proxy; 2225} 2226function toRaw(observed) { 2227 return observed && toRaw(observed["__v_raw"]) || observed; 2228} 2229function isRef(r) { 2230 return Boolean(r && r.__v_isRef === true); 2231} 2232 2233// packages/alpinejs/src/magics/$nextTick.js 2234magic("nextTick", () => nextTick); 2235 2236// packages/alpinejs/src/magics/$dispatch.js 2237magic("dispatch", (el) => dispatch.bind(dispatch, el)); 2238 2239// packages/alpinejs/src/magics/$watch.js 2240magic("watch", (el, {evaluateLater: evaluateLater2, effect: effect3}) => (key, callback) => { 2241 let evaluate2 = evaluateLater2(key); 2242 let firstTime = true; 2243 let oldValue; 2244 let effectReference = effect3(() => evaluate2((value) => { 2245 JSON.stringify(value); 2246 if (!firstTime) { 2247 queueMicrotask(() => { 2248 callback(value, oldValue); 2249 oldValue = value; 2250 }); 2251 } else { 2252 oldValue = value; 2253 } 2254 firstTime = false; 2255 })); 2256 el._x_effects.delete(effectReference); 2257}); 2258 2259// packages/alpinejs/src/magics/$store.js 2260magic("store", getStores); 2261 2262// packages/alpinejs/src/magics/$data.js 2263magic("data", (el) => scope(el)); 2264 2265// packages/alpinejs/src/magics/$root.js 2266magic("root", (el) => closestRoot(el)); 2267 2268// packages/alpinejs/src/magics/$refs.js 2269magic("refs", (el) => { 2270 if (el._x_refs_proxy) 2271 return el._x_refs_proxy; 2272 el._x_refs_proxy = mergeProxies(getArrayOfRefObject(el)); 2273 return el._x_refs_proxy; 2274}); 2275function getArrayOfRefObject(el) { 2276 let refObjects = []; 2277 let currentEl = el; 2278 while (currentEl) { 2279 if (currentEl._x_refs) 2280 refObjects.push(currentEl._x_refs); 2281 currentEl = currentEl.parentNode; 2282 } 2283 return refObjects; 2284} 2285 2286// packages/alpinejs/src/ids.js 2287var globalIdMemo = {}; 2288function findAndIncrementId(name) { 2289 if (!globalIdMemo[name]) 2290 globalIdMemo[name] = 0; 2291 return ++globalIdMemo[name]; 2292} 2293function closestIdRoot(el, name) { 2294 return findClosest(el, (element) => { 2295 if (element._x_ids && element._x_ids[name]) 2296 return true; 2297 }); 2298} 2299function setIdRoot(el, name) { 2300 if (!el._x_ids) 2301 el._x_ids = {}; 2302 if (!el._x_ids[name]) 2303 el._x_ids[name] = findAndIncrementId(name); 2304} 2305 2306// packages/alpinejs/src/magics/$id.js 2307magic("id", (el) => (name, key = null) => { 2308 let root = closestIdRoot(el, name); 2309 let id = root ? root._x_ids[name] : findAndIncrementId(name); 2310 return key ? `${name}-${id}-${key}` : `${name}-${id}`; 2311}); 2312 2313// packages/alpinejs/src/magics/$el.js 2314magic("el", (el) => el); 2315 2316// packages/alpinejs/src/magics/index.js 2317warnMissingPluginMagic("Focus", "focus", "focus"); 2318warnMissingPluginMagic("Persist", "persist", "persist"); 2319function warnMissingPluginMagic(name, magicName, slug) { 2320 magic(magicName, (el) => warn(`You can't use [$${directiveName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); 2321} 2322 2323// packages/alpinejs/src/directives/x-modelable.js 2324directive("modelable", (el, {expression}, {effect: effect3, evaluateLater: evaluateLater2}) => { 2325 let func = evaluateLater2(expression); 2326 let innerGet = () => { 2327 let result; 2328 func((i) => result = i); 2329 return result; 2330 }; 2331 let evaluateInnerSet = evaluateLater2(`${expression} = __placeholder`); 2332 let innerSet = (val) => evaluateInnerSet(() => { 2333 }, {scope: {__placeholder: val}}); 2334 let initialValue = innerGet(); 2335 innerSet(initialValue); 2336 queueMicrotask(() => { 2337 if (!el._x_model) 2338 return; 2339 el._x_removeModelListeners["default"](); 2340 let outerGet = el._x_model.get; 2341 let outerSet = el._x_model.set; 2342 effect3(() => innerSet(outerGet())); 2343 effect3(() => outerSet(innerGet())); 2344 }); 2345}); 2346 2347// packages/alpinejs/src/directives/x-teleport.js 2348directive("teleport", (el, {expression}, {cleanup: cleanup2}) => { 2349 if (el.tagName.toLowerCase() !== "template") 2350 warn("x-teleport can only be used on a <template> tag", el); 2351 let target = document.querySelector(expression); 2352 if (!target) 2353 warn(`Cannot find x-teleport element for selector: "${expression}"`); 2354 let clone2 = el.content.cloneNode(true).firstElementChild; 2355 el._x_teleport = clone2; 2356 clone2._x_teleportBack = el; 2357 if (el._x_forwardEvents) { 2358 el._x_forwardEvents.forEach((eventName) => { 2359 clone2.addEventListener(eventName, (e) => { 2360 e.stopPropagation(); 2361 el.dispatchEvent(new e.constructor(e.type, e)); 2362 }); 2363 }); 2364 } 2365 addScopeToNode(clone2, {}, el); 2366 mutateDom(() => { 2367 target.appendChild(clone2); 2368 initTree(clone2); 2369 clone2._x_ignore = true; 2370 }); 2371 cleanup2(() => clone2.remove()); 2372}); 2373 2374// packages/alpinejs/src/directives/x-ignore.js 2375var handler = () => { 2376}; 2377handler.inline = (el, {modifiers}, {cleanup: cleanup2}) => { 2378 modifiers.includes("self") ? el._x_ignoreSelf = true : el._x_ignore = true; 2379 cleanup2(() => { 2380 modifiers.includes("self") ? delete el._x_ignoreSelf : delete el._x_ignore; 2381 }); 2382}; 2383directive("ignore", handler); 2384 2385// packages/alpinejs/src/directives/x-effect.js 2386directive("effect", (el, {expression}, {effect: effect3}) => effect3(evaluateLater(el, expression))); 2387 2388// packages/alpinejs/src/utils/on.js 2389function on(el, event, modifiers, callback) { 2390 let listenerTarget = el; 2391 let handler3 = (e) => callback(e); 2392 let options = {}; 2393 let wrapHandler = (callback2, wrapper) => (e) => wrapper(callback2, e); 2394 if (modifiers.includes("dot")) 2395 event = dotSyntax(event); 2396 if (modifiers.includes("camel")) 2397 event = camelCase2(event); 2398 if (modifiers.includes("passive")) 2399 options.passive = true; 2400 if (modifiers.includes("capture")) 2401 options.capture = true; 2402 if (modifiers.includes("window")) 2403 listenerTarget = window; 2404 if (modifiers.includes("document")) 2405 listenerTarget = document; 2406 if (modifiers.includes("prevent")) 2407 handler3 = wrapHandler(handler3, (next, e) => { 2408 e.preventDefault(); 2409 next(e); 2410 }); 2411 if (modifiers.includes("stop")) 2412 handler3 = wrapHandler(handler3, (next, e) => { 2413 e.stopPropagation(); 2414 next(e); 2415 }); 2416 if (modifiers.includes("self")) 2417 handler3 = wrapHandler(handler3, (next, e) => { 2418 e.target === el && next(e); 2419 }); 2420 if (modifiers.includes("away") || modifiers.includes("outside")) { 2421 listenerTarget = document; 2422 handler3 = wrapHandler(handler3, (next, e) => { 2423 if (el.contains(e.target)) 2424 return; 2425 if (e.target.isConnected === false) 2426 return; 2427 if (el.offsetWidth < 1 && el.offsetHeight < 1) 2428 return; 2429 if (el._x_isShown === false) 2430 return; 2431 next(e); 2432 }); 2433 } 2434 if (modifiers.includes("once")) { 2435 handler3 = wrapHandler(handler3, (next, e) => { 2436 next(e); 2437 listenerTarget.removeEventListener(event, handler3, options); 2438 }); 2439 } 2440 handler3 = wrapHandler(handler3, (next, e) => { 2441 if (isKeyEvent(event)) { 2442 if (isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers)) { 2443 return; 2444 } 2445 } 2446 next(e); 2447 }); 2448 if (modifiers.includes("debounce")) { 2449 let nextModifier = modifiers[modifiers.indexOf("debounce") + 1] || "invalid-wait"; 2450 let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250; 2451 handler3 = debounce(handler3, wait); 2452 } 2453 if (modifiers.includes("throttle")) { 2454 let nextModifier = modifiers[modifiers.indexOf("throttle") + 1] || "invalid-wait"; 2455 let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250; 2456 handler3 = throttle(handler3, wait); 2457 } 2458 listenerTarget.addEventListener(event, handler3, options); 2459 return () => { 2460 listenerTarget.removeEventListener(event, handler3, options); 2461 }; 2462} 2463function dotSyntax(subject) { 2464 return subject.replace(/-/g, "."); 2465} 2466function camelCase2(subject) { 2467 return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase()); 2468} 2469function isNumeric(subject) { 2470 return !Array.isArray(subject) && !isNaN(subject); 2471} 2472function kebabCase2(subject) { 2473 return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase(); 2474} 2475function isKeyEvent(event) { 2476 return ["keydown", "keyup"].includes(event); 2477} 2478function isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers) { 2479 let keyModifiers = modifiers.filter((i) => { 2480 return !["window", "document", "prevent", "stop", "once"].includes(i); 2481 }); 2482 if (keyModifiers.includes("debounce")) { 2483 let debounceIndex = keyModifiers.indexOf("debounce"); 2484 keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); 2485 } 2486 if (keyModifiers.length === 0) 2487 return false; 2488 if (keyModifiers.length === 1 && keyToModifiers(e.key).includes(keyModifiers[0])) 2489 return false; 2490 const systemKeyModifiers = ["ctrl", "shift", "alt", "meta", "cmd", "super"]; 2491 const selectedSystemKeyModifiers = systemKeyModifiers.filter((modifier) => keyModifiers.includes(modifier)); 2492 keyModifiers = keyModifiers.filter((i) => !selectedSystemKeyModifiers.includes(i)); 2493 if (selectedSystemKeyModifiers.length > 0) { 2494 const activelyPressedKeyModifiers = selectedSystemKeyModifiers.filter((modifier) => { 2495 if (modifier === "cmd" || modifier === "super") 2496 modifier = "meta"; 2497 return e[`${modifier}Key`]; 2498 }); 2499 if (activelyPressedKeyModifiers.length === selectedSystemKeyModifiers.length) { 2500 if (keyToModifiers(e.key).includes(keyModifiers[0])) 2501 return false; 2502 } 2503 } 2504 return true; 2505} 2506function keyToModifiers(key) { 2507 if (!key) 2508 return []; 2509 key = kebabCase2(key); 2510 let modifierToKeyMap = { 2511 ctrl: "control", 2512 slash: "/", 2513 space: "-", 2514 spacebar: "-", 2515 cmd: "meta", 2516 esc: "escape", 2517 up: "arrow-up", 2518 down: "arrow-down", 2519 left: "arrow-left", 2520 right: "arrow-right", 2521 period: ".", 2522 equal: "=" 2523 }; 2524 modifierToKeyMap[key] = key; 2525 return Object.keys(modifierToKeyMap).map((modifier) => { 2526 if (modifierToKeyMap[modifier] === key) 2527 return modifier; 2528 }).filter((modifier) => modifier); 2529} 2530 2531// packages/alpinejs/src/directives/x-model.js 2532directive("model", (el, {modifiers, expression}, {effect: effect3, cleanup: cleanup2}) => { 2533 let evaluate2 = evaluateLater(el, expression); 2534 let assignmentExpression = `${expression} = rightSideOfExpression($event, ${expression})`; 2535 let evaluateAssignment = evaluateLater(el, assignmentExpression); 2536 var event = el.tagName.toLowerCase() === "select" || ["checkbox", "radio"].includes(el.type) || modifiers.includes("lazy") ? "change" : "input"; 2537 let assigmentFunction = generateAssignmentFunction(el, modifiers, expression); 2538 let removeListener = on(el, event, modifiers, (e) => { 2539 evaluateAssignment(() => { 2540 }, {scope: { 2541 $event: e, 2542 rightSideOfExpression: assigmentFunction 2543 }}); 2544 }); 2545 if (!el._x_removeModelListeners) 2546 el._x_removeModelListeners = {}; 2547 el._x_removeModelListeners["default"] = removeListener; 2548 cleanup2(() => el._x_removeModelListeners["default"]()); 2549 let evaluateSetModel = evaluateLater(el, `${expression} = __placeholder`); 2550 el._x_model = { 2551 get() { 2552 let result; 2553 evaluate2((value) => result = value); 2554 return result; 2555 }, 2556 set(value) { 2557 evaluateSetModel(() => { 2558 }, {scope: {__placeholder: value}}); 2559 } 2560 }; 2561 el._x_forceModelUpdate = () => { 2562 evaluate2((value) => { 2563 if (value === void 0 && expression.match(/\./)) 2564 value = ""; 2565 window.fromModel = true; 2566 mutateDom(() => bind(el, "value", value)); 2567 delete window.fromModel; 2568 }); 2569 }; 2570 effect3(() => { 2571 if (modifiers.includes("unintrusive") && document.activeElement.isSameNode(el)) 2572 return; 2573 el._x_forceModelUpdate(); 2574 }); 2575}); 2576function generateAssignmentFunction(el, modifiers, expression) { 2577 if (el.type === "radio") { 2578 mutateDom(() => { 2579 if (!el.hasAttribute("name")) 2580 el.setAttribute("name", expression); 2581 }); 2582 } 2583 return (event, currentValue) => { 2584 return mutateDom(() => { 2585 if (event instanceof CustomEvent && event.detail !== void 0) { 2586 return event.detail || event.target.value; 2587 } else if (el.type === "checkbox") { 2588 if (Array.isArray(currentValue)) { 2589 let newValue = modifiers.includes("number") ? safeParseNumber(event.target.value) : event.target.value; 2590 return event.target.checked ? currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue)); 2591 } else { 2592 return event.target.checked; 2593 } 2594 } else if (el.tagName.toLowerCase() === "select" && el.multiple) { 2595 return modifiers.includes("number") ? Array.from(event.target.selectedOptions).map((option) => { 2596 let rawValue = option.value || option.text; 2597 return safeParseNumber(rawValue); 2598 }) : Array.from(event.target.selectedOptions).map((option) => { 2599 return option.value || option.text; 2600 }); 2601 } else { 2602 let rawValue = event.target.value; 2603 return modifiers.includes("number") ? safeParseNumber(rawValue) : modifiers.includes("trim") ? rawValue.trim() : rawValue; 2604 } 2605 }); 2606 }; 2607} 2608function safeParseNumber(rawValue) { 2609 let number = rawValue ? parseFloat(rawValue) : null; 2610 return isNumeric2(number) ? number : rawValue; 2611} 2612function checkedAttrLooseCompare2(valueA, valueB) { 2613 return valueA == valueB; 2614} 2615function isNumeric2(subject) { 2616 return !Array.isArray(subject) && !isNaN(subject); 2617} 2618 2619// packages/alpinejs/src/directives/x-cloak.js 2620directive("cloak", (el) => queueMicrotask(() => mutateDom(() => el.removeAttribute(prefix("cloak"))))); 2621 2622// packages/alpinejs/src/directives/x-init.js 2623addInitSelector(() => `[${prefix("init")}]`); 2624directive("init", skipDuringClone((el, {expression}, {evaluate: evaluate2}) => { 2625 if (typeof expression === "string") { 2626 return !!expression.trim() && evaluate2(expression, {}, false); 2627 } 2628 return evaluate2(expression, {}, false); 2629})); 2630 2631// packages/alpinejs/src/directives/x-text.js 2632directive("text", (el, {expression}, {effect: effect3, evaluateLater: evaluateLater2}) => { 2633 let evaluate2 = evaluateLater2(expression); 2634 effect3(() => { 2635 evaluate2((value) => { 2636 mutateDom(() => { 2637 el.textContent = value; 2638 }); 2639 }); 2640 }); 2641}); 2642 2643// packages/alpinejs/src/directives/x-html.js 2644directive("html", (el, {expression}, {effect: effect3, evaluateLater: evaluateLater2}) => { 2645 let evaluate2 = evaluateLater2(expression); 2646 effect3(() => { 2647 evaluate2((value) => { 2648 mutateDom(() => { 2649 el.innerHTML = value; 2650 el._x_ignoreSelf = true; 2651 initTree(el); 2652 delete el._x_ignoreSelf; 2653 }); 2654 }); 2655 }); 2656}); 2657 2658// packages/alpinejs/src/directives/x-bind.js 2659mapAttributes(startingWith(":", into(prefix("bind:")))); 2660directive("bind", (el, {value, modifiers, expression, original}, {effect: effect3}) => { 2661 if (!value) { 2662 return applyBindingsObject(el, expression, original, effect3); 2663 } 2664 if (value === "key") 2665 return storeKeyForXFor(el, expression); 2666 let evaluate2 = evaluateLater(el, expression); 2667 effect3(() => evaluate2((result) => { 2668 if (result === void 0 && expression.match(/\./)) 2669 result = ""; 2670 mutateDom(() => bind(el, value, result, modifiers)); 2671 })); 2672}); 2673function applyBindingsObject(el, expression, original, effect3) { 2674 let bindingProviders = {}; 2675 injectBindingProviders(bindingProviders); 2676 let getBindings = evaluateLater(el, expression); 2677 let cleanupRunners = []; 2678 while (cleanupRunners.length) 2679 cleanupRunners.pop()(); 2680 getBindings((bindings) => { 2681 let attributes = Object.entries(bindings).map(([name, value]) => ({name, value})); 2682 let staticAttributes = attributesOnly(attributes); 2683 attributes = attributes.map((attribute) => { 2684 if (staticAttributes.find((attr) => attr.name === attribute.name)) { 2685 return { 2686 name: `x-bind:${attribute.name}`, 2687 value: `"${attribute.value}"` 2688 }; 2689 } 2690 return attribute; 2691 }); 2692 directives(el, attributes, original).map((handle) => { 2693 cleanupRunners.push(handle.runCleanups); 2694 handle(); 2695 }); 2696 }, {scope: bindingProviders}); 2697} 2698function storeKeyForXFor(el, expression) { 2699 el._x_keyExpression = expression; 2700} 2701 2702// packages/alpinejs/src/directives/x-data.js 2703addRootSelector(() => `[${prefix("data")}]`); 2704directive("data", skipDuringClone((el, {expression}, {cleanup: cleanup2}) => { 2705 expression = expression === "" ? "{}" : expression; 2706 let magicContext = {}; 2707 injectMagics(magicContext, el); 2708 let dataProviderContext = {}; 2709 injectDataProviders(dataProviderContext, magicContext); 2710 let data2 = evaluate(el, expression, {scope: dataProviderContext}); 2711 if (data2 === void 0) 2712 data2 = {}; 2713 injectMagics(data2, el); 2714 let reactiveData = reactive(data2); 2715 initInterceptors(reactiveData); 2716 let undo = addScopeToNode(el, reactiveData); 2717 reactiveData["init"] && evaluate(el, reactiveData["init"]); 2718 cleanup2(() => { 2719 reactiveData["destroy"] && evaluate(el, reactiveData["destroy"]); 2720 undo(); 2721 }); 2722})); 2723 2724// packages/alpinejs/src/directives/x-show.js 2725directive("show", (el, {modifiers, expression}, {effect: effect3}) => { 2726 let evaluate2 = evaluateLater(el, expression); 2727 if (!el._x_doHide) 2728 el._x_doHide = () => { 2729 mutateDom(() => el.style.display = "none"); 2730 }; 2731 if (!el._x_doShow) 2732 el._x_doShow = () => { 2733 mutateDom(() => { 2734 if (el.style.length === 1 && el.style.display === "none") { 2735 el.removeAttribute("style"); 2736 } else { 2737 el.style.removeProperty("display"); 2738 } 2739 }); 2740 }; 2741 let hide = () => { 2742 el._x_doHide(); 2743 el._x_isShown = false; 2744 }; 2745 let show = () => { 2746 el._x_doShow(); 2747 el._x_isShown = true; 2748 }; 2749 let clickAwayCompatibleShow = () => setTimeout(show); 2750 let toggle = once((value) => value ? show() : hide(), (value) => { 2751 if (typeof el._x_toggleAndCascadeWithTransitions === "function") { 2752 el._x_toggleAndCascadeWithTransitions(el, value, show, hide); 2753 } else { 2754 value ? clickAwayCompatibleShow() : hide(); 2755 } 2756 }); 2757 let oldValue; 2758 let firstTime = true; 2759 effect3(() => evaluate2((value) => { 2760 if (!firstTime && value === oldValue) 2761 return; 2762 if (modifiers.includes("immediate")) 2763 value ? clickAwayCompatibleShow() : hide(); 2764 toggle(value); 2765 oldValue = value; 2766 firstTime = false; 2767 })); 2768}); 2769 2770// packages/alpinejs/src/directives/x-for.js 2771directive("for", (el, {expression}, {effect: effect3, cleanup: cleanup2}) => { 2772 let iteratorNames = parseForExpression(expression); 2773 let evaluateItems = evaluateLater(el, iteratorNames.items); 2774 let evaluateKey = evaluateLater(el, el._x_keyExpression || "index"); 2775 el._x_prevKeys = []; 2776 el._x_lookup = {}; 2777 effect3(() => loop(el, iteratorNames, evaluateItems, evaluateKey)); 2778 cleanup2(() => { 2779 Object.values(el._x_lookup).forEach((el2) => el2.remove()); 2780 delete el._x_prevKeys; 2781 delete el._x_lookup; 2782 }); 2783}); 2784function loop(el, iteratorNames, evaluateItems, evaluateKey) { 2785 let isObject2 = (i) => typeof i === "object" && !Array.isArray(i); 2786 let templateEl = el; 2787 evaluateItems((items) => { 2788 if (isNumeric3(items) && items >= 0) { 2789 items = Array.from(Array(items).keys(), (i) => i + 1); 2790 } 2791 if (items === void 0) 2792 items = []; 2793 let lookup = el._x_lookup; 2794 let prevKeys = el._x_prevKeys; 2795 let scopes = []; 2796 let keys = []; 2797 if (isObject2(items)) { 2798 items = Object.entries(items).map(([key, value]) => { 2799 let scope2 = getIterationScopeVariables(iteratorNames, value, key, items); 2800 evaluateKey((value2) => keys.push(value2), {scope: {index: key, ...scope2}}); 2801 scopes.push(scope2); 2802 }); 2803 } else { 2804 for (let i = 0; i < items.length; i++) { 2805 let scope2 = getIterationScopeVariables(iteratorNames, items[i], i, items); 2806 evaluateKey((value) => keys.push(value), {scope: {index: i, ...scope2}}); 2807 scopes.push(scope2); 2808 } 2809 } 2810 let adds = []; 2811 let moves = []; 2812 let removes = []; 2813 let sames = []; 2814 for (let i = 0; i < prevKeys.length; i++) { 2815 let key = prevKeys[i]; 2816 if (keys.indexOf(key) === -1) 2817 removes.push(key); 2818 } 2819 prevKeys = prevKeys.filter((key) => !removes.includes(key)); 2820 let lastKey = "template"; 2821 for (let i = 0; i < keys.length; i++) { 2822 let key = keys[i]; 2823 let prevIndex = prevKeys.indexOf(key); 2824 if (prevIndex === -1) { 2825 prevKeys.splice(i, 0, key); 2826 adds.push([lastKey, i]); 2827 } else if (prevIndex !== i) { 2828 let keyInSpot = prevKeys.splice(i, 1)[0]; 2829 let keyForSpot = prevKeys.splice(prevIndex - 1, 1)[0]; 2830 prevKeys.splice(i, 0, keyForSpot); 2831 prevKeys.splice(prevIndex, 0, keyInSpot); 2832 moves.push([keyInSpot, keyForSpot]); 2833 } else { 2834 sames.push(key); 2835 } 2836 lastKey = key; 2837 } 2838 for (let i = 0; i < removes.length; i++) { 2839 let key = removes[i]; 2840 if (!!lookup[key]._x_effects) { 2841 lookup[key]._x_effects.forEach(dequeueJob); 2842 } 2843 lookup[key].remove(); 2844 lookup[key] = null; 2845 delete lookup[key]; 2846 } 2847 for (let i = 0; i < moves.length; i++) { 2848 let [keyInSpot, keyForSpot] = moves[i]; 2849 let elInSpot = lookup[keyInSpot]; 2850 let elForSpot = lookup[keyForSpot]; 2851 let marker = document.createElement("div"); 2852 mutateDom(() => { 2853 elForSpot.after(marker); 2854 elInSpot.after(elForSpot); 2855 elForSpot._x_currentIfEl && elForSpot.after(elForSpot._x_currentIfEl); 2856 marker.before(elInSpot); 2857 elInSpot._x_currentIfEl && elInSpot.after(elInSpot._x_currentIfEl); 2858 marker.remove(); 2859 }); 2860 refreshScope(elForSpot, scopes[keys.indexOf(keyForSpot)]); 2861 } 2862 for (let i = 0; i < adds.length; i++) { 2863 let [lastKey2, index] = adds[i]; 2864 let lastEl = lastKey2 === "template" ? templateEl : lookup[lastKey2]; 2865 if (lastEl._x_currentIfEl) 2866 lastEl = lastEl._x_currentIfEl; 2867 let scope2 = scopes[index]; 2868 let key = keys[index]; 2869 let clone2 = document.importNode(templateEl.content, true).firstElementChild; 2870 addScopeToNode(clone2, reactive(scope2), templateEl); 2871 mutateDom(() => { 2872 lastEl.after(clone2); 2873 initTree(clone2); 2874 }); 2875 if (typeof key === "object") { 2876 warn("x-for key cannot be an object, it must be a string or an integer", templateEl); 2877 } 2878 lookup[key] = clone2; 2879 } 2880 for (let i = 0; i < sames.length; i++) { 2881 refreshScope(lookup[sames[i]], scopes[keys.indexOf(sames[i])]); 2882 } 2883 templateEl._x_prevKeys = keys; 2884 }); 2885} 2886function parseForExpression(expression) { 2887 let forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; 2888 let stripParensRE = /^\s*\(|\)\s*$/g; 2889 let forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/; 2890 let inMatch = expression.match(forAliasRE); 2891 if (!inMatch) 2892 return; 2893 let res = {}; 2894 res.items = inMatch[2].trim(); 2895 let item = inMatch[1].replace(stripParensRE, "").trim(); 2896 let iteratorMatch = item.match(forIteratorRE); 2897 if (iteratorMatch) { 2898 res.item = item.replace(forIteratorRE, "").trim(); 2899 res.index = iteratorMatch[1].trim(); 2900 if (iteratorMatch[2]) { 2901 res.collection = iteratorMatch[2].trim(); 2902 } 2903 } else { 2904 res.item = item; 2905 } 2906 return res; 2907} 2908function getIterationScopeVariables(iteratorNames, item, index, items) { 2909 let scopeVariables = {}; 2910 if (/^\[.*\]$/.test(iteratorNames.item) && Array.isArray(item)) { 2911 let names = iteratorNames.item.replace("[", "").replace("]", "").split(",").map((i) => i.trim()); 2912 names.forEach((name, i) => { 2913 scopeVariables[name] = item[i]; 2914 }); 2915 } else if (/^\{.*\}$/.test(iteratorNames.item) && !Array.isArray(item) && typeof item === "object") { 2916 let names = iteratorNames.item.replace("{", "").replace("}", "").split(",").map((i) => i.trim()); 2917 names.forEach((name) => { 2918 scopeVariables[name] = item[name]; 2919 }); 2920 } else { 2921 scopeVariables[iteratorNames.item] = item; 2922 } 2923 if (iteratorNames.index) 2924 scopeVariables[iteratorNames.index] = index; 2925 if (iteratorNames.collection) 2926 scopeVariables[iteratorNames.collection] = items; 2927 return scopeVariables; 2928} 2929function isNumeric3(subject) { 2930 return !Array.isArray(subject) && !isNaN(subject); 2931} 2932 2933// packages/alpinejs/src/directives/x-ref.js 2934function handler2() { 2935} 2936handler2.inline = (el, {expression}, {cleanup: cleanup2}) => { 2937 let root = closestRoot(el); 2938 if (!root._x_refs) 2939 root._x_refs = {}; 2940 root._x_refs[expression] = el; 2941 cleanup2(() => delete root._x_refs[expression]); 2942}; 2943directive("ref", handler2); 2944 2945// packages/alpinejs/src/directives/x-if.js 2946directive("if", (el, {expression}, {effect: effect3, cleanup: cleanup2}) => { 2947 let evaluate2 = evaluateLater(el, expression); 2948 let show = () => { 2949 if (el._x_currentIfEl) 2950 return el._x_currentIfEl; 2951 let clone2 = el.content.cloneNode(true).firstElementChild; 2952 addScopeToNode(clone2, {}, el); 2953 mutateDom(() => { 2954 el.after(clone2); 2955 initTree(clone2); 2956 }); 2957 el._x_currentIfEl = clone2; 2958 el._x_undoIf = () => { 2959 walk(clone2, (node) => { 2960 if (!!node._x_effects) { 2961 node._x_effects.forEach(dequeueJob); 2962 } 2963 }); 2964 clone2.remove(); 2965 delete el._x_currentIfEl; 2966 }; 2967 return clone2; 2968 }; 2969 let hide = () => { 2970 if (!el._x_undoIf) 2971 return; 2972 el._x_undoIf(); 2973 delete el._x_undoIf; 2974 }; 2975 effect3(() => evaluate2((value) => { 2976 value ? show() : hide(); 2977 })); 2978 cleanup2(() => el._x_undoIf && el._x_undoIf()); 2979}); 2980 2981// packages/alpinejs/src/directives/x-id.js 2982directive("id", (el, {expression}, {evaluate: evaluate2}) => { 2983 let names = evaluate2(expression); 2984 names.forEach((name) => setIdRoot(el, name)); 2985}); 2986 2987// packages/alpinejs/src/directives/x-on.js 2988mapAttributes(startingWith("@", into(prefix("on:")))); 2989directive("on", skipDuringClone((el, {value, modifiers, expression}, {cleanup: cleanup2}) => { 2990 let evaluate2 = expression ? evaluateLater(el, expression) : () => { 2991 }; 2992 if (el.tagName.toLowerCase() === "template") { 2993 if (!el._x_forwardEvents) 2994 el._x_forwardEvents = []; 2995 if (!el._x_forwardEvents.includes(value)) 2996 el._x_forwardEvents.push(value); 2997 } 2998 let removeListener = on(el, value, modifiers, (e) => { 2999 evaluate2(() => { 3000 }, {scope: {$event: e}, params: [e]}); 3001 }); 3002 cleanup2(() => removeListener()); 3003})); 3004 3005// packages/alpinejs/src/directives/index.js 3006warnMissingPluginDirective("Collapse", "collapse", "collapse"); 3007warnMissingPluginDirective("Intersect", "intersect", "intersect"); 3008warnMissingPluginDirective("Focus", "trap", "focus"); 3009warnMissingPluginDirective("Mask", "mask", "mask"); 3010function warnMissingPluginDirective(name, directiveName2, slug) { 3011 directive(directiveName2, (el) => warn(`You can't use [x-${directiveName2}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); 3012} 3013 3014// packages/alpinejs/src/index.js 3015alpine_default.setEvaluator(normalEvaluator); 3016alpine_default.setReactivityEngine({reactive: reactive2, effect: effect2, release: stop, raw: toRaw}); 3017var src_default = alpine_default; 3018 3019// packages/alpinejs/builds/module.js 3020var module_default = src_default; 3021 3022 3023 3024/***/ }), 3025
vendor: 342 bytes, lines 3026-3035
3026/***/ "./node_modules/axios/index.js": 3027/*!*************************************!*\ 3028 !*** ./node_modules/axios/index.js ***! 3029 \*************************************/ 3030/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3031 3032module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js"); 3033 3034/***/ }), 3035
vendor: 7,873 bytes, lines 3036-3258
3036/***/ "./node_modules/axios/lib/adapters/xhr.js": 3037/*!************************************************!*\ 3038 !*** ./node_modules/axios/lib/adapters/xhr.js ***! 3039 \************************************************/ 3040/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3041 3042"use strict"; 3043 3044 3045var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 3046var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js"); 3047var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js"); 3048var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 3049var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js"); 3050var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js"); 3051var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js"); 3052var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js"); 3053var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js"); 3054var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 3055 3056module.exports = function xhrAdapter(config) { 3057 return new Promise(function dispatchXhrRequest(resolve, reject) { 3058 var requestData = config.data; 3059 var requestHeaders = config.headers; 3060 var responseType = config.responseType; 3061 var onCanceled; 3062 function done() { 3063 if (config.cancelToken) { 3064 config.cancelToken.unsubscribe(onCanceled); 3065 } 3066 3067 if (config.signal) { 3068 config.signal.removeEventListener('abort', onCanceled); 3069 } 3070 } 3071 3072 if (utils.isFormData(requestData)) { 3073 delete requestHeaders['Content-Type']; // Let the browser set it 3074 } 3075 3076 var request = new XMLHttpRequest(); 3077 3078 // HTTP basic authentication 3079 if (config.auth) { 3080 var username = config.auth.username || ''; 3081 var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; 3082 requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); 3083 } 3084 3085 var fullPath = buildFullPath(config.baseURL, config.url); 3086 request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); 3087 3088 // Set the request timeout in MS 3089 request.timeout = config.timeout; 3090 3091 function onloadend() { 3092 if (!request) { 3093 return; 3094 } 3095 // Prepare the response 3096 var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; 3097 var responseData = !responseType || responseType === 'text' || responseType === 'json' ? 3098 request.responseText : request.response; 3099 var response = { 3100 data: responseData, 3101 status: request.status, 3102 statusText: request.statusText, 3103 headers: responseHeaders, 3104 config: config, 3105 request: request 3106 }; 3107 3108 settle(function _resolve(value) { 3109 resolve(value); 3110 done(); 3111 }, function _reject(err) { 3112 reject(err); 3113 done(); 3114 }, response); 3115 3116 // Clean up request 3117 request = null; 3118 } 3119 3120 if ('onloadend' in request) { 3121 // Use onloadend if available 3122 request.onloadend = onloadend; 3123 } else { 3124 // Listen for ready state to emulate onloadend 3125 request.onreadystatechange = function handleLoad() { 3126 if (!request || request.readyState !== 4) { 3127 return; 3128 } 3129 3130 // The request errored out and we didn't get a response, this will be 3131 // handled by onerror instead 3132 // With one exception: request that using file: protocol, most browsers 3133 // will return status as 0 even though it's a successful request 3134 if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { 3135 return; 3136 } 3137 // readystate handler is calling before onerror or ontimeout handlers, 3138 // so we should call onloadend on the next 'tick' 3139 setTimeout(onloadend); 3140 }; 3141 } 3142 3143 // Handle browser request cancellation (as opposed to a manual cancellation) 3144 request.onabort = function handleAbort() { 3145 if (!request) { 3146 return; 3147 } 3148 3149 reject(createError('Request aborted', config, 'ECONNABORTED', request)); 3150 3151 // Clean up request 3152 request = null; 3153 }; 3154 3155 // Handle low level network errors 3156 request.onerror = function handleError() { 3157 // Real errors are hidden from us by the browser 3158 // onerror should only fire if it's a network error 3159 reject(createError('Network Error', config, null, request)); 3160 3161 // Clean up request 3162 request = null; 3163 }; 3164 3165 // Handle timeout 3166 request.ontimeout = function handleTimeout() { 3167 var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; 3168 var transitional = config.transitional || defaults.transitional; 3169 if (config.timeoutErrorMessage) { 3170 timeoutErrorMessage = config.timeoutErrorMessage; 3171 } 3172 reject(createError( 3173 timeoutErrorMessage, 3174 config, 3175 transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', 3176 request)); 3177 3178 // Clean up request 3179 request = null; 3180 }; 3181 3182 // Add xsrf header 3183 // This is only done if running in a standard browser environment. 3184 // Specifically not if we're in a web worker, or react-native. 3185 if (utils.isStandardBrowserEnv()) { 3186 // Add xsrf header 3187 var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? 3188 cookies.read(config.xsrfCookieName) : 3189 undefined; 3190 3191 if (xsrfValue) { 3192 requestHeaders[config.xsrfHeaderName] = xsrfValue; 3193 } 3194 } 3195 3196 // Add headers to the request 3197 if ('setRequestHeader' in request) { 3198 utils.forEach(requestHeaders, function setRequestHeader(val, key) { 3199 if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { 3200 // Remove Content-Type if data is undefined 3201 delete requestHeaders[key]; 3202 } else { 3203 // Otherwise add header to the request 3204 request.setRequestHeader(key, val); 3205 } 3206 }); 3207 } 3208 3209 // Add withCredentials to request if needed 3210 if (!utils.isUndefined(config.withCredentials)) { 3211 request.withCredentials = !!config.withCredentials; 3212 } 3213 3214 // Add responseType to request if needed 3215 if (responseType && responseType !== 'json') { 3216 request.responseType = config.responseType; 3217 } 3218 3219 // Handle progress if needed 3220 if (typeof config.onDownloadProgress === 'function') { 3221 request.addEventListener('progress', config.onDownloadProgress); 3222 } 3223 3224 // Not all browsers support upload events 3225 if (typeof config.onUploadProgress === 'function' && request.upload) { 3226 request.upload.addEventListener('progress', config.onUploadProgress); 3227 } 3228 3229 if (config.cancelToken || config.signal) { 3230 // Handle cancellation 3231 // eslint-disable-next-line func-names 3232 onCanceled = function(cancel) { 3233 if (!request) { 3234 return; 3235 } 3236 reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel); 3237 request.abort(); 3238 request = null; 3239 }; 3240 3241 config.cancelToken && config.cancelToken.subscribe(onCanceled); 3242 if (config.signal) { 3243 config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled); 3244 } 3245 } 3246 3247 if (!requestData) { 3248 requestData = null; 3249 } 3250 3251 // Send the request 3252 request.send(requestData); 3253 }); 3254}; 3255 3256 3257/***/ }), 3258
vendor: 2,498 bytes, lines 3259-3326
3259/***/ "./node_modules/axios/lib/axios.js": 3260/*!*****************************************!*\ 3261 !*** ./node_modules/axios/lib/axios.js ***! 3262 \*****************************************/ 3263/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3264 3265"use strict"; 3266 3267 3268var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 3269var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 3270var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js"); 3271var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 3272var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js"); 3273 3274/** 3275 * Create an instance of Axios 3276 * 3277 * @param {Object} defaultConfig The default config for the instance 3278 * @return {Axios} A new instance of Axios 3279 */ 3280function createInstance(defaultConfig) { 3281 var context = new Axios(defaultConfig); 3282 var instance = bind(Axios.prototype.request, context); 3283 3284 // Copy axios.prototype to instance 3285 utils.extend(instance, Axios.prototype, context); 3286 3287 // Copy context to instance 3288 utils.extend(instance, context); 3289 3290 // Factory for creating new instances 3291 instance.create = function create(instanceConfig) { 3292 return createInstance(mergeConfig(defaultConfig, instanceConfig)); 3293 }; 3294 3295 return instance; 3296} 3297 3298// Create the default instance to be exported 3299var axios = createInstance(defaults); 3300 3301// Expose Axios class to allow class inheritance 3302axios.Axios = Axios; 3303 3304// Expose Cancel & CancelToken 3305axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 3306axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js"); 3307axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 3308axios.VERSION = (__webpack_require__(/*! ./env/data */ "./node_modules/axios/lib/env/data.js").version); 3309 3310// Expose all/spread 3311axios.all = function all(promises) { 3312 return Promise.all(promises); 3313}; 3314axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js"); 3315 3316// Expose isAxiosError 3317axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js"); 3318 3319module.exports = axios; 3320 3321// Allow use of default import syntax in TypeScript 3322module.exports["default"] = axios; 3323 3324 3325/***/ }), 3326
vendor: 636 bytes, lines 3327-3356
3327/***/ "./node_modules/axios/lib/cancel/Cancel.js": 3328/*!*************************************************!*\ 3329 !*** ./node_modules/axios/lib/cancel/Cancel.js ***! 3330 \*************************************************/ 3331/***/ ((module) => { 3332 3333"use strict"; 3334 3335 3336/** 3337 * A `Cancel` is an object that is thrown when an operation is canceled. 3338 * 3339 * @class 3340 * @param {string=} message The message. 3341 */ 3342function Cancel(message) { 3343 this.message = message; 3344} 3345 3346Cancel.prototype.toString = function toString() { 3347 return 'Cancel' + (this.message ? ': ' + this.message : ''); 3348}; 3349 3350Cancel.prototype.__CANCEL__ = true; 3351 3352module.exports = Cancel; 3353 3354 3355/***/ }), 3356
vendor: 2,848 bytes, lines 3357-3486
3357/***/ "./node_modules/axios/lib/cancel/CancelToken.js": 3358/*!******************************************************!*\ 3359 !*** ./node_modules/axios/lib/cancel/CancelToken.js ***! 3360 \******************************************************/ 3361/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3362 3363"use strict"; 3364 3365 3366var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 3367 3368/** 3369 * A `CancelToken` is an object that can be used to request cancellation of an operation. 3370 * 3371 * @class 3372 * @param {Function} executor The executor function. 3373 */ 3374function CancelToken(executor) { 3375 if (typeof executor !== 'function') { 3376 throw new TypeError('executor must be a function.'); 3377 } 3378 3379 var resolvePromise; 3380 3381 this.promise = new Promise(function promiseExecutor(resolve) { 3382 resolvePromise = resolve; 3383 }); 3384 3385 var token = this; 3386 3387 // eslint-disable-next-line func-names 3388 this.promise.then(function(cancel) { 3389 if (!token._listeners) return; 3390 3391 var i; 3392 var l = token._listeners.length; 3393 3394 for (i = 0; i < l; i++) { 3395 token._listeners[i](cancel); 3396 } 3397 token._listeners = null; 3398 }); 3399 3400 // eslint-disable-next-line func-names 3401 this.promise.then = function(onfulfilled) { 3402 var _resolve; 3403 // eslint-disable-next-line func-names 3404 var promise = new Promise(function(resolve) { 3405 token.subscribe(resolve); 3406 _resolve = resolve; 3407 }).then(onfulfilled); 3408 3409 promise.cancel = function reject() { 3410 token.unsubscribe(_resolve); 3411 }; 3412 3413 return promise; 3414 }; 3415 3416 executor(function cancel(message) { 3417 if (token.reason) { 3418 // Cancellation has already been requested 3419 return; 3420 } 3421 3422 token.reason = new Cancel(message); 3423 resolvePromise(token.reason); 3424 }); 3425} 3426 3427/** 3428 * Throws a `Cancel` if cancellation has been requested. 3429 */ 3430CancelToken.prototype.throwIfRequested = function throwIfRequested() { 3431 if (this.reason) { 3432 throw this.reason; 3433 } 3434}; 3435 3436/** 3437 * Subscribe to the cancel signal 3438 */ 3439 3440CancelToken.prototype.subscribe = function subscribe(listener) { 3441 if (this.reason) { 3442 listener(this.reason); 3443 return; 3444 } 3445 3446 if (this._listeners) { 3447 this._listeners.push(listener); 3448 } else { 3449 this._listeners = [listener]; 3450 } 3451}; 3452 3453/** 3454 * Unsubscribe from the cancel signal 3455 */ 3456 3457CancelToken.prototype.unsubscribe = function unsubscribe(listener) { 3458 if (!this._listeners) { 3459 return; 3460 } 3461 var index = this._listeners.indexOf(listener); 3462 if (index !== -1) { 3463 this._listeners.splice(index, 1); 3464 } 3465}; 3466 3467/** 3468 * Returns an object that contains a new `CancelToken` and a function that, when called, 3469 * cancels the `CancelToken`. 3470 */ 3471CancelToken.source = function source() { 3472 var cancel; 3473 var token = new CancelToken(function executor(c) { 3474 cancel = c; 3475 }); 3476 return { 3477 token: token, 3478 cancel: cancel 3479 }; 3480}; 3481 3482module.exports = CancelToken; 3483 3484 3485/***/ }), 3486
vendor: 361 bytes, lines 3487-3502
3487/***/ "./node_modules/axios/lib/cancel/isCancel.js": 3488/*!***************************************************!*\ 3489 !*** ./node_modules/axios/lib/cancel/isCancel.js ***! 3490 \***************************************************/ 3491/***/ ((module) => { 3492 3493"use strict"; 3494 3495 3496module.exports = function isCancel(value) { 3497 return !!(value && value.__CANCEL__); 3498}; 3499 3500 3501/***/ }), 3502
vendor: 5,073 bytes, lines 3503-3668
3503/***/ "./node_modules/axios/lib/core/Axios.js": 3504/*!**********************************************!*\ 3505 !*** ./node_modules/axios/lib/core/Axios.js ***! 3506 \**********************************************/ 3507/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3508 3509"use strict"; 3510 3511 3512var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 3513var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 3514var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js"); 3515var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js"); 3516var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 3517var validator = __webpack_require__(/*! ../helpers/validator */ "./node_modules/axios/lib/helpers/validator.js"); 3518 3519var validators = validator.validators; 3520/** 3521 * Create a new instance of Axios 3522 * 3523 * @param {Object} instanceConfig The default config for the instance 3524 */ 3525function Axios(instanceConfig) { 3526 this.defaults = instanceConfig; 3527 this.interceptors = { 3528 request: new InterceptorManager(), 3529 response: new InterceptorManager() 3530 }; 3531} 3532 3533/** 3534 * Dispatch a request 3535 * 3536 * @param {Object} config The config specific for this request (merged with this.defaults) 3537 */ 3538Axios.prototype.request = function request(configOrUrl, config) { 3539 /*eslint no-param-reassign:0*/ 3540 // Allow for axios('example/url'[, config]) a la fetch API 3541 if (typeof configOrUrl === 'string') { 3542 config = config || {}; 3543 config.url = configOrUrl; 3544 } else { 3545 config = configOrUrl || {}; 3546 } 3547 3548 if (!config.url) { 3549 throw new Error('Provided config url is not valid'); 3550 } 3551 3552 config = mergeConfig(this.defaults, config); 3553 3554 // Set config.method 3555 if (config.method) { 3556 config.method = config.method.toLowerCase(); 3557 } else if (this.defaults.method) { 3558 config.method = this.defaults.method.toLowerCase(); 3559 } else { 3560 config.method = 'get'; 3561 } 3562 3563 var transitional = config.transitional; 3564 3565 if (transitional !== undefined) { 3566 validator.assertOptions(transitional, { 3567 silentJSONParsing: validators.transitional(validators.boolean), 3568 forcedJSONParsing: validators.transitional(validators.boolean), 3569 clarifyTimeoutError: validators.transitional(validators.boolean) 3570 }, false); 3571 } 3572 3573 // filter out skipped interceptors 3574 var requestInterceptorChain = []; 3575 var synchronousRequestInterceptors = true; 3576 this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 3577 if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { 3578 return; 3579 } 3580 3581 synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; 3582 3583 requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); 3584 }); 3585 3586 var responseInterceptorChain = []; 3587 this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 3588 responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); 3589 }); 3590 3591 var promise; 3592 3593 if (!synchronousRequestInterceptors) { 3594 var chain = [dispatchRequest, undefined]; 3595 3596 Array.prototype.unshift.apply(chain, requestInterceptorChain); 3597 chain = chain.concat(responseInterceptorChain); 3598 3599 promise = Promise.resolve(config); 3600 while (chain.length) { 3601 promise = promise.then(chain.shift(), chain.shift()); 3602 } 3603 3604 return promise; 3605 } 3606 3607 3608 var newConfig = config; 3609 while (requestInterceptorChain.length) { 3610 var onFulfilled = requestInterceptorChain.shift(); 3611 var onRejected = requestInterceptorChain.shift(); 3612 try { 3613 newConfig = onFulfilled(newConfig); 3614 } catch (error) { 3615 onRejected(error); 3616 break; 3617 } 3618 } 3619 3620 try { 3621 promise = dispatchRequest(newConfig); 3622 } catch (error) { 3623 return Promise.reject(error); 3624 } 3625 3626 while (responseInterceptorChain.length) { 3627 promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); 3628 } 3629 3630 return promise; 3631}; 3632 3633Axios.prototype.getUri = function getUri(config) { 3634 if (!config.url) { 3635 throw new Error('Provided config url is not valid'); 3636 } 3637 config = mergeConfig(this.defaults, config); 3638 return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); 3639}; 3640 3641// Provide aliases for supported request methods 3642utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 3643 /*eslint func-names:0*/ 3644 Axios.prototype[method] = function(url, config) { 3645 return this.request(mergeConfig(config || {}, { 3646 method: method, 3647 url: url, 3648 data: (config || {}).data 3649 })); 3650 }; 3651}); 3652 3653utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 3654 /*eslint func-names:0*/ 3655 Axios.prototype[method] = function(url, data, config) { 3656 return this.request(mergeConfig(config || {}, { 3657 method: method, 3658 url: url, 3659 data: data 3660 })); 3661 }; 3662}); 3663 3664module.exports = Axios; 3665 3666 3667/***/ }), 3668
vendor: 1,754 bytes, lines 3669-3733
3669/***/ "./node_modules/axios/lib/core/InterceptorManager.js": 3670/*!***********************************************************!*\ 3671 !*** ./node_modules/axios/lib/core/InterceptorManager.js ***! 3672 \***********************************************************/ 3673/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3674 3675"use strict"; 3676 3677 3678var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 3679 3680function InterceptorManager() { 3681 this.handlers = []; 3682} 3683 3684/** 3685 * Add a new interceptor to the stack 3686 * 3687 * @param {Function} fulfilled The function to handle `then` for a `Promise` 3688 * @param {Function} rejected The function to handle `reject` for a `Promise` 3689 * 3690 * @return {Number} An ID used to remove interceptor later 3691 */ 3692InterceptorManager.prototype.use = function use(fulfilled, rejected, options) { 3693 this.handlers.push({ 3694 fulfilled: fulfilled, 3695 rejected: rejected, 3696 synchronous: options ? options.synchronous : false, 3697 runWhen: options ? options.runWhen : null 3698 }); 3699 return this.handlers.length - 1; 3700}; 3701 3702/** 3703 * Remove an interceptor from the stack 3704 * 3705 * @param {Number} id The ID that was returned by `use` 3706 */ 3707InterceptorManager.prototype.eject = function eject(id) { 3708 if (this.handlers[id]) { 3709 this.handlers[id] = null; 3710 } 3711}; 3712 3713/** 3714 * Iterate over all the registered interceptors 3715 * 3716 * This method is particularly useful for skipping over any 3717 * interceptors that may have become `null` calling `eject`. 3718 * 3719 * @param {Function} fn The function to call for each interceptor 3720 */ 3721InterceptorManager.prototype.forEach = function forEach(fn) { 3722 utils.forEach(this.handlers, function forEachHandler(h) { 3723 if (h !== null) { 3724 fn(h); 3725 } 3726 }); 3727}; 3728 3729module.exports = InterceptorManager; 3730 3731 3732/***/ }), 3733
vendor: 1,149 bytes, lines 3734-3764
3734/***/ "./node_modules/axios/lib/core/buildFullPath.js": 3735/*!******************************************************!*\ 3736 !*** ./node_modules/axios/lib/core/buildFullPath.js ***! 3737 \******************************************************/ 3738/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3739 3740"use strict"; 3741 3742 3743var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js"); 3744var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js"); 3745 3746/** 3747 * Creates a new URL by combining the baseURL with the requestedURL, 3748 * only when the requestedURL is not already an absolute URL. 3749 * If the requestURL is absolute, this function returns the requestedURL untouched. 3750 * 3751 * @param {string} baseURL The base URL 3752 * @param {string} requestedURL Absolute or relative URL to combine 3753 * @returns {string} The combined full path 3754 */ 3755module.exports = function buildFullPath(baseURL, requestedURL) { 3756 if (baseURL && !isAbsoluteURL(requestedURL)) { 3757 return combineURLs(baseURL, requestedURL); 3758 } 3759 return requestedURL; 3760}; 3761 3762 3763/***/ }), 3764
vendor: 1,000 bytes, lines 3765-3793
3765/***/ "./node_modules/axios/lib/core/createError.js": 3766/*!****************************************************!*\ 3767 !*** ./node_modules/axios/lib/core/createError.js ***! 3768 \****************************************************/ 3769/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3770 3771"use strict"; 3772 3773 3774var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js"); 3775 3776/** 3777 * Create an Error with the specified message, config, error code, request and response. 3778 * 3779 * @param {string} message The error message. 3780 * @param {Object} config The config. 3781 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 3782 * @param {Object} [request] The request. 3783 * @param {Object} [response] The response. 3784 * @returns {Error} The created error. 3785 */ 3786module.exports = function createError(message, config, code, request, response) { 3787 var error = new Error(message); 3788 return enhanceError(error, config, code, request, response); 3789}; 3790 3791 3792/***/ }), 3793
vendor: 2,747 bytes, lines 3794-3891
3794/***/ "./node_modules/axios/lib/core/dispatchRequest.js": 3795/*!********************************************************!*\ 3796 !*** ./node_modules/axios/lib/core/dispatchRequest.js ***! 3797 \********************************************************/ 3798/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3799 3800"use strict"; 3801 3802 3803var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 3804var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js"); 3805var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 3806var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js"); 3807var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 3808 3809/** 3810 * Throws a `Cancel` if cancellation has been requested. 3811 */ 3812function throwIfCancellationRequested(config) { 3813 if (config.cancelToken) { 3814 config.cancelToken.throwIfRequested(); 3815 } 3816 3817 if (config.signal && config.signal.aborted) { 3818 throw new Cancel('canceled'); 3819 } 3820} 3821 3822/** 3823 * Dispatch a request to the server using the configured adapter. 3824 * 3825 * @param {object} config The config that is to be used for the request 3826 * @returns {Promise} The Promise to be fulfilled 3827 */ 3828module.exports = function dispatchRequest(config) { 3829 throwIfCancellationRequested(config); 3830 3831 // Ensure headers exist 3832 config.headers = config.headers || {}; 3833 3834 // Transform request data 3835 config.data = transformData.call( 3836 config, 3837 config.data, 3838 config.headers, 3839 config.transformRequest 3840 ); 3841 3842 // Flatten headers 3843 config.headers = utils.merge( 3844 config.headers.common || {}, 3845 config.headers[config.method] || {}, 3846 config.headers 3847 ); 3848 3849 utils.forEach( 3850 ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 3851 function cleanHeaderConfig(method) { 3852 delete config.headers[method]; 3853 } 3854 ); 3855 3856 var adapter = config.adapter || defaults.adapter; 3857 3858 return adapter(config).then(function onAdapterResolution(response) { 3859 throwIfCancellationRequested(config); 3860 3861 // Transform response data 3862 response.data = transformData.call( 3863 config, 3864 response.data, 3865 response.headers, 3866 config.transformResponse 3867 ); 3868 3869 return response; 3870 }, function onAdapterRejection(reason) { 3871 if (!isCancel(reason)) { 3872 throwIfCancellationRequested(config); 3873 3874 // Transform response data 3875 if (reason && reason.response) { 3876 reason.response.data = transformData.call( 3877 config, 3878 reason.response.data, 3879 reason.response.headers, 3880 config.transformResponse 3881 ); 3882 } 3883 } 3884 3885 return Promise.reject(reason); 3886 }); 3887}; 3888 3889 3890/***/ }), 3891
vendor: 1,399 bytes, lines 3892-3945
3892/***/ "./node_modules/axios/lib/core/enhanceError.js": 3893/*!*****************************************************!*\ 3894 !*** ./node_modules/axios/lib/core/enhanceError.js ***! 3895 \*****************************************************/ 3896/***/ ((module) => { 3897 3898"use strict"; 3899 3900 3901/** 3902 * Update an Error with the specified config, error code, and response. 3903 * 3904 * @param {Error} error The error to update. 3905 * @param {Object} config The config. 3906 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 3907 * @param {Object} [request] The request. 3908 * @param {Object} [response] The response. 3909 * @returns {Error} The error. 3910 */ 3911module.exports = function enhanceError(error, config, code, request, response) { 3912 error.config = config; 3913 if (code) { 3914 error.code = code; 3915 } 3916 3917 error.request = request; 3918 error.response = response; 3919 error.isAxiosError = true; 3920 3921 error.toJSON = function toJSON() { 3922 return { 3923 // Standard 3924 message: this.message, 3925 name: this.name, 3926 // Microsoft 3927 description: this.description, 3928 number: this.number, 3929 // Mozilla 3930 fileName: this.fileName, 3931 lineNumber: this.lineNumber, 3932 columnNumber: this.columnNumber, 3933 stack: this.stack, 3934 // Axios 3935 config: this.config, 3936 code: this.code, 3937 status: this.response && this.response.status ? this.response.status : null 3938 }; 3939 }; 3940 return error; 3941}; 3942 3943 3944/***/ }), 3945
vendor: 3,558 bytes, lines 3946-4055
3946/***/ "./node_modules/axios/lib/core/mergeConfig.js": 3947/*!****************************************************!*\ 3948 !*** ./node_modules/axios/lib/core/mergeConfig.js ***! 3949 \****************************************************/ 3950/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 3951 3952"use strict"; 3953 3954 3955var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 3956 3957/** 3958 * Config-specific merge-function which creates a new config-object 3959 * by merging two configuration objects together. 3960 * 3961 * @param {Object} config1 3962 * @param {Object} config2 3963 * @returns {Object} New object resulting from merging config2 to config1 3964 */ 3965module.exports = function mergeConfig(config1, config2) { 3966 // eslint-disable-next-line no-param-reassign 3967 config2 = config2 || {}; 3968 var config = {}; 3969 3970 function getMergedValue(target, source) { 3971 if (utils.isPlainObject(target) && utils.isPlainObject(source)) { 3972 return utils.merge(target, source); 3973 } else if (utils.isPlainObject(source)) { 3974 return utils.merge({}, source); 3975 } else if (utils.isArray(source)) { 3976 return source.slice(); 3977 } 3978 return source; 3979 } 3980 3981 // eslint-disable-next-line consistent-return 3982 function mergeDeepProperties(prop) { 3983 if (!utils.isUndefined(config2[prop])) { 3984 return getMergedValue(config1[prop], config2[prop]); 3985 } else if (!utils.isUndefined(config1[prop])) { 3986 return getMergedValue(undefined, config1[prop]); 3987 } 3988 } 3989 3990 // eslint-disable-next-line consistent-return 3991 function valueFromConfig2(prop) { 3992 if (!utils.isUndefined(config2[prop])) { 3993 return getMergedValue(undefined, config2[prop]); 3994 } 3995 } 3996 3997 // eslint-disable-next-line consistent-return 3998 function defaultToConfig2(prop) { 3999 if (!utils.isUndefined(config2[prop])) { 4000 return getMergedValue(undefined, config2[prop]); 4001 } else if (!utils.isUndefined(config1[prop])) { 4002 return getMergedValue(undefined, config1[prop]); 4003 } 4004 } 4005 4006 // eslint-disable-next-line consistent-return 4007 function mergeDirectKeys(prop) { 4008 if (prop in config2) { 4009 return getMergedValue(config1[prop], config2[prop]); 4010 } else if (prop in config1) { 4011 return getMergedValue(undefined, config1[prop]); 4012 } 4013 } 4014 4015 var mergeMap = { 4016 'url': valueFromConfig2, 4017 'method': valueFromConfig2, 4018 'data': valueFromConfig2, 4019 'baseURL': defaultToConfig2, 4020 'transformRequest': defaultToConfig2, 4021 'transformResponse': defaultToConfig2, 4022 'paramsSerializer': defaultToConfig2, 4023 'timeout': defaultToConfig2, 4024 'timeoutMessage': defaultToConfig2, 4025 'withCredentials': defaultToConfig2, 4026 'adapter': defaultToConfig2, 4027 'responseType': defaultToConfig2, 4028 'xsrfCookieName': defaultToConfig2, 4029 'xsrfHeaderName': defaultToConfig2, 4030 'onUploadProgress': defaultToConfig2, 4031 'onDownloadProgress': defaultToConfig2, 4032 'decompress': defaultToConfig2, 4033 'maxContentLength': defaultToConfig2, 4034 'maxBodyLength': defaultToConfig2, 4035 'transport': defaultToConfig2, 4036 'httpAgent': defaultToConfig2, 4037 'httpsAgent': defaultToConfig2, 4038 'cancelToken': defaultToConfig2, 4039 'socketPath': defaultToConfig2, 4040 'responseEncoding': defaultToConfig2, 4041 'validateStatus': mergeDirectKeys 4042 }; 4043 4044 utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) { 4045 var merge = mergeMap[prop] || mergeDeepProperties; 4046 var configValue = merge(prop); 4047 (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); 4048 }); 4049 4050 return config; 4051}; 4052 4053 4054/***/ }), 4055
vendor: 1,060 bytes, lines 4056-4091
4056/***/ "./node_modules/axios/lib/core/settle.js": 4057/*!***********************************************!*\ 4058 !*** ./node_modules/axios/lib/core/settle.js ***! 4059 \***********************************************/ 4060/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4061 4062"use strict"; 4063 4064 4065var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js"); 4066 4067/** 4068 * Resolve or reject a Promise based on response status. 4069 * 4070 * @param {Function} resolve A function that resolves the promise. 4071 * @param {Function} reject A function that rejects the promise. 4072 * @param {object} response The response. 4073 */ 4074module.exports = function settle(resolve, reject, response) { 4075 var validateStatus = response.config.validateStatus; 4076 if (!response.status || !validateStatus || validateStatus(response.status)) { 4077 resolve(response); 4078 } else { 4079 reject(createError( 4080 'Request failed with status code ' + response.status, 4081 response.config, 4082 null, 4083 response.request, 4084 response 4085 )); 4086 } 4087}; 4088 4089 4090/***/ }), 4091
vendor: 1,066 bytes, lines 4092-4124
4092/***/ "./node_modules/axios/lib/core/transformData.js": 4093/*!******************************************************!*\ 4094 !*** ./node_modules/axios/lib/core/transformData.js ***! 4095 \******************************************************/ 4096/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4097 4098"use strict"; 4099 4100 4101var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 4102var defaults = __webpack_require__(/*! ./../defaults */ "./node_modules/axios/lib/defaults.js"); 4103 4104/** 4105 * Transform the data for a request or a response 4106 * 4107 * @param {Object|String} data The data to be transformed 4108 * @param {Array} headers The headers for the request or response 4109 * @param {Array|Function} fns A single function or Array of functions 4110 * @returns {*} The resulting transformed data 4111 */ 4112module.exports = function transformData(data, headers, fns) { 4113 var context = this || defaults; 4114 /*eslint no-param-reassign:0*/ 4115 utils.forEach(fns, function transform(fn) { 4116 data = fn.call(context, data, headers); 4117 }); 4118 4119 return data; 4120}; 4121 4122 4123/***/ }), 4124
vendor: 4,297 bytes, lines 4125-4270
4125/***/ "./node_modules/axios/lib/defaults.js": 4126/*!********************************************!*\ 4127 !*** ./node_modules/axios/lib/defaults.js ***! 4128 \********************************************/ 4129/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4130 4131"use strict"; 4132/* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js"); 4133 4134 4135var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 4136var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js"); 4137var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./node_modules/axios/lib/core/enhanceError.js"); 4138 4139var DEFAULT_CONTENT_TYPE = { 4140 'Content-Type': 'application/x-www-form-urlencoded' 4141}; 4142 4143function setContentTypeIfUnset(headers, value) { 4144 if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 4145 headers['Content-Type'] = value; 4146 } 4147} 4148 4149function getDefaultAdapter() { 4150 var adapter; 4151 if (typeof XMLHttpRequest !== 'undefined') { 4152 // For browsers use XHR adapter 4153 adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js"); 4154 } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { 4155 // For node use HTTP adapter 4156 adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js"); 4157 } 4158 return adapter; 4159} 4160 4161function stringifySafely(rawValue, parser, encoder) { 4162 if (utils.isString(rawValue)) { 4163 try { 4164 (parser || JSON.parse)(rawValue); 4165 return utils.trim(rawValue); 4166 } catch (e) { 4167 if (e.name !== 'SyntaxError') { 4168 throw e; 4169 } 4170 } 4171 } 4172 4173 return (encoder || JSON.stringify)(rawValue); 4174} 4175 4176var defaults = { 4177 4178 transitional: { 4179 silentJSONParsing: true, 4180 forcedJSONParsing: true, 4181 clarifyTimeoutError: false 4182 }, 4183 4184 adapter: getDefaultAdapter(), 4185 4186 transformRequest: [function transformRequest(data, headers) { 4187 normalizeHeaderName(headers, 'Accept'); 4188 normalizeHeaderName(headers, 'Content-Type'); 4189 4190 if (utils.isFormData(data) || 4191 utils.isArrayBuffer(data) || 4192 utils.isBuffer(data) || 4193 utils.isStream(data) || 4194 utils.isFile(data) || 4195 utils.isBlob(data) 4196 ) { 4197 return data; 4198 } 4199 if (utils.isArrayBufferView(data)) { 4200 return data.buffer; 4201 } 4202 if (utils.isURLSearchParams(data)) { 4203 setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 4204 return data.toString(); 4205 } 4206 if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) { 4207 setContentTypeIfUnset(headers, 'application/json'); 4208 return stringifySafely(data); 4209 } 4210 return data; 4211 }], 4212 4213 transformResponse: [function transformResponse(data) { 4214 var transitional = this.transitional || defaults.transitional; 4215 var silentJSONParsing = transitional && transitional.silentJSONParsing; 4216 var forcedJSONParsing = transitional && transitional.forcedJSONParsing; 4217 var strictJSONParsing = !silentJSONParsing && this.responseType === 'json'; 4218 4219 if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) { 4220 try { 4221 return JSON.parse(data); 4222 } catch (e) { 4223 if (strictJSONParsing) { 4224 if (e.name === 'SyntaxError') { 4225 throw enhanceError(e, this, 'E_JSON_PARSE'); 4226 } 4227 throw e; 4228 } 4229 } 4230 } 4231 4232 return data; 4233 }], 4234 4235 /** 4236 * A timeout in milliseconds to abort a request. If set to 0 (default) a 4237 * timeout is not created. 4238 */ 4239 timeout: 0, 4240 4241 xsrfCookieName: 'XSRF-TOKEN', 4242 xsrfHeaderName: 'X-XSRF-TOKEN', 4243 4244 maxContentLength: -1, 4245 maxBodyLength: -1, 4246 4247 validateStatus: function validateStatus(status) { 4248 return status >= 200 && status < 300; 4249 }, 4250 4251 headers: { 4252 common: { 4253 'Accept': 'application/json, text/plain, */*' 4254 } 4255 } 4256}; 4257 4258utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 4259 defaults.headers[method] = {}; 4260}); 4261 4262utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 4263 defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 4264}); 4265 4266module.exports = defaults; 4267 4268 4269/***/ }), 4270
vendor: 273 bytes, lines 4271-4282
4271/***/ "./node_modules/axios/lib/env/data.js": 4272/*!********************************************!*\ 4273 !*** ./node_modules/axios/lib/env/data.js ***! 4274 \********************************************/ 4275/***/ ((module) => { 4276 4277module.exports = { 4278 "version": "0.25.0" 4279}; 4280 4281/***/ }), 4282
vendor: 503 bytes, lines 4283-4304
4283/***/ "./node_modules/axios/lib/helpers/bind.js": 4284/*!************************************************!*\ 4285 !*** ./node_modules/axios/lib/helpers/bind.js ***! 4286 \************************************************/ 4287/***/ ((module) => { 4288 4289"use strict"; 4290 4291 4292module.exports = function bind(fn, thisArg) { 4293 return function wrap() { 4294 var args = new Array(arguments.length); 4295 for (var i = 0; i < args.length; i++) { 4296 args[i] = arguments[i]; 4297 } 4298 return fn.apply(thisArg, args); 4299 }; 4300}; 4301 4302 4303/***/ }), 4304
vendor: 2,007 bytes, lines 4305-4385
4305/***/ "./node_modules/axios/lib/helpers/buildURL.js": 4306/*!****************************************************!*\ 4307 !*** ./node_modules/axios/lib/helpers/buildURL.js ***! 4308 \****************************************************/ 4309/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4310 4311"use strict"; 4312 4313 4314var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 4315 4316function encode(val) { 4317 return encodeURIComponent(val). 4318 replace(/%3A/gi, ':'). 4319 replace(/%24/g, '$'). 4320 replace(/%2C/gi, ','). 4321 replace(/%20/g, '+'). 4322 replace(/%5B/gi, '['). 4323 replace(/%5D/gi, ']'); 4324} 4325 4326/** 4327 * Build a URL by appending params to the end 4328 * 4329 * @param {string} url The base of the url (e.g., http://www.google.com) 4330 * @param {object} [params] The params to be appended 4331 * @returns {string} The formatted url 4332 */ 4333module.exports = function buildURL(url, params, paramsSerializer) { 4334 /*eslint no-param-reassign:0*/ 4335 if (!params) { 4336 return url; 4337 } 4338 4339 var serializedParams; 4340 if (paramsSerializer) { 4341 serializedParams = paramsSerializer(params); 4342 } else if (utils.isURLSearchParams(params)) { 4343 serializedParams = params.toString(); 4344 } else { 4345 var parts = []; 4346 4347 utils.forEach(params, function serialize(val, key) { 4348 if (val === null || typeof val === 'undefined') { 4349 return; 4350 } 4351 4352 if (utils.isArray(val)) { 4353 key = key + '[]'; 4354 } else { 4355 val = [val]; 4356 } 4357 4358 utils.forEach(val, function parseValue(v) { 4359 if (utils.isDate(v)) { 4360 v = v.toISOString(); 4361 } else if (utils.isObject(v)) { 4362 v = JSON.stringify(v); 4363 } 4364 parts.push(encode(key) + '=' + encode(v)); 4365 }); 4366 }); 4367 4368 serializedParams = parts.join('&'); 4369 } 4370 4371 if (serializedParams) { 4372 var hashmarkIndex = url.indexOf('#'); 4373 if (hashmarkIndex !== -1) { 4374 url = url.slice(0, hashmarkIndex); 4375 } 4376 4377 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 4378 } 4379 4380 return url; 4381}; 4382 4383 4384/***/ }), 4385
vendor: 655 bytes, lines 4386-4410
4386/***/ "./node_modules/axios/lib/helpers/combineURLs.js": 4387/*!*******************************************************!*\ 4388 !*** ./node_modules/axios/lib/helpers/combineURLs.js ***! 4389 \*******************************************************/ 4390/***/ ((module) => { 4391 4392"use strict"; 4393 4394 4395/** 4396 * Creates a new URL by combining the specified URLs 4397 * 4398 * @param {string} baseURL The base URL 4399 * @param {string} relativeURL The relative URL 4400 * @returns {string} The combined URL 4401 */ 4402module.exports = function combineURLs(baseURL, relativeURL) { 4403 return relativeURL 4404 ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 4405 : baseURL; 4406}; 4407 4408 4409/***/ }), 4410
vendor: 1,794 bytes, lines 4411-4474
4411/***/ "./node_modules/axios/lib/helpers/cookies.js": 4412/*!***************************************************!*\ 4413 !*** ./node_modules/axios/lib/helpers/cookies.js ***! 4414 \***************************************************/ 4415/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4416 4417"use strict"; 4418 4419 4420var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 4421 4422module.exports = ( 4423 utils.isStandardBrowserEnv() ? 4424 4425 // Standard browser envs support document.cookie 4426 (function standardBrowserEnv() { 4427 return { 4428 write: function write(name, value, expires, path, domain, secure) { 4429 var cookie = []; 4430 cookie.push(name + '=' + encodeURIComponent(value)); 4431 4432 if (utils.isNumber(expires)) { 4433 cookie.push('expires=' + new Date(expires).toGMTString()); 4434 } 4435 4436 if (utils.isString(path)) { 4437 cookie.push('path=' + path); 4438 } 4439 4440 if (utils.isString(domain)) { 4441 cookie.push('domain=' + domain); 4442 } 4443 4444 if (secure === true) { 4445 cookie.push('secure'); 4446 } 4447 4448 document.cookie = cookie.join('; '); 4449 }, 4450 4451 read: function read(name) { 4452 var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 4453 return (match ? decodeURIComponent(match[3]) : null); 4454 }, 4455 4456 remove: function remove(name) { 4457 this.write(name, '', Date.now() - 86400000); 4458 } 4459 }; 4460 })() : 4461 4462 // Non standard browser env (web workers, react-native) lack needed support. 4463 (function nonStandardBrowserEnv() { 4464 return { 4465 write: function write() {}, 4466 read: function read() { return null; }, 4467 remove: function remove() {} 4468 }; 4469 })() 4470); 4471 4472 4473/***/ }), 4474
vendor: 844 bytes, lines 4475-4499
4475/***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js": 4476/*!*********************************************************!*\ 4477 !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***! 4478 \*********************************************************/ 4479/***/ ((module) => { 4480 4481"use strict"; 4482 4483 4484/** 4485 * Determines whether the specified URL is absolute 4486 * 4487 * @param {string} url The URL to test 4488 * @returns {boolean} True if the specified URL is absolute, otherwise false 4489 */ 4490module.exports = function isAbsoluteURL(url) { 4491 // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). 4492 // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 4493 // by any combination of letters, digits, plus, period, or hyphen. 4494 return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); 4495}; 4496 4497 4498/***/ }), 4499
vendor: 752 bytes, lines 4500-4523
4500/***/ "./node_modules/axios/lib/helpers/isAxiosError.js": 4501/*!********************************************************!*\ 4502 !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***! 4503 \********************************************************/ 4504/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4505 4506"use strict"; 4507 4508 4509var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 4510 4511/** 4512 * Determines whether the payload is an error thrown by Axios 4513 * 4514 * @param {*} payload The value to test 4515 * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false 4516 */ 4517module.exports = function isAxiosError(payload) { 4518 return utils.isObject(payload) && (payload.isAxiosError === true); 4519}; 4520 4521 4522/***/ }), 4523
vendor: 2,696 bytes, lines 4524-4602
4524/***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js": 4525/*!***********************************************************!*\ 4526 !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***! 4527 \***********************************************************/ 4528/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4529 4530"use strict"; 4531 4532 4533var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 4534 4535module.exports = ( 4536 utils.isStandardBrowserEnv() ? 4537 4538 // Standard browser envs have full support of the APIs needed to test 4539 // whether the request URL is of the same origin as current location. 4540 (function standardBrowserEnv() { 4541 var msie = /(msie|trident)/i.test(navigator.userAgent); 4542 var urlParsingNode = document.createElement('a'); 4543 var originURL; 4544 4545 /** 4546 * Parse a URL to discover it's components 4547 * 4548 * @param {String} url The URL to be parsed 4549 * @returns {Object} 4550 */ 4551 function resolveURL(url) { 4552 var href = url; 4553 4554 if (msie) { 4555 // IE needs attribute set twice to normalize properties 4556 urlParsingNode.setAttribute('href', href); 4557 href = urlParsingNode.href; 4558 } 4559 4560 urlParsingNode.setAttribute('href', href); 4561 4562 // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 4563 return { 4564 href: urlParsingNode.href, 4565 protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 4566 host: urlParsingNode.host, 4567 search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 4568 hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 4569 hostname: urlParsingNode.hostname, 4570 port: urlParsingNode.port, 4571 pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 4572 urlParsingNode.pathname : 4573 '/' + urlParsingNode.pathname 4574 }; 4575 } 4576 4577 originURL = resolveURL(window.location.href); 4578 4579 /** 4580 * Determine if a URL shares the same origin as the current location 4581 * 4582 * @param {String} requestURL The URL to test 4583 * @returns {boolean} True if URL shares the same origin, otherwise false 4584 */ 4585 return function isURLSameOrigin(requestURL) { 4586 var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 4587 return (parsed.protocol === originURL.protocol && 4588 parsed.host === originURL.host); 4589 }; 4590 })() : 4591 4592 // Non standard browser envs (web workers, react-native) lack needed support. 4593 (function nonStandardBrowserEnv() { 4594 return function isURLSameOrigin() { 4595 return true; 4596 }; 4597 })() 4598); 4599 4600 4601/***/ }), 4602
vendor: 764 bytes, lines 4603-4625
4603/***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js": 4604/*!***************************************************************!*\ 4605 !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***! 4606 \***************************************************************/ 4607/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4608 4609"use strict"; 4610 4611 4612var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 4613 4614module.exports = function normalizeHeaderName(headers, normalizedName) { 4615 utils.forEach(headers, function processHeader(value, name) { 4616 if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 4617 headers[normalizedName] = value; 4618 delete headers[name]; 4619 } 4620 }); 4621}; 4622 4623 4624/***/ }), 4625
vendor: 1,772 bytes, lines 4626-4689
4626/***/ "./node_modules/axios/lib/helpers/parseHeaders.js": 4627/*!********************************************************!*\ 4628 !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***! 4629 \********************************************************/ 4630/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4631 4632"use strict"; 4633 4634 4635var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 4636 4637// Headers whose duplicates are ignored by node 4638// c.f. https://nodejs.org/api/http.html#http_message_headers 4639var ignoreDuplicateOf = [ 4640 'age', 'authorization', 'content-length', 'content-type', 'etag', 4641 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 4642 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 4643 'referer', 'retry-after', 'user-agent' 4644]; 4645 4646/** 4647 * Parse headers into an object 4648 * 4649 * ``` 4650 * Date: Wed, 27 Aug 2014 08:58:49 GMT 4651 * Content-Type: application/json 4652 * Connection: keep-alive 4653 * Transfer-Encoding: chunked 4654 * ``` 4655 * 4656 * @param {String} headers Headers needing to be parsed 4657 * @returns {Object} Headers parsed into an object 4658 */ 4659module.exports = function parseHeaders(headers) { 4660 var parsed = {}; 4661 var key; 4662 var val; 4663 var i; 4664 4665 if (!headers) { return parsed; } 4666 4667 utils.forEach(headers.split('\n'), function parser(line) { 4668 i = line.indexOf(':'); 4669 key = utils.trim(line.substr(0, i)).toLowerCase(); 4670 val = utils.trim(line.substr(i + 1)); 4671 4672 if (key) { 4673 if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 4674 return; 4675 } 4676 if (key === 'set-cookie') { 4677 parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 4678 } else { 4679 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 4680 } 4681 } 4682 }); 4683 4684 return parsed; 4685}; 4686 4687 4688/***/ }), 4689
vendor: 819 bytes, lines 4690-4727
4690/***/ "./node_modules/axios/lib/helpers/spread.js": 4691/*!**************************************************!*\ 4692 !*** ./node_modules/axios/lib/helpers/spread.js ***! 4693 \**************************************************/ 4694/***/ ((module) => { 4695 4696"use strict"; 4697 4698 4699/** 4700 * Syntactic sugar for invoking a function and expanding an array for arguments. 4701 * 4702 * Common use case would be to use `Function.prototype.apply`. 4703 * 4704 * ```js 4705 * function f(x, y, z) {} 4706 * var args = [1, 2, 3]; 4707 * f.apply(null, args); 4708 * ``` 4709 * 4710 * With `spread` this example can be re-written. 4711 * 4712 * ```js 4713 * spread(function(x, y, z) {})([1, 2, 3]); 4714 * ``` 4715 * 4716 * @param {Function} callback 4717 * @returns {Function} 4718 */ 4719module.exports = function spread(callback) { 4720 return function wrap(arr) { 4721 return callback.apply(null, arr); 4722 }; 4723}; 4724 4725 4726/***/ }), 4727
vendor: 2,719 bytes, lines 4728-4820
4728/***/ "./node_modules/axios/lib/helpers/validator.js": 4729/*!*****************************************************!*\ 4730 !*** ./node_modules/axios/lib/helpers/validator.js ***! 4731 \*****************************************************/ 4732/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4733 4734"use strict"; 4735 4736 4737var VERSION = (__webpack_require__(/*! ../env/data */ "./node_modules/axios/lib/env/data.js").version); 4738 4739var validators = {}; 4740 4741// eslint-disable-next-line func-names 4742['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { 4743 validators[type] = function validator(thing) { 4744 return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; 4745 }; 4746}); 4747 4748var deprecatedWarnings = {}; 4749 4750/** 4751 * Transitional option validator 4752 * @param {function|boolean?} validator - set to false if the transitional option has been removed 4753 * @param {string?} version - deprecated version / removed since version 4754 * @param {string?} message - some message with additional info 4755 * @returns {function} 4756 */ 4757validators.transitional = function transitional(validator, version, message) { 4758 function formatMessage(opt, desc) { 4759 return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); 4760 } 4761 4762 // eslint-disable-next-line func-names 4763 return function(value, opt, opts) { 4764 if (validator === false) { 4765 throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : ''))); 4766 } 4767 4768 if (version && !deprecatedWarnings[opt]) { 4769 deprecatedWarnings[opt] = true; 4770 // eslint-disable-next-line no-console 4771 console.warn( 4772 formatMessage( 4773 opt, 4774 ' has been deprecated since v' + version + ' and will be removed in the near future' 4775 ) 4776 ); 4777 } 4778 4779 return validator ? validator(value, opt, opts) : true; 4780 }; 4781}; 4782 4783/** 4784 * Assert object's properties type 4785 * @param {object} options 4786 * @param {object} schema 4787 * @param {boolean?} allowUnknown 4788 */ 4789 4790function assertOptions(options, schema, allowUnknown) { 4791 if (typeof options !== 'object') { 4792 throw new TypeError('options must be an object'); 4793 } 4794 var keys = Object.keys(options); 4795 var i = keys.length; 4796 while (i-- > 0) { 4797 var opt = keys[i]; 4798 var validator = schema[opt]; 4799 if (validator) { 4800 var value = options[opt]; 4801 var result = value === undefined || validator(value, opt, options); 4802 if (result !== true) { 4803 throw new TypeError('option ' + opt + ' must be ' + result); 4804 } 4805 continue; 4806 } 4807 if (allowUnknown !== true) { 4808 throw Error('Unknown option ' + opt); 4809 } 4810 } 4811} 4812 4813module.exports = { 4814 assertOptions: assertOptions, 4815 validators: validators 4816}; 4817 4818 4819/***/ }), 4820
vendor: 9,185 bytes, lines 4821-5180
4821/***/ "./node_modules/axios/lib/utils.js": 4822/*!*****************************************!*\ 4823 !*** ./node_modules/axios/lib/utils.js ***! 4824 \*****************************************/ 4825/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 4826 4827"use strict"; 4828 4829 4830var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 4831 4832// utils is a library of generic helper functions non-specific to axios 4833 4834var toString = Object.prototype.toString; 4835 4836/** 4837 * Determine if a value is an Array 4838 * 4839 * @param {Object} val The value to test 4840 * @returns {boolean} True if value is an Array, otherwise false 4841 */ 4842function isArray(val) { 4843 return Array.isArray(val); 4844} 4845 4846/** 4847 * Determine if a value is undefined 4848 * 4849 * @param {Object} val The value to test 4850 * @returns {boolean} True if the value is undefined, otherwise false 4851 */ 4852function isUndefined(val) { 4853 return typeof val === 'undefined'; 4854} 4855 4856/** 4857 * Determine if a value is a Buffer 4858 * 4859 * @param {Object} val The value to test 4860 * @returns {boolean} True if value is a Buffer, otherwise false 4861 */ 4862function isBuffer(val) { 4863 return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) 4864 && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); 4865} 4866 4867/** 4868 * Determine if a value is an ArrayBuffer 4869 * 4870 * @param {Object} val The value to test 4871 * @returns {boolean} True if value is an ArrayBuffer, otherwise false 4872 */ 4873function isArrayBuffer(val) { 4874 return toString.call(val) === '[object ArrayBuffer]'; 4875} 4876 4877/** 4878 * Determine if a value is a FormData 4879 * 4880 * @param {Object} val The value to test 4881 * @returns {boolean} True if value is an FormData, otherwise false 4882 */ 4883function isFormData(val) { 4884 return toString.call(val) === '[object FormData]'; 4885} 4886 4887/** 4888 * Determine if a value is a view on an ArrayBuffer 4889 * 4890 * @param {Object} val The value to test 4891 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 4892 */ 4893function isArrayBufferView(val) { 4894 var result; 4895 if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 4896 result = ArrayBuffer.isView(val); 4897 } else { 4898 result = (val) && (val.buffer) && (isArrayBuffer(val.buffer)); 4899 } 4900 return result; 4901} 4902 4903/** 4904 * Determine if a value is a String 4905 * 4906 * @param {Object} val The value to test 4907 * @returns {boolean} True if value is a String, otherwise false 4908 */ 4909function isString(val) { 4910 return typeof val === 'string'; 4911} 4912 4913/** 4914 * Determine if a value is a Number 4915 * 4916 * @param {Object} val The value to test 4917 * @returns {boolean} True if value is a Number, otherwise false 4918 */ 4919function isNumber(val) { 4920 return typeof val === 'number'; 4921} 4922 4923/** 4924 * Determine if a value is an Object 4925 * 4926 * @param {Object} val The value to test 4927 * @returns {boolean} True if value is an Object, otherwise false 4928 */ 4929function isObject(val) { 4930 return val !== null && typeof val === 'object'; 4931} 4932 4933/** 4934 * Determine if a value is a plain Object 4935 * 4936 * @param {Object} val The value to test 4937 * @return {boolean} True if value is a plain Object, otherwise false 4938 */ 4939function isPlainObject(val) { 4940 if (toString.call(val) !== '[object Object]') { 4941 return false; 4942 } 4943 4944 var prototype = Object.getPrototypeOf(val); 4945 return prototype === null || prototype === Object.prototype; 4946} 4947 4948/** 4949 * Determine if a value is a Date 4950 * 4951 * @param {Object} val The value to test 4952 * @returns {boolean} True if value is a Date, otherwise false 4953 */ 4954function isDate(val) { 4955 return toString.call(val) === '[object Date]'; 4956} 4957 4958/** 4959 * Determine if a value is a File 4960 * 4961 * @param {Object} val The value to test 4962 * @returns {boolean} True if value is a File, otherwise false 4963 */ 4964function isFile(val) { 4965 return toString.call(val) === '[object File]'; 4966} 4967 4968/** 4969 * Determine if a value is a Blob 4970 * 4971 * @param {Object} val The value to test 4972 * @returns {boolean} True if value is a Blob, otherwise false 4973 */ 4974function isBlob(val) { 4975 return toString.call(val) === '[object Blob]'; 4976} 4977 4978/** 4979 * Determine if a value is a Function 4980 * 4981 * @param {Object} val The value to test 4982 * @returns {boolean} True if value is a Function, otherwise false 4983 */ 4984function isFunction(val) { 4985 return toString.call(val) === '[object Function]'; 4986} 4987 4988/** 4989 * Determine if a value is a Stream 4990 * 4991 * @param {Object} val The value to test 4992 * @returns {boolean} True if value is a Stream, otherwise false 4993 */ 4994function isStream(val) { 4995 return isObject(val) && isFunction(val.pipe); 4996} 4997 4998/** 4999 * Determine if a value is a URLSearchParams object 5000 * 5001 * @param {Object} val The value to test 5002 * @returns {boolean} True if value is a URLSearchParams object, otherwise false 5003 */ 5004function isURLSearchParams(val) { 5005 return toString.call(val) === '[object URLSearchParams]'; 5006} 5007 5008/** 5009 * Trim excess whitespace off the beginning and end of a string 5010 * 5011 * @param {String} str The String to trim 5012 * @returns {String} The String freed of excess whitespace 5013 */ 5014function trim(str) { 5015 return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); 5016} 5017 5018/** 5019 * Determine if we're running in a standard browser environment 5020 * 5021 * This allows axios to run in a web worker, and react-native. 5022 * Both environments support XMLHttpRequest, but not fully standard globals. 5023 * 5024 * web workers: 5025 * typeof window -> undefined 5026 * typeof document -> undefined 5027 * 5028 * react-native: 5029 * navigator.product -> 'ReactNative' 5030 * nativescript 5031 * navigator.product -> 'NativeScript' or 'NS' 5032 */ 5033function isStandardBrowserEnv() { 5034 if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || 5035 navigator.product === 'NativeScript' || 5036 navigator.product === 'NS')) { 5037 return false; 5038 } 5039 return ( 5040 typeof window !== 'undefined' && 5041 typeof document !== 'undefined' 5042 ); 5043} 5044 5045/** 5046 * Iterate over an Array or an Object invoking a function for each item. 5047 * 5048 * If `obj` is an Array callback will be called passing 5049 * the value, index, and complete array for each item. 5050 * 5051 * If 'obj' is an Object callback will be called passing 5052 * the value, key, and complete object for each property. 5053 * 5054 * @param {Object|Array} obj The object to iterate 5055 * @param {Function} fn The callback to invoke for each item 5056 */ 5057function forEach(obj, fn) { 5058 // Don't bother if no value provided 5059 if (obj === null || typeof obj === 'undefined') { 5060 return; 5061 } 5062 5063 // Force an array if not already something iterable 5064 if (typeof obj !== 'object') { 5065 /*eslint no-param-reassign:0*/ 5066 obj = [obj]; 5067 } 5068 5069 if (isArray(obj)) { 5070 // Iterate over array values 5071 for (var i = 0, l = obj.length; i < l; i++) { 5072 fn.call(null, obj[i], i, obj); 5073 } 5074 } else { 5075 // Iterate over object keys 5076 for (var key in obj) { 5077 if (Object.prototype.hasOwnProperty.call(obj, key)) { 5078 fn.call(null, obj[key], key, obj); 5079 } 5080 } 5081 } 5082} 5083 5084/** 5085 * Accepts varargs expecting each argument to be an object, then 5086 * immutably merges the properties of each object and returns result. 5087 * 5088 * When multiple objects contain the same key the later object in 5089 * the arguments list will take precedence. 5090 * 5091 * Example: 5092 * 5093 * ```js 5094 * var result = merge({foo: 123}, {foo: 456}); 5095 * console.log(result.foo); // outputs 456 5096 * ``` 5097 * 5098 * @param {Object} obj1 Object to merge 5099 * @returns {Object} Result of all merge properties 5100 */ 5101function merge(/* obj1, obj2, obj3, ... */) { 5102 var result = {}; 5103 function assignValue(val, key) { 5104 if (isPlainObject(result[key]) && isPlainObject(val)) { 5105 result[key] = merge(result[key], val); 5106 } else if (isPlainObject(val)) { 5107 result[key] = merge({}, val); 5108 } else if (isArray(val)) { 5109 result[key] = val.slice(); 5110 } else { 5111 result[key] = val; 5112 } 5113 } 5114 5115 for (var i = 0, l = arguments.length; i < l; i++) { 5116 forEach(arguments[i], assignValue); 5117 } 5118 return result; 5119} 5120 5121/** 5122 * Extends object a by mutably adding to it the properties of object b. 5123 * 5124 * @param {Object} a The object to be extended 5125 * @param {Object} b The object to copy properties from 5126 * @param {Object} thisArg The object to bind function to 5127 * @return {Object} The resulting value of object a 5128 */ 5129function extend(a, b, thisArg) { 5130 forEach(b, function assignValue(val, key) { 5131 if (thisArg && typeof val === 'function') { 5132 a[key] = bind(val, thisArg); 5133 } else { 5134 a[key] = val; 5135 } 5136 }); 5137 return a; 5138} 5139 5140/** 5141 * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) 5142 * 5143 * @param {string} content with BOM 5144 * @return {string} content value without BOM 5145 */ 5146function stripBOM(content) { 5147 if (content.charCodeAt(0) === 0xFEFF) { 5148 content = content.slice(1); 5149 } 5150 return content; 5151} 5152 5153module.exports = { 5154 isArray: isArray, 5155 isArrayBuffer: isArrayBuffer, 5156 isBuffer: isBuffer, 5157 isFormData: isFormData, 5158 isArrayBufferView: isArrayBufferView, 5159 isString: isString, 5160 isNumber: isNumber, 5161 isObject: isObject, 5162 isPlainObject: isPlainObject, 5163 isUndefined: isUndefined, 5164 isDate: isDate, 5165 isFile: isFile, 5166 isBlob: isBlob, 5167 isFunction: isFunction, 5168 isStream: isStream, 5169 isURLSearchParams: isURLSearchParams, 5170 isStandardBrowserEnv: isStandardBrowserEnv, 5171 forEach: forEach, 5172 merge: merge, 5173 extend: extend, 5174 trim: trim, 5175 stripBOM: stripBOM 5176}; 5177 5178 5179/***/ }), 5180
5181/***/ "./resources/js/bootstrap.js": 5182/*!***********************************!*\ 5183 !*** ./resources/js/bootstrap.js ***! 5184 \***********************************/ 5185/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { 5186 5187window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"); 5188/** 5189 * We'll load the axios HTTP library which allows us to easily issue requests 5190 * to our Laravel back-end. This library automatically handles sending the 5191 * CSRF token as a header based on the value of the "XSRF" token cookie. 5192 */ 5193 5194window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js"); 5195window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 5196/** 5197 * Echo exposes an expressive API for subscribing to channels and listening 5198 * for events that are broadcast by Laravel. Echo and event broadcasting 5199 * allows your team to easily build robust real-time web applications. 5200 */ 5201// import Echo from 'laravel-echo'; 5202// window.Pusher = require('pusher-js'); 5203// window.Echo = new Echo({ 5204// broadcaster: 'pusher', 5205// key: process.env.MIX_PUSHER_APP_KEY, 5206// cluster: process.env.MIX_PUSHER_APP_CLUSTER, 5207// forceTLS: true 5208// }); 5209 5210/***/ }), 5211
vendor: 544,380 bytes, lines 5212-22423
5212/***/ "./node_modules/lodash/lodash.js": 5213/*!***************************************!*\ 5214 !*** ./node_modules/lodash/lodash.js ***! 5215 \***************************************/ 5216/***/ (function(module, exports, __webpack_require__) { 5217 5218/* module decorator */ module = __webpack_require__.nmd(module); 5219var __WEBPACK_AMD_DEFINE_RESULT__;/** 5220 * @license 5221 * Lodash <https://lodash.com/> 5222 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 5223 * Released under MIT license <https://lodash.com/license> 5224 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 5225 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 5226 */ 5227;(function() { 5228 5229 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 5230 var undefined; 5231 5232 /** Used as the semantic version number. */ 5233 var VERSION = '4.17.21'; 5234 5235 /** Used as the size to enable large array optimizations. */ 5236 var LARGE_ARRAY_SIZE = 200; 5237 5238 /** Error message constants. */ 5239 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 5240 FUNC_ERROR_TEXT = 'Expected a function', 5241 INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; 5242 5243 /** Used to stand-in for `undefined` hash values. */ 5244 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 5245 5246 /** Used as the maximum memoize cache size. */ 5247 var MAX_MEMOIZE_SIZE = 500; 5248 5249 /** Used as the internal argument placeholder. */ 5250 var PLACEHOLDER = '__lodash_placeholder__'; 5251 5252 /** Used to compose bitmasks for cloning. */ 5253 var CLONE_DEEP_FLAG = 1, 5254 CLONE_FLAT_FLAG = 2, 5255 CLONE_SYMBOLS_FLAG = 4; 5256 5257 /** Used to compose bitmasks for value comparisons. */ 5258 var COMPARE_PARTIAL_FLAG = 1, 5259 COMPARE_UNORDERED_FLAG = 2; 5260 5261 /** Used to compose bitmasks for function metadata. */ 5262 var WRAP_BIND_FLAG = 1, 5263 WRAP_BIND_KEY_FLAG = 2, 5264 WRAP_CURRY_BOUND_FLAG = 4, 5265 WRAP_CURRY_FLAG = 8, 5266 WRAP_CURRY_RIGHT_FLAG = 16, 5267 WRAP_PARTIAL_FLAG = 32, 5268 WRAP_PARTIAL_RIGHT_FLAG = 64, 5269 WRAP_ARY_FLAG = 128, 5270 WRAP_REARG_FLAG = 256, 5271 WRAP_FLIP_FLAG = 512; 5272 5273 /** Used as default options for `_.truncate`. */ 5274 var DEFAULT_TRUNC_LENGTH = 30, 5275 DEFAULT_TRUNC_OMISSION = '...'; 5276 5277 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 5278 var HOT_COUNT = 800, 5279 HOT_SPAN = 16; 5280 5281 /** Used to indicate the type of lazy iteratees. */ 5282 var LAZY_FILTER_FLAG = 1, 5283 LAZY_MAP_FLAG = 2, 5284 LAZY_WHILE_FLAG = 3; 5285 5286 /** Used as references for various `Number` constants. */ 5287 var INFINITY = 1 / 0, 5288 MAX_SAFE_INTEGER = 9007199254740991, 5289 MAX_INTEGER = 1.7976931348623157e+308, 5290 NAN = 0 / 0; 5291 5292 /** Used as references for the maximum length and index of an array. */ 5293 var MAX_ARRAY_LENGTH = 4294967295, 5294 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 5295 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 5296 5297 /** Used to associate wrap methods with their bit flags. */ 5298 var wrapFlags = [ 5299 ['ary', WRAP_ARY_FLAG], 5300 ['bind', WRAP_BIND_FLAG], 5301 ['bindKey', WRAP_BIND_KEY_FLAG], 5302 ['curry', WRAP_CURRY_FLAG], 5303 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 5304 ['flip', WRAP_FLIP_FLAG], 5305 ['partial', WRAP_PARTIAL_FLAG], 5306 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 5307 ['rearg', WRAP_REARG_FLAG] 5308 ]; 5309 5310 /** `Object#toString` result references. */ 5311 var argsTag = '[object Arguments]', 5312 arrayTag = '[object Array]', 5313 asyncTag = '[object AsyncFunction]', 5314 boolTag = '[object Boolean]', 5315 dateTag = '[object Date]', 5316 domExcTag = '[object DOMException]', 5317 errorTag = '[object Error]', 5318 funcTag = '[object Function]', 5319 genTag = '[object GeneratorFunction]', 5320 mapTag = '[object Map]', 5321 numberTag = '[object Number]', 5322 nullTag = '[object Null]', 5323 objectTag = '[object Object]', 5324 promiseTag = '[object Promise]', 5325 proxyTag = '[object Proxy]', 5326 regexpTag = '[object RegExp]', 5327 setTag = '[object Set]', 5328 stringTag = '[object String]', 5329 symbolTag = '[object Symbol]', 5330 undefinedTag = '[object Undefined]', 5331 weakMapTag = '[object WeakMap]', 5332 weakSetTag = '[object WeakSet]'; 5333 5334 var arrayBufferTag = '[object ArrayBuffer]', 5335 dataViewTag = '[object DataView]', 5336 float32Tag = '[object Float32Array]', 5337 float64Tag = '[object Float64Array]', 5338 int8Tag = '[object Int8Array]', 5339 int16Tag = '[object Int16Array]', 5340 int32Tag = '[object Int32Array]', 5341 uint8Tag = '[object Uint8Array]', 5342 uint8ClampedTag = '[object Uint8ClampedArray]', 5343 uint16Tag = '[object Uint16Array]', 5344 uint32Tag = '[object Uint32Array]'; 5345 5346 /** Used to match empty string literals in compiled template source. */ 5347 var reEmptyStringLeading = /\b__p \+= '';/g, 5348 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 5349 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 5350 5351 /** Used to match HTML entities and HTML characters. */ 5352 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 5353 reUnescapedHtml = /[&<>"']/g, 5354 reHasEscapedHtml = RegExp(reEscapedHtml.source), 5355 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 5356 5357 /** Used to match template delimiters. */ 5358 var reEscape = /<%-([\s\S]+?)%>/g, 5359 reEvaluate = /<%([\s\S]+?)%>/g, 5360 reInterpolate = /<%=([\s\S]+?)%>/g; 5361 5362 /** Used to match property names within property paths. */ 5363 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 5364 reIsPlainProp = /^\w*$/, 5365 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 5366 5367 /** 5368 * Used to match `RegExp` 5369 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 5370 */ 5371 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 5372 reHasRegExpChar = RegExp(reRegExpChar.source); 5373 5374 /** Used to match leading whitespace. */ 5375 var reTrimStart = /^\s+/; 5376 5377 /** Used to match a single whitespace character. */ 5378 var reWhitespace = /\s/; 5379 5380 /** Used to match wrap detail comments. */ 5381 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 5382 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 5383 reSplitDetails = /,? & /; 5384 5385 /** Used to match words composed of alphanumeric characters. */ 5386 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 5387 5388 /** 5389 * Used to validate the `validate` option in `_.template` variable. 5390 * 5391 * Forbids characters which could potentially change the meaning of the function argument definition: 5392 * - "()," (modification of function parameters) 5393 * - "=" (default value) 5394 * - "[]{}" (destructuring of function parameters) 5395 * - "/" (beginning of a comment) 5396 * - whitespace 5397 */ 5398 var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; 5399 5400 /** Used to match backslashes in property paths. */ 5401 var reEscapeChar = /\\(\\)?/g; 5402 5403 /** 5404 * Used to match 5405 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 5406 */ 5407 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 5408 5409 /** Used to match `RegExp` flags from their coerced string values. */ 5410 var reFlags = /\w*$/; 5411 5412 /** Used to detect bad signed hexadecimal string values. */ 5413 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 5414 5415 /** Used to detect binary string values. */ 5416 var reIsBinary = /^0b[01]+$/i; 5417 5418 /** Used to detect host constructors (Safari). */ 5419 var reIsHostCtor = /^\[object .+?Constructor\]$/; 5420 5421 /** Used to detect octal string values. */ 5422 var reIsOctal = /^0o[0-7]+$/i; 5423 5424 /** Used to detect unsigned integer values. */ 5425 var reIsUint = /^(?:0|[1-9]\d*)$/; 5426 5427 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 5428 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 5429 5430 /** Used to ensure capturing order of template delimiters. */ 5431 var reNoMatch = /($^)/; 5432 5433 /** Used to match unescaped characters in compiled string literals. */ 5434 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 5435 5436 /** Used to compose unicode character classes. */ 5437 var rsAstralRange = '\\ud800-\\udfff', 5438 rsComboMarksRange = '\\u0300-\\u036f', 5439 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 5440 rsComboSymbolsRange = '\\u20d0-\\u20ff', 5441 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 5442 rsDingbatRange = '\\u2700-\\u27bf', 5443 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 5444 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 5445 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 5446 rsPunctuationRange = '\\u2000-\\u206f', 5447 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', 5448 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 5449 rsVarRange = '\\ufe0e\\ufe0f', 5450 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 5451 5452 /** Used to compose unicode capture groups. */ 5453 var rsApos = "['\u2019]", 5454 rsAstral = '[' + rsAstralRange + ']', 5455 rsBreak = '[' + rsBreakRange + ']', 5456 rsCombo = '[' + rsComboRange + ']', 5457 rsDigits = '\\d+', 5458 rsDingbat = '[' + rsDingbatRange + ']', 5459 rsLower = '[' + rsLowerRange + ']', 5460 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 5461 rsFitz = '\\ud83c[\\udffb-\\udfff]', 5462 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 5463 rsNonAstral = '[^' + rsAstralRange + ']', 5464 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 5465 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 5466 rsUpper = '[' + rsUpperRange + ']', 5467 rsZWJ = '\\u200d'; 5468 5469 /** Used to compose unicode regexes. */ 5470 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 5471 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 5472 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 5473 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 5474 reOptMod = rsModifier + '?', 5475 rsOptVar = '[' + rsVarRange + ']?', 5476 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 5477 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 5478 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 5479 rsSeq = rsOptVar + reOptMod + rsOptJoin, 5480 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 5481 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 5482 5483 /** Used to match apostrophes. */ 5484 var reApos = RegExp(rsApos, 'g'); 5485 5486 /** 5487 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 5488 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 5489 */ 5490 var reComboMark = RegExp(rsCombo, 'g'); 5491 5492 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 5493 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 5494 5495 /** Used to match complex or compound words. */ 5496 var reUnicodeWord = RegExp([ 5497 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 5498 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 5499 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 5500 rsUpper + '+' + rsOptContrUpper, 5501 rsOrdUpper, 5502 rsOrdLower, 5503 rsDigits, 5504 rsEmoji 5505 ].join('|'), 'g'); 5506 5507 /** 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/). */ 5508 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 5509 5510 /** Used to detect strings that need a more robust regexp to match words. */ 5511 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 ]/; 5512 5513 /** Used to assign default `context` object properties. */ 5514 var contextProps = [ 5515 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 5516 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 5517 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 5518 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 5519 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 5520 ]; 5521 5522 /** Used to make template sourceURLs easier to identify. */ 5523 var templateCounter = -1; 5524 5525 /** Used to identify `toStringTag` values of typed arrays. */ 5526 var typedArrayTags = {}; 5527 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 5528 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 5529 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 5530 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 5531 typedArrayTags[uint32Tag] = true; 5532 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 5533 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 5534 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 5535 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 5536 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 5537 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 5538 typedArrayTags[setTag] = typedArrayTags[stringTag] = 5539 typedArrayTags[weakMapTag] = false; 5540 5541 /** Used to identify `toStringTag` values supported by `_.clone`. */ 5542 var cloneableTags = {}; 5543 cloneableTags[argsTag] = cloneableTags[arrayTag] = 5544 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 5545 cloneableTags[boolTag] = cloneableTags[dateTag] = 5546 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 5547 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 5548 cloneableTags[int32Tag] = cloneableTags[mapTag] = 5549 cloneableTags[numberTag] = cloneableTags[objectTag] = 5550 cloneableTags[regexpTag] = cloneableTags[setTag] = 5551 cloneableTags[stringTag] = cloneableTags[symbolTag] = 5552 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 5553 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 5554 cloneableTags[errorTag] = cloneableTags[funcTag] = 5555 cloneableTags[weakMapTag] = false; 5556 5557 /** Used to map Latin Unicode letters to basic Latin letters. */ 5558 var deburredLetters = { 5559 // Latin-1 Supplement block. 5560 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 5561 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 5562 '\xc7': 'C', '\xe7': 'c', 5563 '\xd0': 'D', '\xf0': 'd', 5564 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 5565 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 5566 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 5567 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 5568 '\xd1': 'N', '\xf1': 'n', 5569 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 5570 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 5571 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 5572 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 5573 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 5574 '\xc6': 'Ae', '\xe6': 'ae', 5575 '\xde': 'Th', '\xfe': 'th', 5576 '\xdf': 'ss', 5577 // Latin Extended-A block. 5578 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 5579 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 5580 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 5581 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 5582 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 5583 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 5584 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 5585 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 5586 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 5587 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 5588 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 5589 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 5590 '\u0134': 'J', '\u0135': 'j', 5591 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 5592 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 5593 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 5594 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 5595 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 5596 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 5597 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 5598 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 5599 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 5600 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 5601 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 5602 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 5603 '\u0163': 't', '\u0165': 't', '\u0167': 't', 5604 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 5605 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 5606 '\u0174': 'W', '\u0175': 'w', 5607 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 5608 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 5609 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 5610 '\u0132': 'IJ', '\u0133': 'ij', 5611 '\u0152': 'Oe', '\u0153': 'oe', 5612 '\u0149': "'n", '\u017f': 's' 5613 }; 5614 5615 /** Used to map characters to HTML entities. */ 5616 var htmlEscapes = { 5617 '&': '&', 5618 '<': '<', 5619 '>': '>', 5620 '"': '"', 5621 "'": ''' 5622 }; 5623 5624 /** Used to map HTML entities to characters. */ 5625 var htmlUnescapes = { 5626 '&': '&', 5627 '<': '<', 5628 '>': '>', 5629 '"': '"', 5630 ''': "'" 5631 }; 5632 5633 /** Used to escape characters for inclusion in compiled string literals. */ 5634 var stringEscapes = { 5635 '\\': '\\', 5636 "'": "'", 5637 '\n': 'n', 5638 '\r': 'r', 5639 '\u2028': 'u2028', 5640 '\u2029': 'u2029' 5641 }; 5642 5643 /** Built-in method references without a dependency on `root`. */ 5644 var freeParseFloat = parseFloat, 5645 freeParseInt = parseInt; 5646 5647 /** Detect free variable `global` from Node.js. */ 5648 var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g; 5649 5650 /** Detect free variable `self`. */ 5651 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 5652 5653 /** Used as a reference to the global object. */ 5654 var root = freeGlobal || freeSelf || Function('return this')(); 5655 5656 /** Detect free variable `exports`. */ 5657 var freeExports = true && exports && !exports.nodeType && exports; 5658 5659 /** Detect free variable `module`. */ 5660 var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; 5661 5662 /** Detect the popular CommonJS extension `module.exports`. */ 5663 var moduleExports = freeModule && freeModule.exports === freeExports; 5664 5665 /** Detect free variable `process` from Node.js. */ 5666 var freeProcess = moduleExports && freeGlobal.process; 5667 5668 /** Used to access faster Node.js helpers. */ 5669 var nodeUtil = (function() { 5670 try { 5671 // Use `util.types` for Node.js 10+. 5672 var types = freeModule && freeModule.require && freeModule.require('util').types; 5673 5674 if (types) { 5675 return types; 5676 } 5677 5678 // Legacy `process.binding('util')` for Node.js < 10. 5679 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 5680 } catch (e) {} 5681 }()); 5682 5683 /* Node.js helper references. */ 5684 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 5685 nodeIsDate = nodeUtil && nodeUtil.isDate, 5686 nodeIsMap = nodeUtil && nodeUtil.isMap, 5687 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 5688 nodeIsSet = nodeUtil && nodeUtil.isSet, 5689 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 5690 5691 /*--------------------------------------------------------------------------*/ 5692 5693 /** 5694 * A faster alternative to `Function#apply`, this function invokes `func` 5695 * with the `this` binding of `thisArg` and the arguments of `args`. 5696 * 5697 * @private 5698 * @param {Function} func The function to invoke. 5699 * @param {*} thisArg The `this` binding of `func`. 5700 * @param {Array} args The arguments to invoke `func` with. 5701 * @returns {*} Returns the result of `func`. 5702 */ 5703 function apply(func, thisArg, args) { 5704 switch (args.length) { 5705 case 0: return func.call(thisArg); 5706 case 1: return func.call(thisArg, args[0]); 5707 case 2: return func.call(thisArg, args[0], args[1]); 5708 case 3: return func.call(thisArg, args[0], args[1], args[2]); 5709 } 5710 return func.apply(thisArg, args); 5711 } 5712 5713 /** 5714 * A specialized version of `baseAggregator` for arrays. 5715 * 5716 * @private 5717 * @param {Array} [array] The array to iterate over. 5718 * @param {Function} setter The function to set `accumulator` values. 5719 * @param {Function} iteratee The iteratee to transform keys. 5720 * @param {Object} accumulator The initial aggregated object. 5721 * @returns {Function} Returns `accumulator`. 5722 */ 5723 function arrayAggregator(array, setter, iteratee, accumulator) { 5724 var index = -1, 5725 length = array == null ? 0 : array.length; 5726 5727 while (++index < length) { 5728 var value = array[index]; 5729 setter(accumulator, value, iteratee(value), array); 5730 } 5731 return accumulator; 5732 } 5733 5734 /** 5735 * A specialized version of `_.forEach` for arrays without support for 5736 * iteratee shorthands. 5737 * 5738 * @private 5739 * @param {Array} [array] The array to iterate over. 5740 * @param {Function} iteratee The function invoked per iteration. 5741 * @returns {Array} Returns `array`. 5742 */ 5743 function arrayEach(array, iteratee) { 5744 var index = -1, 5745 length = array == null ? 0 : array.length; 5746 5747 while (++index < length) { 5748 if (iteratee(array[index], index, array) === false) { 5749 break; 5750 } 5751 } 5752 return array; 5753 } 5754 5755 /** 5756 * A specialized version of `_.forEachRight` for arrays without support for 5757 * iteratee shorthands. 5758 * 5759 * @private 5760 * @param {Array} [array] The array to iterate over. 5761 * @param {Function} iteratee The function invoked per iteration. 5762 * @returns {Array} Returns `array`. 5763 */ 5764 function arrayEachRight(array, iteratee) { 5765 var length = array == null ? 0 : array.length; 5766 5767 while (length--) { 5768 if (iteratee(array[length], length, array) === false) { 5769 break; 5770 } 5771 } 5772 return array; 5773 } 5774 5775 /** 5776 * A specialized version of `_.every` for arrays without support for 5777 * iteratee shorthands. 5778 * 5779 * @private 5780 * @param {Array} [array] The array to iterate over. 5781 * @param {Function} predicate The function invoked per iteration. 5782 * @returns {boolean} Returns `true` if all elements pass the predicate check, 5783 * else `false`. 5784 */ 5785 function arrayEvery(array, predicate) { 5786 var index = -1, 5787 length = array == null ? 0 : array.length; 5788 5789 while (++index < length) { 5790 if (!predicate(array[index], index, array)) { 5791 return false; 5792 } 5793 } 5794 return true; 5795 } 5796 5797 /** 5798 * A specialized version of `_.filter` for arrays without support for 5799 * iteratee shorthands. 5800 * 5801 * @private 5802 * @param {Array} [array] The array to iterate over. 5803 * @param {Function} predicate The function invoked per iteration. 5804 * @returns {Array} Returns the new filtered array. 5805 */ 5806 function arrayFilter(array, predicate) { 5807 var index = -1, 5808 length = array == null ? 0 : array.length, 5809 resIndex = 0, 5810 result = []; 5811 5812 while (++index < length) { 5813 var value = array[index]; 5814 if (predicate(value, index, array)) { 5815 result[resIndex++] = value; 5816 } 5817 } 5818 return result; 5819 } 5820 5821 /** 5822 * A specialized version of `_.includes` for arrays without support for 5823 * specifying an index to search from. 5824 * 5825 * @private 5826 * @param {Array} [array] The array to inspect. 5827 * @param {*} target The value to search for. 5828 * @returns {boolean} Returns `true` if `target` is found, else `false`. 5829 */ 5830 function arrayIncludes(array, value) { 5831 var length = array == null ? 0 : array.length; 5832 return !!length && baseIndexOf(array, value, 0) > -1; 5833 } 5834 5835 /** 5836 * This function is like `arrayIncludes` except that it accepts a comparator. 5837 * 5838 * @private 5839 * @param {Array} [array] The array to inspect. 5840 * @param {*} target The value to search for. 5841 * @param {Function} comparator The comparator invoked per element. 5842 * @returns {boolean} Returns `true` if `target` is found, else `false`. 5843 */ 5844 function arrayIncludesWith(array, value, comparator) { 5845 var index = -1, 5846 length = array == null ? 0 : array.length; 5847 5848 while (++index < length) { 5849 if (comparator(value, array[index])) { 5850 return true; 5851 } 5852 } 5853 return false; 5854 } 5855 5856 /** 5857 * A specialized version of `_.map` for arrays without support for iteratee 5858 * shorthands. 5859 * 5860 * @private 5861 * @param {Array} [array] The array to iterate over. 5862 * @param {Function} iteratee The function invoked per iteration. 5863 * @returns {Array} Returns the new mapped array. 5864 */ 5865 function arrayMap(array, iteratee) { 5866 var index = -1, 5867 length = array == null ? 0 : array.length, 5868 result = Array(length); 5869 5870 while (++index < length) { 5871 result[index] = iteratee(array[index], index, array); 5872 } 5873 return result; 5874 } 5875 5876 /** 5877 * Appends the elements of `values` to `array`. 5878 * 5879 * @private 5880 * @param {Array} array The array to modify. 5881 * @param {Array} values The values to append. 5882 * @returns {Array} Returns `array`. 5883 */ 5884 function arrayPush(array, values) { 5885 var index = -1, 5886 length = values.length, 5887 offset = array.length; 5888 5889 while (++index < length) { 5890 array[offset + index] = values[index]; 5891 } 5892 return array; 5893 } 5894 5895 /** 5896 * A specialized version of `_.reduce` for arrays without support for 5897 * iteratee shorthands. 5898 * 5899 * @private 5900 * @param {Array} [array] The array to iterate over. 5901 * @param {Function} iteratee The function invoked per iteration. 5902 * @param {*} [accumulator] The initial value. 5903 * @param {boolean} [initAccum] Specify using the first element of `array` as 5904 * the initial value. 5905 * @returns {*} Returns the accumulated value. 5906 */ 5907 function arrayReduce(array, iteratee, accumulator, initAccum) { 5908 var index = -1, 5909 length = array == null ? 0 : array.length; 5910 5911 if (initAccum && length) { 5912 accumulator = array[++index]; 5913 } 5914 while (++index < length) { 5915 accumulator = iteratee(accumulator, array[index], index, array); 5916 } 5917 return accumulator; 5918 } 5919 5920 /** 5921 * A specialized version of `_.reduceRight` for arrays without support for 5922 * iteratee shorthands. 5923 * 5924 * @private 5925 * @param {Array} [array] The array to iterate over. 5926 * @param {Function} iteratee The function invoked per iteration. 5927 * @param {*} [accumulator] The initial value. 5928 * @param {boolean} [initAccum] Specify using the last element of `array` as 5929 * the initial value. 5930 * @returns {*} Returns the accumulated value. 5931 */ 5932 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 5933 var length = array == null ? 0 : array.length; 5934 if (initAccum && length) { 5935 accumulator = array[--length]; 5936 } 5937 while (length--) { 5938 accumulator = iteratee(accumulator, array[length], length, array); 5939 } 5940 return accumulator; 5941 } 5942 5943 /** 5944 * A specialized version of `_.some` for arrays without support for iteratee 5945 * shorthands. 5946 * 5947 * @private 5948 * @param {Array} [array] The array to iterate over. 5949 * @param {Function} predicate The function invoked per iteration. 5950 * @returns {boolean} Returns `true` if any element passes the predicate check, 5951 * else `false`. 5952 */ 5953 function arraySome(array, predicate) { 5954 var index = -1, 5955 length = array == null ? 0 : array.length; 5956 5957 while (++index < length) { 5958 if (predicate(array[index], index, array)) { 5959 return true; 5960 } 5961 } 5962 return false; 5963 } 5964 5965 /** 5966 * Gets the size of an ASCII `string`. 5967 * 5968 * @private 5969 * @param {string} string The string inspect. 5970 * @returns {number} Returns the string size. 5971 */ 5972 var asciiSize = baseProperty('length'); 5973 5974 /** 5975 * Converts an ASCII `string` to an array. 5976 * 5977 * @private 5978 * @param {string} string The string to convert. 5979 * @returns {Array} Returns the converted array. 5980 */ 5981 function asciiToArray(string) { 5982 return string.split(''); 5983 } 5984 5985 /** 5986 * Splits an ASCII `string` into an array of its words. 5987 * 5988 * @private 5989 * @param {string} The string to inspect. 5990 * @returns {Array} Returns the words of `string`. 5991 */ 5992 function asciiWords(string) { 5993 return string.match(reAsciiWord) || []; 5994 } 5995 5996 /** 5997 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 5998 * without support for iteratee shorthands, which iterates over `collection` 5999 * using `eachFunc`. 6000 * 6001 * @private 6002 * @param {Array|Object} collection The collection to inspect. 6003 * @param {Function} predicate The function invoked per iteration. 6004 * @param {Function} eachFunc The function to iterate over `collection`. 6005 * @returns {*} Returns the found element or its key, else `undefined`. 6006 */ 6007 function baseFindKey(collection, predicate, eachFunc) { 6008 var result; 6009 eachFunc(collection, function(value, key, collection) { 6010 if (predicate(value, key, collection)) { 6011 result = key; 6012 return false; 6013 } 6014 }); 6015 return result; 6016 } 6017 6018 /** 6019 * The base implementation of `_.findIndex` and `_.findLastIndex` without 6020 * support for iteratee shorthands. 6021 * 6022 * @private 6023 * @param {Array} array The array to inspect. 6024 * @param {Function} predicate The function invoked per iteration. 6025 * @param {number} fromIndex The index to search from. 6026 * @param {boolean} [fromRight] Specify iterating from right to left. 6027 * @returns {number} Returns the index of the matched value, else `-1`. 6028 */ 6029 function baseFindIndex(array, predicate, fromIndex, fromRight) { 6030 var length = array.length, 6031 index = fromIndex + (fromRight ? 1 : -1); 6032 6033 while ((fromRight ? index-- : ++index < length)) { 6034 if (predicate(array[index], index, array)) { 6035 return index; 6036 } 6037 } 6038 return -1; 6039 } 6040 6041 /** 6042 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 6043 * 6044 * @private 6045 * @param {Array} array The array to inspect. 6046 * @param {*} value The value to search for. 6047 * @param {number} fromIndex The index to search from. 6048 * @returns {number} Returns the index of the matched value, else `-1`. 6049 */ 6050 function baseIndexOf(array, value, fromIndex) { 6051 return value === value 6052 ? strictIndexOf(array, value, fromIndex) 6053 : baseFindIndex(array, baseIsNaN, fromIndex); 6054 } 6055 6056 /** 6057 * This function is like `baseIndexOf` except that it accepts a comparator. 6058 * 6059 * @private 6060 * @param {Array} array The array to inspect. 6061 * @param {*} value The value to search for. 6062 * @param {number} fromIndex The index to search from. 6063 * @param {Function} comparator The comparator invoked per element. 6064 * @returns {number} Returns the index of the matched value, else `-1`. 6065 */ 6066 function baseIndexOfWith(array, value, fromIndex, comparator) { 6067 var index = fromIndex - 1, 6068 length = array.length; 6069 6070 while (++index < length) { 6071 if (comparator(array[index], value)) { 6072 return index; 6073 } 6074 } 6075 return -1; 6076 } 6077 6078 /** 6079 * The base implementation of `_.isNaN` without support for number objects. 6080 * 6081 * @private 6082 * @param {*} value The value to check. 6083 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 6084 */ 6085 function baseIsNaN(value) { 6086 return value !== value; 6087 } 6088 6089 /** 6090 * The base implementation of `_.mean` and `_.meanBy` without support for 6091 * iteratee shorthands. 6092 * 6093 * @private 6094 * @param {Array} array The array to iterate over. 6095 * @param {Function} iteratee The function invoked per iteration. 6096 * @returns {number} Returns the mean. 6097 */ 6098 function baseMean(array, iteratee) { 6099 var length = array == null ? 0 : array.length; 6100 return length ? (baseSum(array, iteratee) / length) : NAN; 6101 } 6102 6103 /** 6104 * The base implementation of `_.property` without support for deep paths. 6105 * 6106 * @private 6107 * @param {string} key The key of the property to get. 6108 * @returns {Function} Returns the new accessor function. 6109 */ 6110 function baseProperty(key) { 6111 return function(object) { 6112 return object == null ? undefined : object[key]; 6113 }; 6114 } 6115 6116 /** 6117 * The base implementation of `_.propertyOf` without support for deep paths. 6118 * 6119 * @private 6120 * @param {Object} object The object to query. 6121 * @returns {Function} Returns the new accessor function. 6122 */ 6123 function basePropertyOf(object) { 6124 return function(key) { 6125 return object == null ? undefined : object[key]; 6126 }; 6127 } 6128 6129 /** 6130 * The base implementation of `_.reduce` and `_.reduceRight`, without support 6131 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 6132 * 6133 * @private 6134 * @param {Array|Object} collection The collection to iterate over. 6135 * @param {Function} iteratee The function invoked per iteration. 6136 * @param {*} accumulator The initial value. 6137 * @param {boolean} initAccum Specify using the first or last element of 6138 * `collection` as the initial value. 6139 * @param {Function} eachFunc The function to iterate over `collection`. 6140 * @returns {*} Returns the accumulated value. 6141 */ 6142 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 6143 eachFunc(collection, function(value, index, collection) { 6144 accumulator = initAccum 6145 ? (initAccum = false, value) 6146 : iteratee(accumulator, value, index, collection); 6147 }); 6148 return accumulator; 6149 } 6150 6151 /** 6152 * The base implementation of `_.sortBy` which uses `comparer` to define the 6153 * sort order of `array` and replaces criteria objects with their corresponding 6154 * values. 6155 * 6156 * @private 6157 * @param {Array} array The array to sort. 6158 * @param {Function} comparer The function to define sort order. 6159 * @returns {Array} Returns `array`. 6160 */ 6161 function baseSortBy(array, comparer) { 6162 var length = array.length; 6163 6164 array.sort(comparer); 6165 while (length--) { 6166 array[length] = array[length].value; 6167 } 6168 return array; 6169 } 6170 6171 /** 6172 * The base implementation of `_.sum` and `_.sumBy` without support for 6173 * iteratee shorthands. 6174 * 6175 * @private 6176 * @param {Array} array The array to iterate over. 6177 * @param {Function} iteratee The function invoked per iteration. 6178 * @returns {number} Returns the sum. 6179 */ 6180 function baseSum(array, iteratee) { 6181 var result, 6182 index = -1, 6183 length = array.length; 6184 6185 while (++index < length) { 6186 var current = iteratee(array[index]); 6187 if (current !== undefined) { 6188 result = result === undefined ? current : (result + current); 6189 } 6190 } 6191 return result; 6192 } 6193 6194 /** 6195 * The base implementation of `_.times` without support for iteratee shorthands 6196 * or max array length checks. 6197 * 6198 * @private 6199 * @param {number} n The number of times to invoke `iteratee`. 6200 * @param {Function} iteratee The function invoked per iteration. 6201 * @returns {Array} Returns the array of results. 6202 */ 6203 function baseTimes(n, iteratee) { 6204 var index = -1, 6205 result = Array(n); 6206 6207 while (++index < n) { 6208 result[index] = iteratee(index); 6209 } 6210 return result; 6211 } 6212 6213 /** 6214 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 6215 * of key-value pairs for `object` corresponding to the property names of `props`. 6216 * 6217 * @private 6218 * @param {Object} object The object to query. 6219 * @param {Array} props The property names to get values for. 6220 * @returns {Object} Returns the key-value pairs. 6221 */ 6222 function baseToPairs(object, props) { 6223 return arrayMap(props, function(key) { 6224 return [key, object[key]]; 6225 }); 6226 } 6227 6228 /** 6229 * The base implementation of `_.trim`. 6230 * 6231 * @private 6232 * @param {string} string The string to trim. 6233 * @returns {string} Returns the trimmed string. 6234 */ 6235 function baseTrim(string) { 6236 return string 6237 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') 6238 : string; 6239 } 6240 6241 /** 6242 * The base implementation of `_.unary` without support for storing metadata. 6243 * 6244 * @private 6245 * @param {Function} func The function to cap arguments for. 6246 * @returns {Function} Returns the new capped function. 6247 */ 6248 function baseUnary(func) { 6249 return function(value) { 6250 return func(value); 6251 }; 6252 } 6253 6254 /** 6255 * The base implementation of `_.values` and `_.valuesIn` which creates an 6256 * array of `object` property values corresponding to the property names 6257 * of `props`. 6258 * 6259 * @private 6260 * @param {Object} object The object to query. 6261 * @param {Array} props The property names to get values for. 6262 * @returns {Object} Returns the array of property values. 6263 */ 6264 function baseValues(object, props) { 6265 return arrayMap(props, function(key) { 6266 return object[key]; 6267 }); 6268 } 6269 6270 /** 6271 * Checks if a `cache` value for `key` exists. 6272 * 6273 * @private 6274 * @param {Object} cache The cache to query. 6275 * @param {string} key The key of the entry to check. 6276 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 6277 */ 6278 function cacheHas(cache, key) { 6279 return cache.has(key); 6280 } 6281 6282 /** 6283 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 6284 * that is not found in the character symbols. 6285 * 6286 * @private 6287 * @param {Array} strSymbols The string symbols to inspect. 6288 * @param {Array} chrSymbols The character symbols to find. 6289 * @returns {number} Returns the index of the first unmatched string symbol. 6290 */ 6291 function charsStartIndex(strSymbols, chrSymbols) { 6292 var index = -1, 6293 length = strSymbols.length; 6294 6295 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 6296 return index; 6297 } 6298 6299 /** 6300 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 6301 * that is not found in the character symbols. 6302 * 6303 * @private 6304 * @param {Array} strSymbols The string symbols to inspect. 6305 * @param {Array} chrSymbols The character symbols to find. 6306 * @returns {number} Returns the index of the last unmatched string symbol. 6307 */ 6308 function charsEndIndex(strSymbols, chrSymbols) { 6309 var index = strSymbols.length; 6310 6311 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 6312 return index; 6313 } 6314 6315 /** 6316 * Gets the number of `placeholder` occurrences in `array`. 6317 * 6318 * @private 6319 * @param {Array} array The array to inspect. 6320 * @param {*} placeholder The placeholder to search for. 6321 * @returns {number} Returns the placeholder count. 6322 */ 6323 function countHolders(array, placeholder) { 6324 var length = array.length, 6325 result = 0; 6326 6327 while (length--) { 6328 if (array[length] === placeholder) { 6329 ++result; 6330 } 6331 } 6332 return result; 6333 } 6334 6335 /** 6336 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 6337 * letters to basic Latin letters. 6338 * 6339 * @private 6340 * @param {string} letter The matched letter to deburr. 6341 * @returns {string} Returns the deburred letter. 6342 */ 6343 var deburrLetter = basePropertyOf(deburredLetters); 6344 6345 /** 6346 * Used by `_.escape` to convert characters to HTML entities. 6347 * 6348 * @private 6349 * @param {string} chr The matched character to escape. 6350 * @returns {string} Returns the escaped character. 6351 */ 6352 var escapeHtmlChar = basePropertyOf(htmlEscapes); 6353 6354 /** 6355 * Used by `_.template` to escape characters for inclusion in compiled string literals. 6356 * 6357 * @private 6358 * @param {string} chr The matched character to escape. 6359 * @returns {string} Returns the escaped character. 6360 */ 6361 function escapeStringChar(chr) { 6362 return '\\' + stringEscapes[chr]; 6363 } 6364 6365 /** 6366 * Gets the value at `key` of `object`. 6367 * 6368 * @private 6369 * @param {Object} [object] The object to query. 6370 * @param {string} key The key of the property to get. 6371 * @returns {*} Returns the property value. 6372 */ 6373 function getValue(object, key) { 6374 return object == null ? undefined : object[key]; 6375 } 6376 6377 /** 6378 * Checks if `string` contains Unicode symbols. 6379 * 6380 * @private 6381 * @param {string} string The string to inspect. 6382 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 6383 */ 6384 function hasUnicode(string) { 6385 return reHasUnicode.test(string); 6386 } 6387 6388 /** 6389 * Checks if `string` contains a word composed of Unicode symbols. 6390 * 6391 * @private 6392 * @param {string} string The string to inspect. 6393 * @returns {boolean} Returns `true` if a word is found, else `false`. 6394 */ 6395 function hasUnicodeWord(string) { 6396 return reHasUnicodeWord.test(string); 6397 } 6398 6399 /** 6400 * Converts `iterator` to an array. 6401 * 6402 * @private 6403 * @param {Object} iterator The iterator to convert. 6404 * @returns {Array} Returns the converted array. 6405 */ 6406 function iteratorToArray(iterator) { 6407 var data, 6408 result = []; 6409 6410 while (!(data = iterator.next()).done) { 6411 result.push(data.value); 6412 } 6413 return result; 6414 } 6415 6416 /** 6417 * Converts `map` to its key-value pairs. 6418 * 6419 * @private 6420 * @param {Object} map The map to convert. 6421 * @returns {Array} Returns the key-value pairs. 6422 */ 6423 function mapToArray(map) { 6424 var index = -1, 6425 result = Array(map.size); 6426 6427 map.forEach(function(value, key) { 6428 result[++index] = [key, value]; 6429 }); 6430 return result; 6431 } 6432 6433 /** 6434 * Creates a unary function that invokes `func` with its argument transformed. 6435 * 6436 * @private 6437 * @param {Function} func The function to wrap. 6438 * @param {Function} transform The argument transform. 6439 * @returns {Function} Returns the new function. 6440 */ 6441 function overArg(func, transform) { 6442 return function(arg) { 6443 return func(transform(arg)); 6444 }; 6445 } 6446 6447 /** 6448 * Replaces all `placeholder` elements in `array` with an internal placeholder 6449 * and returns an array of their indexes. 6450 * 6451 * @private 6452 * @param {Array} array The array to modify. 6453 * @param {*} placeholder The placeholder to replace. 6454 * @returns {Array} Returns the new array of placeholder indexes. 6455 */ 6456 function replaceHolders(array, placeholder) { 6457 var index = -1, 6458 length = array.length, 6459 resIndex = 0, 6460 result = []; 6461 6462 while (++index < length) { 6463 var value = array[index]; 6464 if (value === placeholder || value === PLACEHOLDER) { 6465 array[index] = PLACEHOLDER; 6466 result[resIndex++] = index; 6467 } 6468 } 6469 return result; 6470 } 6471 6472 /** 6473 * Converts `set` to an array of its values. 6474 * 6475 * @private 6476 * @param {Object} set The set to convert. 6477 * @returns {Array} Returns the values. 6478 */ 6479 function setToArray(set) { 6480 var index = -1, 6481 result = Array(set.size); 6482 6483 set.forEach(function(value) { 6484 result[++index] = value; 6485 }); 6486 return result; 6487 } 6488 6489 /** 6490 * Converts `set` to its value-value pairs. 6491 * 6492 * @private 6493 * @param {Object} set The set to convert. 6494 * @returns {Array} Returns the value-value pairs. 6495 */ 6496 function setToPairs(set) { 6497 var index = -1, 6498 result = Array(set.size); 6499 6500 set.forEach(function(value) { 6501 result[++index] = [value, value]; 6502 }); 6503 return result; 6504 } 6505 6506 /** 6507 * A specialized version of `_.indexOf` which performs strict equality 6508 * comparisons of values, i.e. `===`. 6509 * 6510 * @private 6511 * @param {Array} array The array to inspect. 6512 * @param {*} value The value to search for. 6513 * @param {number} fromIndex The index to search from. 6514 * @returns {number} Returns the index of the matched value, else `-1`. 6515 */ 6516 function strictIndexOf(array, value, fromIndex) { 6517 var index = fromIndex - 1, 6518 length = array.length; 6519 6520 while (++index < length) { 6521 if (array[index] === value) { 6522 return index; 6523 } 6524 } 6525 return -1; 6526 } 6527 6528 /** 6529 * A specialized version of `_.lastIndexOf` which performs strict equality 6530 * comparisons of values, i.e. `===`. 6531 * 6532 * @private 6533 * @param {Array} array The array to inspect. 6534 * @param {*} value The value to search for. 6535 * @param {number} fromIndex The index to search from. 6536 * @returns {number} Returns the index of the matched value, else `-1`. 6537 */ 6538 function strictLastIndexOf(array, value, fromIndex) { 6539 var index = fromIndex + 1; 6540 while (index--) { 6541 if (array[index] === value) { 6542 return index; 6543 } 6544 } 6545 return index; 6546 } 6547 6548 /** 6549 * Gets the number of symbols in `string`. 6550 * 6551 * @private 6552 * @param {string} string The string to inspect. 6553 * @returns {number} Returns the string size. 6554 */ 6555 function stringSize(string) { 6556 return hasUnicode(string) 6557 ? unicodeSize(string) 6558 : asciiSize(string); 6559 } 6560 6561 /** 6562 * Converts `string` to an array. 6563 * 6564 * @private 6565 * @param {string} string The string to convert. 6566 * @returns {Array} Returns the converted array. 6567 */ 6568 function stringToArray(string) { 6569 return hasUnicode(string) 6570 ? unicodeToArray(string) 6571 : asciiToArray(string); 6572 } 6573 6574 /** 6575 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 6576 * character of `string`. 6577 * 6578 * @private 6579 * @param {string} string The string to inspect. 6580 * @returns {number} Returns the index of the last non-whitespace character. 6581 */ 6582 function trimmedEndIndex(string) { 6583 var index = string.length; 6584 6585 while (index-- && reWhitespace.test(string.charAt(index))) {} 6586 return index; 6587 } 6588 6589 /** 6590 * Used by `_.unescape` to convert HTML entities to characters. 6591 * 6592 * @private 6593 * @param {string} chr The matched character to unescape. 6594 * @returns {string} Returns the unescaped character. 6595 */ 6596 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 6597 6598 /** 6599 * Gets the size of a Unicode `string`. 6600 * 6601 * @private 6602 * @param {string} string The string inspect. 6603 * @returns {number} Returns the string size. 6604 */ 6605 function unicodeSize(string) { 6606 var result = reUnicode.lastIndex = 0; 6607 while (reUnicode.test(string)) { 6608 ++result; 6609 } 6610 return result; 6611 } 6612 6613 /** 6614 * Converts a Unicode `string` to an array. 6615 * 6616 * @private 6617 * @param {string} string The string to convert. 6618 * @returns {Array} Returns the converted array. 6619 */ 6620 function unicodeToArray(string) { 6621 return string.match(reUnicode) || []; 6622 } 6623 6624 /** 6625 * Splits a Unicode `string` into an array of its words. 6626 * 6627 * @private 6628 * @param {string} The string to inspect. 6629 * @returns {Array} Returns the words of `string`. 6630 */ 6631 function unicodeWords(string) { 6632 return string.match(reUnicodeWord) || []; 6633 } 6634 6635 /*--------------------------------------------------------------------------*/ 6636 6637 /** 6638 * Create a new pristine `lodash` function using the `context` object. 6639 * 6640 * @static 6641 * @memberOf _ 6642 * @since 1.1.0 6643 * @category Util 6644 * @param {Object} [context=root] The context object. 6645 * @returns {Function} Returns a new `lodash` function. 6646 * @example 6647 * 6648 * _.mixin({ 'foo': _.constant('foo') }); 6649 * 6650 * var lodash = _.runInContext(); 6651 * lodash.mixin({ 'bar': lodash.constant('bar') }); 6652 * 6653 * _.isFunction(_.foo); 6654 * // => true 6655 * _.isFunction(_.bar); 6656 * // => false 6657 * 6658 * lodash.isFunction(lodash.foo); 6659 * // => false 6660 * lodash.isFunction(lodash.bar); 6661 * // => true 6662 * 6663 * // Create a suped-up `defer` in Node.js. 6664 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 6665 */ 6666 var runInContext = (function runInContext(context) { 6667 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 6668 6669 /** Built-in constructor references. */ 6670 var Array = context.Array, 6671 Date = context.Date, 6672 Error = context.Error, 6673 Function = context.Function, 6674 Math = context.Math, 6675 Object = context.Object, 6676 RegExp = context.RegExp, 6677 String = context.String, 6678 TypeError = context.TypeError; 6679 6680 /** Used for built-in method references. */ 6681 var arrayProto = Array.prototype, 6682 funcProto = Function.prototype, 6683 objectProto = Object.prototype; 6684 6685 /** Used to detect overreaching core-js shims. */ 6686 var coreJsData = context['__core-js_shared__']; 6687 6688 /** Used to resolve the decompiled source of functions. */ 6689 var funcToString = funcProto.toString; 6690 6691 /** Used to check objects for own properties. */ 6692 var hasOwnProperty = objectProto.hasOwnProperty; 6693 6694 /** Used to generate unique IDs. */ 6695 var idCounter = 0; 6696 6697 /** Used to detect methods masquerading as native. */ 6698 var maskSrcKey = (function() { 6699 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 6700 return uid ? ('Symbol(src)_1.' + uid) : ''; 6701 }()); 6702 6703 /** 6704 * Used to resolve the 6705 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 6706 * of values. 6707 */ 6708 var nativeObjectToString = objectProto.toString; 6709 6710 /** Used to infer the `Object` constructor. */ 6711 var objectCtorString = funcToString.call(Object); 6712 6713 /** Used to restore the original `_` reference in `_.noConflict`. */ 6714 var oldDash = root._; 6715 6716 /** Used to detect if a method is native. */ 6717 var reIsNative = RegExp('^' + 6718 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 6719 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 6720 ); 6721 6722 /** Built-in value references. */ 6723 var Buffer = moduleExports ? context.Buffer : undefined, 6724 Symbol = context.Symbol, 6725 Uint8Array = context.Uint8Array, 6726 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 6727 getPrototype = overArg(Object.getPrototypeOf, Object), 6728 objectCreate = Object.create, 6729 propertyIsEnumerable = objectProto.propertyIsEnumerable, 6730 splice = arrayProto.splice, 6731 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 6732 symIterator = Symbol ? Symbol.iterator : undefined, 6733 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 6734 6735 var defineProperty = (function() { 6736 try { 6737 var func = getNative(Object, 'defineProperty'); 6738 func({}, '', {}); 6739 return func; 6740 } catch (e) {} 6741 }()); 6742 6743 /** Mocked built-ins. */ 6744 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 6745 ctxNow = Date && Date.now !== root.Date.now && Date.now, 6746 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 6747 6748 /* Built-in method references for those with the same name as other `lodash` methods. */ 6749 var nativeCeil = Math.ceil, 6750 nativeFloor = Math.floor, 6751 nativeGetSymbols = Object.getOwnPropertySymbols, 6752 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 6753 nativeIsFinite = context.isFinite, 6754 nativeJoin = arrayProto.join, 6755 nativeKeys = overArg(Object.keys, Object), 6756 nativeMax = Math.max, 6757 nativeMin = Math.min, 6758 nativeNow = Date.now, 6759 nativeParseInt = context.parseInt, 6760 nativeRandom = Math.random, 6761 nativeReverse = arrayProto.reverse; 6762 6763 /* Built-in method references that are verified to be native. */ 6764 var DataView = getNative(context, 'DataView'), 6765 Map = getNative(context, 'Map'), 6766 Promise = getNative(context, 'Promise'), 6767 Set = getNative(context, 'Set'), 6768 WeakMap = getNative(context, 'WeakMap'), 6769 nativeCreate = getNative(Object, 'create'); 6770 6771 /** Used to store function metadata. */ 6772 var metaMap = WeakMap && new WeakMap; 6773 6774 /** Used to lookup unminified function names. */ 6775 var realNames = {}; 6776 6777 /** Used to detect maps, sets, and weakmaps. */ 6778 var dataViewCtorString = toSource(DataView), 6779 mapCtorString = toSource(Map), 6780 promiseCtorString = toSource(Promise), 6781 setCtorString = toSource(Set), 6782 weakMapCtorString = toSource(WeakMap); 6783 6784 /** Used to convert symbols to primitives and strings. */ 6785 var symbolProto = Symbol ? Symbol.prototype : undefined, 6786 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 6787 symbolToString = symbolProto ? symbolProto.toString : undefined; 6788 6789 /*------------------------------------------------------------------------*/ 6790 6791 /** 6792 * Creates a `lodash` object which wraps `value` to enable implicit method 6793 * chain sequences. Methods that operate on and return arrays, collections, 6794 * and functions can be chained together. Methods that retrieve a single value 6795 * or may return a primitive value will automatically end the chain sequence 6796 * and return the unwrapped value. Otherwise, the value must be unwrapped 6797 * with `_#value`. 6798 * 6799 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 6800 * enabled using `_.chain`. 6801 * 6802 * The execution of chained methods is lazy, that is, it's deferred until 6803 * `_#value` is implicitly or explicitly called. 6804 * 6805 * Lazy evaluation allows several methods to support shortcut fusion. 6806 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 6807 * the creation of intermediate arrays and can greatly reduce the number of 6808 * iteratee executions. Sections of a chain sequence qualify for shortcut 6809 * fusion if the section is applied to an array and iteratees accept only 6810 * one argument. The heuristic for whether a section qualifies for shortcut 6811 * fusion is subject to change. 6812 * 6813 * Chaining is supported in custom builds as long as the `_#value` method is 6814 * directly or indirectly included in the build. 6815 * 6816 * In addition to lodash methods, wrappers have `Array` and `String` methods. 6817 * 6818 * The wrapper `Array` methods are: 6819 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 6820 * 6821 * The wrapper `String` methods are: 6822 * `replace` and `split` 6823 * 6824 * The wrapper methods that support shortcut fusion are: 6825 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 6826 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 6827 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 6828 * 6829 * The chainable wrapper methods are: 6830 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 6831 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 6832 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 6833 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 6834 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 6835 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 6836 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 6837 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 6838 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 6839 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 6840 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 6841 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 6842 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 6843 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 6844 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 6845 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 6846 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 6847 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 6848 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 6849 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 6850 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 6851 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 6852 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 6853 * `zipObject`, `zipObjectDeep`, and `zipWith` 6854 * 6855 * The wrapper methods that are **not** chainable by default are: 6856 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 6857 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 6858 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 6859 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 6860 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 6861 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 6862 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 6863 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 6864 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 6865 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 6866 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 6867 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 6868 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 6869 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 6870 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 6871 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 6872 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 6873 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 6874 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 6875 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 6876 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 6877 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 6878 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 6879 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 6880 * `upperFirst`, `value`, and `words` 6881 * 6882 * @name _ 6883 * @constructor 6884 * @category Seq 6885 * @param {*} value The value to wrap in a `lodash` instance. 6886 * @returns {Object} Returns the new `lodash` wrapper instance. 6887 * @example 6888 * 6889 * function square(n) { 6890 * return n * n; 6891 * } 6892 * 6893 * var wrapped = _([1, 2, 3]); 6894 * 6895 * // Returns an unwrapped value. 6896 * wrapped.reduce(_.add); 6897 * // => 6 6898 * 6899 * // Returns a wrapped value. 6900 * var squares = wrapped.map(square); 6901 * 6902 * _.isArray(squares); 6903 * // => false 6904 * 6905 * _.isArray(squares.value()); 6906 * // => true 6907 */ 6908 function lodash(value) { 6909 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 6910 if (value instanceof LodashWrapper) { 6911 return value; 6912 } 6913 if (hasOwnProperty.call(value, '__wrapped__')) { 6914 return wrapperClone(value); 6915 } 6916 } 6917 return new LodashWrapper(value); 6918 } 6919 6920 /** 6921 * The base implementation of `_.create` without support for assigning 6922 * properties to the created object. 6923 * 6924 * @private 6925 * @param {Object} proto The object to inherit from. 6926 * @returns {Object} Returns the new object. 6927 */ 6928 var baseCreate = (function() { 6929 function object() {} 6930 return function(proto) { 6931 if (!isObject(proto)) { 6932 return {}; 6933 } 6934 if (objectCreate) { 6935 return objectCreate(proto); 6936 } 6937 object.prototype = proto; 6938 var result = new object; 6939 object.prototype = undefined; 6940 return result; 6941 }; 6942 }()); 6943 6944 /** 6945 * The function whose prototype chain sequence wrappers inherit from. 6946 * 6947 * @private 6948 */ 6949 function baseLodash() { 6950 // No operation performed. 6951 } 6952 6953 /** 6954 * The base constructor for creating `lodash` wrapper objects. 6955 * 6956 * @private 6957 * @param {*} value The value to wrap. 6958 * @param {boolean} [chainAll] Enable explicit method chain sequences. 6959 */ 6960 function LodashWrapper(value, chainAll) { 6961 this.__wrapped__ = value; 6962 this.__actions__ = []; 6963 this.__chain__ = !!chainAll; 6964 this.__index__ = 0; 6965 this.__values__ = undefined; 6966 } 6967 6968 /** 6969 * By default, the template delimiters used by lodash are like those in 6970 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 6971 * following template settings to use alternative delimiters. 6972 * 6973 * @static 6974 * @memberOf _ 6975 * @type {Object} 6976 */ 6977 lodash.templateSettings = { 6978 6979 /** 6980 * Used to detect `data` property values to be HTML-escaped. 6981 * 6982 * @memberOf _.templateSettings 6983 * @type {RegExp} 6984 */ 6985 'escape': reEscape, 6986 6987 /** 6988 * Used to detect code to be evaluated. 6989 * 6990 * @memberOf _.templateSettings 6991 * @type {RegExp} 6992 */ 6993 'evaluate': reEvaluate, 6994 6995 /** 6996 * Used to detect `data` property values to inject. 6997 * 6998 * @memberOf _.templateSettings 6999 * @type {RegExp} 7000 */ 7001 'interpolate': reInterpolate, 7002 7003 /** 7004 * Used to reference the data object in the template text. 7005 * 7006 * @memberOf _.templateSettings 7007 * @type {string} 7008 */ 7009 'variable': '', 7010 7011 /** 7012 * Used to import variables into the compiled template. 7013 * 7014 * @memberOf _.templateSettings 7015 * @type {Object} 7016 */ 7017 'imports': { 7018 7019 /** 7020 * A reference to the `lodash` function. 7021 * 7022 * @memberOf _.templateSettings.imports 7023 * @type {Function} 7024 */ 7025 '_': lodash 7026 } 7027 }; 7028 7029 // Ensure wrappers are instances of `baseLodash`. 7030 lodash.prototype = baseLodash.prototype; 7031 lodash.prototype.constructor = lodash; 7032 7033 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 7034 LodashWrapper.prototype.constructor = LodashWrapper; 7035 7036 /*------------------------------------------------------------------------*/ 7037 7038 /** 7039 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 7040 * 7041 * @private 7042 * @constructor 7043 * @param {*} value The value to wrap. 7044 */ 7045 function LazyWrapper(value) { 7046 this.__wrapped__ = value; 7047 this.__actions__ = []; 7048 this.__dir__ = 1; 7049 this.__filtered__ = false; 7050 this.__iteratees__ = []; 7051 this.__takeCount__ = MAX_ARRAY_LENGTH; 7052 this.__views__ = []; 7053 } 7054 7055 /** 7056 * Creates a clone of the lazy wrapper object. 7057 * 7058 * @private 7059 * @name clone 7060 * @memberOf LazyWrapper 7061 * @returns {Object} Returns the cloned `LazyWrapper` object. 7062 */ 7063 function lazyClone() { 7064 var result = new LazyWrapper(this.__wrapped__); 7065 result.__actions__ = copyArray(this.__actions__); 7066 result.__dir__ = this.__dir__; 7067 result.__filtered__ = this.__filtered__; 7068 result.__iteratees__ = copyArray(this.__iteratees__); 7069 result.__takeCount__ = this.__takeCount__; 7070 result.__views__ = copyArray(this.__views__); 7071 return result; 7072 } 7073 7074 /** 7075 * Reverses the direction of lazy iteration. 7076 * 7077 * @private 7078 * @name reverse 7079 * @memberOf LazyWrapper 7080 * @returns {Object} Returns the new reversed `LazyWrapper` object. 7081 */ 7082 function lazyReverse() { 7083 if (this.__filtered__) { 7084 var result = new LazyWrapper(this); 7085 result.__dir__ = -1; 7086 result.__filtered__ = true; 7087 } else { 7088 result = this.clone(); 7089 result.__dir__ *= -1; 7090 } 7091 return result; 7092 } 7093 7094 /** 7095 * Extracts the unwrapped value from its lazy wrapper. 7096 * 7097 * @private 7098 * @name value 7099 * @memberOf LazyWrapper 7100 * @returns {*} Returns the unwrapped value. 7101 */ 7102 function lazyValue() { 7103 var array = this.__wrapped__.value(), 7104 dir = this.__dir__, 7105 isArr = isArray(array), 7106 isRight = dir < 0, 7107 arrLength = isArr ? array.length : 0, 7108 view = getView(0, arrLength, this.__views__), 7109 start = view.start, 7110 end = view.end, 7111 length = end - start, 7112 index = isRight ? end : (start - 1), 7113 iteratees = this.__iteratees__, 7114 iterLength = iteratees.length, 7115 resIndex = 0, 7116 takeCount = nativeMin(length, this.__takeCount__); 7117 7118 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 7119 return baseWrapperValue(array, this.__actions__); 7120 } 7121 var result = []; 7122 7123 outer: 7124 while (length-- && resIndex < takeCount) { 7125 index += dir; 7126 7127 var iterIndex = -1, 7128 value = array[index]; 7129 7130 while (++iterIndex < iterLength) { 7131 var data = iteratees[iterIndex], 7132 iteratee = data.iteratee, 7133 type = data.type, 7134 computed = iteratee(value); 7135 7136 if (type == LAZY_MAP_FLAG) { 7137 value = computed; 7138 } else if (!computed) { 7139 if (type == LAZY_FILTER_FLAG) { 7140 continue outer; 7141 } else { 7142 break outer; 7143 } 7144 } 7145 } 7146 result[resIndex++] = value; 7147 } 7148 return result; 7149 } 7150 7151 // Ensure `LazyWrapper` is an instance of `baseLodash`. 7152 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 7153 LazyWrapper.prototype.constructor = LazyWrapper; 7154 7155 /*------------------------------------------------------------------------*/ 7156 7157 /** 7158 * Creates a hash object. 7159 * 7160 * @private 7161 * @constructor 7162 * @param {Array} [entries] The key-value pairs to cache. 7163 */ 7164 function Hash(entries) { 7165 var index = -1, 7166 length = entries == null ? 0 : entries.length; 7167 7168 this.clear(); 7169 while (++index < length) { 7170 var entry = entries[index]; 7171 this.set(entry[0], entry[1]); 7172 } 7173 } 7174 7175 /** 7176 * Removes all key-value entries from the hash. 7177 * 7178 * @private 7179 * @name clear 7180 * @memberOf Hash 7181 */ 7182 function hashClear() { 7183 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 7184 this.size = 0; 7185 } 7186 7187 /** 7188 * Removes `key` and its value from the hash. 7189 * 7190 * @private 7191 * @name delete 7192 * @memberOf Hash 7193 * @param {Object} hash The hash to modify. 7194 * @param {string} key The key of the value to remove. 7195 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7196 */ 7197 function hashDelete(key) { 7198 var result = this.has(key) && delete this.__data__[key]; 7199 this.size -= result ? 1 : 0; 7200 return result; 7201 } 7202 7203 /** 7204 * Gets the hash value for `key`. 7205 * 7206 * @private 7207 * @name get 7208 * @memberOf Hash 7209 * @param {string} key The key of the value to get. 7210 * @returns {*} Returns the entry value. 7211 */ 7212 function hashGet(key) { 7213 var data = this.__data__; 7214 if (nativeCreate) { 7215 var result = data[key]; 7216 return result === HASH_UNDEFINED ? undefined : result; 7217 } 7218 return hasOwnProperty.call(data, key) ? data[key] : undefined; 7219 } 7220 7221 /** 7222 * Checks if a hash value for `key` exists. 7223 * 7224 * @private 7225 * @name has 7226 * @memberOf Hash 7227 * @param {string} key The key of the entry to check. 7228 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7229 */ 7230 function hashHas(key) { 7231 var data = this.__data__; 7232 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 7233 } 7234 7235 /** 7236 * Sets the hash `key` to `value`. 7237 * 7238 * @private 7239 * @name set 7240 * @memberOf Hash 7241 * @param {string} key The key of the value to set. 7242 * @param {*} value The value to set. 7243 * @returns {Object} Returns the hash instance. 7244 */ 7245 function hashSet(key, value) { 7246 var data = this.__data__; 7247 this.size += this.has(key) ? 0 : 1; 7248 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 7249 return this; 7250 } 7251 7252 // Add methods to `Hash`. 7253 Hash.prototype.clear = hashClear; 7254 Hash.prototype['delete'] = hashDelete; 7255 Hash.prototype.get = hashGet; 7256 Hash.prototype.has = hashHas; 7257 Hash.prototype.set = hashSet; 7258 7259 /*------------------------------------------------------------------------*/ 7260 7261 /** 7262 * Creates an list cache object. 7263 * 7264 * @private 7265 * @constructor 7266 * @param {Array} [entries] The key-value pairs to cache. 7267 */ 7268 function ListCache(entries) { 7269 var index = -1, 7270 length = entries == null ? 0 : entries.length; 7271 7272 this.clear(); 7273 while (++index < length) { 7274 var entry = entries[index]; 7275 this.set(entry[0], entry[1]); 7276 } 7277 } 7278 7279 /** 7280 * Removes all key-value entries from the list cache. 7281 * 7282 * @private 7283 * @name clear 7284 * @memberOf ListCache 7285 */ 7286 function listCacheClear() { 7287 this.__data__ = []; 7288 this.size = 0; 7289 } 7290 7291 /** 7292 * Removes `key` and its value from the list cache. 7293 * 7294 * @private 7295 * @name delete 7296 * @memberOf ListCache 7297 * @param {string} key The key of the value to remove. 7298 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7299 */ 7300 function listCacheDelete(key) { 7301 var data = this.__data__, 7302 index = assocIndexOf(data, key); 7303 7304 if (index < 0) { 7305 return false; 7306 } 7307 var lastIndex = data.length - 1; 7308 if (index == lastIndex) { 7309 data.pop(); 7310 } else { 7311 splice.call(data, index, 1); 7312 } 7313 --this.size; 7314 return true; 7315 } 7316 7317 /** 7318 * Gets the list cache value for `key`. 7319 * 7320 * @private 7321 * @name get 7322 * @memberOf ListCache 7323 * @param {string} key The key of the value to get. 7324 * @returns {*} Returns the entry value. 7325 */ 7326 function listCacheGet(key) { 7327 var data = this.__data__, 7328 index = assocIndexOf(data, key); 7329 7330 return index < 0 ? undefined : data[index][1]; 7331 } 7332 7333 /** 7334 * Checks if a list cache value for `key` exists. 7335 * 7336 * @private 7337 * @name has 7338 * @memberOf ListCache 7339 * @param {string} key The key of the entry to check. 7340 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7341 */ 7342 function listCacheHas(key) { 7343 return assocIndexOf(this.__data__, key) > -1; 7344 } 7345 7346 /** 7347 * Sets the list cache `key` to `value`. 7348 * 7349 * @private 7350 * @name set 7351 * @memberOf ListCache 7352 * @param {string} key The key of the value to set. 7353 * @param {*} value The value to set. 7354 * @returns {Object} Returns the list cache instance. 7355 */ 7356 function listCacheSet(key, value) { 7357 var data = this.__data__, 7358 index = assocIndexOf(data, key); 7359 7360 if (index < 0) { 7361 ++this.size; 7362 data.push([key, value]); 7363 } else { 7364 data[index][1] = value; 7365 } 7366 return this; 7367 } 7368 7369 // Add methods to `ListCache`. 7370 ListCache.prototype.clear = listCacheClear; 7371 ListCache.prototype['delete'] = listCacheDelete; 7372 ListCache.prototype.get = listCacheGet; 7373 ListCache.prototype.has = listCacheHas; 7374 ListCache.prototype.set = listCacheSet; 7375 7376 /*------------------------------------------------------------------------*/ 7377 7378 /** 7379 * Creates a map cache object to store key-value pairs. 7380 * 7381 * @private 7382 * @constructor 7383 * @param {Array} [entries] The key-value pairs to cache. 7384 */ 7385 function MapCache(entries) { 7386 var index = -1, 7387 length = entries == null ? 0 : entries.length; 7388 7389 this.clear(); 7390 while (++index < length) { 7391 var entry = entries[index]; 7392 this.set(entry[0], entry[1]); 7393 } 7394 } 7395 7396 /** 7397 * Removes all key-value entries from the map. 7398 * 7399 * @private 7400 * @name clear 7401 * @memberOf MapCache 7402 */ 7403 function mapCacheClear() { 7404 this.size = 0; 7405 this.__data__ = { 7406 'hash': new Hash, 7407 'map': new (Map || ListCache), 7408 'string': new Hash 7409 }; 7410 } 7411 7412 /** 7413 * Removes `key` and its value from the map. 7414 * 7415 * @private 7416 * @name delete 7417 * @memberOf MapCache 7418 * @param {string} key The key of the value to remove. 7419 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7420 */ 7421 function mapCacheDelete(key) { 7422 var result = getMapData(this, key)['delete'](key); 7423 this.size -= result ? 1 : 0; 7424 return result; 7425 } 7426 7427 /** 7428 * Gets the map value for `key`. 7429 * 7430 * @private 7431 * @name get 7432 * @memberOf MapCache 7433 * @param {string} key The key of the value to get. 7434 * @returns {*} Returns the entry value. 7435 */ 7436 function mapCacheGet(key) { 7437 return getMapData(this, key).get(key); 7438 } 7439 7440 /** 7441 * Checks if a map value for `key` exists. 7442 * 7443 * @private 7444 * @name has 7445 * @memberOf MapCache 7446 * @param {string} key The key of the entry to check. 7447 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7448 */ 7449 function mapCacheHas(key) { 7450 return getMapData(this, key).has(key); 7451 } 7452 7453 /** 7454 * Sets the map `key` to `value`. 7455 * 7456 * @private 7457 * @name set 7458 * @memberOf MapCache 7459 * @param {string} key The key of the value to set. 7460 * @param {*} value The value to set. 7461 * @returns {Object} Returns the map cache instance. 7462 */ 7463 function mapCacheSet(key, value) { 7464 var data = getMapData(this, key), 7465 size = data.size; 7466 7467 data.set(key, value); 7468 this.size += data.size == size ? 0 : 1; 7469 return this; 7470 } 7471 7472 // Add methods to `MapCache`. 7473 MapCache.prototype.clear = mapCacheClear; 7474 MapCache.prototype['delete'] = mapCacheDelete; 7475 MapCache.prototype.get = mapCacheGet; 7476 MapCache.prototype.has = mapCacheHas; 7477 MapCache.prototype.set = mapCacheSet; 7478 7479 /*------------------------------------------------------------------------*/ 7480 7481 /** 7482 * 7483 * Creates an array cache object to store unique values. 7484 * 7485 * @private 7486 * @constructor 7487 * @param {Array} [values] The values to cache. 7488 */ 7489 function SetCache(values) { 7490 var index = -1, 7491 length = values == null ? 0 : values.length; 7492 7493 this.__data__ = new MapCache; 7494 while (++index < length) { 7495 this.add(values[index]); 7496 } 7497 } 7498 7499 /** 7500 * Adds `value` to the array cache. 7501 * 7502 * @private 7503 * @name add 7504 * @memberOf SetCache 7505 * @alias push 7506 * @param {*} value The value to cache. 7507 * @returns {Object} Returns the cache instance. 7508 */ 7509 function setCacheAdd(value) { 7510 this.__data__.set(value, HASH_UNDEFINED); 7511 return this; 7512 } 7513 7514 /** 7515 * Checks if `value` is in the array cache. 7516 * 7517 * @private 7518 * @name has 7519 * @memberOf SetCache 7520 * @param {*} value The value to search for. 7521 * @returns {number} Returns `true` if `value` is found, else `false`. 7522 */ 7523 function setCacheHas(value) { 7524 return this.__data__.has(value); 7525 } 7526 7527 // Add methods to `SetCache`. 7528 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 7529 SetCache.prototype.has = setCacheHas; 7530 7531 /*------------------------------------------------------------------------*/ 7532 7533 /** 7534 * Creates a stack cache object to store key-value pairs. 7535 * 7536 * @private 7537 * @constructor 7538 * @param {Array} [entries] The key-value pairs to cache. 7539 */ 7540 function Stack(entries) { 7541 var data = this.__data__ = new ListCache(entries); 7542 this.size = data.size; 7543 } 7544 7545 /** 7546 * Removes all key-value entries from the stack. 7547 * 7548 * @private 7549 * @name clear 7550 * @memberOf Stack 7551 */ 7552 function stackClear() { 7553 this.__data__ = new ListCache; 7554 this.size = 0; 7555 } 7556 7557 /** 7558 * Removes `key` and its value from the stack. 7559 * 7560 * @private 7561 * @name delete 7562 * @memberOf Stack 7563 * @param {string} key The key of the value to remove. 7564 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 7565 */ 7566 function stackDelete(key) { 7567 var data = this.__data__, 7568 result = data['delete'](key); 7569 7570 this.size = data.size; 7571 return result; 7572 } 7573 7574 /** 7575 * Gets the stack value for `key`. 7576 * 7577 * @private 7578 * @name get 7579 * @memberOf Stack 7580 * @param {string} key The key of the value to get. 7581 * @returns {*} Returns the entry value. 7582 */ 7583 function stackGet(key) { 7584 return this.__data__.get(key); 7585 } 7586 7587 /** 7588 * Checks if a stack value for `key` exists. 7589 * 7590 * @private 7591 * @name has 7592 * @memberOf Stack 7593 * @param {string} key The key of the entry to check. 7594 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 7595 */ 7596 function stackHas(key) { 7597 return this.__data__.has(key); 7598 } 7599 7600 /** 7601 * Sets the stack `key` to `value`. 7602 * 7603 * @private 7604 * @name set 7605 * @memberOf Stack 7606 * @param {string} key The key of the value to set. 7607 * @param {*} value The value to set. 7608 * @returns {Object} Returns the stack cache instance. 7609 */ 7610 function stackSet(key, value) { 7611 var data = this.__data__; 7612 if (data instanceof ListCache) { 7613 var pairs = data.__data__; 7614 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 7615 pairs.push([key, value]); 7616 this.size = ++data.size; 7617 return this; 7618 } 7619 data = this.__data__ = new MapCache(pairs); 7620 } 7621 data.set(key, value); 7622 this.size = data.size; 7623 return this; 7624 } 7625 7626 // Add methods to `Stack`. 7627 Stack.prototype.clear = stackClear; 7628 Stack.prototype['delete'] = stackDelete; 7629 Stack.prototype.get = stackGet; 7630 Stack.prototype.has = stackHas; 7631 Stack.prototype.set = stackSet; 7632 7633 /*------------------------------------------------------------------------*/ 7634 7635 /** 7636 * Creates an array of the enumerable property names of the array-like `value`. 7637 * 7638 * @private 7639 * @param {*} value The value to query. 7640 * @param {boolean} inherited Specify returning inherited property names. 7641 * @returns {Array} Returns the array of property names. 7642 */ 7643 function arrayLikeKeys(value, inherited) { 7644 var isArr = isArray(value), 7645 isArg = !isArr && isArguments(value), 7646 isBuff = !isArr && !isArg && isBuffer(value), 7647 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 7648 skipIndexes = isArr || isArg || isBuff || isType, 7649 result = skipIndexes ? baseTimes(value.length, String) : [], 7650 length = result.length; 7651 7652 for (var key in value) { 7653 if ((inherited || hasOwnProperty.call(value, key)) && 7654 !(skipIndexes && ( 7655 // Safari 9 has enumerable `arguments.length` in strict mode. 7656 key == 'length' || 7657 // Node.js 0.10 has enumerable non-index properties on buffers. 7658 (isBuff && (key == 'offset' || key == 'parent')) || 7659 // PhantomJS 2 has enumerable non-index properties on typed arrays. 7660 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 7661 // Skip index properties. 7662 isIndex(key, length) 7663 ))) { 7664 result.push(key); 7665 } 7666 } 7667 return result; 7668 } 7669 7670 /** 7671 * A specialized version of `_.sample` for arrays. 7672 * 7673 * @private 7674 * @param {Array} array The array to sample. 7675 * @returns {*} Returns the random element. 7676 */ 7677 function arraySample(array) { 7678 var length = array.length; 7679 return length ? array[baseRandom(0, length - 1)] : undefined; 7680 } 7681 7682 /** 7683 * A specialized version of `_.sampleSize` for arrays. 7684 * 7685 * @private 7686 * @param {Array} array The array to sample. 7687 * @param {number} n The number of elements to sample. 7688 * @returns {Array} Returns the random elements. 7689 */ 7690 function arraySampleSize(array, n) { 7691 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 7692 } 7693 7694 /** 7695 * A specialized version of `_.shuffle` for arrays. 7696 * 7697 * @private 7698 * @param {Array} array The array to shuffle. 7699 * @returns {Array} Returns the new shuffled array. 7700 */ 7701 function arrayShuffle(array) { 7702 return shuffleSelf(copyArray(array)); 7703 } 7704 7705 /** 7706 * This function is like `assignValue` except that it doesn't assign 7707 * `undefined` values. 7708 * 7709 * @private 7710 * @param {Object} object The object to modify. 7711 * @param {string} key The key of the property to assign. 7712 * @param {*} value The value to assign. 7713 */ 7714 function assignMergeValue(object, key, value) { 7715 if ((value !== undefined && !eq(object[key], value)) || 7716 (value === undefined && !(key in object))) { 7717 baseAssignValue(object, key, value); 7718 } 7719 } 7720 7721 /** 7722 * Assigns `value` to `key` of `object` if the existing value is not equivalent 7723 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 7724 * for equality comparisons. 7725 * 7726 * @private 7727 * @param {Object} object The object to modify. 7728 * @param {string} key The key of the property to assign. 7729 * @param {*} value The value to assign. 7730 */ 7731 function assignValue(object, key, value) { 7732 var objValue = object[key]; 7733 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 7734 (value === undefined && !(key in object))) { 7735 baseAssignValue(object, key, value); 7736 } 7737 } 7738 7739 /** 7740 * Gets the index at which the `key` is found in `array` of key-value pairs. 7741 * 7742 * @private 7743 * @param {Array} array The array to inspect. 7744 * @param {*} key The key to search for. 7745 * @returns {number} Returns the index of the matched value, else `-1`. 7746 */ 7747 function assocIndexOf(array, key) { 7748 var length = array.length; 7749 while (length--) { 7750 if (eq(array[length][0], key)) { 7751 return length; 7752 } 7753 } 7754 return -1; 7755 } 7756 7757 /** 7758 * Aggregates elements of `collection` on `accumulator` with keys transformed 7759 * by `iteratee` and values set by `setter`. 7760 * 7761 * @private 7762 * @param {Array|Object} collection The collection to iterate over. 7763 * @param {Function} setter The function to set `accumulator` values. 7764 * @param {Function} iteratee The iteratee to transform keys. 7765 * @param {Object} accumulator The initial aggregated object. 7766 * @returns {Function} Returns `accumulator`. 7767 */ 7768 function baseAggregator(collection, setter, iteratee, accumulator) { 7769 baseEach(collection, function(value, key, collection) { 7770 setter(accumulator, value, iteratee(value), collection); 7771 }); 7772 return accumulator; 7773 } 7774 7775 /** 7776 * The base implementation of `_.assign` without support for multiple sources 7777 * or `customizer` functions. 7778 * 7779 * @private 7780 * @param {Object} object The destination object. 7781 * @param {Object} source The source object. 7782 * @returns {Object} Returns `object`. 7783 */ 7784 function baseAssign(object, source) { 7785 return object && copyObject(source, keys(source), object); 7786 } 7787 7788 /** 7789 * The base implementation of `_.assignIn` without support for multiple sources 7790 * or `customizer` functions. 7791 * 7792 * @private 7793 * @param {Object} object The destination object. 7794 * @param {Object} source The source object. 7795 * @returns {Object} Returns `object`. 7796 */ 7797 function baseAssignIn(object, source) { 7798 return object && copyObject(source, keysIn(source), object); 7799 } 7800 7801 /** 7802 * The base implementation of `assignValue` and `assignMergeValue` without 7803 * value checks. 7804 * 7805 * @private 7806 * @param {Object} object The object to modify. 7807 * @param {string} key The key of the property to assign. 7808 * @param {*} value The value to assign. 7809 */ 7810 function baseAssignValue(object, key, value) { 7811 if (key == '__proto__' && defineProperty) { 7812 defineProperty(object, key, { 7813 'configurable': true, 7814 'enumerable': true, 7815 'value': value, 7816 'writable': true 7817 }); 7818 } else { 7819 object[key] = value; 7820 } 7821 } 7822 7823 /** 7824 * The base implementation of `_.at` without support for individual paths. 7825 * 7826 * @private 7827 * @param {Object} object The object to iterate over. 7828 * @param {string[]} paths The property paths to pick. 7829 * @returns {Array} Returns the picked elements. 7830 */ 7831 function baseAt(object, paths) { 7832 var index = -1, 7833 length = paths.length, 7834 result = Array(length), 7835 skip = object == null; 7836 7837 while (++index < length) { 7838 result[index] = skip ? undefined : get(object, paths[index]); 7839 } 7840 return result; 7841 } 7842 7843 /** 7844 * The base implementation of `_.clamp` which doesn't coerce arguments. 7845 * 7846 * @private 7847 * @param {number} number The number to clamp. 7848 * @param {number} [lower] The lower bound. 7849 * @param {number} upper The upper bound. 7850 * @returns {number} Returns the clamped number. 7851 */ 7852 function baseClamp(number, lower, upper) { 7853 if (number === number) { 7854 if (upper !== undefined) { 7855 number = number <= upper ? number : upper; 7856 } 7857 if (lower !== undefined) { 7858 number = number >= lower ? number : lower; 7859 } 7860 } 7861 return number; 7862 } 7863 7864 /** 7865 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 7866 * traversed objects. 7867 * 7868 * @private 7869 * @param {*} value The value to clone. 7870 * @param {boolean} bitmask The bitmask flags. 7871 * 1 - Deep clone 7872 * 2 - Flatten inherited properties 7873 * 4 - Clone symbols 7874 * @param {Function} [customizer] The function to customize cloning. 7875 * @param {string} [key] The key of `value`. 7876 * @param {Object} [object] The parent object of `value`. 7877 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 7878 * @returns {*} Returns the cloned value. 7879 */ 7880 function baseClone(value, bitmask, customizer, key, object, stack) { 7881 var result, 7882 isDeep = bitmask & CLONE_DEEP_FLAG, 7883 isFlat = bitmask & CLONE_FLAT_FLAG, 7884 isFull = bitmask & CLONE_SYMBOLS_FLAG; 7885 7886 if (customizer) { 7887 result = object ? customizer(value, key, object, stack) : customizer(value); 7888 } 7889 if (result !== undefined) { 7890 return result; 7891 } 7892 if (!isObject(value)) { 7893 return value; 7894 } 7895 var isArr = isArray(value); 7896 if (isArr) { 7897 result = initCloneArray(value); 7898 if (!isDeep) { 7899 return copyArray(value, result); 7900 } 7901 } else { 7902 var tag = getTag(value), 7903 isFunc = tag == funcTag || tag == genTag; 7904 7905 if (isBuffer(value)) { 7906 return cloneBuffer(value, isDeep); 7907 } 7908 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 7909 result = (isFlat || isFunc) ? {} : initCloneObject(value); 7910 if (!isDeep) { 7911 return isFlat 7912 ? copySymbolsIn(value, baseAssignIn(result, value)) 7913 : copySymbols(value, baseAssign(result, value)); 7914 } 7915 } else { 7916 if (!cloneableTags[tag]) { 7917 return object ? value : {}; 7918 } 7919 result = initCloneByTag(value, tag, isDeep); 7920 } 7921 } 7922 // Check for circular references and return its corresponding clone. 7923 stack || (stack = new Stack); 7924 var stacked = stack.get(value); 7925 if (stacked) { 7926 return stacked; 7927 } 7928 stack.set(value, result); 7929 7930 if (isSet(value)) { 7931 value.forEach(function(subValue) { 7932 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 7933 }); 7934 } else if (isMap(value)) { 7935 value.forEach(function(subValue, key) { 7936 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 7937 }); 7938 } 7939 7940 var keysFunc = isFull 7941 ? (isFlat ? getAllKeysIn : getAllKeys) 7942 : (isFlat ? keysIn : keys); 7943 7944 var props = isArr ? undefined : keysFunc(value); 7945 arrayEach(props || value, function(subValue, key) { 7946 if (props) { 7947 key = subValue; 7948 subValue = value[key]; 7949 } 7950 // Recursively populate clone (susceptible to call stack limits). 7951 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 7952 }); 7953 return result; 7954 } 7955 7956 /** 7957 * The base implementation of `_.conforms` which doesn't clone `source`. 7958 * 7959 * @private 7960 * @param {Object} source The object of property predicates to conform to. 7961 * @returns {Function} Returns the new spec function. 7962 */ 7963 function baseConforms(source) { 7964 var props = keys(source); 7965 return function(object) { 7966 return baseConformsTo(object, source, props); 7967 }; 7968 } 7969 7970 /** 7971 * The base implementation of `_.conformsTo` which accepts `props` to check. 7972 * 7973 * @private 7974 * @param {Object} object The object to inspect. 7975 * @param {Object} source The object of property predicates to conform to. 7976 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 7977 */ 7978 function baseConformsTo(object, source, props) { 7979 var length = props.length; 7980 if (object == null) { 7981 return !length; 7982 } 7983 object = Object(object); 7984 while (length--) { 7985 var key = props[length], 7986 predicate = source[key], 7987 value = object[key]; 7988 7989 if ((value === undefined && !(key in object)) || !predicate(value)) { 7990 return false; 7991 } 7992 } 7993 return true; 7994 } 7995 7996 /** 7997 * The base implementation of `_.delay` and `_.defer` which accepts `args` 7998 * to provide to `func`. 7999 * 8000 * @private 8001 * @param {Function} func The function to delay. 8002 * @param {number} wait The number of milliseconds to delay invocation. 8003 * @param {Array} args The arguments to provide to `func`. 8004 * @returns {number|Object} Returns the timer id or timeout object. 8005 */ 8006 function baseDelay(func, wait, args) { 8007 if (typeof func != 'function') { 8008 throw new TypeError(FUNC_ERROR_TEXT); 8009 } 8010 return setTimeout(function() { func.apply(undefined, args); }, wait); 8011 } 8012 8013 /** 8014 * The base implementation of methods like `_.difference` without support 8015 * for excluding multiple arrays or iteratee shorthands. 8016 * 8017 * @private 8018 * @param {Array} array The array to inspect. 8019 * @param {Array} values The values to exclude. 8020 * @param {Function} [iteratee] The iteratee invoked per element. 8021 * @param {Function} [comparator] The comparator invoked per element. 8022 * @returns {Array} Returns the new array of filtered values. 8023 */ 8024 function baseDifference(array, values, iteratee, comparator) { 8025 var index = -1, 8026 includes = arrayIncludes, 8027 isCommon = true, 8028 length = array.length, 8029 result = [], 8030 valuesLength = values.length; 8031 8032 if (!length) { 8033 return result; 8034 } 8035 if (iteratee) { 8036 values = arrayMap(values, baseUnary(iteratee)); 8037 } 8038 if (comparator) { 8039 includes = arrayIncludesWith; 8040 isCommon = false; 8041 } 8042 else if (values.length >= LARGE_ARRAY_SIZE) { 8043 includes = cacheHas; 8044 isCommon = false; 8045 values = new SetCache(values); 8046 } 8047 outer: 8048 while (++index < length) { 8049 var value = array[index], 8050 computed = iteratee == null ? value : iteratee(value); 8051 8052 value = (comparator || value !== 0) ? value : 0; 8053 if (isCommon && computed === computed) { 8054 var valuesIndex = valuesLength; 8055 while (valuesIndex--) { 8056 if (values[valuesIndex] === computed) { 8057 continue outer; 8058 } 8059 } 8060 result.push(value); 8061 } 8062 else if (!includes(values, computed, comparator)) { 8063 result.push(value); 8064 } 8065 } 8066 return result; 8067 } 8068 8069 /** 8070 * The base implementation of `_.forEach` without support for iteratee shorthands. 8071 * 8072 * @private 8073 * @param {Array|Object} collection The collection to iterate over. 8074 * @param {Function} iteratee The function invoked per iteration. 8075 * @returns {Array|Object} Returns `collection`. 8076 */ 8077 var baseEach = createBaseEach(baseForOwn); 8078 8079 /** 8080 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 8081 * 8082 * @private 8083 * @param {Array|Object} collection The collection to iterate over. 8084 * @param {Function} iteratee The function invoked per iteration. 8085 * @returns {Array|Object} Returns `collection`. 8086 */ 8087 var baseEachRight = createBaseEach(baseForOwnRight, true); 8088 8089 /** 8090 * The base implementation of `_.every` without support for iteratee shorthands. 8091 * 8092 * @private 8093 * @param {Array|Object} collection The collection to iterate over. 8094 * @param {Function} predicate The function invoked per iteration. 8095 * @returns {boolean} Returns `true` if all elements pass the predicate check, 8096 * else `false` 8097 */ 8098 function baseEvery(collection, predicate) { 8099 var result = true; 8100 baseEach(collection, function(value, index, collection) { 8101 result = !!predicate(value, index, collection); 8102 return result; 8103 }); 8104 return result; 8105 } 8106 8107 /** 8108 * The base implementation of methods like `_.max` and `_.min` which accepts a 8109 * `comparator` to determine the extremum value. 8110 * 8111 * @private 8112 * @param {Array} array The array to iterate over. 8113 * @param {Function} iteratee The iteratee invoked per iteration. 8114 * @param {Function} comparator The comparator used to compare values. 8115 * @returns {*} Returns the extremum value. 8116 */ 8117 function baseExtremum(array, iteratee, comparator) { 8118 var index = -1, 8119 length = array.length; 8120 8121 while (++index < length) { 8122 var value = array[index], 8123 current = iteratee(value); 8124 8125 if (current != null && (computed === undefined 8126 ? (current === current && !isSymbol(current)) 8127 : comparator(current, computed) 8128 )) { 8129 var computed = current, 8130 result = value; 8131 } 8132 } 8133 return result; 8134 } 8135 8136 /** 8137 * The base implementation of `_.fill` without an iteratee call guard. 8138 * 8139 * @private 8140 * @param {Array} array The array to fill. 8141 * @param {*} value The value to fill `array` with. 8142 * @param {number} [start=0] The start position. 8143 * @param {number} [end=array.length] The end position. 8144 * @returns {Array} Returns `array`. 8145 */ 8146 function baseFill(array, value, start, end) { 8147 var length = array.length; 8148 8149 start = toInteger(start); 8150 if (start < 0) { 8151 start = -start > length ? 0 : (length + start); 8152 } 8153 end = (end === undefined || end > length) ? length : toInteger(end); 8154 if (end < 0) { 8155 end += length; 8156 } 8157 end = start > end ? 0 : toLength(end); 8158 while (start < end) { 8159 array[start++] = value; 8160 } 8161 return array; 8162 } 8163 8164 /** 8165 * The base implementation of `_.filter` without support for iteratee shorthands. 8166 * 8167 * @private 8168 * @param {Array|Object} collection The collection to iterate over. 8169 * @param {Function} predicate The function invoked per iteration. 8170 * @returns {Array} Returns the new filtered array. 8171 */ 8172 function baseFilter(collection, predicate) { 8173 var result = []; 8174 baseEach(collection, function(value, index, collection) { 8175 if (predicate(value, index, collection)) { 8176 result.push(value); 8177 } 8178 }); 8179 return result; 8180 } 8181 8182 /** 8183 * The base implementation of `_.flatten` with support for restricting flattening. 8184 * 8185 * @private 8186 * @param {Array} array The array to flatten. 8187 * @param {number} depth The maximum recursion depth. 8188 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 8189 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 8190 * @param {Array} [result=[]] The initial result value. 8191 * @returns {Array} Returns the new flattened array. 8192 */ 8193 function baseFlatten(array, depth, predicate, isStrict, result) { 8194 var index = -1, 8195 length = array.length; 8196 8197 predicate || (predicate = isFlattenable); 8198 result || (result = []); 8199 8200 while (++index < length) { 8201 var value = array[index]; 8202 if (depth > 0 && predicate(value)) { 8203 if (depth > 1) { 8204 // Recursively flatten arrays (susceptible to call stack limits). 8205 baseFlatten(value, depth - 1, predicate, isStrict, result); 8206 } else { 8207 arrayPush(result, value); 8208 } 8209 } else if (!isStrict) { 8210 result[result.length] = value; 8211 } 8212 } 8213 return result; 8214 } 8215 8216 /** 8217 * The base implementation of `baseForOwn` which iterates over `object` 8218 * properties returned by `keysFunc` and invokes `iteratee` for each property. 8219 * Iteratee functions may exit iteration early by explicitly returning `false`. 8220 * 8221 * @private 8222 * @param {Object} object The object to iterate over. 8223 * @param {Function} iteratee The function invoked per iteration. 8224 * @param {Function} keysFunc The function to get the keys of `object`. 8225 * @returns {Object} Returns `object`. 8226 */ 8227 var baseFor = createBaseFor(); 8228 8229 /** 8230 * This function is like `baseFor` except that it iterates over properties 8231 * in the opposite order. 8232 * 8233 * @private 8234 * @param {Object} object The object to iterate over. 8235 * @param {Function} iteratee The function invoked per iteration. 8236 * @param {Function} keysFunc The function to get the keys of `object`. 8237 * @returns {Object} Returns `object`. 8238 */ 8239 var baseForRight = createBaseFor(true); 8240 8241 /** 8242 * The base implementation of `_.forOwn` without support for iteratee shorthands. 8243 * 8244 * @private 8245 * @param {Object} object The object to iterate over. 8246 * @param {Function} iteratee The function invoked per iteration. 8247 * @returns {Object} Returns `object`. 8248 */ 8249 function baseForOwn(object, iteratee) { 8250 return object && baseFor(object, iteratee, keys); 8251 } 8252 8253 /** 8254 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 8255 * 8256 * @private 8257 * @param {Object} object The object to iterate over. 8258 * @param {Function} iteratee The function invoked per iteration. 8259 * @returns {Object} Returns `object`. 8260 */ 8261 function baseForOwnRight(object, iteratee) { 8262 return object && baseForRight(object, iteratee, keys); 8263 } 8264 8265 /** 8266 * The base implementation of `_.functions` which creates an array of 8267 * `object` function property names filtered from `props`. 8268 * 8269 * @private 8270 * @param {Object} object The object to inspect. 8271 * @param {Array} props The property names to filter. 8272 * @returns {Array} Returns the function names. 8273 */ 8274 function baseFunctions(object, props) { 8275 return arrayFilter(props, function(key) { 8276 return isFunction(object[key]); 8277 }); 8278 } 8279 8280 /** 8281 * The base implementation of `_.get` without support for default values. 8282 * 8283 * @private 8284 * @param {Object} object The object to query. 8285 * @param {Array|string} path The path of the property to get. 8286 * @returns {*} Returns the resolved value. 8287 */ 8288 function baseGet(object, path) { 8289 path = castPath(path, object); 8290 8291 var index = 0, 8292 length = path.length; 8293 8294 while (object != null && index < length) { 8295 object = object[toKey(path[index++])]; 8296 } 8297 return (index && index == length) ? object : undefined; 8298 } 8299 8300 /** 8301 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 8302 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 8303 * symbols of `object`. 8304 * 8305 * @private 8306 * @param {Object} object The object to query. 8307 * @param {Function} keysFunc The function to get the keys of `object`. 8308 * @param {Function} symbolsFunc The function to get the symbols of `object`. 8309 * @returns {Array} Returns the array of property names and symbols. 8310 */ 8311 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 8312 var result = keysFunc(object); 8313 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 8314 } 8315 8316 /** 8317 * The base implementation of `getTag` without fallbacks for buggy environments. 8318 * 8319 * @private 8320 * @param {*} value The value to query. 8321 * @returns {string} Returns the `toStringTag`. 8322 */ 8323 function baseGetTag(value) { 8324 if (value == null) { 8325 return value === undefined ? undefinedTag : nullTag; 8326 } 8327 return (symToStringTag && symToStringTag in Object(value)) 8328 ? getRawTag(value) 8329 : objectToString(value); 8330 } 8331 8332 /** 8333 * The base implementation of `_.gt` which doesn't coerce arguments. 8334 * 8335 * @private 8336 * @param {*} value The value to compare. 8337 * @param {*} other The other value to compare. 8338 * @returns {boolean} Returns `true` if `value` is greater than `other`, 8339 * else `false`. 8340 */ 8341 function baseGt(value, other) { 8342 return value > other; 8343 } 8344 8345 /** 8346 * The base implementation of `_.has` without support for deep paths. 8347 * 8348 * @private 8349 * @param {Object} [object] The object to query. 8350 * @param {Array|string} key The key to check. 8351 * @returns {boolean} Returns `true` if `key` exists, else `false`. 8352 */ 8353 function baseHas(object, key) { 8354 return object != null && hasOwnProperty.call(object, key); 8355 } 8356 8357 /** 8358 * The base implementation of `_.hasIn` without support for deep paths. 8359 * 8360 * @private 8361 * @param {Object} [object] The object to query. 8362 * @param {Array|string} key The key to check. 8363 * @returns {boolean} Returns `true` if `key` exists, else `false`. 8364 */ 8365 function baseHasIn(object, key) { 8366 return object != null && key in Object(object); 8367 } 8368 8369 /** 8370 * The base implementation of `_.inRange` which doesn't coerce arguments. 8371 * 8372 * @private 8373 * @param {number} number The number to check. 8374 * @param {number} start The start of the range. 8375 * @param {number} end The end of the range. 8376 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 8377 */ 8378 function baseInRange(number, start, end) { 8379 return number >= nativeMin(start, end) && number < nativeMax(start, end); 8380 } 8381 8382 /** 8383 * The base implementation of methods like `_.intersection`, without support 8384 * for iteratee shorthands, that accepts an array of arrays to inspect. 8385 * 8386 * @private 8387 * @param {Array} arrays The arrays to inspect. 8388 * @param {Function} [iteratee] The iteratee invoked per element. 8389 * @param {Function} [comparator] The comparator invoked per element. 8390 * @returns {Array} Returns the new array of shared values. 8391 */ 8392 function baseIntersection(arrays, iteratee, comparator) { 8393 var includes = comparator ? arrayIncludesWith : arrayIncludes, 8394 length = arrays[0].length, 8395 othLength = arrays.length, 8396 othIndex = othLength, 8397 caches = Array(othLength), 8398 maxLength = Infinity, 8399 result = []; 8400 8401 while (othIndex--) { 8402 var array = arrays[othIndex]; 8403 if (othIndex && iteratee) { 8404 array = arrayMap(array, baseUnary(iteratee)); 8405 } 8406 maxLength = nativeMin(array.length, maxLength); 8407 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 8408 ? new SetCache(othIndex && array) 8409 : undefined; 8410 } 8411 array = arrays[0]; 8412 8413 var index = -1, 8414 seen = caches[0]; 8415 8416 outer: 8417 while (++index < length && result.length < maxLength) { 8418 var value = array[index], 8419 computed = iteratee ? iteratee(value) : value; 8420 8421 value = (comparator || value !== 0) ? value : 0; 8422 if (!(seen 8423 ? cacheHas(seen, computed) 8424 : includes(result, computed, comparator) 8425 )) { 8426 othIndex = othLength; 8427 while (--othIndex) { 8428 var cache = caches[othIndex]; 8429 if (!(cache 8430 ? cacheHas(cache, computed) 8431 : includes(arrays[othIndex], computed, comparator)) 8432 ) { 8433 continue outer; 8434 } 8435 } 8436 if (seen) { 8437 seen.push(computed); 8438 } 8439 result.push(value); 8440 } 8441 } 8442 return result; 8443 } 8444 8445 /** 8446 * The base implementation of `_.invert` and `_.invertBy` which inverts 8447 * `object` with values transformed by `iteratee` and set by `setter`. 8448 * 8449 * @private 8450 * @param {Object} object The object to iterate over. 8451 * @param {Function} setter The function to set `accumulator` values. 8452 * @param {Function} iteratee The iteratee to transform values. 8453 * @param {Object} accumulator The initial inverted object. 8454 * @returns {Function} Returns `accumulator`. 8455 */ 8456 function baseInverter(object, setter, iteratee, accumulator) { 8457 baseForOwn(object, function(value, key, object) { 8458 setter(accumulator, iteratee(value), key, object); 8459 }); 8460 return accumulator; 8461 } 8462 8463 /** 8464 * The base implementation of `_.invoke` without support for individual 8465 * method arguments. 8466 * 8467 * @private 8468 * @param {Object} object The object to query. 8469 * @param {Array|string} path The path of the method to invoke. 8470 * @param {Array} args The arguments to invoke the method with. 8471 * @returns {*} Returns the result of the invoked method. 8472 */ 8473 function baseInvoke(object, path, args) { 8474 path = castPath(path, object); 8475 object = parent(object, path); 8476 var func = object == null ? object : object[toKey(last(path))]; 8477 return func == null ? undefined : apply(func, object, args); 8478 } 8479 8480 /** 8481 * The base implementation of `_.isArguments`. 8482 * 8483 * @private 8484 * @param {*} value The value to check. 8485 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 8486 */ 8487 function baseIsArguments(value) { 8488 return isObjectLike(value) && baseGetTag(value) == argsTag; 8489 } 8490 8491 /** 8492 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 8493 * 8494 * @private 8495 * @param {*} value The value to check. 8496 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 8497 */ 8498 function baseIsArrayBuffer(value) { 8499 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 8500 } 8501 8502 /** 8503 * The base implementation of `_.isDate` without Node.js optimizations. 8504 * 8505 * @private 8506 * @param {*} value The value to check. 8507 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 8508 */ 8509 function baseIsDate(value) { 8510 return isObjectLike(value) && baseGetTag(value) == dateTag; 8511 } 8512 8513 /** 8514 * The base implementation of `_.isEqual` which supports partial comparisons 8515 * and tracks traversed objects. 8516 * 8517 * @private 8518 * @param {*} value The value to compare. 8519 * @param {*} other The other value to compare. 8520 * @param {boolean} bitmask The bitmask flags. 8521 * 1 - Unordered comparison 8522 * 2 - Partial comparison 8523 * @param {Function} [customizer] The function to customize comparisons. 8524 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 8525 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 8526 */ 8527 function baseIsEqual(value, other, bitmask, customizer, stack) { 8528 if (value === other) { 8529 return true; 8530 } 8531 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 8532 return value !== value && other !== other; 8533 } 8534 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 8535 } 8536 8537 /** 8538 * A specialized version of `baseIsEqual` for arrays and objects which performs 8539 * deep comparisons and tracks traversed objects enabling objects with circular 8540 * references to be compared. 8541 * 8542 * @private 8543 * @param {Object} object The object to compare. 8544 * @param {Object} other The other object to compare. 8545 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 8546 * @param {Function} customizer The function to customize comparisons. 8547 * @param {Function} equalFunc The function to determine equivalents of values. 8548 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 8549 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 8550 */ 8551 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 8552 var objIsArr = isArray(object), 8553 othIsArr = isArray(other), 8554 objTag = objIsArr ? arrayTag : getTag(object), 8555 othTag = othIsArr ? arrayTag : getTag(other); 8556 8557 objTag = objTag == argsTag ? objectTag : objTag; 8558 othTag = othTag == argsTag ? objectTag : othTag; 8559 8560 var objIsObj = objTag == objectTag, 8561 othIsObj = othTag == objectTag, 8562 isSameTag = objTag == othTag; 8563 8564 if (isSameTag && isBuffer(object)) { 8565 if (!isBuffer(other)) { 8566 return false; 8567 } 8568 objIsArr = true; 8569 objIsObj = false; 8570 } 8571 if (isSameTag && !objIsObj) { 8572 stack || (stack = new Stack); 8573 return (objIsArr || isTypedArray(object)) 8574 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 8575 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 8576 } 8577 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 8578 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 8579 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 8580 8581 if (objIsWrapped || othIsWrapped) { 8582 var objUnwrapped = objIsWrapped ? object.value() : object, 8583 othUnwrapped = othIsWrapped ? other.value() : other; 8584 8585 stack || (stack = new Stack); 8586 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 8587 } 8588 } 8589 if (!isSameTag) { 8590 return false; 8591 } 8592 stack || (stack = new Stack); 8593 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 8594 } 8595 8596 /** 8597 * The base implementation of `_.isMap` without Node.js optimizations. 8598 * 8599 * @private 8600 * @param {*} value The value to check. 8601 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 8602 */ 8603 function baseIsMap(value) { 8604 return isObjectLike(value) && getTag(value) == mapTag; 8605 } 8606 8607 /** 8608 * The base implementation of `_.isMatch` without support for iteratee shorthands. 8609 * 8610 * @private 8611 * @param {Object} object The object to inspect. 8612 * @param {Object} source The object of property values to match. 8613 * @param {Array} matchData The property names, values, and compare flags to match. 8614 * @param {Function} [customizer] The function to customize comparisons. 8615 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 8616 */ 8617 function baseIsMatch(object, source, matchData, customizer) { 8618 var index = matchData.length, 8619 length = index, 8620 noCustomizer = !customizer; 8621 8622 if (object == null) { 8623 return !length; 8624 } 8625 object = Object(object); 8626 while (index--) { 8627 var data = matchData[index]; 8628 if ((noCustomizer && data[2]) 8629 ? data[1] !== object[data[0]] 8630 : !(data[0] in object) 8631 ) { 8632 return false; 8633 } 8634 } 8635 while (++index < length) { 8636 data = matchData[index]; 8637 var key = data[0], 8638 objValue = object[key], 8639 srcValue = data[1]; 8640 8641 if (noCustomizer && data[2]) { 8642 if (objValue === undefined && !(key in object)) { 8643 return false; 8644 } 8645 } else { 8646 var stack = new Stack; 8647 if (customizer) { 8648 var result = customizer(objValue, srcValue, key, object, source, stack); 8649 } 8650 if (!(result === undefined 8651 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 8652 : result 8653 )) { 8654 return false; 8655 } 8656 } 8657 } 8658 return true; 8659 } 8660 8661 /** 8662 * The base implementation of `_.isNative` without bad shim checks. 8663 * 8664 * @private 8665 * @param {*} value The value to check. 8666 * @returns {boolean} Returns `true` if `value` is a native function, 8667 * else `false`. 8668 */ 8669 function baseIsNative(value) { 8670 if (!isObject(value) || isMasked(value)) { 8671 return false; 8672 } 8673 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 8674 return pattern.test(toSource(value)); 8675 } 8676 8677 /** 8678 * The base implementation of `_.isRegExp` without Node.js optimizations. 8679 * 8680 * @private 8681 * @param {*} value The value to check. 8682 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 8683 */ 8684 function baseIsRegExp(value) { 8685 return isObjectLike(value) && baseGetTag(value) == regexpTag; 8686 } 8687 8688 /** 8689 * The base implementation of `_.isSet` without Node.js optimizations. 8690 * 8691 * @private 8692 * @param {*} value The value to check. 8693 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 8694 */ 8695 function baseIsSet(value) { 8696 return isObjectLike(value) && getTag(value) == setTag; 8697 } 8698 8699 /** 8700 * The base implementation of `_.isTypedArray` without Node.js optimizations. 8701 * 8702 * @private 8703 * @param {*} value The value to check. 8704 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 8705 */ 8706 function baseIsTypedArray(value) { 8707 return isObjectLike(value) && 8708 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 8709 } 8710 8711 /** 8712 * The base implementation of `_.iteratee`. 8713 * 8714 * @private 8715 * @param {*} [value=_.identity] The value to convert to an iteratee. 8716 * @returns {Function} Returns the iteratee. 8717 */ 8718 function baseIteratee(value) { 8719 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 8720 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 8721 if (typeof value == 'function') { 8722 return value; 8723 } 8724 if (value == null) { 8725 return identity; 8726 } 8727 if (typeof value == 'object') { 8728 return isArray(value) 8729 ? baseMatchesProperty(value[0], value[1]) 8730 : baseMatches(value); 8731 } 8732 return property(value); 8733 } 8734 8735 /** 8736 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 8737 * 8738 * @private 8739 * @param {Object} object The object to query. 8740 * @returns {Array} Returns the array of property names. 8741 */ 8742 function baseKeys(object) { 8743 if (!isPrototype(object)) { 8744 return nativeKeys(object); 8745 } 8746 var result = []; 8747 for (var key in Object(object)) { 8748 if (hasOwnProperty.call(object, key) && key != 'constructor') { 8749 result.push(key); 8750 } 8751 } 8752 return result; 8753 } 8754 8755 /** 8756 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 8757 * 8758 * @private 8759 * @param {Object} object The object to query. 8760 * @returns {Array} Returns the array of property names. 8761 */ 8762 function baseKeysIn(object) { 8763 if (!isObject(object)) { 8764 return nativeKeysIn(object); 8765 } 8766 var isProto = isPrototype(object), 8767 result = []; 8768 8769 for (var key in object) { 8770 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 8771 result.push(key); 8772 } 8773 } 8774 return result; 8775 } 8776 8777 /** 8778 * The base implementation of `_.lt` which doesn't coerce arguments. 8779 * 8780 * @private 8781 * @param {*} value The value to compare. 8782 * @param {*} other The other value to compare. 8783 * @returns {boolean} Returns `true` if `value` is less than `other`, 8784 * else `false`. 8785 */ 8786 function baseLt(value, other) { 8787 return value < other; 8788 } 8789 8790 /** 8791 * The base implementation of `_.map` without support for iteratee shorthands. 8792 * 8793 * @private 8794 * @param {Array|Object} collection The collection to iterate over. 8795 * @param {Function} iteratee The function invoked per iteration. 8796 * @returns {Array} Returns the new mapped array. 8797 */ 8798 function baseMap(collection, iteratee) { 8799 var index = -1, 8800 result = isArrayLike(collection) ? Array(collection.length) : []; 8801 8802 baseEach(collection, function(value, key, collection) { 8803 result[++index] = iteratee(value, key, collection); 8804 }); 8805 return result; 8806 } 8807 8808 /** 8809 * The base implementation of `_.matches` which doesn't clone `source`. 8810 * 8811 * @private 8812 * @param {Object} source The object of property values to match. 8813 * @returns {Function} Returns the new spec function. 8814 */ 8815 function baseMatches(source) { 8816 var matchData = getMatchData(source); 8817 if (matchData.length == 1 && matchData[0][2]) { 8818 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 8819 } 8820 return function(object) { 8821 return object === source || baseIsMatch(object, source, matchData); 8822 }; 8823 } 8824 8825 /** 8826 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 8827 * 8828 * @private 8829 * @param {string} path The path of the property to get. 8830 * @param {*} srcValue The value to match. 8831 * @returns {Function} Returns the new spec function. 8832 */ 8833 function baseMatchesProperty(path, srcValue) { 8834 if (isKey(path) && isStrictComparable(srcValue)) { 8835 return matchesStrictComparable(toKey(path), srcValue); 8836 } 8837 return function(object) { 8838 var objValue = get(object, path); 8839 return (objValue === undefined && objValue === srcValue) 8840 ? hasIn(object, path) 8841 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 8842 }; 8843 } 8844 8845 /** 8846 * The base implementation of `_.merge` without support for multiple sources. 8847 * 8848 * @private 8849 * @param {Object} object The destination object. 8850 * @param {Object} source The source object. 8851 * @param {number} srcIndex The index of `source`. 8852 * @param {Function} [customizer] The function to customize merged values. 8853 * @param {Object} [stack] Tracks traversed source values and their merged 8854 * counterparts. 8855 */ 8856 function baseMerge(object, source, srcIndex, customizer, stack) { 8857 if (object === source) { 8858 return; 8859 } 8860 baseFor(source, function(srcValue, key) { 8861 stack || (stack = new Stack); 8862 if (isObject(srcValue)) { 8863 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 8864 } 8865 else { 8866 var newValue = customizer 8867 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 8868 : undefined; 8869 8870 if (newValue === undefined) { 8871 newValue = srcValue; 8872 } 8873 assignMergeValue(object, key, newValue); 8874 } 8875 }, keysIn); 8876 } 8877 8878 /** 8879 * A specialized version of `baseMerge` for arrays and objects which performs 8880 * deep merges and tracks traversed objects enabling objects with circular 8881 * references to be merged. 8882 * 8883 * @private 8884 * @param {Object} object The destination object. 8885 * @param {Object} source The source object. 8886 * @param {string} key The key of the value to merge. 8887 * @param {number} srcIndex The index of `source`. 8888 * @param {Function} mergeFunc The function to merge values. 8889 * @param {Function} [customizer] The function to customize assigned values. 8890 * @param {Object} [stack] Tracks traversed source values and their merged 8891 * counterparts. 8892 */ 8893 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 8894 var objValue = safeGet(object, key), 8895 srcValue = safeGet(source, key), 8896 stacked = stack.get(srcValue); 8897 8898 if (stacked) { 8899 assignMergeValue(object, key, stacked); 8900 return; 8901 } 8902 var newValue = customizer 8903 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 8904 : undefined; 8905 8906 var isCommon = newValue === undefined; 8907 8908 if (isCommon) { 8909 var isArr = isArray(srcValue), 8910 isBuff = !isArr && isBuffer(srcValue), 8911 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 8912 8913 newValue = srcValue; 8914 if (isArr || isBuff || isTyped) { 8915 if (isArray(objValue)) { 8916 newValue = objValue; 8917 } 8918 else if (isArrayLikeObject(objValue)) { 8919 newValue = copyArray(objValue); 8920 } 8921 else if (isBuff) { 8922 isCommon = false; 8923 newValue = cloneBuffer(srcValue, true); 8924 } 8925 else if (isTyped) { 8926 isCommon = false; 8927 newValue = cloneTypedArray(srcValue, true); 8928 } 8929 else { 8930 newValue = []; 8931 } 8932 } 8933 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 8934 newValue = objValue; 8935 if (isArguments(objValue)) { 8936 newValue = toPlainObject(objValue); 8937 } 8938 else if (!isObject(objValue) || isFunction(objValue)) { 8939 newValue = initCloneObject(srcValue); 8940 } 8941 } 8942 else { 8943 isCommon = false; 8944 } 8945 } 8946 if (isCommon) { 8947 // Recursively merge objects and arrays (susceptible to call stack limits). 8948 stack.set(srcValue, newValue); 8949 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 8950 stack['delete'](srcValue); 8951 } 8952 assignMergeValue(object, key, newValue); 8953 } 8954 8955 /** 8956 * The base implementation of `_.nth` which doesn't coerce arguments. 8957 * 8958 * @private 8959 * @param {Array} array The array to query. 8960 * @param {number} n The index of the element to return. 8961 * @returns {*} Returns the nth element of `array`. 8962 */ 8963 function baseNth(array, n) { 8964 var length = array.length; 8965 if (!length) { 8966 return; 8967 } 8968 n += n < 0 ? length : 0; 8969 return isIndex(n, length) ? array[n] : undefined; 8970 } 8971 8972 /** 8973 * The base implementation of `_.orderBy` without param guards. 8974 * 8975 * @private 8976 * @param {Array|Object} collection The collection to iterate over. 8977 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 8978 * @param {string[]} orders The sort orders of `iteratees`. 8979 * @returns {Array} Returns the new sorted array. 8980 */ 8981 function baseOrderBy(collection, iteratees, orders) { 8982 if (iteratees.length) { 8983 iteratees = arrayMap(iteratees, function(iteratee) { 8984 if (isArray(iteratee)) { 8985 return function(value) { 8986 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); 8987 } 8988 } 8989 return iteratee; 8990 }); 8991 } else { 8992 iteratees = [identity]; 8993 } 8994 8995 var index = -1; 8996 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 8997 8998 var result = baseMap(collection, function(value, key, collection) { 8999 var criteria = arrayMap(iteratees, function(iteratee) { 9000 return iteratee(value); 9001 }); 9002 return { 'criteria': criteria, 'index': ++index, 'value': value }; 9003 }); 9004 9005 return baseSortBy(result, function(object, other) { 9006 return compareMultiple(object, other, orders); 9007 }); 9008 } 9009 9010 /** 9011 * The base implementation of `_.pick` without support for individual 9012 * property identifiers. 9013 * 9014 * @private 9015 * @param {Object} object The source object. 9016 * @param {string[]} paths The property paths to pick. 9017 * @returns {Object} Returns the new object. 9018 */ 9019 function basePick(object, paths) { 9020 return basePickBy(object, paths, function(value, path) { 9021 return hasIn(object, path); 9022 }); 9023 } 9024 9025 /** 9026 * The base implementation of `_.pickBy` without support for iteratee shorthands. 9027 * 9028 * @private 9029 * @param {Object} object The source object. 9030 * @param {string[]} paths The property paths to pick. 9031 * @param {Function} predicate The function invoked per property. 9032 * @returns {Object} Returns the new object. 9033 */ 9034 function basePickBy(object, paths, predicate) { 9035 var index = -1, 9036 length = paths.length, 9037 result = {}; 9038 9039 while (++index < length) { 9040 var path = paths[index], 9041 value = baseGet(object, path); 9042 9043 if (predicate(value, path)) { 9044 baseSet(result, castPath(path, object), value); 9045 } 9046 } 9047 return result; 9048 } 9049 9050 /** 9051 * A specialized version of `baseProperty` which supports deep paths. 9052 * 9053 * @private 9054 * @param {Array|string} path The path of the property to get. 9055 * @returns {Function} Returns the new accessor function. 9056 */ 9057 function basePropertyDeep(path) { 9058 return function(object) { 9059 return baseGet(object, path); 9060 }; 9061 } 9062 9063 /** 9064 * The base implementation of `_.pullAllBy` without support for iteratee 9065 * shorthands. 9066 * 9067 * @private 9068 * @param {Array} array The array to modify. 9069 * @param {Array} values The values to remove. 9070 * @param {Function} [iteratee] The iteratee invoked per element. 9071 * @param {Function} [comparator] The comparator invoked per element. 9072 * @returns {Array} Returns `array`. 9073 */ 9074 function basePullAll(array, values, iteratee, comparator) { 9075 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 9076 index = -1, 9077 length = values.length, 9078 seen = array; 9079 9080 if (array === values) { 9081 values = copyArray(values); 9082 } 9083 if (iteratee) { 9084 seen = arrayMap(array, baseUnary(iteratee)); 9085 } 9086 while (++index < length) { 9087 var fromIndex = 0, 9088 value = values[index], 9089 computed = iteratee ? iteratee(value) : value; 9090 9091 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 9092 if (seen !== array) { 9093 splice.call(seen, fromIndex, 1); 9094 } 9095 splice.call(array, fromIndex, 1); 9096 } 9097 } 9098 return array; 9099 } 9100 9101 /** 9102 * The base implementation of `_.pullAt` without support for individual 9103 * indexes or capturing the removed elements. 9104 * 9105 * @private 9106 * @param {Array} array The array to modify. 9107 * @param {number[]} indexes The indexes of elements to remove. 9108 * @returns {Array} Returns `array`. 9109 */ 9110 function basePullAt(array, indexes) { 9111 var length = array ? indexes.length : 0, 9112 lastIndex = length - 1; 9113 9114 while (length--) { 9115 var index = indexes[length]; 9116 if (length == lastIndex || index !== previous) { 9117 var previous = index; 9118 if (isIndex(index)) { 9119 splice.call(array, index, 1); 9120 } else { 9121 baseUnset(array, index); 9122 } 9123 } 9124 } 9125 return array; 9126 } 9127 9128 /** 9129 * The base implementation of `_.random` without support for returning 9130 * floating-point numbers. 9131 * 9132 * @private 9133 * @param {number} lower The lower bound. 9134 * @param {number} upper The upper bound. 9135 * @returns {number} Returns the random number. 9136 */ 9137 function baseRandom(lower, upper) { 9138 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 9139 } 9140 9141 /** 9142 * The base implementation of `_.range` and `_.rangeRight` which doesn't 9143 * coerce arguments. 9144 * 9145 * @private 9146 * @param {number} start The start of the range. 9147 * @param {number} end The end of the range. 9148 * @param {number} step The value to increment or decrement by. 9149 * @param {boolean} [fromRight] Specify iterating from right to left. 9150 * @returns {Array} Returns the range of numbers. 9151 */ 9152 function baseRange(start, end, step, fromRight) { 9153 var index = -1, 9154 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 9155 result = Array(length); 9156 9157 while (length--) { 9158 result[fromRight ? length : ++index] = start; 9159 start += step; 9160 } 9161 return result; 9162 } 9163 9164 /** 9165 * The base implementation of `_.repeat` which doesn't coerce arguments. 9166 * 9167 * @private 9168 * @param {string} string The string to repeat. 9169 * @param {number} n The number of times to repeat the string. 9170 * @returns {string} Returns the repeated string. 9171 */ 9172 function baseRepeat(string, n) { 9173 var result = ''; 9174 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 9175 return result; 9176 } 9177 // Leverage the exponentiation by squaring algorithm for a faster repeat. 9178 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 9179 do { 9180 if (n % 2) { 9181 result += string; 9182 } 9183 n = nativeFloor(n / 2); 9184 if (n) { 9185 string += string; 9186 } 9187 } while (n); 9188 9189 return result; 9190 } 9191 9192 /** 9193 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 9194 * 9195 * @private 9196 * @param {Function} func The function to apply a rest parameter to. 9197 * @param {number} [start=func.length-1] The start position of the rest parameter. 9198 * @returns {Function} Returns the new function. 9199 */ 9200 function baseRest(func, start) { 9201 return setToString(overRest(func, start, identity), func + ''); 9202 } 9203 9204 /** 9205 * The base implementation of `_.sample`. 9206 * 9207 * @private 9208 * @param {Array|Object} collection The collection to sample. 9209 * @returns {*} Returns the random element. 9210 */ 9211 function baseSample(collection) { 9212 return arraySample(values(collection)); 9213 } 9214 9215 /** 9216 * The base implementation of `_.sampleSize` without param guards. 9217 * 9218 * @private 9219 * @param {Array|Object} collection The collection to sample. 9220 * @param {number} n The number of elements to sample. 9221 * @returns {Array} Returns the random elements. 9222 */ 9223 function baseSampleSize(collection, n) { 9224 var array = values(collection); 9225 return shuffleSelf(array, baseClamp(n, 0, array.length)); 9226 } 9227 9228 /** 9229 * The base implementation of `_.set`. 9230 * 9231 * @private 9232 * @param {Object} object The object to modify. 9233 * @param {Array|string} path The path of the property to set. 9234 * @param {*} value The value to set. 9235 * @param {Function} [customizer] The function to customize path creation. 9236 * @returns {Object} Returns `object`. 9237 */ 9238 function baseSet(object, path, value, customizer) { 9239 if (!isObject(object)) { 9240 return object; 9241 } 9242 path = castPath(path, object); 9243 9244 var index = -1, 9245 length = path.length, 9246 lastIndex = length - 1, 9247 nested = object; 9248 9249 while (nested != null && ++index < length) { 9250 var key = toKey(path[index]), 9251 newValue = value; 9252 9253 if (key === '__proto__' || key === 'constructor' || key === 'prototype') { 9254 return object; 9255 } 9256 9257 if (index != lastIndex) { 9258 var objValue = nested[key]; 9259 newValue = customizer ? customizer(objValue, key, nested) : undefined; 9260 if (newValue === undefined) { 9261 newValue = isObject(objValue) 9262 ? objValue 9263 : (isIndex(path[index + 1]) ? [] : {}); 9264 } 9265 } 9266 assignValue(nested, key, newValue); 9267 nested = nested[key]; 9268 } 9269 return object; 9270 } 9271 9272 /** 9273 * The base implementation of `setData` without support for hot loop shorting. 9274 * 9275 * @private 9276 * @param {Function} func The function to associate metadata with. 9277 * @param {*} data The metadata. 9278 * @returns {Function} Returns `func`. 9279 */ 9280 var baseSetData = !metaMap ? identity : function(func, data) { 9281 metaMap.set(func, data); 9282 return func; 9283 }; 9284 9285 /** 9286 * The base implementation of `setToString` without support for hot loop shorting. 9287 * 9288 * @private 9289 * @param {Function} func The function to modify. 9290 * @param {Function} string The `toString` result. 9291 * @returns {Function} Returns `func`. 9292 */ 9293 var baseSetToString = !defineProperty ? identity : function(func, string) { 9294 return defineProperty(func, 'toString', { 9295 'configurable': true, 9296 'enumerable': false, 9297 'value': constant(string), 9298 'writable': true 9299 }); 9300 }; 9301 9302 /** 9303 * The base implementation of `_.shuffle`. 9304 * 9305 * @private 9306 * @param {Array|Object} collection The collection to shuffle. 9307 * @returns {Array} Returns the new shuffled array. 9308 */ 9309 function baseShuffle(collection) { 9310 return shuffleSelf(values(collection)); 9311 } 9312 9313 /** 9314 * The base implementation of `_.slice` without an iteratee call guard. 9315 * 9316 * @private 9317 * @param {Array} array The array to slice. 9318 * @param {number} [start=0] The start position. 9319 * @param {number} [end=array.length] The end position. 9320 * @returns {Array} Returns the slice of `array`. 9321 */ 9322 function baseSlice(array, start, end) { 9323 var index = -1, 9324 length = array.length; 9325 9326 if (start < 0) { 9327 start = -start > length ? 0 : (length + start); 9328 } 9329 end = end > length ? length : end; 9330 if (end < 0) { 9331 end += length; 9332 } 9333 length = start > end ? 0 : ((end - start) >>> 0); 9334 start >>>= 0; 9335 9336 var result = Array(length); 9337 while (++index < length) { 9338 result[index] = array[index + start]; 9339 } 9340 return result; 9341 } 9342 9343 /** 9344 * The base implementation of `_.some` without support for iteratee shorthands. 9345 * 9346 * @private 9347 * @param {Array|Object} collection The collection to iterate over. 9348 * @param {Function} predicate The function invoked per iteration. 9349 * @returns {boolean} Returns `true` if any element passes the predicate check, 9350 * else `false`. 9351 */ 9352 function baseSome(collection, predicate) { 9353 var result; 9354 9355 baseEach(collection, function(value, index, collection) { 9356 result = predicate(value, index, collection); 9357 return !result; 9358 }); 9359 return !!result; 9360 } 9361 9362 /** 9363 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 9364 * performs a binary search of `array` to determine the index at which `value` 9365 * should be inserted into `array` in order to maintain its sort order. 9366 * 9367 * @private 9368 * @param {Array} array The sorted array to inspect. 9369 * @param {*} value The value to evaluate. 9370 * @param {boolean} [retHighest] Specify returning the highest qualified index. 9371 * @returns {number} Returns the index at which `value` should be inserted 9372 * into `array`. 9373 */ 9374 function baseSortedIndex(array, value, retHighest) { 9375 var low = 0, 9376 high = array == null ? low : array.length; 9377 9378 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 9379 while (low < high) { 9380 var mid = (low + high) >>> 1, 9381 computed = array[mid]; 9382 9383 if (computed !== null && !isSymbol(computed) && 9384 (retHighest ? (computed <= value) : (computed < value))) { 9385 low = mid + 1; 9386 } else { 9387 high = mid; 9388 } 9389 } 9390 return high; 9391 } 9392 return baseSortedIndexBy(array, value, identity, retHighest); 9393 } 9394 9395 /** 9396 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 9397 * which invokes `iteratee` for `value` and each element of `array` to compute 9398 * their sort ranking. The iteratee is invoked with one argument; (value). 9399 * 9400 * @private 9401 * @param {Array} array The sorted array to inspect. 9402 * @param {*} value The value to evaluate. 9403 * @param {Function} iteratee The iteratee invoked per element. 9404 * @param {boolean} [retHighest] Specify returning the highest qualified index. 9405 * @returns {number} Returns the index at which `value` should be inserted 9406 * into `array`. 9407 */ 9408 function baseSortedIndexBy(array, value, iteratee, retHighest) { 9409 var low = 0, 9410 high = array == null ? 0 : array.length; 9411 if (high === 0) { 9412 return 0; 9413 } 9414 9415 value = iteratee(value); 9416 var valIsNaN = value !== value, 9417 valIsNull = value === null, 9418 valIsSymbol = isSymbol(value), 9419 valIsUndefined = value === undefined; 9420 9421 while (low < high) { 9422 var mid = nativeFloor((low + high) / 2), 9423 computed = iteratee(array[mid]), 9424 othIsDefined = computed !== undefined, 9425 othIsNull = computed === null, 9426 othIsReflexive = computed === computed, 9427 othIsSymbol = isSymbol(computed); 9428 9429 if (valIsNaN) { 9430 var setLow = retHighest || othIsReflexive; 9431 } else if (valIsUndefined) { 9432 setLow = othIsReflexive && (retHighest || othIsDefined); 9433 } else if (valIsNull) { 9434 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 9435 } else if (valIsSymbol) { 9436 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 9437 } else if (othIsNull || othIsSymbol) { 9438 setLow = false; 9439 } else { 9440 setLow = retHighest ? (computed <= value) : (computed < value); 9441 } 9442 if (setLow) { 9443 low = mid + 1; 9444 } else { 9445 high = mid; 9446 } 9447 } 9448 return nativeMin(high, MAX_ARRAY_INDEX); 9449 } 9450 9451 /** 9452 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 9453 * support for iteratee shorthands. 9454 * 9455 * @private 9456 * @param {Array} array The array to inspect. 9457 * @param {Function} [iteratee] The iteratee invoked per element. 9458 * @returns {Array} Returns the new duplicate free array. 9459 */ 9460 function baseSortedUniq(array, iteratee) { 9461 var index = -1, 9462 length = array.length, 9463 resIndex = 0, 9464 result = []; 9465 9466 while (++index < length) { 9467 var value = array[index], 9468 computed = iteratee ? iteratee(value) : value; 9469 9470 if (!index || !eq(computed, seen)) { 9471 var seen = computed; 9472 result[resIndex++] = value === 0 ? 0 : value; 9473 } 9474 } 9475 return result; 9476 } 9477 9478 /** 9479 * The base implementation of `_.toNumber` which doesn't ensure correct 9480 * conversions of binary, hexadecimal, or octal string values. 9481 * 9482 * @private 9483 * @param {*} value The value to process. 9484 * @returns {number} Returns the number. 9485 */ 9486 function baseToNumber(value) { 9487 if (typeof value == 'number') { 9488 return value; 9489 } 9490 if (isSymbol(value)) { 9491 return NAN; 9492 } 9493 return +value; 9494 } 9495 9496 /** 9497 * The base implementation of `_.toString` which doesn't convert nullish 9498 * values to empty strings. 9499 * 9500 * @private 9501 * @param {*} value The value to process. 9502 * @returns {string} Returns the string. 9503 */ 9504 function baseToString(value) { 9505 // Exit early for strings to avoid a performance hit in some environments. 9506 if (typeof value == 'string') { 9507 return value; 9508 } 9509 if (isArray(value)) { 9510 // Recursively convert values (susceptible to call stack limits). 9511 return arrayMap(value, baseToString) + ''; 9512 } 9513 if (isSymbol(value)) { 9514 return symbolToString ? symbolToString.call(value) : ''; 9515 } 9516 var result = (value + ''); 9517 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 9518 } 9519 9520 /** 9521 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 9522 * 9523 * @private 9524 * @param {Array} array The array to inspect. 9525 * @param {Function} [iteratee] The iteratee invoked per element. 9526 * @param {Function} [comparator] The comparator invoked per element. 9527 * @returns {Array} Returns the new duplicate free array. 9528 */ 9529 function baseUniq(array, iteratee, comparator) { 9530 var index = -1, 9531 includes = arrayIncludes, 9532 length = array.length, 9533 isCommon = true, 9534 result = [], 9535 seen = result; 9536 9537 if (comparator) { 9538 isCommon = false; 9539 includes = arrayIncludesWith; 9540 } 9541 else if (length >= LARGE_ARRAY_SIZE) { 9542 var set = iteratee ? null : createSet(array); 9543 if (set) { 9544 return setToArray(set); 9545 } 9546 isCommon = false; 9547 includes = cacheHas; 9548 seen = new SetCache; 9549 } 9550 else { 9551 seen = iteratee ? [] : result; 9552 } 9553 outer: 9554 while (++index < length) { 9555 var value = array[index], 9556 computed = iteratee ? iteratee(value) : value; 9557 9558 value = (comparator || value !== 0) ? value : 0; 9559 if (isCommon && computed === computed) { 9560 var seenIndex = seen.length; 9561 while (seenIndex--) { 9562 if (seen[seenIndex] === computed) { 9563 continue outer; 9564 } 9565 } 9566 if (iteratee) { 9567 seen.push(computed); 9568 } 9569 result.push(value); 9570 } 9571 else if (!includes(seen, computed, comparator)) { 9572 if (seen !== result) { 9573 seen.push(computed); 9574 } 9575 result.push(value); 9576 } 9577 } 9578 return result; 9579 } 9580 9581 /** 9582 * The base implementation of `_.unset`. 9583 * 9584 * @private 9585 * @param {Object} object The object to modify. 9586 * @param {Array|string} path The property path to unset. 9587 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 9588 */ 9589 function baseUnset(object, path) { 9590 path = castPath(path, object); 9591 object = parent(object, path); 9592 return object == null || delete object[toKey(last(path))]; 9593 } 9594 9595 /** 9596 * The base implementation of `_.update`. 9597 * 9598 * @private 9599 * @param {Object} object The object to modify. 9600 * @param {Array|string} path The path of the property to update. 9601 * @param {Function} updater The function to produce the updated value. 9602 * @param {Function} [customizer] The function to customize path creation. 9603 * @returns {Object} Returns `object`. 9604 */ 9605 function baseUpdate(object, path, updater, customizer) { 9606 return baseSet(object, path, updater(baseGet(object, path)), customizer); 9607 } 9608 9609 /** 9610 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 9611 * without support for iteratee shorthands. 9612 * 9613 * @private 9614 * @param {Array} array The array to query. 9615 * @param {Function} predicate The function invoked per iteration. 9616 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 9617 * @param {boolean} [fromRight] Specify iterating from right to left. 9618 * @returns {Array} Returns the slice of `array`. 9619 */ 9620 function baseWhile(array, predicate, isDrop, fromRight) { 9621 var length = array.length, 9622 index = fromRight ? length : -1; 9623 9624 while ((fromRight ? index-- : ++index < length) && 9625 predicate(array[index], index, array)) {} 9626 9627 return isDrop 9628 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 9629 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 9630 } 9631 9632 /** 9633 * The base implementation of `wrapperValue` which returns the result of 9634 * performing a sequence of actions on the unwrapped `value`, where each 9635 * successive action is supplied the return value of the previous. 9636 * 9637 * @private 9638 * @param {*} value The unwrapped value. 9639 * @param {Array} actions Actions to perform to resolve the unwrapped value. 9640 * @returns {*} Returns the resolved value. 9641 */ 9642 function baseWrapperValue(value, actions) { 9643 var result = value; 9644 if (result instanceof LazyWrapper) { 9645 result = result.value(); 9646 } 9647 return arrayReduce(actions, function(result, action) { 9648 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 9649 }, result); 9650 } 9651 9652 /** 9653 * The base implementation of methods like `_.xor`, without support for 9654 * iteratee shorthands, that accepts an array of arrays to inspect. 9655 * 9656 * @private 9657 * @param {Array} arrays The arrays to inspect. 9658 * @param {Function} [iteratee] The iteratee invoked per element. 9659 * @param {Function} [comparator] The comparator invoked per element. 9660 * @returns {Array} Returns the new array of values. 9661 */ 9662 function baseXor(arrays, iteratee, comparator) { 9663 var length = arrays.length; 9664 if (length < 2) { 9665 return length ? baseUniq(arrays[0]) : []; 9666 } 9667 var index = -1, 9668 result = Array(length); 9669 9670 while (++index < length) { 9671 var array = arrays[index], 9672 othIndex = -1; 9673 9674 while (++othIndex < length) { 9675 if (othIndex != index) { 9676 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 9677 } 9678 } 9679 } 9680 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 9681 } 9682 9683 /** 9684 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 9685 * 9686 * @private 9687 * @param {Array} props The property identifiers. 9688 * @param {Array} values The property values. 9689 * @param {Function} assignFunc The function to assign values. 9690 * @returns {Object} Returns the new object. 9691 */ 9692 function baseZipObject(props, values, assignFunc) { 9693 var index = -1, 9694 length = props.length, 9695 valsLength = values.length, 9696 result = {}; 9697 9698 while (++index < length) { 9699 var value = index < valsLength ? values[index] : undefined; 9700 assignFunc(result, props[index], value); 9701 } 9702 return result; 9703 } 9704 9705 /** 9706 * Casts `value` to an empty array if it's not an array like object. 9707 * 9708 * @private 9709 * @param {*} value The value to inspect. 9710 * @returns {Array|Object} Returns the cast array-like object. 9711 */ 9712 function castArrayLikeObject(value) { 9713 return isArrayLikeObject(value) ? value : []; 9714 } 9715 9716 /** 9717 * Casts `value` to `identity` if it's not a function. 9718 * 9719 * @private 9720 * @param {*} value The value to inspect. 9721 * @returns {Function} Returns cast function. 9722 */ 9723 function castFunction(value) { 9724 return typeof value == 'function' ? value : identity; 9725 } 9726 9727 /** 9728 * Casts `value` to a path array if it's not one. 9729 * 9730 * @private 9731 * @param {*} value The value to inspect. 9732 * @param {Object} [object] The object to query keys on. 9733 * @returns {Array} Returns the cast property path array. 9734 */ 9735 function castPath(value, object) { 9736 if (isArray(value)) { 9737 return value; 9738 } 9739 return isKey(value, object) ? [value] : stringToPath(toString(value)); 9740 } 9741 9742 /** 9743 * A `baseRest` alias which can be replaced with `identity` by module 9744 * replacement plugins. 9745 * 9746 * @private 9747 * @type {Function} 9748 * @param {Function} func The function to apply a rest parameter to. 9749 * @returns {Function} Returns the new function. 9750 */ 9751 var castRest = baseRest; 9752 9753 /** 9754 * Casts `array` to a slice if it's needed. 9755 * 9756 * @private 9757 * @param {Array} array The array to inspect. 9758 * @param {number} start The start position. 9759 * @param {number} [end=array.length] The end position. 9760 * @returns {Array} Returns the cast slice. 9761 */ 9762 function castSlice(array, start, end) { 9763 var length = array.length; 9764 end = end === undefined ? length : end; 9765 return (!start && end >= length) ? array : baseSlice(array, start, end); 9766 } 9767 9768 /** 9769 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 9770 * 9771 * @private 9772 * @param {number|Object} id The timer id or timeout object of the timer to clear. 9773 */ 9774 var clearTimeout = ctxClearTimeout || function(id) { 9775 return root.clearTimeout(id); 9776 }; 9777 9778 /** 9779 * Creates a clone of `buffer`. 9780 * 9781 * @private 9782 * @param {Buffer} buffer The buffer to clone. 9783 * @param {boolean} [isDeep] Specify a deep clone. 9784 * @returns {Buffer} Returns the cloned buffer. 9785 */ 9786 function cloneBuffer(buffer, isDeep) { 9787 if (isDeep) { 9788 return buffer.slice(); 9789 } 9790 var length = buffer.length, 9791 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 9792 9793 buffer.copy(result); 9794 return result; 9795 } 9796 9797 /** 9798 * Creates a clone of `arrayBuffer`. 9799 * 9800 * @private 9801 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 9802 * @returns {ArrayBuffer} Returns the cloned array buffer. 9803 */ 9804 function cloneArrayBuffer(arrayBuffer) { 9805 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 9806 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 9807 return result; 9808 } 9809 9810 /** 9811 * Creates a clone of `dataView`. 9812 * 9813 * @private 9814 * @param {Object} dataView The data view to clone. 9815 * @param {boolean} [isDeep] Specify a deep clone. 9816 * @returns {Object} Returns the cloned data view. 9817 */ 9818 function cloneDataView(dataView, isDeep) { 9819 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 9820 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 9821 } 9822 9823 /** 9824 * Creates a clone of `regexp`. 9825 * 9826 * @private 9827 * @param {Object} regexp The regexp to clone. 9828 * @returns {Object} Returns the cloned regexp. 9829 */ 9830 function cloneRegExp(regexp) { 9831 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 9832 result.lastIndex = regexp.lastIndex; 9833 return result; 9834 } 9835 9836 /** 9837 * Creates a clone of the `symbol` object. 9838 * 9839 * @private 9840 * @param {Object} symbol The symbol object to clone. 9841 * @returns {Object} Returns the cloned symbol object. 9842 */ 9843 function cloneSymbol(symbol) { 9844 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 9845 } 9846 9847 /** 9848 * Creates a clone of `typedArray`. 9849 * 9850 * @private 9851 * @param {Object} typedArray The typed array to clone. 9852 * @param {boolean} [isDeep] Specify a deep clone. 9853 * @returns {Object} Returns the cloned typed array. 9854 */ 9855 function cloneTypedArray(typedArray, isDeep) { 9856 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 9857 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 9858 } 9859 9860 /** 9861 * Compares values to sort them in ascending order. 9862 * 9863 * @private 9864 * @param {*} value The value to compare. 9865 * @param {*} other The other value to compare. 9866 * @returns {number} Returns the sort order indicator for `value`. 9867 */ 9868 function compareAscending(value, other) { 9869 if (value !== other) { 9870 var valIsDefined = value !== undefined, 9871 valIsNull = value === null, 9872 valIsReflexive = value === value, 9873 valIsSymbol = isSymbol(value); 9874 9875 var othIsDefined = other !== undefined, 9876 othIsNull = other === null, 9877 othIsReflexive = other === other, 9878 othIsSymbol = isSymbol(other); 9879 9880 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 9881 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 9882 (valIsNull && othIsDefined && othIsReflexive) || 9883 (!valIsDefined && othIsReflexive) || 9884 !valIsReflexive) { 9885 return 1; 9886 } 9887 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 9888 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 9889 (othIsNull && valIsDefined && valIsReflexive) || 9890 (!othIsDefined && valIsReflexive) || 9891 !othIsReflexive) { 9892 return -1; 9893 } 9894 } 9895 return 0; 9896 } 9897 9898 /** 9899 * Used by `_.orderBy` to compare multiple properties of a value to another 9900 * and stable sort them. 9901 * 9902 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 9903 * specify an order of "desc" for descending or "asc" for ascending sort order 9904 * of corresponding values. 9905 * 9906 * @private 9907 * @param {Object} object The object to compare. 9908 * @param {Object} other The other object to compare. 9909 * @param {boolean[]|string[]} orders The order to sort by for each property. 9910 * @returns {number} Returns the sort order indicator for `object`. 9911 */ 9912 function compareMultiple(object, other, orders) { 9913 var index = -1, 9914 objCriteria = object.criteria, 9915 othCriteria = other.criteria, 9916 length = objCriteria.length, 9917 ordersLength = orders.length; 9918 9919 while (++index < length) { 9920 var result = compareAscending(objCriteria[index], othCriteria[index]); 9921 if (result) { 9922 if (index >= ordersLength) { 9923 return result; 9924 } 9925 var order = orders[index]; 9926 return result * (order == 'desc' ? -1 : 1); 9927 } 9928 } 9929 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 9930 // that causes it, under certain circumstances, to provide the same value for 9931 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 9932 // for more details. 9933 // 9934 // This also ensures a stable sort in V8 and other engines. 9935 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 9936 return object.index - other.index; 9937 } 9938 9939 /** 9940 * Creates an array that is the composition of partially applied arguments, 9941 * placeholders, and provided arguments into a single array of arguments. 9942 * 9943 * @private 9944 * @param {Array} args The provided arguments. 9945 * @param {Array} partials The arguments to prepend to those provided. 9946 * @param {Array} holders The `partials` placeholder indexes. 9947 * @params {boolean} [isCurried] Specify composing for a curried function. 9948 * @returns {Array} Returns the new array of composed arguments. 9949 */ 9950 function composeArgs(args, partials, holders, isCurried) { 9951 var argsIndex = -1, 9952 argsLength = args.length, 9953 holdersLength = holders.length, 9954 leftIndex = -1, 9955 leftLength = partials.length, 9956 rangeLength = nativeMax(argsLength - holdersLength, 0), 9957 result = Array(leftLength + rangeLength), 9958 isUncurried = !isCurried; 9959 9960 while (++leftIndex < leftLength) { 9961 result[leftIndex] = partials[leftIndex]; 9962 } 9963 while (++argsIndex < holdersLength) { 9964 if (isUncurried || argsIndex < argsLength) { 9965 result[holders[argsIndex]] = args[argsIndex]; 9966 } 9967 } 9968 while (rangeLength--) { 9969 result[leftIndex++] = args[argsIndex++]; 9970 } 9971 return result; 9972 } 9973 9974 /** 9975 * This function is like `composeArgs` except that the arguments composition 9976 * is tailored for `_.partialRight`. 9977 * 9978 * @private 9979 * @param {Array} args The provided arguments. 9980 * @param {Array} partials The arguments to append to those provided. 9981 * @param {Array} holders The `partials` placeholder indexes. 9982 * @params {boolean} [isCurried] Specify composing for a curried function. 9983 * @returns {Array} Returns the new array of composed arguments. 9984 */ 9985 function composeArgsRight(args, partials, holders, isCurried) { 9986 var argsIndex = -1, 9987 argsLength = args.length, 9988 holdersIndex = -1, 9989 holdersLength = holders.length, 9990 rightIndex = -1, 9991 rightLength = partials.length, 9992 rangeLength = nativeMax(argsLength - holdersLength, 0), 9993 result = Array(rangeLength + rightLength), 9994 isUncurried = !isCurried; 9995 9996 while (++argsIndex < rangeLength) { 9997 result[argsIndex] = args[argsIndex]; 9998 } 9999 var offset = argsIndex; 10000 while (++rightIndex < rightLength) { 10001 result[offset + rightIndex] = partials[rightIndex]; 10002 } 10003 while (++holdersIndex < holdersLength) { 10004 if (isUncurried || argsIndex < argsLength) { 10005 result[offset + holders[holdersIndex]] = args[argsIndex++]; 10006 } 10007 } 10008 return result; 10009 } 10010 10011 /** 10012 * Copies the values of `source` to `array`. 10013 * 10014 * @private 10015 * @param {Array} source The array to copy values from. 10016 * @param {Array} [array=[]] The array to copy values to. 10017 * @returns {Array} Returns `array`. 10018 */ 10019 function copyArray(source, array) { 10020 var index = -1, 10021 length = source.length; 10022 10023 array || (array = Array(length)); 10024 while (++index < length) { 10025 array[index] = source[index]; 10026 } 10027 return array; 10028 } 10029 10030 /** 10031 * Copies properties of `source` to `object`. 10032 * 10033 * @private 10034 * @param {Object} source The object to copy properties from. 10035 * @param {Array} props The property identifiers to copy. 10036 * @param {Object} [object={}] The object to copy properties to. 10037 * @param {Function} [customizer] The function to customize copied values. 10038 * @returns {Object} Returns `object`. 10039 */ 10040 function copyObject(source, props, object, customizer) { 10041 var isNew = !object; 10042 object || (object = {}); 10043 10044 var index = -1, 10045 length = props.length; 10046 10047 while (++index < length) { 10048 var key = props[index]; 10049 10050 var newValue = customizer 10051 ? customizer(object[key], source[key], key, object, source) 10052 : undefined; 10053 10054 if (newValue === undefined) { 10055 newValue = source[key]; 10056 } 10057 if (isNew) { 10058 baseAssignValue(object, key, newValue); 10059 } else { 10060 assignValue(object, key, newValue); 10061 } 10062 } 10063 return object; 10064 } 10065 10066 /** 10067 * Copies own symbols of `source` to `object`. 10068 * 10069 * @private 10070 * @param {Object} source The object to copy symbols from. 10071 * @param {Object} [object={}] The object to copy symbols to. 10072 * @returns {Object} Returns `object`. 10073 */ 10074 function copySymbols(source, object) { 10075 return copyObject(source, getSymbols(source), object); 10076 } 10077 10078 /** 10079 * Copies own and inherited symbols of `source` to `object`. 10080 * 10081 * @private 10082 * @param {Object} source The object to copy symbols from. 10083 * @param {Object} [object={}] The object to copy symbols to. 10084 * @returns {Object} Returns `object`. 10085 */ 10086 function copySymbolsIn(source, object) { 10087 return copyObject(source, getSymbolsIn(source), object); 10088 } 10089 10090 /** 10091 * Creates a function like `_.groupBy`. 10092 * 10093 * @private 10094 * @param {Function} setter The function to set accumulator values. 10095 * @param {Function} [initializer] The accumulator object initializer. 10096 * @returns {Function} Returns the new aggregator function. 10097 */ 10098 function createAggregator(setter, initializer) { 10099 return function(collection, iteratee) { 10100 var func = isArray(collection) ? arrayAggregator : baseAggregator, 10101 accumulator = initializer ? initializer() : {}; 10102 10103 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 10104 }; 10105 } 10106 10107 /** 10108 * Creates a function like `_.assign`. 10109 * 10110 * @private 10111 * @param {Function} assigner The function to assign values. 10112 * @returns {Function} Returns the new assigner function. 10113 */ 10114 function createAssigner(assigner) { 10115 return baseRest(function(object, sources) { 10116 var index = -1, 10117 length = sources.length, 10118 customizer = length > 1 ? sources[length - 1] : undefined, 10119 guard = length > 2 ? sources[2] : undefined; 10120 10121 customizer = (assigner.length > 3 && typeof customizer == 'function') 10122 ? (length--, customizer) 10123 : undefined; 10124 10125 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 10126 customizer = length < 3 ? undefined : customizer; 10127 length = 1; 10128 } 10129 object = Object(object); 10130 while (++index < length) { 10131 var source = sources[index]; 10132 if (source) { 10133 assigner(object, source, index, customizer); 10134 } 10135 } 10136 return object; 10137 }); 10138 } 10139 10140 /** 10141 * Creates a `baseEach` or `baseEachRight` function. 10142 * 10143 * @private 10144 * @param {Function} eachFunc The function to iterate over a collection. 10145 * @param {boolean} [fromRight] Specify iterating from right to left. 10146 * @returns {Function} Returns the new base function. 10147 */ 10148 function createBaseEach(eachFunc, fromRight) { 10149 return function(collection, iteratee) { 10150 if (collection == null) { 10151 return collection; 10152 } 10153 if (!isArrayLike(collection)) { 10154 return eachFunc(collection, iteratee); 10155 } 10156 var length = collection.length, 10157 index = fromRight ? length : -1, 10158 iterable = Object(collection); 10159 10160 while ((fromRight ? index-- : ++index < length)) { 10161 if (iteratee(iterable[index], index, iterable) === false) { 10162 break; 10163 } 10164 } 10165 return collection; 10166 }; 10167 } 10168 10169 /** 10170 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 10171 * 10172 * @private 10173 * @param {boolean} [fromRight] Specify iterating from right to left. 10174 * @returns {Function} Returns the new base function. 10175 */ 10176 function createBaseFor(fromRight) { 10177 return function(object, iteratee, keysFunc) { 10178 var index = -1, 10179 iterable = Object(object), 10180 props = keysFunc(object), 10181 length = props.length; 10182 10183 while (length--) { 10184 var key = props[fromRight ? length : ++index]; 10185 if (iteratee(iterable[key], key, iterable) === false) { 10186 break; 10187 } 10188 } 10189 return object; 10190 }; 10191 } 10192 10193 /** 10194 * Creates a function that wraps `func` to invoke it with the optional `this` 10195 * binding of `thisArg`. 10196 * 10197 * @private 10198 * @param {Function} func The function to wrap. 10199 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10200 * @param {*} [thisArg] The `this` binding of `func`. 10201 * @returns {Function} Returns the new wrapped function. 10202 */ 10203 function createBind(func, bitmask, thisArg) { 10204 var isBind = bitmask & WRAP_BIND_FLAG, 10205 Ctor = createCtor(func); 10206 10207 function wrapper() { 10208 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 10209 return fn.apply(isBind ? thisArg : this, arguments); 10210 } 10211 return wrapper; 10212 } 10213 10214 /** 10215 * Creates a function like `_.lowerFirst`. 10216 * 10217 * @private 10218 * @param {string} methodName The name of the `String` case method to use. 10219 * @returns {Function} Returns the new case function. 10220 */ 10221 function createCaseFirst(methodName) { 10222 return function(string) { 10223 string = toString(string); 10224 10225 var strSymbols = hasUnicode(string) 10226 ? stringToArray(string) 10227 : undefined; 10228 10229 var chr = strSymbols 10230 ? strSymbols[0] 10231 : string.charAt(0); 10232 10233 var trailing = strSymbols 10234 ? castSlice(strSymbols, 1).join('') 10235 : string.slice(1); 10236 10237 return chr[methodName]() + trailing; 10238 }; 10239 } 10240 10241 /** 10242 * Creates a function like `_.camelCase`. 10243 * 10244 * @private 10245 * @param {Function} callback The function to combine each word. 10246 * @returns {Function} Returns the new compounder function. 10247 */ 10248 function createCompounder(callback) { 10249 return function(string) { 10250 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 10251 }; 10252 } 10253 10254 /** 10255 * Creates a function that produces an instance of `Ctor` regardless of 10256 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 10257 * 10258 * @private 10259 * @param {Function} Ctor The constructor to wrap. 10260 * @returns {Function} Returns the new wrapped function. 10261 */ 10262 function createCtor(Ctor) { 10263 return function() { 10264 // Use a `switch` statement to work with class constructors. See 10265 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 10266 // for more details. 10267 var args = arguments; 10268 switch (args.length) { 10269 case 0: return new Ctor; 10270 case 1: return new Ctor(args[0]); 10271 case 2: return new Ctor(args[0], args[1]); 10272 case 3: return new Ctor(args[0], args[1], args[2]); 10273 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 10274 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 10275 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 10276 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 10277 } 10278 var thisBinding = baseCreate(Ctor.prototype), 10279 result = Ctor.apply(thisBinding, args); 10280 10281 // Mimic the constructor's `return` behavior. 10282 // See https://es5.github.io/#x13.2.2 for more details. 10283 return isObject(result) ? result : thisBinding; 10284 }; 10285 } 10286 10287 /** 10288 * Creates a function that wraps `func` to enable currying. 10289 * 10290 * @private 10291 * @param {Function} func The function to wrap. 10292 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10293 * @param {number} arity The arity of `func`. 10294 * @returns {Function} Returns the new wrapped function. 10295 */ 10296 function createCurry(func, bitmask, arity) { 10297 var Ctor = createCtor(func); 10298 10299 function wrapper() { 10300 var length = arguments.length, 10301 args = Array(length), 10302 index = length, 10303 placeholder = getHolder(wrapper); 10304 10305 while (index--) { 10306 args[index] = arguments[index]; 10307 } 10308 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 10309 ? [] 10310 : replaceHolders(args, placeholder); 10311 10312 length -= holders.length; 10313 if (length < arity) { 10314 return createRecurry( 10315 func, bitmask, createHybrid, wrapper.placeholder, undefined, 10316 args, holders, undefined, undefined, arity - length); 10317 } 10318 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 10319 return apply(fn, this, args); 10320 } 10321 return wrapper; 10322 } 10323 10324 /** 10325 * Creates a `_.find` or `_.findLast` function. 10326 * 10327 * @private 10328 * @param {Function} findIndexFunc The function to find the collection index. 10329 * @returns {Function} Returns the new find function. 10330 */ 10331 function createFind(findIndexFunc) { 10332 return function(collection, predicate, fromIndex) { 10333 var iterable = Object(collection); 10334 if (!isArrayLike(collection)) { 10335 var iteratee = getIteratee(predicate, 3); 10336 collection = keys(collection); 10337 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 10338 } 10339 var index = findIndexFunc(collection, predicate, fromIndex); 10340 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 10341 }; 10342 } 10343 10344 /** 10345 * Creates a `_.flow` or `_.flowRight` function. 10346 * 10347 * @private 10348 * @param {boolean} [fromRight] Specify iterating from right to left. 10349 * @returns {Function} Returns the new flow function. 10350 */ 10351 function createFlow(fromRight) { 10352 return flatRest(function(funcs) { 10353 var length = funcs.length, 10354 index = length, 10355 prereq = LodashWrapper.prototype.thru; 10356 10357 if (fromRight) { 10358 funcs.reverse(); 10359 } 10360 while (index--) { 10361 var func = funcs[index]; 10362 if (typeof func != 'function') { 10363 throw new TypeError(FUNC_ERROR_TEXT); 10364 } 10365 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 10366 var wrapper = new LodashWrapper([], true); 10367 } 10368 } 10369 index = wrapper ? index : length; 10370 while (++index < length) { 10371 func = funcs[index]; 10372 10373 var funcName = getFuncName(func), 10374 data = funcName == 'wrapper' ? getData(func) : undefined; 10375 10376 if (data && isLaziable(data[0]) && 10377 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 10378 !data[4].length && data[9] == 1 10379 ) { 10380 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 10381 } else { 10382 wrapper = (func.length == 1 && isLaziable(func)) 10383 ? wrapper[funcName]() 10384 : wrapper.thru(func); 10385 } 10386 } 10387 return function() { 10388 var args = arguments, 10389 value = args[0]; 10390 10391 if (wrapper && args.length == 1 && isArray(value)) { 10392 return wrapper.plant(value).value(); 10393 } 10394 var index = 0, 10395 result = length ? funcs[index].apply(this, args) : value; 10396 10397 while (++index < length) { 10398 result = funcs[index].call(this, result); 10399 } 10400 return result; 10401 }; 10402 }); 10403 } 10404 10405 /** 10406 * Creates a function that wraps `func` to invoke it with optional `this` 10407 * binding of `thisArg`, partial application, and currying. 10408 * 10409 * @private 10410 * @param {Function|string} func The function or method name to wrap. 10411 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10412 * @param {*} [thisArg] The `this` binding of `func`. 10413 * @param {Array} [partials] The arguments to prepend to those provided to 10414 * the new function. 10415 * @param {Array} [holders] The `partials` placeholder indexes. 10416 * @param {Array} [partialsRight] The arguments to append to those provided 10417 * to the new function. 10418 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 10419 * @param {Array} [argPos] The argument positions of the new function. 10420 * @param {number} [ary] The arity cap of `func`. 10421 * @param {number} [arity] The arity of `func`. 10422 * @returns {Function} Returns the new wrapped function. 10423 */ 10424 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 10425 var isAry = bitmask & WRAP_ARY_FLAG, 10426 isBind = bitmask & WRAP_BIND_FLAG, 10427 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 10428 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 10429 isFlip = bitmask & WRAP_FLIP_FLAG, 10430 Ctor = isBindKey ? undefined : createCtor(func); 10431 10432 function wrapper() { 10433 var length = arguments.length, 10434 args = Array(length), 10435 index = length; 10436 10437 while (index--) { 10438 args[index] = arguments[index]; 10439 } 10440 if (isCurried) { 10441 var placeholder = getHolder(wrapper), 10442 holdersCount = countHolders(args, placeholder); 10443 } 10444 if (partials) { 10445 args = composeArgs(args, partials, holders, isCurried); 10446 } 10447 if (partialsRight) { 10448 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 10449 } 10450 length -= holdersCount; 10451 if (isCurried && length < arity) { 10452 var newHolders = replaceHolders(args, placeholder); 10453 return createRecurry( 10454 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 10455 args, newHolders, argPos, ary, arity - length 10456 ); 10457 } 10458 var thisBinding = isBind ? thisArg : this, 10459 fn = isBindKey ? thisBinding[func] : func; 10460 10461 length = args.length; 10462 if (argPos) { 10463 args = reorder(args, argPos); 10464 } else if (isFlip && length > 1) { 10465 args.reverse(); 10466 } 10467 if (isAry && ary < length) { 10468 args.length = ary; 10469 } 10470 if (this && this !== root && this instanceof wrapper) { 10471 fn = Ctor || createCtor(fn); 10472 } 10473 return fn.apply(thisBinding, args); 10474 } 10475 return wrapper; 10476 } 10477 10478 /** 10479 * Creates a function like `_.invertBy`. 10480 * 10481 * @private 10482 * @param {Function} setter The function to set accumulator values. 10483 * @param {Function} toIteratee The function to resolve iteratees. 10484 * @returns {Function} Returns the new inverter function. 10485 */ 10486 function createInverter(setter, toIteratee) { 10487 return function(object, iteratee) { 10488 return baseInverter(object, setter, toIteratee(iteratee), {}); 10489 }; 10490 } 10491 10492 /** 10493 * Creates a function that performs a mathematical operation on two values. 10494 * 10495 * @private 10496 * @param {Function} operator The function to perform the operation. 10497 * @param {number} [defaultValue] The value used for `undefined` arguments. 10498 * @returns {Function} Returns the new mathematical operation function. 10499 */ 10500 function createMathOperation(operator, defaultValue) { 10501 return function(value, other) { 10502 var result; 10503 if (value === undefined && other === undefined) { 10504 return defaultValue; 10505 } 10506 if (value !== undefined) { 10507 result = value; 10508 } 10509 if (other !== undefined) { 10510 if (result === undefined) { 10511 return other; 10512 } 10513 if (typeof value == 'string' || typeof other == 'string') { 10514 value = baseToString(value); 10515 other = baseToString(other); 10516 } else { 10517 value = baseToNumber(value); 10518 other = baseToNumber(other); 10519 } 10520 result = operator(value, other); 10521 } 10522 return result; 10523 }; 10524 } 10525 10526 /** 10527 * Creates a function like `_.over`. 10528 * 10529 * @private 10530 * @param {Function} arrayFunc The function to iterate over iteratees. 10531 * @returns {Function} Returns the new over function. 10532 */ 10533 function createOver(arrayFunc) { 10534 return flatRest(function(iteratees) { 10535 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 10536 return baseRest(function(args) { 10537 var thisArg = this; 10538 return arrayFunc(iteratees, function(iteratee) { 10539 return apply(iteratee, thisArg, args); 10540 }); 10541 }); 10542 }); 10543 } 10544 10545 /** 10546 * Creates the padding for `string` based on `length`. The `chars` string 10547 * is truncated if the number of characters exceeds `length`. 10548 * 10549 * @private 10550 * @param {number} length The padding length. 10551 * @param {string} [chars=' '] The string used as padding. 10552 * @returns {string} Returns the padding for `string`. 10553 */ 10554 function createPadding(length, chars) { 10555 chars = chars === undefined ? ' ' : baseToString(chars); 10556 10557 var charsLength = chars.length; 10558 if (charsLength < 2) { 10559 return charsLength ? baseRepeat(chars, length) : chars; 10560 } 10561 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 10562 return hasUnicode(chars) 10563 ? castSlice(stringToArray(result), 0, length).join('') 10564 : result.slice(0, length); 10565 } 10566 10567 /** 10568 * Creates a function that wraps `func` to invoke it with the `this` binding 10569 * of `thisArg` and `partials` prepended to the arguments it receives. 10570 * 10571 * @private 10572 * @param {Function} func The function to wrap. 10573 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10574 * @param {*} thisArg The `this` binding of `func`. 10575 * @param {Array} partials The arguments to prepend to those provided to 10576 * the new function. 10577 * @returns {Function} Returns the new wrapped function. 10578 */ 10579 function createPartial(func, bitmask, thisArg, partials) { 10580 var isBind = bitmask & WRAP_BIND_FLAG, 10581 Ctor = createCtor(func); 10582 10583 function wrapper() { 10584 var argsIndex = -1, 10585 argsLength = arguments.length, 10586 leftIndex = -1, 10587 leftLength = partials.length, 10588 args = Array(leftLength + argsLength), 10589 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 10590 10591 while (++leftIndex < leftLength) { 10592 args[leftIndex] = partials[leftIndex]; 10593 } 10594 while (argsLength--) { 10595 args[leftIndex++] = arguments[++argsIndex]; 10596 } 10597 return apply(fn, isBind ? thisArg : this, args); 10598 } 10599 return wrapper; 10600 } 10601 10602 /** 10603 * Creates a `_.range` or `_.rangeRight` function. 10604 * 10605 * @private 10606 * @param {boolean} [fromRight] Specify iterating from right to left. 10607 * @returns {Function} Returns the new range function. 10608 */ 10609 function createRange(fromRight) { 10610 return function(start, end, step) { 10611 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 10612 end = step = undefined; 10613 } 10614 // Ensure the sign of `-0` is preserved. 10615 start = toFinite(start); 10616 if (end === undefined) { 10617 end = start; 10618 start = 0; 10619 } else { 10620 end = toFinite(end); 10621 } 10622 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 10623 return baseRange(start, end, step, fromRight); 10624 }; 10625 } 10626 10627 /** 10628 * Creates a function that performs a relational operation on two values. 10629 * 10630 * @private 10631 * @param {Function} operator The function to perform the operation. 10632 * @returns {Function} Returns the new relational operation function. 10633 */ 10634 function createRelationalOperation(operator) { 10635 return function(value, other) { 10636 if (!(typeof value == 'string' && typeof other == 'string')) { 10637 value = toNumber(value); 10638 other = toNumber(other); 10639 } 10640 return operator(value, other); 10641 }; 10642 } 10643 10644 /** 10645 * Creates a function that wraps `func` to continue currying. 10646 * 10647 * @private 10648 * @param {Function} func The function to wrap. 10649 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 10650 * @param {Function} wrapFunc The function to create the `func` wrapper. 10651 * @param {*} placeholder The placeholder value. 10652 * @param {*} [thisArg] The `this` binding of `func`. 10653 * @param {Array} [partials] The arguments to prepend to those provided to 10654 * the new function. 10655 * @param {Array} [holders] The `partials` placeholder indexes. 10656 * @param {Array} [argPos] The argument positions of the new function. 10657 * @param {number} [ary] The arity cap of `func`. 10658 * @param {number} [arity] The arity of `func`. 10659 * @returns {Function} Returns the new wrapped function. 10660 */ 10661 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 10662 var isCurry = bitmask & WRAP_CURRY_FLAG, 10663 newHolders = isCurry ? holders : undefined, 10664 newHoldersRight = isCurry ? undefined : holders, 10665 newPartials = isCurry ? partials : undefined, 10666 newPartialsRight = isCurry ? undefined : partials; 10667 10668 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 10669 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 10670 10671 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 10672 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 10673 } 10674 var newData = [ 10675 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 10676 newHoldersRight, argPos, ary, arity 10677 ]; 10678 10679 var result = wrapFunc.apply(undefined, newData); 10680 if (isLaziable(func)) { 10681 setData(result, newData); 10682 } 10683 result.placeholder = placeholder; 10684 return setWrapToString(result, func, bitmask); 10685 } 10686 10687 /** 10688 * Creates a function like `_.round`. 10689 * 10690 * @private 10691 * @param {string} methodName The name of the `Math` method to use when rounding. 10692 * @returns {Function} Returns the new round function. 10693 */ 10694 function createRound(methodName) { 10695 var func = Math[methodName]; 10696 return function(number, precision) { 10697 number = toNumber(number); 10698 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 10699 if (precision && nativeIsFinite(number)) { 10700 // Shift with exponential notation to avoid floating-point issues. 10701 // See [MDN](https://mdn.io/round#Examples) for more details. 10702 var pair = (toString(number) + 'e').split('e'), 10703 value = func(pair[0] + 'e' + (+pair[1] + precision)); 10704 10705 pair = (toString(value) + 'e').split('e'); 10706 return +(pair[0] + 'e' + (+pair[1] - precision)); 10707 } 10708 return func(number); 10709 }; 10710 } 10711 10712 /** 10713 * Creates a set object of `values`. 10714 * 10715 * @private 10716 * @param {Array} values The values to add to the set. 10717 * @returns {Object} Returns the new set. 10718 */ 10719 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 10720 return new Set(values); 10721 }; 10722 10723 /** 10724 * Creates a `_.toPairs` or `_.toPairsIn` function. 10725 * 10726 * @private 10727 * @param {Function} keysFunc The function to get the keys of a given object. 10728 * @returns {Function} Returns the new pairs function. 10729 */ 10730 function createToPairs(keysFunc) { 10731 return function(object) { 10732 var tag = getTag(object); 10733 if (tag == mapTag) { 10734 return mapToArray(object); 10735 } 10736 if (tag == setTag) { 10737 return setToPairs(object); 10738 } 10739 return baseToPairs(object, keysFunc(object)); 10740 }; 10741 } 10742 10743 /** 10744 * Creates a function that either curries or invokes `func` with optional 10745 * `this` binding and partially applied arguments. 10746 * 10747 * @private 10748 * @param {Function|string} func The function or method name to wrap. 10749 * @param {number} bitmask The bitmask flags. 10750 * 1 - `_.bind` 10751 * 2 - `_.bindKey` 10752 * 4 - `_.curry` or `_.curryRight` of a bound function 10753 * 8 - `_.curry` 10754 * 16 - `_.curryRight` 10755 * 32 - `_.partial` 10756 * 64 - `_.partialRight` 10757 * 128 - `_.rearg` 10758 * 256 - `_.ary` 10759 * 512 - `_.flip` 10760 * @param {*} [thisArg] The `this` binding of `func`. 10761 * @param {Array} [partials] The arguments to be partially applied. 10762 * @param {Array} [holders] The `partials` placeholder indexes. 10763 * @param {Array} [argPos] The argument positions of the new function. 10764 * @param {number} [ary] The arity cap of `func`. 10765 * @param {number} [arity] The arity of `func`. 10766 * @returns {Function} Returns the new wrapped function. 10767 */ 10768 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 10769 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 10770 if (!isBindKey && typeof func != 'function') { 10771 throw new TypeError(FUNC_ERROR_TEXT); 10772 } 10773 var length = partials ? partials.length : 0; 10774 if (!length) { 10775 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 10776 partials = holders = undefined; 10777 } 10778 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 10779 arity = arity === undefined ? arity : toInteger(arity); 10780 length -= holders ? holders.length : 0; 10781 10782 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 10783 var partialsRight = partials, 10784 holdersRight = holders; 10785 10786 partials = holders = undefined; 10787 } 10788 var data = isBindKey ? undefined : getData(func); 10789 10790 var newData = [ 10791 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 10792 argPos, ary, arity 10793 ]; 10794 10795 if (data) { 10796 mergeData(newData, data); 10797 } 10798 func = newData[0]; 10799 bitmask = newData[1]; 10800 thisArg = newData[2]; 10801 partials = newData[3]; 10802 holders = newData[4]; 10803 arity = newData[9] = newData[9] === undefined 10804 ? (isBindKey ? 0 : func.length) 10805 : nativeMax(newData[9] - length, 0); 10806 10807 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 10808 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 10809 } 10810 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 10811 var result = createBind(func, bitmask, thisArg); 10812 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 10813 result = createCurry(func, bitmask, arity); 10814 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 10815 result = createPartial(func, bitmask, thisArg, partials); 10816 } else { 10817 result = createHybrid.apply(undefined, newData); 10818 } 10819 var setter = data ? baseSetData : setData; 10820 return setWrapToString(setter(result, newData), func, bitmask); 10821 } 10822 10823 /** 10824 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 10825 * of source objects to the destination object for all destination properties 10826 * that resolve to `undefined`. 10827 * 10828 * @private 10829 * @param {*} objValue The destination value. 10830 * @param {*} srcValue The source value. 10831 * @param {string} key The key of the property to assign. 10832 * @param {Object} object The parent object of `objValue`. 10833 * @returns {*} Returns the value to assign. 10834 */ 10835 function customDefaultsAssignIn(objValue, srcValue, key, object) { 10836 if (objValue === undefined || 10837 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 10838 return srcValue; 10839 } 10840 return objValue; 10841 } 10842 10843 /** 10844 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 10845 * objects into destination objects that are passed thru. 10846 * 10847 * @private 10848 * @param {*} objValue The destination value. 10849 * @param {*} srcValue The source value. 10850 * @param {string} key The key of the property to merge. 10851 * @param {Object} object The parent object of `objValue`. 10852 * @param {Object} source The parent object of `srcValue`. 10853 * @param {Object} [stack] Tracks traversed source values and their merged 10854 * counterparts. 10855 * @returns {*} Returns the value to assign. 10856 */ 10857 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 10858 if (isObject(objValue) && isObject(srcValue)) { 10859 // Recursively merge objects and arrays (susceptible to call stack limits). 10860 stack.set(srcValue, objValue); 10861 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 10862 stack['delete'](srcValue); 10863 } 10864 return objValue; 10865 } 10866 10867 /** 10868 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 10869 * objects. 10870 * 10871 * @private 10872 * @param {*} value The value to inspect. 10873 * @param {string} key The key of the property to inspect. 10874 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 10875 */ 10876 function customOmitClone(value) { 10877 return isPlainObject(value) ? undefined : value; 10878 } 10879 10880 /** 10881 * A specialized version of `baseIsEqualDeep` for arrays with support for 10882 * partial deep comparisons. 10883 * 10884 * @private 10885 * @param {Array} array The array to compare. 10886 * @param {Array} other The other array to compare. 10887 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 10888 * @param {Function} customizer The function to customize comparisons. 10889 * @param {Function} equalFunc The function to determine equivalents of values. 10890 * @param {Object} stack Tracks traversed `array` and `other` objects. 10891 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 10892 */ 10893 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 10894 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 10895 arrLength = array.length, 10896 othLength = other.length; 10897 10898 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 10899 return false; 10900 } 10901 // Check that cyclic values are equal. 10902 var arrStacked = stack.get(array); 10903 var othStacked = stack.get(other); 10904 if (arrStacked && othStacked) { 10905 return arrStacked == other && othStacked == array; 10906 } 10907 var index = -1, 10908 result = true, 10909 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 10910 10911 stack.set(array, other); 10912 stack.set(other, array); 10913 10914 // Ignore non-index properties. 10915 while (++index < arrLength) { 10916 var arrValue = array[index], 10917 othValue = other[index]; 10918 10919 if (customizer) { 10920 var compared = isPartial 10921 ? customizer(othValue, arrValue, index, other, array, stack) 10922 : customizer(arrValue, othValue, index, array, other, stack); 10923 } 10924 if (compared !== undefined) { 10925 if (compared) { 10926 continue; 10927 } 10928 result = false; 10929 break; 10930 } 10931 // Recursively compare arrays (susceptible to call stack limits). 10932 if (seen) { 10933 if (!arraySome(other, function(othValue, othIndex) { 10934 if (!cacheHas(seen, othIndex) && 10935 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 10936 return seen.push(othIndex); 10937 } 10938 })) { 10939 result = false; 10940 break; 10941 } 10942 } else if (!( 10943 arrValue === othValue || 10944 equalFunc(arrValue, othValue, bitmask, customizer, stack) 10945 )) { 10946 result = false; 10947 break; 10948 } 10949 } 10950 stack['delete'](array); 10951 stack['delete'](other); 10952 return result; 10953 } 10954 10955 /** 10956 * A specialized version of `baseIsEqualDeep` for comparing objects of 10957 * the same `toStringTag`. 10958 * 10959 * **Note:** This function only supports comparing values with tags of 10960 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 10961 * 10962 * @private 10963 * @param {Object} object The object to compare. 10964 * @param {Object} other The other object to compare. 10965 * @param {string} tag The `toStringTag` of the objects to compare. 10966 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 10967 * @param {Function} customizer The function to customize comparisons. 10968 * @param {Function} equalFunc The function to determine equivalents of values. 10969 * @param {Object} stack Tracks traversed `object` and `other` objects. 10970 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 10971 */ 10972 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 10973 switch (tag) { 10974 case dataViewTag: 10975 if ((object.byteLength != other.byteLength) || 10976 (object.byteOffset != other.byteOffset)) { 10977 return false; 10978 } 10979 object = object.buffer; 10980 other = other.buffer; 10981 10982 case arrayBufferTag: 10983 if ((object.byteLength != other.byteLength) || 10984 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 10985 return false; 10986 } 10987 return true; 10988 10989 case boolTag: 10990 case dateTag: 10991 case numberTag: 10992 // Coerce booleans to `1` or `0` and dates to milliseconds. 10993 // Invalid dates are coerced to `NaN`. 10994 return eq(+object, +other); 10995 10996 case errorTag: 10997 return object.name == other.name && object.message == other.message; 10998 10999 case regexpTag: 11000 case stringTag: 11001 // Coerce regexes to strings and treat strings, primitives and objects, 11002 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 11003 // for more details. 11004 return object == (other + ''); 11005 11006 case mapTag: 11007 var convert = mapToArray; 11008 11009 case setTag: 11010 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 11011 convert || (convert = setToArray); 11012 11013 if (object.size != other.size && !isPartial) { 11014 return false; 11015 } 11016 // Assume cyclic values are equal. 11017 var stacked = stack.get(object); 11018 if (stacked) { 11019 return stacked == other; 11020 } 11021 bitmask |= COMPARE_UNORDERED_FLAG; 11022 11023 // Recursively compare objects (susceptible to call stack limits). 11024 stack.set(object, other); 11025 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 11026 stack['delete'](object); 11027 return result; 11028 11029 case symbolTag: 11030 if (symbolValueOf) { 11031 return symbolValueOf.call(object) == symbolValueOf.call(other); 11032 } 11033 } 11034 return false; 11035 } 11036 11037 /** 11038 * A specialized version of `baseIsEqualDeep` for objects with support for 11039 * partial deep comparisons. 11040 * 11041 * @private 11042 * @param {Object} object The object to compare. 11043 * @param {Object} other The other object to compare. 11044 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 11045 * @param {Function} customizer The function to customize comparisons. 11046 * @param {Function} equalFunc The function to determine equivalents of values. 11047 * @param {Object} stack Tracks traversed `object` and `other` objects. 11048 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 11049 */ 11050 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 11051 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 11052 objProps = getAllKeys(object), 11053 objLength = objProps.length, 11054 othProps = getAllKeys(other), 11055 othLength = othProps.length; 11056 11057 if (objLength != othLength && !isPartial) { 11058 return false; 11059 } 11060 var index = objLength; 11061 while (index--) { 11062 var key = objProps[index]; 11063 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 11064 return false; 11065 } 11066 } 11067 // Check that cyclic values are equal. 11068 var objStacked = stack.get(object); 11069 var othStacked = stack.get(other); 11070 if (objStacked && othStacked) { 11071 return objStacked == other && othStacked == object; 11072 } 11073 var result = true; 11074 stack.set(object, other); 11075 stack.set(other, object); 11076 11077 var skipCtor = isPartial; 11078 while (++index < objLength) { 11079 key = objProps[index]; 11080 var objValue = object[key], 11081 othValue = other[key]; 11082 11083 if (customizer) { 11084 var compared = isPartial 11085 ? customizer(othValue, objValue, key, other, object, stack) 11086 : customizer(objValue, othValue, key, object, other, stack); 11087 } 11088 // Recursively compare objects (susceptible to call stack limits). 11089 if (!(compared === undefined 11090 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 11091 : compared 11092 )) { 11093 result = false; 11094 break; 11095 } 11096 skipCtor || (skipCtor = key == 'constructor'); 11097 } 11098 if (result && !skipCtor) { 11099 var objCtor = object.constructor, 11100 othCtor = other.constructor; 11101 11102 // Non `Object` object instances with different constructors are not equal. 11103 if (objCtor != othCtor && 11104 ('constructor' in object && 'constructor' in other) && 11105 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 11106 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 11107 result = false; 11108 } 11109 } 11110 stack['delete'](object); 11111 stack['delete'](other); 11112 return result; 11113 } 11114 11115 /** 11116 * A specialized version of `baseRest` which flattens the rest array. 11117 * 11118 * @private 11119 * @param {Function} func The function to apply a rest parameter to. 11120 * @returns {Function} Returns the new function. 11121 */ 11122 function flatRest(func) { 11123 return setToString(overRest(func, undefined, flatten), func + ''); 11124 } 11125 11126 /** 11127 * Creates an array of own enumerable property names and symbols of `object`. 11128 * 11129 * @private 11130 * @param {Object} object The object to query. 11131 * @returns {Array} Returns the array of property names and symbols. 11132 */ 11133 function getAllKeys(object) { 11134 return baseGetAllKeys(object, keys, getSymbols); 11135 } 11136 11137 /** 11138 * Creates an array of own and inherited enumerable property names and 11139 * symbols of `object`. 11140 * 11141 * @private 11142 * @param {Object} object The object to query. 11143 * @returns {Array} Returns the array of property names and symbols. 11144 */ 11145 function getAllKeysIn(object) { 11146 return baseGetAllKeys(object, keysIn, getSymbolsIn); 11147 } 11148 11149 /** 11150 * Gets metadata for `func`. 11151 * 11152 * @private 11153 * @param {Function} func The function to query. 11154 * @returns {*} Returns the metadata for `func`. 11155 */ 11156 var getData = !metaMap ? noop : function(func) { 11157 return metaMap.get(func); 11158 }; 11159 11160 /** 11161 * Gets the name of `func`. 11162 * 11163 * @private 11164 * @param {Function} func The function to query. 11165 * @returns {string} Returns the function name. 11166 */ 11167 function getFuncName(func) { 11168 var result = (func.name + ''), 11169 array = realNames[result], 11170 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 11171 11172 while (length--) { 11173 var data = array[length], 11174 otherFunc = data.func; 11175 if (otherFunc == null || otherFunc == func) { 11176 return data.name; 11177 } 11178 } 11179 return result; 11180 } 11181 11182 /** 11183 * Gets the argument placeholder value for `func`. 11184 * 11185 * @private 11186 * @param {Function} func The function to inspect. 11187 * @returns {*} Returns the placeholder value. 11188 */ 11189 function getHolder(func) { 11190 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 11191 return object.placeholder; 11192 } 11193 11194 /** 11195 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 11196 * this function returns the custom method, otherwise it returns `baseIteratee`. 11197 * If arguments are provided, the chosen function is invoked with them and 11198 * its result is returned. 11199 * 11200 * @private 11201 * @param {*} [value] The value to convert to an iteratee. 11202 * @param {number} [arity] The arity of the created iteratee. 11203 * @returns {Function} Returns the chosen function or its result. 11204 */ 11205 function getIteratee() { 11206 var result = lodash.iteratee || iteratee; 11207 result = result === iteratee ? baseIteratee : result; 11208 return arguments.length ? result(arguments[0], arguments[1]) : result; 11209 } 11210 11211 /** 11212 * Gets the data for `map`. 11213 * 11214 * @private 11215 * @param {Object} map The map to query. 11216 * @param {string} key The reference key. 11217 * @returns {*} Returns the map data. 11218 */ 11219 function getMapData(map, key) { 11220 var data = map.__data__; 11221 return isKeyable(key) 11222 ? data[typeof key == 'string' ? 'string' : 'hash'] 11223 : data.map; 11224 } 11225 11226 /** 11227 * Gets the property names, values, and compare flags of `object`. 11228 * 11229 * @private 11230 * @param {Object} object The object to query. 11231 * @returns {Array} Returns the match data of `object`. 11232 */ 11233 function getMatchData(object) { 11234 var result = keys(object), 11235 length = result.length; 11236 11237 while (length--) { 11238 var key = result[length], 11239 value = object[key]; 11240 11241 result[length] = [key, value, isStrictComparable(value)]; 11242 } 11243 return result; 11244 } 11245 11246 /** 11247 * Gets the native function at `key` of `object`. 11248 * 11249 * @private 11250 * @param {Object} object The object to query. 11251 * @param {string} key The key of the method to get. 11252 * @returns {*} Returns the function if it's native, else `undefined`. 11253 */ 11254 function getNative(object, key) { 11255 var value = getValue(object, key); 11256 return baseIsNative(value) ? value : undefined; 11257 } 11258 11259 /** 11260 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 11261 * 11262 * @private 11263 * @param {*} value The value to query. 11264 * @returns {string} Returns the raw `toStringTag`. 11265 */ 11266 function getRawTag(value) { 11267 var isOwn = hasOwnProperty.call(value, symToStringTag), 11268 tag = value[symToStringTag]; 11269 11270 try { 11271 value[symToStringTag] = undefined; 11272 var unmasked = true; 11273 } catch (e) {} 11274 11275 var result = nativeObjectToString.call(value); 11276 if (unmasked) { 11277 if (isOwn) { 11278 value[symToStringTag] = tag; 11279 } else { 11280 delete value[symToStringTag]; 11281 } 11282 } 11283 return result; 11284 } 11285 11286 /** 11287 * Creates an array of the own enumerable symbols of `object`. 11288 * 11289 * @private 11290 * @param {Object} object The object to query. 11291 * @returns {Array} Returns the array of symbols. 11292 */ 11293 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 11294 if (object == null) { 11295 return []; 11296 } 11297 object = Object(object); 11298 return arrayFilter(nativeGetSymbols(object), function(symbol) { 11299 return propertyIsEnumerable.call(object, symbol); 11300 }); 11301 }; 11302 11303 /** 11304 * Creates an array of the own and inherited enumerable symbols of `object`. 11305 * 11306 * @private 11307 * @param {Object} object The object to query. 11308 * @returns {Array} Returns the array of symbols. 11309 */ 11310 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 11311 var result = []; 11312 while (object) { 11313 arrayPush(result, getSymbols(object)); 11314 object = getPrototype(object); 11315 } 11316 return result; 11317 }; 11318 11319 /** 11320 * Gets the `toStringTag` of `value`. 11321 * 11322 * @private 11323 * @param {*} value The value to query. 11324 * @returns {string} Returns the `toStringTag`. 11325 */ 11326 var getTag = baseGetTag; 11327 11328 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 11329 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 11330 (Map && getTag(new Map) != mapTag) || 11331 (Promise && getTag(Promise.resolve()) != promiseTag) || 11332 (Set && getTag(new Set) != setTag) || 11333 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 11334 getTag = function(value) { 11335 var result = baseGetTag(value), 11336 Ctor = result == objectTag ? value.constructor : undefined, 11337 ctorString = Ctor ? toSource(Ctor) : ''; 11338 11339 if (ctorString) { 11340 switch (ctorString) { 11341 case dataViewCtorString: return dataViewTag; 11342 case mapCtorString: return mapTag; 11343 case promiseCtorString: return promiseTag; 11344 case setCtorString: return setTag; 11345 case weakMapCtorString: return weakMapTag; 11346 } 11347 } 11348 return result; 11349 }; 11350 } 11351 11352 /** 11353 * Gets the view, applying any `transforms` to the `start` and `end` positions. 11354 * 11355 * @private 11356 * @param {number} start The start of the view. 11357 * @param {number} end The end of the view. 11358 * @param {Array} transforms The transformations to apply to the view. 11359 * @returns {Object} Returns an object containing the `start` and `end` 11360 * positions of the view. 11361 */ 11362 function getView(start, end, transforms) { 11363 var index = -1, 11364 length = transforms.length; 11365 11366 while (++index < length) { 11367 var data = transforms[index], 11368 size = data.size; 11369 11370 switch (data.type) { 11371 case 'drop': start += size; break; 11372 case 'dropRight': end -= size; break; 11373 case 'take': end = nativeMin(end, start + size); break; 11374 case 'takeRight': start = nativeMax(start, end - size); break; 11375 } 11376 } 11377 return { 'start': start, 'end': end }; 11378 } 11379 11380 /** 11381 * Extracts wrapper details from the `source` body comment. 11382 * 11383 * @private 11384 * @param {string} source The source to inspect. 11385 * @returns {Array} Returns the wrapper details. 11386 */ 11387 function getWrapDetails(source) { 11388 var match = source.match(reWrapDetails); 11389 return match ? match[1].split(reSplitDetails) : []; 11390 } 11391 11392 /** 11393 * Checks if `path` exists on `object`. 11394 * 11395 * @private 11396 * @param {Object} object The object to query. 11397 * @param {Array|string} path The path to check. 11398 * @param {Function} hasFunc The function to check properties. 11399 * @returns {boolean} Returns `true` if `path` exists, else `false`. 11400 */ 11401 function hasPath(object, path, hasFunc) { 11402 path = castPath(path, object); 11403 11404 var index = -1, 11405 length = path.length, 11406 result = false; 11407 11408 while (++index < length) { 11409 var key = toKey(path[index]); 11410 if (!(result = object != null && hasFunc(object, key))) { 11411 break; 11412 } 11413 object = object[key]; 11414 } 11415 if (result || ++index != length) { 11416 return result; 11417 } 11418 length = object == null ? 0 : object.length; 11419 return !!length && isLength(length) && isIndex(key, length) && 11420 (isArray(object) || isArguments(object)); 11421 } 11422 11423 /** 11424 * Initializes an array clone. 11425 * 11426 * @private 11427 * @param {Array} array The array to clone. 11428 * @returns {Array} Returns the initialized clone. 11429 */ 11430 function initCloneArray(array) { 11431 var length = array.length, 11432 result = new array.constructor(length); 11433 11434 // Add properties assigned by `RegExp#exec`. 11435 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 11436 result.index = array.index; 11437 result.input = array.input; 11438 } 11439 return result; 11440 } 11441 11442 /** 11443 * Initializes an object clone. 11444 * 11445 * @private 11446 * @param {Object} object The object to clone. 11447 * @returns {Object} Returns the initialized clone. 11448 */ 11449 function initCloneObject(object) { 11450 return (typeof object.constructor == 'function' && !isPrototype(object)) 11451 ? baseCreate(getPrototype(object)) 11452 : {}; 11453 } 11454 11455 /** 11456 * Initializes an object clone based on its `toStringTag`. 11457 * 11458 * **Note:** This function only supports cloning values with tags of 11459 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 11460 * 11461 * @private 11462 * @param {Object} object The object to clone. 11463 * @param {string} tag The `toStringTag` of the object to clone. 11464 * @param {boolean} [isDeep] Specify a deep clone. 11465 * @returns {Object} Returns the initialized clone. 11466 */ 11467 function initCloneByTag(object, tag, isDeep) { 11468 var Ctor = object.constructor; 11469 switch (tag) { 11470 case arrayBufferTag: 11471 return cloneArrayBuffer(object); 11472 11473 case boolTag: 11474 case dateTag: 11475 return new Ctor(+object); 11476 11477 case dataViewTag: 11478 return cloneDataView(object, isDeep); 11479 11480 case float32Tag: case float64Tag: 11481 case int8Tag: case int16Tag: case int32Tag: 11482 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 11483 return cloneTypedArray(object, isDeep); 11484 11485 case mapTag: 11486 return new Ctor; 11487 11488 case numberTag: 11489 case stringTag: 11490 return new Ctor(object); 11491 11492 case regexpTag: 11493 return cloneRegExp(object); 11494 11495 case setTag: 11496 return new Ctor; 11497 11498 case symbolTag: 11499 return cloneSymbol(object); 11500 } 11501 } 11502 11503 /** 11504 * Inserts wrapper `details` in a comment at the top of the `source` body. 11505 * 11506 * @private 11507 * @param {string} source The source to modify. 11508 * @returns {Array} details The details to insert. 11509 * @returns {string} Returns the modified source. 11510 */ 11511 function insertWrapDetails(source, details) { 11512 var length = details.length; 11513 if (!length) { 11514 return source; 11515 } 11516 var lastIndex = length - 1; 11517 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 11518 details = details.join(length > 2 ? ', ' : ' '); 11519 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 11520 } 11521 11522 /** 11523 * Checks if `value` is a flattenable `arguments` object or array. 11524 * 11525 * @private 11526 * @param {*} value The value to check. 11527 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 11528 */ 11529 function isFlattenable(value) { 11530 return isArray(value) || isArguments(value) || 11531 !!(spreadableSymbol && value && value[spreadableSymbol]); 11532 } 11533 11534 /** 11535 * Checks if `value` is a valid array-like index. 11536 * 11537 * @private 11538 * @param {*} value The value to check. 11539 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 11540 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 11541 */ 11542 function isIndex(value, length) { 11543 var type = typeof value; 11544 length = length == null ? MAX_SAFE_INTEGER : length; 11545 11546 return !!length && 11547 (type == 'number' || 11548 (type != 'symbol' && reIsUint.test(value))) && 11549 (value > -1 && value % 1 == 0 && value < length); 11550 } 11551 11552 /** 11553 * Checks if the given arguments are from an iteratee call. 11554 * 11555 * @private 11556 * @param {*} value The potential iteratee value argument. 11557 * @param {*} index The potential iteratee index or key argument. 11558 * @param {*} object The potential iteratee object argument. 11559 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 11560 * else `false`. 11561 */ 11562 function isIterateeCall(value, index, object) { 11563 if (!isObject(object)) { 11564 return false; 11565 } 11566 var type = typeof index; 11567 if (type == 'number' 11568 ? (isArrayLike(object) && isIndex(index, object.length)) 11569 : (type == 'string' && index in object) 11570 ) { 11571 return eq(object[index], value); 11572 } 11573 return false; 11574 } 11575 11576 /** 11577 * Checks if `value` is a property name and not a property path. 11578 * 11579 * @private 11580 * @param {*} value The value to check. 11581 * @param {Object} [object] The object to query keys on. 11582 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 11583 */ 11584 function isKey(value, object) { 11585 if (isArray(value)) { 11586 return false; 11587 } 11588 var type = typeof value; 11589 if (type == 'number' || type == 'symbol' || type == 'boolean' || 11590 value == null || isSymbol(value)) { 11591 return true; 11592 } 11593 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 11594 (object != null && value in Object(object)); 11595 } 11596 11597 /** 11598 * Checks if `value` is suitable for use as unique object key. 11599 * 11600 * @private 11601 * @param {*} value The value to check. 11602 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 11603 */ 11604 function isKeyable(value) { 11605 var type = typeof value; 11606 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 11607 ? (value !== '__proto__') 11608 : (value === null); 11609 } 11610 11611 /** 11612 * Checks if `func` has a lazy counterpart. 11613 * 11614 * @private 11615 * @param {Function} func The function to check. 11616 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 11617 * else `false`. 11618 */ 11619 function isLaziable(func) { 11620 var funcName = getFuncName(func), 11621 other = lodash[funcName]; 11622 11623 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 11624 return false; 11625 } 11626 if (func === other) { 11627 return true; 11628 } 11629 var data = getData(other); 11630 return !!data && func === data[0]; 11631 } 11632 11633 /** 11634 * Checks if `func` has its source masked. 11635 * 11636 * @private 11637 * @param {Function} func The function to check. 11638 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 11639 */ 11640 function isMasked(func) { 11641 return !!maskSrcKey && (maskSrcKey in func); 11642 } 11643 11644 /** 11645 * Checks if `func` is capable of being masked. 11646 * 11647 * @private 11648 * @param {*} value The value to check. 11649 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 11650 */ 11651 var isMaskable = coreJsData ? isFunction : stubFalse; 11652 11653 /** 11654 * Checks if `value` is likely a prototype object. 11655 * 11656 * @private 11657 * @param {*} value The value to check. 11658 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 11659 */ 11660 function isPrototype(value) { 11661 var Ctor = value && value.constructor, 11662 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 11663 11664 return value === proto; 11665 } 11666 11667 /** 11668 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 11669 * 11670 * @private 11671 * @param {*} value The value to check. 11672 * @returns {boolean} Returns `true` if `value` if suitable for strict 11673 * equality comparisons, else `false`. 11674 */ 11675 function isStrictComparable(value) { 11676 return value === value && !isObject(value); 11677 } 11678 11679 /** 11680 * A specialized version of `matchesProperty` for source values suitable 11681 * for strict equality comparisons, i.e. `===`. 11682 * 11683 * @private 11684 * @param {string} key The key of the property to get. 11685 * @param {*} srcValue The value to match. 11686 * @returns {Function} Returns the new spec function. 11687 */ 11688 function matchesStrictComparable(key, srcValue) { 11689 return function(object) { 11690 if (object == null) { 11691 return false; 11692 } 11693 return object[key] === srcValue && 11694 (srcValue !== undefined || (key in Object(object))); 11695 }; 11696 } 11697 11698 /** 11699 * A specialized version of `_.memoize` which clears the memoized function's 11700 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 11701 * 11702 * @private 11703 * @param {Function} func The function to have its output memoized. 11704 * @returns {Function} Returns the new memoized function. 11705 */ 11706 function memoizeCapped(func) { 11707 var result = memoize(func, function(key) { 11708 if (cache.size === MAX_MEMOIZE_SIZE) { 11709 cache.clear(); 11710 } 11711 return key; 11712 }); 11713 11714 var cache = result.cache; 11715 return result; 11716 } 11717 11718 /** 11719 * Merges the function metadata of `source` into `data`. 11720 * 11721 * Merging metadata reduces the number of wrappers used to invoke a function. 11722 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 11723 * may be applied regardless of execution order. Methods like `_.ary` and 11724 * `_.rearg` modify function arguments, making the order in which they are 11725 * executed important, preventing the merging of metadata. However, we make 11726 * an exception for a safe combined case where curried functions have `_.ary` 11727 * and or `_.rearg` applied. 11728 * 11729 * @private 11730 * @param {Array} data The destination metadata. 11731 * @param {Array} source The source metadata. 11732 * @returns {Array} Returns `data`. 11733 */ 11734 function mergeData(data, source) { 11735 var bitmask = data[1], 11736 srcBitmask = source[1], 11737 newBitmask = bitmask | srcBitmask, 11738 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 11739 11740 var isCombo = 11741 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 11742 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 11743 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 11744 11745 // Exit early if metadata can't be merged. 11746 if (!(isCommon || isCombo)) { 11747 return data; 11748 } 11749 // Use source `thisArg` if available. 11750 if (srcBitmask & WRAP_BIND_FLAG) { 11751 data[2] = source[2]; 11752 // Set when currying a bound function. 11753 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 11754 } 11755 // Compose partial arguments. 11756 var value = source[3]; 11757 if (value) { 11758 var partials = data[3]; 11759 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 11760 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 11761 } 11762 // Compose partial right arguments. 11763 value = source[5]; 11764 if (value) { 11765 partials = data[5]; 11766 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 11767 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 11768 } 11769 // Use source `argPos` if available. 11770 value = source[7]; 11771 if (value) { 11772 data[7] = value; 11773 } 11774 // Use source `ary` if it's smaller. 11775 if (srcBitmask & WRAP_ARY_FLAG) { 11776 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 11777 } 11778 // Use source `arity` if one is not provided. 11779 if (data[9] == null) { 11780 data[9] = source[9]; 11781 } 11782 // Use source `func` and merge bitmasks. 11783 data[0] = source[0]; 11784 data[1] = newBitmask; 11785 11786 return data; 11787 } 11788 11789 /** 11790 * This function is like 11791 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 11792 * except that it includes inherited enumerable properties. 11793 * 11794 * @private 11795 * @param {Object} object The object to query. 11796 * @returns {Array} Returns the array of property names. 11797 */ 11798 function nativeKeysIn(object) { 11799 var result = []; 11800 if (object != null) { 11801 for (var key in Object(object)) { 11802 result.push(key); 11803 } 11804 } 11805 return result; 11806 } 11807 11808 /** 11809 * Converts `value` to a string using `Object.prototype.toString`. 11810 * 11811 * @private 11812 * @param {*} value The value to convert. 11813 * @returns {string} Returns the converted string. 11814 */ 11815 function objectToString(value) { 11816 return nativeObjectToString.call(value); 11817 } 11818 11819 /** 11820 * A specialized version of `baseRest` which transforms the rest array. 11821 * 11822 * @private 11823 * @param {Function} func The function to apply a rest parameter to. 11824 * @param {number} [start=func.length-1] The start position of the rest parameter. 11825 * @param {Function} transform The rest array transform. 11826 * @returns {Function} Returns the new function. 11827 */ 11828 function overRest(func, start, transform) { 11829 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 11830 return function() { 11831 var args = arguments, 11832 index = -1, 11833 length = nativeMax(args.length - start, 0), 11834 array = Array(length); 11835 11836 while (++index < length) { 11837 array[index] = args[start + index]; 11838 } 11839 index = -1; 11840 var otherArgs = Array(start + 1); 11841 while (++index < start) { 11842 otherArgs[index] = args[index]; 11843 } 11844 otherArgs[start] = transform(array); 11845 return apply(func, this, otherArgs); 11846 }; 11847 } 11848 11849 /** 11850 * Gets the parent value at `path` of `object`. 11851 * 11852 * @private 11853 * @param {Object} object The object to query. 11854 * @param {Array} path The path to get the parent value of. 11855 * @returns {*} Returns the parent value. 11856 */ 11857 function parent(object, path) { 11858 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 11859 } 11860 11861 /** 11862 * Reorder `array` according to the specified indexes where the element at 11863 * the first index is assigned as the first element, the element at 11864 * the second index is assigned as the second element, and so on. 11865 * 11866 * @private 11867 * @param {Array} array The array to reorder. 11868 * @param {Array} indexes The arranged array indexes. 11869 * @returns {Array} Returns `array`. 11870 */ 11871 function reorder(array, indexes) { 11872 var arrLength = array.length, 11873 length = nativeMin(indexes.length, arrLength), 11874 oldArray = copyArray(array); 11875 11876 while (length--) { 11877 var index = indexes[length]; 11878 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 11879 } 11880 return array; 11881 } 11882 11883 /** 11884 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 11885 * 11886 * @private 11887 * @param {Object} object The object to query. 11888 * @param {string} key The key of the property to get. 11889 * @returns {*} Returns the property value. 11890 */ 11891 function safeGet(object, key) { 11892 if (key === 'constructor' && typeof object[key] === 'function') { 11893 return; 11894 } 11895 11896 if (key == '__proto__') { 11897 return; 11898 } 11899 11900 return object[key]; 11901 } 11902 11903 /** 11904 * Sets metadata for `func`. 11905 * 11906 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 11907 * period of time, it will trip its breaker and transition to an identity 11908 * function to avoid garbage collection pauses in V8. See 11909 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 11910 * for more details. 11911 * 11912 * @private 11913 * @param {Function} func The function to associate metadata with. 11914 * @param {*} data The metadata. 11915 * @returns {Function} Returns `func`. 11916 */ 11917 var setData = shortOut(baseSetData); 11918 11919 /** 11920 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 11921 * 11922 * @private 11923 * @param {Function} func The function to delay. 11924 * @param {number} wait The number of milliseconds to delay invocation. 11925 * @returns {number|Object} Returns the timer id or timeout object. 11926 */ 11927 var setTimeout = ctxSetTimeout || function(func, wait) { 11928 return root.setTimeout(func, wait); 11929 }; 11930 11931 /** 11932 * Sets the `toString` method of `func` to return `string`. 11933 * 11934 * @private 11935 * @param {Function} func The function to modify. 11936 * @param {Function} string The `toString` result. 11937 * @returns {Function} Returns `func`. 11938 */ 11939 var setToString = shortOut(baseSetToString); 11940 11941 /** 11942 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 11943 * with wrapper details in a comment at the top of the source body. 11944 * 11945 * @private 11946 * @param {Function} wrapper The function to modify. 11947 * @param {Function} reference The reference function. 11948 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 11949 * @returns {Function} Returns `wrapper`. 11950 */ 11951 function setWrapToString(wrapper, reference, bitmask) { 11952 var source = (reference + ''); 11953 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 11954 } 11955 11956 /** 11957 * Creates a function that'll short out and invoke `identity` instead 11958 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 11959 * milliseconds. 11960 * 11961 * @private 11962 * @param {Function} func The function to restrict. 11963 * @returns {Function} Returns the new shortable function. 11964 */ 11965 function shortOut(func) { 11966 var count = 0, 11967 lastCalled = 0; 11968 11969 return function() { 11970 var stamp = nativeNow(), 11971 remaining = HOT_SPAN - (stamp - lastCalled); 11972 11973 lastCalled = stamp; 11974 if (remaining > 0) { 11975 if (++count >= HOT_COUNT) { 11976 return arguments[0]; 11977 } 11978 } else { 11979 count = 0; 11980 } 11981 return func.apply(undefined, arguments); 11982 }; 11983 } 11984 11985 /** 11986 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 11987 * 11988 * @private 11989 * @param {Array} array The array to shuffle. 11990 * @param {number} [size=array.length] The size of `array`. 11991 * @returns {Array} Returns `array`. 11992 */ 11993 function shuffleSelf(array, size) { 11994 var index = -1, 11995 length = array.length, 11996 lastIndex = length - 1; 11997 11998 size = size === undefined ? length : size; 11999 while (++index < size) { 12000 var rand = baseRandom(index, lastIndex), 12001 value = array[rand]; 12002 12003 array[rand] = array[index]; 12004 array[index] = value; 12005 } 12006 array.length = size; 12007 return array; 12008 } 12009 12010 /** 12011 * Converts `string` to a property path array. 12012 * 12013 * @private 12014 * @param {string} string The string to convert. 12015 * @returns {Array} Returns the property path array. 12016 */ 12017 var stringToPath = memoizeCapped(function(string) { 12018 var result = []; 12019 if (string.charCodeAt(0) === 46 /* . */) { 12020 result.push(''); 12021 } 12022 string.replace(rePropName, function(match, number, quote, subString) { 12023 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 12024 }); 12025 return result; 12026 }); 12027 12028 /** 12029 * Converts `value` to a string key if it's not a string or symbol. 12030 * 12031 * @private 12032 * @param {*} value The value to inspect. 12033 * @returns {string|symbol} Returns the key. 12034 */ 12035 function toKey(value) { 12036 if (typeof value == 'string' || isSymbol(value)) { 12037 return value; 12038 } 12039 var result = (value + ''); 12040 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 12041 } 12042 12043 /** 12044 * Converts `func` to its source code. 12045 * 12046 * @private 12047 * @param {Function} func The function to convert. 12048 * @returns {string} Returns the source code. 12049 */ 12050 function toSource(func) { 12051 if (func != null) { 12052 try { 12053 return funcToString.call(func); 12054 } catch (e) {} 12055 try { 12056 return (func + ''); 12057 } catch (e) {} 12058 } 12059 return ''; 12060 } 12061 12062 /** 12063 * Updates wrapper `details` based on `bitmask` flags. 12064 * 12065 * @private 12066 * @returns {Array} details The details to modify. 12067 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 12068 * @returns {Array} Returns `details`. 12069 */ 12070 function updateWrapDetails(details, bitmask) { 12071 arrayEach(wrapFlags, function(pair) { 12072 var value = '_.' + pair[0]; 12073 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 12074 details.push(value); 12075 } 12076 }); 12077 return details.sort(); 12078 } 12079 12080 /** 12081 * Creates a clone of `wrapper`. 12082 * 12083 * @private 12084 * @param {Object} wrapper The wrapper to clone. 12085 * @returns {Object} Returns the cloned wrapper. 12086 */ 12087 function wrapperClone(wrapper) { 12088 if (wrapper instanceof LazyWrapper) { 12089 return wrapper.clone(); 12090 } 12091 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 12092 result.__actions__ = copyArray(wrapper.__actions__); 12093 result.__index__ = wrapper.__index__; 12094 result.__values__ = wrapper.__values__; 12095 return result; 12096 } 12097 12098 /*------------------------------------------------------------------------*/ 12099 12100 /** 12101 * Creates an array of elements split into groups the length of `size`. 12102 * If `array` can't be split evenly, the final chunk will be the remaining 12103 * elements. 12104 * 12105 * @static 12106 * @memberOf _ 12107 * @since 3.0.0 12108 * @category Array 12109 * @param {Array} array The array to process. 12110 * @param {number} [size=1] The length of each chunk 12111 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12112 * @returns {Array} Returns the new array of chunks. 12113 * @example 12114 * 12115 * _.chunk(['a', 'b', 'c', 'd'], 2); 12116 * // => [['a', 'b'], ['c', 'd']] 12117 * 12118 * _.chunk(['a', 'b', 'c', 'd'], 3); 12119 * // => [['a', 'b', 'c'], ['d']] 12120 */ 12121 function chunk(array, size, guard) { 12122 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 12123 size = 1; 12124 } else { 12125 size = nativeMax(toInteger(size), 0); 12126 } 12127 var length = array == null ? 0 : array.length; 12128 if (!length || size < 1) { 12129 return []; 12130 } 12131 var index = 0, 12132 resIndex = 0, 12133 result = Array(nativeCeil(length / size)); 12134 12135 while (index < length) { 12136 result[resIndex++] = baseSlice(array, index, (index += size)); 12137 } 12138 return result; 12139 } 12140 12141 /** 12142 * Creates an array with all falsey values removed. The values `false`, `null`, 12143 * `0`, `""`, `undefined`, and `NaN` are falsey. 12144 * 12145 * @static 12146 * @memberOf _ 12147 * @since 0.1.0 12148 * @category Array 12149 * @param {Array} array The array to compact. 12150 * @returns {Array} Returns the new array of filtered values. 12151 * @example 12152 * 12153 * _.compact([0, 1, false, 2, '', 3]); 12154 * // => [1, 2, 3] 12155 */ 12156 function compact(array) { 12157 var index = -1, 12158 length = array == null ? 0 : array.length, 12159 resIndex = 0, 12160 result = []; 12161 12162 while (++index < length) { 12163 var value = array[index]; 12164 if (value) { 12165 result[resIndex++] = value; 12166 } 12167 } 12168 return result; 12169 } 12170 12171 /** 12172 * Creates a new array concatenating `array` with any additional arrays 12173 * and/or values. 12174 * 12175 * @static 12176 * @memberOf _ 12177 * @since 4.0.0 12178 * @category Array 12179 * @param {Array} array The array to concatenate. 12180 * @param {...*} [values] The values to concatenate. 12181 * @returns {Array} Returns the new concatenated array. 12182 * @example 12183 * 12184 * var array = [1]; 12185 * var other = _.concat(array, 2, [3], [[4]]); 12186 * 12187 * console.log(other); 12188 * // => [1, 2, 3, [4]] 12189 * 12190 * console.log(array); 12191 * // => [1] 12192 */ 12193 function concat() { 12194 var length = arguments.length; 12195 if (!length) { 12196 return []; 12197 } 12198 var args = Array(length - 1), 12199 array = arguments[0], 12200 index = length; 12201 12202 while (index--) { 12203 args[index - 1] = arguments[index]; 12204 } 12205 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 12206 } 12207 12208 /** 12209 * Creates an array of `array` values not included in the other given arrays 12210 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12211 * for equality comparisons. The order and references of result values are 12212 * determined by the first array. 12213 * 12214 * **Note:** Unlike `_.pullAll`, this method returns a new array. 12215 * 12216 * @static 12217 * @memberOf _ 12218 * @since 0.1.0 12219 * @category Array 12220 * @param {Array} array The array to inspect. 12221 * @param {...Array} [values] The values to exclude. 12222 * @returns {Array} Returns the new array of filtered values. 12223 * @see _.without, _.xor 12224 * @example 12225 * 12226 * _.difference([2, 1], [2, 3]); 12227 * // => [1] 12228 */ 12229 var difference = baseRest(function(array, values) { 12230 return isArrayLikeObject(array) 12231 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 12232 : []; 12233 }); 12234 12235 /** 12236 * This method is like `_.difference` except that it accepts `iteratee` which 12237 * is invoked for each element of `array` and `values` to generate the criterion 12238 * by which they're compared. The order and references of result values are 12239 * determined by the first array. The iteratee is invoked with one argument: 12240 * (value). 12241 * 12242 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 12243 * 12244 * @static 12245 * @memberOf _ 12246 * @since 4.0.0 12247 * @category Array 12248 * @param {Array} array The array to inspect. 12249 * @param {...Array} [values] The values to exclude. 12250 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 12251 * @returns {Array} Returns the new array of filtered values. 12252 * @example 12253 * 12254 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 12255 * // => [1.2] 12256 * 12257 * // The `_.property` iteratee shorthand. 12258 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 12259 * // => [{ 'x': 2 }] 12260 */ 12261 var differenceBy = baseRest(function(array, values) { 12262 var iteratee = last(values); 12263 if (isArrayLikeObject(iteratee)) { 12264 iteratee = undefined; 12265 } 12266 return isArrayLikeObject(array) 12267 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 12268 : []; 12269 }); 12270 12271 /** 12272 * This method is like `_.difference` except that it accepts `comparator` 12273 * which is invoked to compare elements of `array` to `values`. The order and 12274 * references of result values are determined by the first array. The comparator 12275 * is invoked with two arguments: (arrVal, othVal). 12276 * 12277 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 12278 * 12279 * @static 12280 * @memberOf _ 12281 * @since 4.0.0 12282 * @category Array 12283 * @param {Array} array The array to inspect. 12284 * @param {...Array} [values] The values to exclude. 12285 * @param {Function} [comparator] The comparator invoked per element. 12286 * @returns {Array} Returns the new array of filtered values. 12287 * @example 12288 * 12289 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 12290 * 12291 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 12292 * // => [{ 'x': 2, 'y': 1 }] 12293 */ 12294 var differenceWith = baseRest(function(array, values) { 12295 var comparator = last(values); 12296 if (isArrayLikeObject(comparator)) { 12297 comparator = undefined; 12298 } 12299 return isArrayLikeObject(array) 12300 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 12301 : []; 12302 }); 12303 12304 /** 12305 * Creates a slice of `array` with `n` elements dropped from the beginning. 12306 * 12307 * @static 12308 * @memberOf _ 12309 * @since 0.5.0 12310 * @category Array 12311 * @param {Array} array The array to query. 12312 * @param {number} [n=1] The number of elements to drop. 12313 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12314 * @returns {Array} Returns the slice of `array`. 12315 * @example 12316 * 12317 * _.drop([1, 2, 3]); 12318 * // => [2, 3] 12319 * 12320 * _.drop([1, 2, 3], 2); 12321 * // => [3] 12322 * 12323 * _.drop([1, 2, 3], 5); 12324 * // => [] 12325 * 12326 * _.drop([1, 2, 3], 0); 12327 * // => [1, 2, 3] 12328 */ 12329 function drop(array, n, guard) { 12330 var length = array == null ? 0 : array.length; 12331 if (!length) { 12332 return []; 12333 } 12334 n = (guard || n === undefined) ? 1 : toInteger(n); 12335 return baseSlice(array, n < 0 ? 0 : n, length); 12336 } 12337 12338 /** 12339 * Creates a slice of `array` with `n` elements dropped from the end. 12340 * 12341 * @static 12342 * @memberOf _ 12343 * @since 3.0.0 12344 * @category Array 12345 * @param {Array} array The array to query. 12346 * @param {number} [n=1] The number of elements to drop. 12347 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12348 * @returns {Array} Returns the slice of `array`. 12349 * @example 12350 * 12351 * _.dropRight([1, 2, 3]); 12352 * // => [1, 2] 12353 * 12354 * _.dropRight([1, 2, 3], 2); 12355 * // => [1] 12356 * 12357 * _.dropRight([1, 2, 3], 5); 12358 * // => [] 12359 * 12360 * _.dropRight([1, 2, 3], 0); 12361 * // => [1, 2, 3] 12362 */ 12363 function dropRight(array, n, guard) { 12364 var length = array == null ? 0 : array.length; 12365 if (!length) { 12366 return []; 12367 } 12368 n = (guard || n === undefined) ? 1 : toInteger(n); 12369 n = length - n; 12370 return baseSlice(array, 0, n < 0 ? 0 : n); 12371 } 12372 12373 /** 12374 * Creates a slice of `array` excluding elements dropped from the end. 12375 * Elements are dropped until `predicate` returns falsey. The predicate is 12376 * invoked with three arguments: (value, index, array). 12377 * 12378 * @static 12379 * @memberOf _ 12380 * @since 3.0.0 12381 * @category Array 12382 * @param {Array} array The array to query. 12383 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12384 * @returns {Array} Returns the slice of `array`. 12385 * @example 12386 * 12387 * var users = [ 12388 * { 'user': 'barney', 'active': true }, 12389 * { 'user': 'fred', 'active': false }, 12390 * { 'user': 'pebbles', 'active': false } 12391 * ]; 12392 * 12393 * _.dropRightWhile(users, function(o) { return !o.active; }); 12394 * // => objects for ['barney'] 12395 * 12396 * // The `_.matches` iteratee shorthand. 12397 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 12398 * // => objects for ['barney', 'fred'] 12399 * 12400 * // The `_.matchesProperty` iteratee shorthand. 12401 * _.dropRightWhile(users, ['active', false]); 12402 * // => objects for ['barney'] 12403 * 12404 * // The `_.property` iteratee shorthand. 12405 * _.dropRightWhile(users, 'active'); 12406 * // => objects for ['barney', 'fred', 'pebbles'] 12407 */ 12408 function dropRightWhile(array, predicate) { 12409 return (array && array.length) 12410 ? baseWhile(array, getIteratee(predicate, 3), true, true) 12411 : []; 12412 } 12413 12414 /** 12415 * Creates a slice of `array` excluding elements dropped from the beginning. 12416 * Elements are dropped until `predicate` returns falsey. The predicate is 12417 * invoked with three arguments: (value, index, array). 12418 * 12419 * @static 12420 * @memberOf _ 12421 * @since 3.0.0 12422 * @category Array 12423 * @param {Array} array The array to query. 12424 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12425 * @returns {Array} Returns the slice of `array`. 12426 * @example 12427 * 12428 * var users = [ 12429 * { 'user': 'barney', 'active': false }, 12430 * { 'user': 'fred', 'active': false }, 12431 * { 'user': 'pebbles', 'active': true } 12432 * ]; 12433 * 12434 * _.dropWhile(users, function(o) { return !o.active; }); 12435 * // => objects for ['pebbles'] 12436 * 12437 * // The `_.matches` iteratee shorthand. 12438 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 12439 * // => objects for ['fred', 'pebbles'] 12440 * 12441 * // The `_.matchesProperty` iteratee shorthand. 12442 * _.dropWhile(users, ['active', false]); 12443 * // => objects for ['pebbles'] 12444 * 12445 * // The `_.property` iteratee shorthand. 12446 * _.dropWhile(users, 'active'); 12447 * // => objects for ['barney', 'fred', 'pebbles'] 12448 */ 12449 function dropWhile(array, predicate) { 12450 return (array && array.length) 12451 ? baseWhile(array, getIteratee(predicate, 3), true) 12452 : []; 12453 } 12454 12455 /** 12456 * Fills elements of `array` with `value` from `start` up to, but not 12457 * including, `end`. 12458 * 12459 * **Note:** This method mutates `array`. 12460 * 12461 * @static 12462 * @memberOf _ 12463 * @since 3.2.0 12464 * @category Array 12465 * @param {Array} array The array to fill. 12466 * @param {*} value The value to fill `array` with. 12467 * @param {number} [start=0] The start position. 12468 * @param {number} [end=array.length] The end position. 12469 * @returns {Array} Returns `array`. 12470 * @example 12471 * 12472 * var array = [1, 2, 3]; 12473 * 12474 * _.fill(array, 'a'); 12475 * console.log(array); 12476 * // => ['a', 'a', 'a'] 12477 * 12478 * _.fill(Array(3), 2); 12479 * // => [2, 2, 2] 12480 * 12481 * _.fill([4, 6, 8, 10], '*', 1, 3); 12482 * // => [4, '*', '*', 10] 12483 */ 12484 function fill(array, value, start, end) { 12485 var length = array == null ? 0 : array.length; 12486 if (!length) { 12487 return []; 12488 } 12489 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 12490 start = 0; 12491 end = length; 12492 } 12493 return baseFill(array, value, start, end); 12494 } 12495 12496 /** 12497 * This method is like `_.find` except that it returns the index of the first 12498 * element `predicate` returns truthy for instead of the element itself. 12499 * 12500 * @static 12501 * @memberOf _ 12502 * @since 1.1.0 12503 * @category Array 12504 * @param {Array} array The array to inspect. 12505 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12506 * @param {number} [fromIndex=0] The index to search from. 12507 * @returns {number} Returns the index of the found element, else `-1`. 12508 * @example 12509 * 12510 * var users = [ 12511 * { 'user': 'barney', 'active': false }, 12512 * { 'user': 'fred', 'active': false }, 12513 * { 'user': 'pebbles', 'active': true } 12514 * ]; 12515 * 12516 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 12517 * // => 0 12518 * 12519 * // The `_.matches` iteratee shorthand. 12520 * _.findIndex(users, { 'user': 'fred', 'active': false }); 12521 * // => 1 12522 * 12523 * // The `_.matchesProperty` iteratee shorthand. 12524 * _.findIndex(users, ['active', false]); 12525 * // => 0 12526 * 12527 * // The `_.property` iteratee shorthand. 12528 * _.findIndex(users, 'active'); 12529 * // => 2 12530 */ 12531 function findIndex(array, predicate, fromIndex) { 12532 var length = array == null ? 0 : array.length; 12533 if (!length) { 12534 return -1; 12535 } 12536 var index = fromIndex == null ? 0 : toInteger(fromIndex); 12537 if (index < 0) { 12538 index = nativeMax(length + index, 0); 12539 } 12540 return baseFindIndex(array, getIteratee(predicate, 3), index); 12541 } 12542 12543 /** 12544 * This method is like `_.findIndex` except that it iterates over elements 12545 * of `collection` from right to left. 12546 * 12547 * @static 12548 * @memberOf _ 12549 * @since 2.0.0 12550 * @category Array 12551 * @param {Array} array The array to inspect. 12552 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12553 * @param {number} [fromIndex=array.length-1] The index to search from. 12554 * @returns {number} Returns the index of the found element, else `-1`. 12555 * @example 12556 * 12557 * var users = [ 12558 * { 'user': 'barney', 'active': true }, 12559 * { 'user': 'fred', 'active': false }, 12560 * { 'user': 'pebbles', 'active': false } 12561 * ]; 12562 * 12563 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 12564 * // => 2 12565 * 12566 * // The `_.matches` iteratee shorthand. 12567 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 12568 * // => 0 12569 * 12570 * // The `_.matchesProperty` iteratee shorthand. 12571 * _.findLastIndex(users, ['active', false]); 12572 * // => 2 12573 * 12574 * // The `_.property` iteratee shorthand. 12575 * _.findLastIndex(users, 'active'); 12576 * // => 0 12577 */ 12578 function findLastIndex(array, predicate, fromIndex) { 12579 var length = array == null ? 0 : array.length; 12580 if (!length) { 12581 return -1; 12582 } 12583 var index = length - 1; 12584 if (fromIndex !== undefined) { 12585 index = toInteger(fromIndex); 12586 index = fromIndex < 0 12587 ? nativeMax(length + index, 0) 12588 : nativeMin(index, length - 1); 12589 } 12590 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 12591 } 12592 12593 /** 12594 * Flattens `array` a single level deep. 12595 * 12596 * @static 12597 * @memberOf _ 12598 * @since 0.1.0 12599 * @category Array 12600 * @param {Array} array The array to flatten. 12601 * @returns {Array} Returns the new flattened array. 12602 * @example 12603 * 12604 * _.flatten([1, [2, [3, [4]], 5]]); 12605 * // => [1, 2, [3, [4]], 5] 12606 */ 12607 function flatten(array) { 12608 var length = array == null ? 0 : array.length; 12609 return length ? baseFlatten(array, 1) : []; 12610 } 12611 12612 /** 12613 * Recursively flattens `array`. 12614 * 12615 * @static 12616 * @memberOf _ 12617 * @since 3.0.0 12618 * @category Array 12619 * @param {Array} array The array to flatten. 12620 * @returns {Array} Returns the new flattened array. 12621 * @example 12622 * 12623 * _.flattenDeep([1, [2, [3, [4]], 5]]); 12624 * // => [1, 2, 3, 4, 5] 12625 */ 12626 function flattenDeep(array) { 12627 var length = array == null ? 0 : array.length; 12628 return length ? baseFlatten(array, INFINITY) : []; 12629 } 12630 12631 /** 12632 * Recursively flatten `array` up to `depth` times. 12633 * 12634 * @static 12635 * @memberOf _ 12636 * @since 4.4.0 12637 * @category Array 12638 * @param {Array} array The array to flatten. 12639 * @param {number} [depth=1] The maximum recursion depth. 12640 * @returns {Array} Returns the new flattened array. 12641 * @example 12642 * 12643 * var array = [1, [2, [3, [4]], 5]]; 12644 * 12645 * _.flattenDepth(array, 1); 12646 * // => [1, 2, [3, [4]], 5] 12647 * 12648 * _.flattenDepth(array, 2); 12649 * // => [1, 2, 3, [4], 5] 12650 */ 12651 function flattenDepth(array, depth) { 12652 var length = array == null ? 0 : array.length; 12653 if (!length) { 12654 return []; 12655 } 12656 depth = depth === undefined ? 1 : toInteger(depth); 12657 return baseFlatten(array, depth); 12658 } 12659 12660 /** 12661 * The inverse of `_.toPairs`; this method returns an object composed 12662 * from key-value `pairs`. 12663 * 12664 * @static 12665 * @memberOf _ 12666 * @since 4.0.0 12667 * @category Array 12668 * @param {Array} pairs The key-value pairs. 12669 * @returns {Object} Returns the new object. 12670 * @example 12671 * 12672 * _.fromPairs([['a', 1], ['b', 2]]); 12673 * // => { 'a': 1, 'b': 2 } 12674 */ 12675 function fromPairs(pairs) { 12676 var index = -1, 12677 length = pairs == null ? 0 : pairs.length, 12678 result = {}; 12679 12680 while (++index < length) { 12681 var pair = pairs[index]; 12682 result[pair[0]] = pair[1]; 12683 } 12684 return result; 12685 } 12686 12687 /** 12688 * Gets the first element of `array`. 12689 * 12690 * @static 12691 * @memberOf _ 12692 * @since 0.1.0 12693 * @alias first 12694 * @category Array 12695 * @param {Array} array The array to query. 12696 * @returns {*} Returns the first element of `array`. 12697 * @example 12698 * 12699 * _.head([1, 2, 3]); 12700 * // => 1 12701 * 12702 * _.head([]); 12703 * // => undefined 12704 */ 12705 function head(array) { 12706 return (array && array.length) ? array[0] : undefined; 12707 } 12708 12709 /** 12710 * Gets the index at which the first occurrence of `value` is found in `array` 12711 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12712 * for equality comparisons. If `fromIndex` is negative, it's used as the 12713 * offset from the end of `array`. 12714 * 12715 * @static 12716 * @memberOf _ 12717 * @since 0.1.0 12718 * @category Array 12719 * @param {Array} array The array to inspect. 12720 * @param {*} value The value to search for. 12721 * @param {number} [fromIndex=0] The index to search from. 12722 * @returns {number} Returns the index of the matched value, else `-1`. 12723 * @example 12724 * 12725 * _.indexOf([1, 2, 1, 2], 2); 12726 * // => 1 12727 * 12728 * // Search from the `fromIndex`. 12729 * _.indexOf([1, 2, 1, 2], 2, 2); 12730 * // => 3 12731 */ 12732 function indexOf(array, value, fromIndex) { 12733 var length = array == null ? 0 : array.length; 12734 if (!length) { 12735 return -1; 12736 } 12737 var index = fromIndex == null ? 0 : toInteger(fromIndex); 12738 if (index < 0) { 12739 index = nativeMax(length + index, 0); 12740 } 12741 return baseIndexOf(array, value, index); 12742 } 12743 12744 /** 12745 * Gets all but the last element of `array`. 12746 * 12747 * @static 12748 * @memberOf _ 12749 * @since 0.1.0 12750 * @category Array 12751 * @param {Array} array The array to query. 12752 * @returns {Array} Returns the slice of `array`. 12753 * @example 12754 * 12755 * _.initial([1, 2, 3]); 12756 * // => [1, 2] 12757 */ 12758 function initial(array) { 12759 var length = array == null ? 0 : array.length; 12760 return length ? baseSlice(array, 0, -1) : []; 12761 } 12762 12763 /** 12764 * Creates an array of unique values that are included in all given arrays 12765 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12766 * for equality comparisons. The order and references of result values are 12767 * determined by the first array. 12768 * 12769 * @static 12770 * @memberOf _ 12771 * @since 0.1.0 12772 * @category Array 12773 * @param {...Array} [arrays] The arrays to inspect. 12774 * @returns {Array} Returns the new array of intersecting values. 12775 * @example 12776 * 12777 * _.intersection([2, 1], [2, 3]); 12778 * // => [2] 12779 */ 12780 var intersection = baseRest(function(arrays) { 12781 var mapped = arrayMap(arrays, castArrayLikeObject); 12782 return (mapped.length && mapped[0] === arrays[0]) 12783 ? baseIntersection(mapped) 12784 : []; 12785 }); 12786 12787 /** 12788 * This method is like `_.intersection` except that it accepts `iteratee` 12789 * which is invoked for each element of each `arrays` to generate the criterion 12790 * by which they're compared. The order and references of result values are 12791 * determined by the first array. The iteratee is invoked with one argument: 12792 * (value). 12793 * 12794 * @static 12795 * @memberOf _ 12796 * @since 4.0.0 12797 * @category Array 12798 * @param {...Array} [arrays] The arrays to inspect. 12799 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 12800 * @returns {Array} Returns the new array of intersecting values. 12801 * @example 12802 * 12803 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 12804 * // => [2.1] 12805 * 12806 * // The `_.property` iteratee shorthand. 12807 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 12808 * // => [{ 'x': 1 }] 12809 */ 12810 var intersectionBy = baseRest(function(arrays) { 12811 var iteratee = last(arrays), 12812 mapped = arrayMap(arrays, castArrayLikeObject); 12813 12814 if (iteratee === last(mapped)) { 12815 iteratee = undefined; 12816 } else { 12817 mapped.pop(); 12818 } 12819 return (mapped.length && mapped[0] === arrays[0]) 12820 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 12821 : []; 12822 }); 12823 12824 /** 12825 * This method is like `_.intersection` except that it accepts `comparator` 12826 * which is invoked to compare elements of `arrays`. The order and references 12827 * of result values are determined by the first array. The comparator is 12828 * invoked with two arguments: (arrVal, othVal). 12829 * 12830 * @static 12831 * @memberOf _ 12832 * @since 4.0.0 12833 * @category Array 12834 * @param {...Array} [arrays] The arrays to inspect. 12835 * @param {Function} [comparator] The comparator invoked per element. 12836 * @returns {Array} Returns the new array of intersecting values. 12837 * @example 12838 * 12839 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 12840 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 12841 * 12842 * _.intersectionWith(objects, others, _.isEqual); 12843 * // => [{ 'x': 1, 'y': 2 }] 12844 */ 12845 var intersectionWith = baseRest(function(arrays) { 12846 var comparator = last(arrays), 12847 mapped = arrayMap(arrays, castArrayLikeObject); 12848 12849 comparator = typeof comparator == 'function' ? comparator : undefined; 12850 if (comparator) { 12851 mapped.pop(); 12852 } 12853 return (mapped.length && mapped[0] === arrays[0]) 12854 ? baseIntersection(mapped, undefined, comparator) 12855 : []; 12856 }); 12857 12858 /** 12859 * Converts all elements in `array` into a string separated by `separator`. 12860 * 12861 * @static 12862 * @memberOf _ 12863 * @since 4.0.0 12864 * @category Array 12865 * @param {Array} array The array to convert. 12866 * @param {string} [separator=','] The element separator. 12867 * @returns {string} Returns the joined string. 12868 * @example 12869 * 12870 * _.join(['a', 'b', 'c'], '~'); 12871 * // => 'a~b~c' 12872 */ 12873 function join(array, separator) { 12874 return array == null ? '' : nativeJoin.call(array, separator); 12875 } 12876 12877 /** 12878 * Gets the last element of `array`. 12879 * 12880 * @static 12881 * @memberOf _ 12882 * @since 0.1.0 12883 * @category Array 12884 * @param {Array} array The array to query. 12885 * @returns {*} Returns the last element of `array`. 12886 * @example 12887 * 12888 * _.last([1, 2, 3]); 12889 * // => 3 12890 */ 12891 function last(array) { 12892 var length = array == null ? 0 : array.length; 12893 return length ? array[length - 1] : undefined; 12894 } 12895 12896 /** 12897 * This method is like `_.indexOf` except that it iterates over elements of 12898 * `array` from right to left. 12899 * 12900 * @static 12901 * @memberOf _ 12902 * @since 0.1.0 12903 * @category Array 12904 * @param {Array} array The array to inspect. 12905 * @param {*} value The value to search for. 12906 * @param {number} [fromIndex=array.length-1] The index to search from. 12907 * @returns {number} Returns the index of the matched value, else `-1`. 12908 * @example 12909 * 12910 * _.lastIndexOf([1, 2, 1, 2], 2); 12911 * // => 3 12912 * 12913 * // Search from the `fromIndex`. 12914 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 12915 * // => 1 12916 */ 12917 function lastIndexOf(array, value, fromIndex) { 12918 var length = array == null ? 0 : array.length; 12919 if (!length) { 12920 return -1; 12921 } 12922 var index = length; 12923 if (fromIndex !== undefined) { 12924 index = toInteger(fromIndex); 12925 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 12926 } 12927 return value === value 12928 ? strictLastIndexOf(array, value, index) 12929 : baseFindIndex(array, baseIsNaN, index, true); 12930 } 12931 12932 /** 12933 * Gets the element at index `n` of `array`. If `n` is negative, the nth 12934 * element from the end is returned. 12935 * 12936 * @static 12937 * @memberOf _ 12938 * @since 4.11.0 12939 * @category Array 12940 * @param {Array} array The array to query. 12941 * @param {number} [n=0] The index of the element to return. 12942 * @returns {*} Returns the nth element of `array`. 12943 * @example 12944 * 12945 * var array = ['a', 'b', 'c', 'd']; 12946 * 12947 * _.nth(array, 1); 12948 * // => 'b' 12949 * 12950 * _.nth(array, -2); 12951 * // => 'c'; 12952 */ 12953 function nth(array, n) { 12954 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 12955 } 12956 12957 /** 12958 * Removes all given values from `array` using 12959 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12960 * for equality comparisons. 12961 * 12962 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 12963 * to remove elements from an array by predicate. 12964 * 12965 * @static 12966 * @memberOf _ 12967 * @since 2.0.0 12968 * @category Array 12969 * @param {Array} array The array to modify. 12970 * @param {...*} [values] The values to remove. 12971 * @returns {Array} Returns `array`. 12972 * @example 12973 * 12974 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 12975 * 12976 * _.pull(array, 'a', 'c'); 12977 * console.log(array); 12978 * // => ['b', 'b'] 12979 */ 12980 var pull = baseRest(pullAll); 12981 12982 /** 12983 * This method is like `_.pull` except that it accepts an array of values to remove. 12984 * 12985 * **Note:** Unlike `_.difference`, this method mutates `array`. 12986 * 12987 * @static 12988 * @memberOf _ 12989 * @since 4.0.0 12990 * @category Array 12991 * @param {Array} array The array to modify. 12992 * @param {Array} values The values to remove. 12993 * @returns {Array} Returns `array`. 12994 * @example 12995 * 12996 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 12997 * 12998 * _.pullAll(array, ['a', 'c']); 12999 * console.log(array); 13000 * // => ['b', 'b'] 13001 */ 13002 function pullAll(array, values) { 13003 return (array && array.length && values && values.length) 13004 ? basePullAll(array, values) 13005 : array; 13006 } 13007 13008 /** 13009 * This method is like `_.pullAll` except that it accepts `iteratee` which is 13010 * invoked for each element of `array` and `values` to generate the criterion 13011 * by which they're compared. The iteratee is invoked with one argument: (value). 13012 * 13013 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 13014 * 13015 * @static 13016 * @memberOf _ 13017 * @since 4.0.0 13018 * @category Array 13019 * @param {Array} array The array to modify. 13020 * @param {Array} values The values to remove. 13021 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13022 * @returns {Array} Returns `array`. 13023 * @example 13024 * 13025 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 13026 * 13027 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 13028 * console.log(array); 13029 * // => [{ 'x': 2 }] 13030 */ 13031 function pullAllBy(array, values, iteratee) { 13032 return (array && array.length && values && values.length) 13033 ? basePullAll(array, values, getIteratee(iteratee, 2)) 13034 : array; 13035 } 13036 13037 /** 13038 * This method is like `_.pullAll` except that it accepts `comparator` which 13039 * is invoked to compare elements of `array` to `values`. The comparator is 13040 * invoked with two arguments: (arrVal, othVal). 13041 * 13042 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 13043 * 13044 * @static 13045 * @memberOf _ 13046 * @since 4.6.0 13047 * @category Array 13048 * @param {Array} array The array to modify. 13049 * @param {Array} values The values to remove. 13050 * @param {Function} [comparator] The comparator invoked per element. 13051 * @returns {Array} Returns `array`. 13052 * @example 13053 * 13054 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 13055 * 13056 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 13057 * console.log(array); 13058 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 13059 */ 13060 function pullAllWith(array, values, comparator) { 13061 return (array && array.length && values && values.length) 13062 ? basePullAll(array, values, undefined, comparator) 13063 : array; 13064 } 13065 13066 /** 13067 * Removes elements from `array` corresponding to `indexes` and returns an 13068 * array of removed elements. 13069 * 13070 * **Note:** Unlike `_.at`, this method mutates `array`. 13071 * 13072 * @static 13073 * @memberOf _ 13074 * @since 3.0.0 13075 * @category Array 13076 * @param {Array} array The array to modify. 13077 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 13078 * @returns {Array} Returns the new array of removed elements. 13079 * @example 13080 * 13081 * var array = ['a', 'b', 'c', 'd']; 13082 * var pulled = _.pullAt(array, [1, 3]); 13083 * 13084 * console.log(array); 13085 * // => ['a', 'c'] 13086 * 13087 * console.log(pulled); 13088 * // => ['b', 'd'] 13089 */ 13090 var pullAt = flatRest(function(array, indexes) { 13091 var length = array == null ? 0 : array.length, 13092 result = baseAt(array, indexes); 13093 13094 basePullAt(array, arrayMap(indexes, function(index) { 13095 return isIndex(index, length) ? +index : index; 13096 }).sort(compareAscending)); 13097 13098 return result; 13099 }); 13100 13101 /** 13102 * Removes all elements from `array` that `predicate` returns truthy for 13103 * and returns an array of the removed elements. The predicate is invoked 13104 * with three arguments: (value, index, array). 13105 * 13106 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 13107 * to pull elements from an array by value. 13108 * 13109 * @static 13110 * @memberOf _ 13111 * @since 2.0.0 13112 * @category Array 13113 * @param {Array} array The array to modify. 13114 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13115 * @returns {Array} Returns the new array of removed elements. 13116 * @example 13117 * 13118 * var array = [1, 2, 3, 4]; 13119 * var evens = _.remove(array, function(n) { 13120 * return n % 2 == 0; 13121 * }); 13122 * 13123 * console.log(array); 13124 * // => [1, 3] 13125 * 13126 * console.log(evens); 13127 * // => [2, 4] 13128 */ 13129 function remove(array, predicate) { 13130 var result = []; 13131 if (!(array && array.length)) { 13132 return result; 13133 } 13134 var index = -1, 13135 indexes = [], 13136 length = array.length; 13137 13138 predicate = getIteratee(predicate, 3); 13139 while (++index < length) { 13140 var value = array[index]; 13141 if (predicate(value, index, array)) { 13142 result.push(value); 13143 indexes.push(index); 13144 } 13145 } 13146 basePullAt(array, indexes); 13147 return result; 13148 } 13149 13150 /** 13151 * Reverses `array` so that the first element becomes the last, the second 13152 * element becomes the second to last, and so on. 13153 * 13154 * **Note:** This method mutates `array` and is based on 13155 * [`Array#reverse`](https://mdn.io/Array/reverse). 13156 * 13157 * @static 13158 * @memberOf _ 13159 * @since 4.0.0 13160 * @category Array 13161 * @param {Array} array The array to modify. 13162 * @returns {Array} Returns `array`. 13163 * @example 13164 * 13165 * var array = [1, 2, 3]; 13166 * 13167 * _.reverse(array); 13168 * // => [3, 2, 1] 13169 * 13170 * console.log(array); 13171 * // => [3, 2, 1] 13172 */ 13173 function reverse(array) { 13174 return array == null ? array : nativeReverse.call(array); 13175 } 13176 13177 /** 13178 * Creates a slice of `array` from `start` up to, but not including, `end`. 13179 * 13180 * **Note:** This method is used instead of 13181 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 13182 * returned. 13183 * 13184 * @static 13185 * @memberOf _ 13186 * @since 3.0.0 13187 * @category Array 13188 * @param {Array} array The array to slice. 13189 * @param {number} [start=0] The start position. 13190 * @param {number} [end=array.length] The end position. 13191 * @returns {Array} Returns the slice of `array`. 13192 */ 13193 function slice(array, start, end) { 13194 var length = array == null ? 0 : array.length; 13195 if (!length) { 13196 return []; 13197 } 13198 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 13199 start = 0; 13200 end = length; 13201 } 13202 else { 13203 start = start == null ? 0 : toInteger(start); 13204 end = end === undefined ? length : toInteger(end); 13205 } 13206 return baseSlice(array, start, end); 13207 } 13208 13209 /** 13210 * Uses a binary search to determine the lowest index at which `value` 13211 * should be inserted into `array` in order to maintain its sort order. 13212 * 13213 * @static 13214 * @memberOf _ 13215 * @since 0.1.0 13216 * @category Array 13217 * @param {Array} array The sorted array to inspect. 13218 * @param {*} value The value to evaluate. 13219 * @returns {number} Returns the index at which `value` should be inserted 13220 * into `array`. 13221 * @example 13222 * 13223 * _.sortedIndex([30, 50], 40); 13224 * // => 1 13225 */ 13226 function sortedIndex(array, value) { 13227 return baseSortedIndex(array, value); 13228 } 13229 13230 /** 13231 * This method is like `_.sortedIndex` except that it accepts `iteratee` 13232 * which is invoked for `value` and each element of `array` to compute their 13233 * sort ranking. The iteratee is invoked with one argument: (value). 13234 * 13235 * @static 13236 * @memberOf _ 13237 * @since 4.0.0 13238 * @category Array 13239 * @param {Array} array The sorted array to inspect. 13240 * @param {*} value The value to evaluate. 13241 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13242 * @returns {number} Returns the index at which `value` should be inserted 13243 * into `array`. 13244 * @example 13245 * 13246 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 13247 * 13248 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 13249 * // => 0 13250 * 13251 * // The `_.property` iteratee shorthand. 13252 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 13253 * // => 0 13254 */ 13255 function sortedIndexBy(array, value, iteratee) { 13256 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 13257 } 13258 13259 /** 13260 * This method is like `_.indexOf` except that it performs a binary 13261 * search on a sorted `array`. 13262 * 13263 * @static 13264 * @memberOf _ 13265 * @since 4.0.0 13266 * @category Array 13267 * @param {Array} array The array to inspect. 13268 * @param {*} value The value to search for. 13269 * @returns {number} Returns the index of the matched value, else `-1`. 13270 * @example 13271 * 13272 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 13273 * // => 1 13274 */ 13275 function sortedIndexOf(array, value) { 13276 var length = array == null ? 0 : array.length; 13277 if (length) { 13278 var index = baseSortedIndex(array, value); 13279 if (index < length && eq(array[index], value)) { 13280 return index; 13281 } 13282 } 13283 return -1; 13284 } 13285 13286 /** 13287 * This method is like `_.sortedIndex` except that it returns the highest 13288 * index at which `value` should be inserted into `array` in order to 13289 * maintain its sort order. 13290 * 13291 * @static 13292 * @memberOf _ 13293 * @since 3.0.0 13294 * @category Array 13295 * @param {Array} array The sorted array to inspect. 13296 * @param {*} value The value to evaluate. 13297 * @returns {number} Returns the index at which `value` should be inserted 13298 * into `array`. 13299 * @example 13300 * 13301 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 13302 * // => 4 13303 */ 13304 function sortedLastIndex(array, value) { 13305 return baseSortedIndex(array, value, true); 13306 } 13307 13308 /** 13309 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 13310 * which is invoked for `value` and each element of `array` to compute their 13311 * sort ranking. The iteratee is invoked with one argument: (value). 13312 * 13313 * @static 13314 * @memberOf _ 13315 * @since 4.0.0 13316 * @category Array 13317 * @param {Array} array The sorted array to inspect. 13318 * @param {*} value The value to evaluate. 13319 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13320 * @returns {number} Returns the index at which `value` should be inserted 13321 * into `array`. 13322 * @example 13323 * 13324 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 13325 * 13326 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 13327 * // => 1 13328 * 13329 * // The `_.property` iteratee shorthand. 13330 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 13331 * // => 1 13332 */ 13333 function sortedLastIndexBy(array, value, iteratee) { 13334 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 13335 } 13336 13337 /** 13338 * This method is like `_.lastIndexOf` except that it performs a binary 13339 * search on a sorted `array`. 13340 * 13341 * @static 13342 * @memberOf _ 13343 * @since 4.0.0 13344 * @category Array 13345 * @param {Array} array The array to inspect. 13346 * @param {*} value The value to search for. 13347 * @returns {number} Returns the index of the matched value, else `-1`. 13348 * @example 13349 * 13350 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 13351 * // => 3 13352 */ 13353 function sortedLastIndexOf(array, value) { 13354 var length = array == null ? 0 : array.length; 13355 if (length) { 13356 var index = baseSortedIndex(array, value, true) - 1; 13357 if (eq(array[index], value)) { 13358 return index; 13359 } 13360 } 13361 return -1; 13362 } 13363 13364 /** 13365 * This method is like `_.uniq` except that it's designed and optimized 13366 * for sorted arrays. 13367 * 13368 * @static 13369 * @memberOf _ 13370 * @since 4.0.0 13371 * @category Array 13372 * @param {Array} array The array to inspect. 13373 * @returns {Array} Returns the new duplicate free array. 13374 * @example 13375 * 13376 * _.sortedUniq([1, 1, 2]); 13377 * // => [1, 2] 13378 */ 13379 function sortedUniq(array) { 13380 return (array && array.length) 13381 ? baseSortedUniq(array) 13382 : []; 13383 } 13384 13385 /** 13386 * This method is like `_.uniqBy` except that it's designed and optimized 13387 * for sorted arrays. 13388 * 13389 * @static 13390 * @memberOf _ 13391 * @since 4.0.0 13392 * @category Array 13393 * @param {Array} array The array to inspect. 13394 * @param {Function} [iteratee] The iteratee invoked per element. 13395 * @returns {Array} Returns the new duplicate free array. 13396 * @example 13397 * 13398 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 13399 * // => [1.1, 2.3] 13400 */ 13401 function sortedUniqBy(array, iteratee) { 13402 return (array && array.length) 13403 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 13404 : []; 13405 } 13406 13407 /** 13408 * Gets all but the first element of `array`. 13409 * 13410 * @static 13411 * @memberOf _ 13412 * @since 4.0.0 13413 * @category Array 13414 * @param {Array} array The array to query. 13415 * @returns {Array} Returns the slice of `array`. 13416 * @example 13417 * 13418 * _.tail([1, 2, 3]); 13419 * // => [2, 3] 13420 */ 13421 function tail(array) { 13422 var length = array == null ? 0 : array.length; 13423 return length ? baseSlice(array, 1, length) : []; 13424 } 13425 13426 /** 13427 * Creates a slice of `array` with `n` elements taken from the beginning. 13428 * 13429 * @static 13430 * @memberOf _ 13431 * @since 0.1.0 13432 * @category Array 13433 * @param {Array} array The array to query. 13434 * @param {number} [n=1] The number of elements to take. 13435 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 13436 * @returns {Array} Returns the slice of `array`. 13437 * @example 13438 * 13439 * _.take([1, 2, 3]); 13440 * // => [1] 13441 * 13442 * _.take([1, 2, 3], 2); 13443 * // => [1, 2] 13444 * 13445 * _.take([1, 2, 3], 5); 13446 * // => [1, 2, 3] 13447 * 13448 * _.take([1, 2, 3], 0); 13449 * // => [] 13450 */ 13451 function take(array, n, guard) { 13452 if (!(array && array.length)) { 13453 return []; 13454 } 13455 n = (guard || n === undefined) ? 1 : toInteger(n); 13456 return baseSlice(array, 0, n < 0 ? 0 : n); 13457 } 13458 13459 /** 13460 * Creates a slice of `array` with `n` elements taken from the end. 13461 * 13462 * @static 13463 * @memberOf _ 13464 * @since 3.0.0 13465 * @category Array 13466 * @param {Array} array The array to query. 13467 * @param {number} [n=1] The number of elements to take. 13468 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 13469 * @returns {Array} Returns the slice of `array`. 13470 * @example 13471 * 13472 * _.takeRight([1, 2, 3]); 13473 * // => [3] 13474 * 13475 * _.takeRight([1, 2, 3], 2); 13476 * // => [2, 3] 13477 * 13478 * _.takeRight([1, 2, 3], 5); 13479 * // => [1, 2, 3] 13480 * 13481 * _.takeRight([1, 2, 3], 0); 13482 * // => [] 13483 */ 13484 function takeRight(array, n, guard) { 13485 var length = array == null ? 0 : array.length; 13486 if (!length) { 13487 return []; 13488 } 13489 n = (guard || n === undefined) ? 1 : toInteger(n); 13490 n = length - n; 13491 return baseSlice(array, n < 0 ? 0 : n, length); 13492 } 13493 13494 /** 13495 * Creates a slice of `array` with elements taken from the end. Elements are 13496 * taken until `predicate` returns falsey. The predicate is invoked with 13497 * three arguments: (value, index, array). 13498 * 13499 * @static 13500 * @memberOf _ 13501 * @since 3.0.0 13502 * @category Array 13503 * @param {Array} array The array to query. 13504 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13505 * @returns {Array} Returns the slice of `array`. 13506 * @example 13507 * 13508 * var users = [ 13509 * { 'user': 'barney', 'active': true }, 13510 * { 'user': 'fred', 'active': false }, 13511 * { 'user': 'pebbles', 'active': false } 13512 * ]; 13513 * 13514 * _.takeRightWhile(users, function(o) { return !o.active; }); 13515 * // => objects for ['fred', 'pebbles'] 13516 * 13517 * // The `_.matches` iteratee shorthand. 13518 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 13519 * // => objects for ['pebbles'] 13520 * 13521 * // The `_.matchesProperty` iteratee shorthand. 13522 * _.takeRightWhile(users, ['active', false]); 13523 * // => objects for ['fred', 'pebbles'] 13524 * 13525 * // The `_.property` iteratee shorthand. 13526 * _.takeRightWhile(users, 'active'); 13527 * // => [] 13528 */ 13529 function takeRightWhile(array, predicate) { 13530 return (array && array.length) 13531 ? baseWhile(array, getIteratee(predicate, 3), false, true) 13532 : []; 13533 } 13534 13535 /** 13536 * Creates a slice of `array` with elements taken from the beginning. Elements 13537 * are taken until `predicate` returns falsey. The predicate is invoked with 13538 * three arguments: (value, index, array). 13539 * 13540 * @static 13541 * @memberOf _ 13542 * @since 3.0.0 13543 * @category Array 13544 * @param {Array} array The array to query. 13545 * @param {Function} [predicate=_.identity] The function invoked per iteration. 13546 * @returns {Array} Returns the slice of `array`. 13547 * @example 13548 * 13549 * var users = [ 13550 * { 'user': 'barney', 'active': false }, 13551 * { 'user': 'fred', 'active': false }, 13552 * { 'user': 'pebbles', 'active': true } 13553 * ]; 13554 * 13555 * _.takeWhile(users, function(o) { return !o.active; }); 13556 * // => objects for ['barney', 'fred'] 13557 * 13558 * // The `_.matches` iteratee shorthand. 13559 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 13560 * // => objects for ['barney'] 13561 * 13562 * // The `_.matchesProperty` iteratee shorthand. 13563 * _.takeWhile(users, ['active', false]); 13564 * // => objects for ['barney', 'fred'] 13565 * 13566 * // The `_.property` iteratee shorthand. 13567 * _.takeWhile(users, 'active'); 13568 * // => [] 13569 */ 13570 function takeWhile(array, predicate) { 13571 return (array && array.length) 13572 ? baseWhile(array, getIteratee(predicate, 3)) 13573 : []; 13574 } 13575 13576 /** 13577 * Creates an array of unique values, in order, from all given arrays using 13578 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13579 * for equality comparisons. 13580 * 13581 * @static 13582 * @memberOf _ 13583 * @since 0.1.0 13584 * @category Array 13585 * @param {...Array} [arrays] The arrays to inspect. 13586 * @returns {Array} Returns the new array of combined values. 13587 * @example 13588 * 13589 * _.union([2], [1, 2]); 13590 * // => [2, 1] 13591 */ 13592 var union = baseRest(function(arrays) { 13593 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 13594 }); 13595 13596 /** 13597 * This method is like `_.union` except that it accepts `iteratee` which is 13598 * invoked for each element of each `arrays` to generate the criterion by 13599 * which uniqueness is computed. Result values are chosen from the first 13600 * array in which the value occurs. The iteratee is invoked with one argument: 13601 * (value). 13602 * 13603 * @static 13604 * @memberOf _ 13605 * @since 4.0.0 13606 * @category Array 13607 * @param {...Array} [arrays] The arrays to inspect. 13608 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13609 * @returns {Array} Returns the new array of combined values. 13610 * @example 13611 * 13612 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 13613 * // => [2.1, 1.2] 13614 * 13615 * // The `_.property` iteratee shorthand. 13616 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 13617 * // => [{ 'x': 1 }, { 'x': 2 }] 13618 */ 13619 var unionBy = baseRest(function(arrays) { 13620 var iteratee = last(arrays); 13621 if (isArrayLikeObject(iteratee)) { 13622 iteratee = undefined; 13623 } 13624 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 13625 }); 13626 13627 /** 13628 * This method is like `_.union` except that it accepts `comparator` which 13629 * is invoked to compare elements of `arrays`. Result values are chosen from 13630 * the first array in which the value occurs. The comparator is invoked 13631 * with two arguments: (arrVal, othVal). 13632 * 13633 * @static 13634 * @memberOf _ 13635 * @since 4.0.0 13636 * @category Array 13637 * @param {...Array} [arrays] The arrays to inspect. 13638 * @param {Function} [comparator] The comparator invoked per element. 13639 * @returns {Array} Returns the new array of combined values. 13640 * @example 13641 * 13642 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 13643 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 13644 * 13645 * _.unionWith(objects, others, _.isEqual); 13646 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 13647 */ 13648 var unionWith = baseRest(function(arrays) { 13649 var comparator = last(arrays); 13650 comparator = typeof comparator == 'function' ? comparator : undefined; 13651 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 13652 }); 13653 13654 /** 13655 * Creates a duplicate-free version of an array, using 13656 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13657 * for equality comparisons, in which only the first occurrence of each element 13658 * is kept. The order of result values is determined by the order they occur 13659 * in the array. 13660 * 13661 * @static 13662 * @memberOf _ 13663 * @since 0.1.0 13664 * @category Array 13665 * @param {Array} array The array to inspect. 13666 * @returns {Array} Returns the new duplicate free array. 13667 * @example 13668 * 13669 * _.uniq([2, 1, 2]); 13670 * // => [2, 1] 13671 */ 13672 function uniq(array) { 13673 return (array && array.length) ? baseUniq(array) : []; 13674 } 13675 13676 /** 13677 * This method is like `_.uniq` except that it accepts `iteratee` which is 13678 * invoked for each element in `array` to generate the criterion by which 13679 * uniqueness is computed. The order of result values is determined by the 13680 * order they occur in the array. The iteratee is invoked with one argument: 13681 * (value). 13682 * 13683 * @static 13684 * @memberOf _ 13685 * @since 4.0.0 13686 * @category Array 13687 * @param {Array} array The array to inspect. 13688 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13689 * @returns {Array} Returns the new duplicate free array. 13690 * @example 13691 * 13692 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 13693 * // => [2.1, 1.2] 13694 * 13695 * // The `_.property` iteratee shorthand. 13696 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 13697 * // => [{ 'x': 1 }, { 'x': 2 }] 13698 */ 13699 function uniqBy(array, iteratee) { 13700 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 13701 } 13702 13703 /** 13704 * This method is like `_.uniq` except that it accepts `comparator` which 13705 * is invoked to compare elements of `array`. The order of result values is 13706 * determined by the order they occur in the array.The comparator is invoked 13707 * with two arguments: (arrVal, othVal). 13708 * 13709 * @static 13710 * @memberOf _ 13711 * @since 4.0.0 13712 * @category Array 13713 * @param {Array} array The array to inspect. 13714 * @param {Function} [comparator] The comparator invoked per element. 13715 * @returns {Array} Returns the new duplicate free array. 13716 * @example 13717 * 13718 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 13719 * 13720 * _.uniqWith(objects, _.isEqual); 13721 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 13722 */ 13723 function uniqWith(array, comparator) { 13724 comparator = typeof comparator == 'function' ? comparator : undefined; 13725 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 13726 } 13727 13728 /** 13729 * This method is like `_.zip` except that it accepts an array of grouped 13730 * elements and creates an array regrouping the elements to their pre-zip 13731 * configuration. 13732 * 13733 * @static 13734 * @memberOf _ 13735 * @since 1.2.0 13736 * @category Array 13737 * @param {Array} array The array of grouped elements to process. 13738 * @returns {Array} Returns the new array of regrouped elements. 13739 * @example 13740 * 13741 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 13742 * // => [['a', 1, true], ['b', 2, false]] 13743 * 13744 * _.unzip(zipped); 13745 * // => [['a', 'b'], [1, 2], [true, false]] 13746 */ 13747 function unzip(array) { 13748 if (!(array && array.length)) { 13749 return []; 13750 } 13751 var length = 0; 13752 array = arrayFilter(array, function(group) { 13753 if (isArrayLikeObject(group)) { 13754 length = nativeMax(group.length, length); 13755 return true; 13756 } 13757 }); 13758 return baseTimes(length, function(index) { 13759 return arrayMap(array, baseProperty(index)); 13760 }); 13761 } 13762 13763 /** 13764 * This method is like `_.unzip` except that it accepts `iteratee` to specify 13765 * how regrouped values should be combined. The iteratee is invoked with the 13766 * elements of each group: (...group). 13767 * 13768 * @static 13769 * @memberOf _ 13770 * @since 3.8.0 13771 * @category Array 13772 * @param {Array} array The array of grouped elements to process. 13773 * @param {Function} [iteratee=_.identity] The function to combine 13774 * regrouped values. 13775 * @returns {Array} Returns the new array of regrouped elements. 13776 * @example 13777 * 13778 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 13779 * // => [[1, 10, 100], [2, 20, 200]] 13780 * 13781 * _.unzipWith(zipped, _.add); 13782 * // => [3, 30, 300] 13783 */ 13784 function unzipWith(array, iteratee) { 13785 if (!(array && array.length)) { 13786 return []; 13787 } 13788 var result = unzip(array); 13789 if (iteratee == null) { 13790 return result; 13791 } 13792 return arrayMap(result, function(group) { 13793 return apply(iteratee, undefined, group); 13794 }); 13795 } 13796 13797 /** 13798 * Creates an array excluding all given values using 13799 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13800 * for equality comparisons. 13801 * 13802 * **Note:** Unlike `_.pull`, this method returns a new array. 13803 * 13804 * @static 13805 * @memberOf _ 13806 * @since 0.1.0 13807 * @category Array 13808 * @param {Array} array The array to inspect. 13809 * @param {...*} [values] The values to exclude. 13810 * @returns {Array} Returns the new array of filtered values. 13811 * @see _.difference, _.xor 13812 * @example 13813 * 13814 * _.without([2, 1, 2, 3], 1, 2); 13815 * // => [3] 13816 */ 13817 var without = baseRest(function(array, values) { 13818 return isArrayLikeObject(array) 13819 ? baseDifference(array, values) 13820 : []; 13821 }); 13822 13823 /** 13824 * Creates an array of unique values that is the 13825 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 13826 * of the given arrays. The order of result values is determined by the order 13827 * they occur in the arrays. 13828 * 13829 * @static 13830 * @memberOf _ 13831 * @since 2.4.0 13832 * @category Array 13833 * @param {...Array} [arrays] The arrays to inspect. 13834 * @returns {Array} Returns the new array of filtered values. 13835 * @see _.difference, _.without 13836 * @example 13837 * 13838 * _.xor([2, 1], [2, 3]); 13839 * // => [1, 3] 13840 */ 13841 var xor = baseRest(function(arrays) { 13842 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 13843 }); 13844 13845 /** 13846 * This method is like `_.xor` except that it accepts `iteratee` which is 13847 * invoked for each element of each `arrays` to generate the criterion by 13848 * which by which they're compared. The order of result values is determined 13849 * by the order they occur in the arrays. The iteratee is invoked with one 13850 * argument: (value). 13851 * 13852 * @static 13853 * @memberOf _ 13854 * @since 4.0.0 13855 * @category Array 13856 * @param {...Array} [arrays] The arrays to inspect. 13857 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 13858 * @returns {Array} Returns the new array of filtered values. 13859 * @example 13860 * 13861 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 13862 * // => [1.2, 3.4] 13863 * 13864 * // The `_.property` iteratee shorthand. 13865 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 13866 * // => [{ 'x': 2 }] 13867 */ 13868 var xorBy = baseRest(function(arrays) { 13869 var iteratee = last(arrays); 13870 if (isArrayLikeObject(iteratee)) { 13871 iteratee = undefined; 13872 } 13873 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 13874 }); 13875 13876 /** 13877 * This method is like `_.xor` except that it accepts `comparator` which is 13878 * invoked to compare elements of `arrays`. The order of result values is 13879 * determined by the order they occur in the arrays. The comparator is invoked 13880 * with two arguments: (arrVal, othVal). 13881 * 13882 * @static 13883 * @memberOf _ 13884 * @since 4.0.0 13885 * @category Array 13886 * @param {...Array} [arrays] The arrays to inspect. 13887 * @param {Function} [comparator] The comparator invoked per element. 13888 * @returns {Array} Returns the new array of filtered values. 13889 * @example 13890 * 13891 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 13892 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 13893 * 13894 * _.xorWith(objects, others, _.isEqual); 13895 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 13896 */ 13897 var xorWith = baseRest(function(arrays) { 13898 var comparator = last(arrays); 13899 comparator = typeof comparator == 'function' ? comparator : undefined; 13900 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 13901 }); 13902 13903 /** 13904 * Creates an array of grouped elements, the first of which contains the 13905 * first elements of the given arrays, the second of which contains the 13906 * second elements of the given arrays, and so on. 13907 * 13908 * @static 13909 * @memberOf _ 13910 * @since 0.1.0 13911 * @category Array 13912 * @param {...Array} [arrays] The arrays to process. 13913 * @returns {Array} Returns the new array of grouped elements. 13914 * @example 13915 * 13916 * _.zip(['a', 'b'], [1, 2], [true, false]); 13917 * // => [['a', 1, true], ['b', 2, false]] 13918 */ 13919 var zip = baseRest(unzip); 13920 13921 /** 13922 * This method is like `_.fromPairs` except that it accepts two arrays, 13923 * one of property identifiers and one of corresponding values. 13924 * 13925 * @static 13926 * @memberOf _ 13927 * @since 0.4.0 13928 * @category Array 13929 * @param {Array} [props=[]] The property identifiers. 13930 * @param {Array} [values=[]] The property values. 13931 * @returns {Object} Returns the new object. 13932 * @example 13933 * 13934 * _.zipObject(['a', 'b'], [1, 2]); 13935 * // => { 'a': 1, 'b': 2 } 13936 */ 13937 function zipObject(props, values) { 13938 return baseZipObject(props || [], values || [], assignValue); 13939 } 13940 13941 /** 13942 * This method is like `_.zipObject` except that it supports property paths. 13943 * 13944 * @static 13945 * @memberOf _ 13946 * @since 4.1.0 13947 * @category Array 13948 * @param {Array} [props=[]] The property identifiers. 13949 * @param {Array} [values=[]] The property values. 13950 * @returns {Object} Returns the new object. 13951 * @example 13952 * 13953 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 13954 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 13955 */ 13956 function zipObjectDeep(props, values) { 13957 return baseZipObject(props || [], values || [], baseSet); 13958 } 13959 13960 /** 13961 * This method is like `_.zip` except that it accepts `iteratee` to specify 13962 * how grouped values should be combined. The iteratee is invoked with the 13963 * elements of each group: (...group). 13964 * 13965 * @static 13966 * @memberOf _ 13967 * @since 3.8.0 13968 * @category Array 13969 * @param {...Array} [arrays] The arrays to process. 13970 * @param {Function} [iteratee=_.identity] The function to combine 13971 * grouped values. 13972 * @returns {Array} Returns the new array of grouped elements. 13973 * @example 13974 * 13975 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 13976 * return a + b + c; 13977 * }); 13978 * // => [111, 222] 13979 */ 13980 var zipWith = baseRest(function(arrays) { 13981 var length = arrays.length, 13982 iteratee = length > 1 ? arrays[length - 1] : undefined; 13983 13984 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 13985 return unzipWith(arrays, iteratee); 13986 }); 13987 13988 /*------------------------------------------------------------------------*/ 13989 13990 /** 13991 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 13992 * chain sequences enabled. The result of such sequences must be unwrapped 13993 * with `_#value`. 13994 * 13995 * @static 13996 * @memberOf _ 13997 * @since 1.3.0 13998 * @category Seq 13999 * @param {*} value The value to wrap. 14000 * @returns {Object} Returns the new `lodash` wrapper instance. 14001 * @example 14002 * 14003 * var users = [ 14004 * { 'user': 'barney', 'age': 36 }, 14005 * { 'user': 'fred', 'age': 40 }, 14006 * { 'user': 'pebbles', 'age': 1 } 14007 * ]; 14008 * 14009 * var youngest = _ 14010 * .chain(users) 14011 * .sortBy('age') 14012 * .map(function(o) { 14013 * return o.user + ' is ' + o.age; 14014 * }) 14015 * .head() 14016 * .value(); 14017 * // => 'pebbles is 1' 14018 */ 14019 function chain(value) { 14020 var result = lodash(value); 14021 result.__chain__ = true; 14022 return result; 14023 } 14024 14025 /** 14026 * This method invokes `interceptor` and returns `value`. The interceptor 14027 * is invoked with one argument; (value). The purpose of this method is to 14028 * "tap into" a method chain sequence in order to modify intermediate results. 14029 * 14030 * @static 14031 * @memberOf _ 14032 * @since 0.1.0 14033 * @category Seq 14034 * @param {*} value The value to provide to `interceptor`. 14035 * @param {Function} interceptor The function to invoke. 14036 * @returns {*} Returns `value`. 14037 * @example 14038 * 14039 * _([1, 2, 3]) 14040 * .tap(function(array) { 14041 * // Mutate input array. 14042 * array.pop(); 14043 * }) 14044 * .reverse() 14045 * .value(); 14046 * // => [2, 1] 14047 */ 14048 function tap(value, interceptor) { 14049 interceptor(value); 14050 return value; 14051 } 14052 14053 /** 14054 * This method is like `_.tap` except that it returns the result of `interceptor`. 14055 * The purpose of this method is to "pass thru" values replacing intermediate 14056 * results in a method chain sequence. 14057 * 14058 * @static 14059 * @memberOf _ 14060 * @since 3.0.0 14061 * @category Seq 14062 * @param {*} value The value to provide to `interceptor`. 14063 * @param {Function} interceptor The function to invoke. 14064 * @returns {*} Returns the result of `interceptor`. 14065 * @example 14066 * 14067 * _(' abc ') 14068 * .chain() 14069 * .trim() 14070 * .thru(function(value) { 14071 * return [value]; 14072 * }) 14073 * .value(); 14074 * // => ['abc'] 14075 */ 14076 function thru(value, interceptor) { 14077 return interceptor(value); 14078 } 14079 14080 /** 14081 * This method is the wrapper version of `_.at`. 14082 * 14083 * @name at 14084 * @memberOf _ 14085 * @since 1.0.0 14086 * @category Seq 14087 * @param {...(string|string[])} [paths] The property paths to pick. 14088 * @returns {Object} Returns the new `lodash` wrapper instance. 14089 * @example 14090 * 14091 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 14092 * 14093 * _(object).at(['a[0].b.c', 'a[1]']).value(); 14094 * // => [3, 4] 14095 */ 14096 var wrapperAt = flatRest(function(paths) { 14097 var length = paths.length, 14098 start = length ? paths[0] : 0, 14099 value = this.__wrapped__, 14100 interceptor = function(object) { return baseAt(object, paths); }; 14101 14102 if (length > 1 || this.__actions__.length || 14103 !(value instanceof LazyWrapper) || !isIndex(start)) { 14104 return this.thru(interceptor); 14105 } 14106 value = value.slice(start, +start + (length ? 1 : 0)); 14107 value.__actions__.push({ 14108 'func': thru, 14109 'args': [interceptor], 14110 'thisArg': undefined 14111 }); 14112 return new LodashWrapper(value, this.__chain__).thru(function(array) { 14113 if (length && !array.length) { 14114 array.push(undefined); 14115 } 14116 return array; 14117 }); 14118 }); 14119 14120 /** 14121 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 14122 * 14123 * @name chain 14124 * @memberOf _ 14125 * @since 0.1.0 14126 * @category Seq 14127 * @returns {Object} Returns the new `lodash` wrapper instance. 14128 * @example 14129 * 14130 * var users = [ 14131 * { 'user': 'barney', 'age': 36 }, 14132 * { 'user': 'fred', 'age': 40 } 14133 * ]; 14134 * 14135 * // A sequence without explicit chaining. 14136 * _(users).head(); 14137 * // => { 'user': 'barney', 'age': 36 } 14138 * 14139 * // A sequence with explicit chaining. 14140 * _(users) 14141 * .chain() 14142 * .head() 14143 * .pick('user') 14144 * .value(); 14145 * // => { 'user': 'barney' } 14146 */ 14147 function wrapperChain() { 14148 return chain(this); 14149 } 14150 14151 /** 14152 * Executes the chain sequence and returns the wrapped result. 14153 * 14154 * @name commit 14155 * @memberOf _ 14156 * @since 3.2.0 14157 * @category Seq 14158 * @returns {Object} Returns the new `lodash` wrapper instance. 14159 * @example 14160 * 14161 * var array = [1, 2]; 14162 * var wrapped = _(array).push(3); 14163 * 14164 * console.log(array); 14165 * // => [1, 2] 14166 * 14167 * wrapped = wrapped.commit(); 14168 * console.log(array); 14169 * // => [1, 2, 3] 14170 * 14171 * wrapped.last(); 14172 * // => 3 14173 * 14174 * console.log(array); 14175 * // => [1, 2, 3] 14176 */ 14177 function wrapperCommit() { 14178 return new LodashWrapper(this.value(), this.__chain__); 14179 } 14180 14181 /** 14182 * Gets the next value on a wrapped object following the 14183 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 14184 * 14185 * @name next 14186 * @memberOf _ 14187 * @since 4.0.0 14188 * @category Seq 14189 * @returns {Object} Returns the next iterator value. 14190 * @example 14191 * 14192 * var wrapped = _([1, 2]); 14193 * 14194 * wrapped.next(); 14195 * // => { 'done': false, 'value': 1 } 14196 * 14197 * wrapped.next(); 14198 * // => { 'done': false, 'value': 2 } 14199 * 14200 * wrapped.next(); 14201 * // => { 'done': true, 'value': undefined } 14202 */ 14203 function wrapperNext() { 14204 if (this.__values__ === undefined) { 14205 this.__values__ = toArray(this.value()); 14206 } 14207 var done = this.__index__ >= this.__values__.length, 14208 value = done ? undefined : this.__values__[this.__index__++]; 14209 14210 return { 'done': done, 'value': value }; 14211 } 14212 14213 /** 14214 * Enables the wrapper to be iterable. 14215 * 14216 * @name Symbol.iterator 14217 * @memberOf _ 14218 * @since 4.0.0 14219 * @category Seq 14220 * @returns {Object} Returns the wrapper object. 14221 * @example 14222 * 14223 * var wrapped = _([1, 2]); 14224 * 14225 * wrapped[Symbol.iterator]() === wrapped; 14226 * // => true 14227 * 14228 * Array.from(wrapped); 14229 * // => [1, 2] 14230 */ 14231 function wrapperToIterator() { 14232 return this; 14233 } 14234 14235 /** 14236 * Creates a clone of the chain sequence planting `value` as the wrapped value. 14237 * 14238 * @name plant 14239 * @memberOf _ 14240 * @since 3.2.0 14241 * @category Seq 14242 * @param {*} value The value to plant. 14243 * @returns {Object} Returns the new `lodash` wrapper instance. 14244 * @example 14245 * 14246 * function square(n) { 14247 * return n * n; 14248 * } 14249 * 14250 * var wrapped = _([1, 2]).map(square); 14251 * var other = wrapped.plant([3, 4]); 14252 * 14253 * other.value(); 14254 * // => [9, 16] 14255 * 14256 * wrapped.value(); 14257 * // => [1, 4] 14258 */ 14259 function wrapperPlant(value) { 14260 var result, 14261 parent = this; 14262 14263 while (parent instanceof baseLodash) { 14264 var clone = wrapperClone(parent); 14265 clone.__index__ = 0; 14266 clone.__values__ = undefined; 14267 if (result) { 14268 previous.__wrapped__ = clone; 14269 } else { 14270 result = clone; 14271 } 14272 var previous = clone; 14273 parent = parent.__wrapped__; 14274 } 14275 previous.__wrapped__ = value; 14276 return result; 14277 } 14278 14279 /** 14280 * This method is the wrapper version of `_.reverse`. 14281 * 14282 * **Note:** This method mutates the wrapped array. 14283 * 14284 * @name reverse 14285 * @memberOf _ 14286 * @since 0.1.0 14287 * @category Seq 14288 * @returns {Object} Returns the new `lodash` wrapper instance. 14289 * @example 14290 * 14291 * var array = [1, 2, 3]; 14292 * 14293 * _(array).reverse().value() 14294 * // => [3, 2, 1] 14295 * 14296 * console.log(array); 14297 * // => [3, 2, 1] 14298 */ 14299 function wrapperReverse() { 14300 var value = this.__wrapped__; 14301 if (value instanceof LazyWrapper) { 14302 var wrapped = value; 14303 if (this.__actions__.length) { 14304 wrapped = new LazyWrapper(this); 14305 } 14306 wrapped = wrapped.reverse(); 14307 wrapped.__actions__.push({ 14308 'func': thru, 14309 'args': [reverse], 14310 'thisArg': undefined 14311 }); 14312 return new LodashWrapper(wrapped, this.__chain__); 14313 } 14314 return this.thru(reverse); 14315 } 14316 14317 /** 14318 * Executes the chain sequence to resolve the unwrapped value. 14319 * 14320 * @name value 14321 * @memberOf _ 14322 * @since 0.1.0 14323 * @alias toJSON, valueOf 14324 * @category Seq 14325 * @returns {*} Returns the resolved unwrapped value. 14326 * @example 14327 * 14328 * _([1, 2, 3]).value(); 14329 * // => [1, 2, 3] 14330 */ 14331 function wrapperValue() { 14332 return baseWrapperValue(this.__wrapped__, this.__actions__); 14333 } 14334 14335 /*------------------------------------------------------------------------*/ 14336 14337 /** 14338 * Creates an object composed of keys generated from the results of running 14339 * each element of `collection` thru `iteratee`. The corresponding value of 14340 * each key is the number of times the key was returned by `iteratee`. The 14341 * iteratee is invoked with one argument: (value). 14342 * 14343 * @static 14344 * @memberOf _ 14345 * @since 0.5.0 14346 * @category Collection 14347 * @param {Array|Object} collection The collection to iterate over. 14348 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 14349 * @returns {Object} Returns the composed aggregate object. 14350 * @example 14351 * 14352 * _.countBy([6.1, 4.2, 6.3], Math.floor); 14353 * // => { '4': 1, '6': 2 } 14354 * 14355 * // The `_.property` iteratee shorthand. 14356 * _.countBy(['one', 'two', 'three'], 'length'); 14357 * // => { '3': 2, '5': 1 } 14358 */ 14359 var countBy = createAggregator(function(result, value, key) { 14360 if (hasOwnProperty.call(result, key)) { 14361 ++result[key]; 14362 } else { 14363 baseAssignValue(result, key, 1); 14364 } 14365 }); 14366 14367 /** 14368 * Checks if `predicate` returns truthy for **all** elements of `collection`. 14369 * Iteration is stopped once `predicate` returns falsey. The predicate is 14370 * invoked with three arguments: (value, index|key, collection). 14371 * 14372 * **Note:** This method returns `true` for 14373 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 14374 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 14375 * elements of empty collections. 14376 * 14377 * @static 14378 * @memberOf _ 14379 * @since 0.1.0 14380 * @category Collection 14381 * @param {Array|Object} collection The collection to iterate over. 14382 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14383 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 14384 * @returns {boolean} Returns `true` if all elements pass the predicate check, 14385 * else `false`. 14386 * @example 14387 * 14388 * _.every([true, 1, null, 'yes'], Boolean); 14389 * // => false 14390 * 14391 * var users = [ 14392 * { 'user': 'barney', 'age': 36, 'active': false }, 14393 * { 'user': 'fred', 'age': 40, 'active': false } 14394 * ]; 14395 * 14396 * // The `_.matches` iteratee shorthand. 14397 * _.every(users, { 'user': 'barney', 'active': false }); 14398 * // => false 14399 * 14400 * // The `_.matchesProperty` iteratee shorthand. 14401 * _.every(users, ['active', false]); 14402 * // => true 14403 * 14404 * // The `_.property` iteratee shorthand. 14405 * _.every(users, 'active'); 14406 * // => false 14407 */ 14408 function every(collection, predicate, guard) { 14409 var func = isArray(collection) ? arrayEvery : baseEvery; 14410 if (guard && isIterateeCall(collection, predicate, guard)) { 14411 predicate = undefined; 14412 } 14413 return func(collection, getIteratee(predicate, 3)); 14414 } 14415 14416 /** 14417 * Iterates over elements of `collection`, returning an array of all elements 14418 * `predicate` returns truthy for. The predicate is invoked with three 14419 * arguments: (value, index|key, collection). 14420 * 14421 * **Note:** Unlike `_.remove`, this method returns a new array. 14422 * 14423 * @static 14424 * @memberOf _ 14425 * @since 0.1.0 14426 * @category Collection 14427 * @param {Array|Object} collection The collection to iterate over. 14428 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14429 * @returns {Array} Returns the new filtered array. 14430 * @see _.reject 14431 * @example 14432 * 14433 * var users = [ 14434 * { 'user': 'barney', 'age': 36, 'active': true }, 14435 * { 'user': 'fred', 'age': 40, 'active': false } 14436 * ]; 14437 * 14438 * _.filter(users, function(o) { return !o.active; }); 14439 * // => objects for ['fred'] 14440 * 14441 * // The `_.matches` iteratee shorthand. 14442 * _.filter(users, { 'age': 36, 'active': true }); 14443 * // => objects for ['barney'] 14444 * 14445 * // The `_.matchesProperty` iteratee shorthand. 14446 * _.filter(users, ['active', false]); 14447 * // => objects for ['fred'] 14448 * 14449 * // The `_.property` iteratee shorthand. 14450 * _.filter(users, 'active'); 14451 * // => objects for ['barney'] 14452 * 14453 * // Combining several predicates using `_.overEvery` or `_.overSome`. 14454 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); 14455 * // => objects for ['fred', 'barney'] 14456 */ 14457 function filter(collection, predicate) { 14458 var func = isArray(collection) ? arrayFilter : baseFilter; 14459 return func(collection, getIteratee(predicate, 3)); 14460 } 14461 14462 /** 14463 * Iterates over elements of `collection`, returning the first element 14464 * `predicate` returns truthy for. The predicate is invoked with three 14465 * arguments: (value, index|key, collection). 14466 * 14467 * @static 14468 * @memberOf _ 14469 * @since 0.1.0 14470 * @category Collection 14471 * @param {Array|Object} collection The collection to inspect. 14472 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14473 * @param {number} [fromIndex=0] The index to search from. 14474 * @returns {*} Returns the matched element, else `undefined`. 14475 * @example 14476 * 14477 * var users = [ 14478 * { 'user': 'barney', 'age': 36, 'active': true }, 14479 * { 'user': 'fred', 'age': 40, 'active': false }, 14480 * { 'user': 'pebbles', 'age': 1, 'active': true } 14481 * ]; 14482 * 14483 * _.find(users, function(o) { return o.age < 40; }); 14484 * // => object for 'barney' 14485 * 14486 * // The `_.matches` iteratee shorthand. 14487 * _.find(users, { 'age': 1, 'active': true }); 14488 * // => object for 'pebbles' 14489 * 14490 * // The `_.matchesProperty` iteratee shorthand. 14491 * _.find(users, ['active', false]); 14492 * // => object for 'fred' 14493 * 14494 * // The `_.property` iteratee shorthand. 14495 * _.find(users, 'active'); 14496 * // => object for 'barney' 14497 */ 14498 var find = createFind(findIndex); 14499 14500 /** 14501 * This method is like `_.find` except that it iterates over elements of 14502 * `collection` from right to left. 14503 * 14504 * @static 14505 * @memberOf _ 14506 * @since 2.0.0 14507 * @category Collection 14508 * @param {Array|Object} collection The collection to inspect. 14509 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14510 * @param {number} [fromIndex=collection.length-1] The index to search from. 14511 * @returns {*} Returns the matched element, else `undefined`. 14512 * @example 14513 * 14514 * _.findLast([1, 2, 3, 4], function(n) { 14515 * return n % 2 == 1; 14516 * }); 14517 * // => 3 14518 */ 14519 var findLast = createFind(findLastIndex); 14520 14521 /** 14522 * Creates a flattened array of values by running each element in `collection` 14523 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 14524 * with three arguments: (value, index|key, collection). 14525 * 14526 * @static 14527 * @memberOf _ 14528 * @since 4.0.0 14529 * @category Collection 14530 * @param {Array|Object} collection The collection to iterate over. 14531 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14532 * @returns {Array} Returns the new flattened array. 14533 * @example 14534 * 14535 * function duplicate(n) { 14536 * return [n, n]; 14537 * } 14538 * 14539 * _.flatMap([1, 2], duplicate); 14540 * // => [1, 1, 2, 2] 14541 */ 14542 function flatMap(collection, iteratee) { 14543 return baseFlatten(map(collection, iteratee), 1); 14544 } 14545 14546 /** 14547 * This method is like `_.flatMap` except that it recursively flattens the 14548 * mapped results. 14549 * 14550 * @static 14551 * @memberOf _ 14552 * @since 4.7.0 14553 * @category Collection 14554 * @param {Array|Object} collection The collection to iterate over. 14555 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14556 * @returns {Array} Returns the new flattened array. 14557 * @example 14558 * 14559 * function duplicate(n) { 14560 * return [[[n, n]]]; 14561 * } 14562 * 14563 * _.flatMapDeep([1, 2], duplicate); 14564 * // => [1, 1, 2, 2] 14565 */ 14566 function flatMapDeep(collection, iteratee) { 14567 return baseFlatten(map(collection, iteratee), INFINITY); 14568 } 14569 14570 /** 14571 * This method is like `_.flatMap` except that it recursively flattens the 14572 * mapped results up to `depth` times. 14573 * 14574 * @static 14575 * @memberOf _ 14576 * @since 4.7.0 14577 * @category Collection 14578 * @param {Array|Object} collection The collection to iterate over. 14579 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14580 * @param {number} [depth=1] The maximum recursion depth. 14581 * @returns {Array} Returns the new flattened array. 14582 * @example 14583 * 14584 * function duplicate(n) { 14585 * return [[[n, n]]]; 14586 * } 14587 * 14588 * _.flatMapDepth([1, 2], duplicate, 2); 14589 * // => [[1, 1], [2, 2]] 14590 */ 14591 function flatMapDepth(collection, iteratee, depth) { 14592 depth = depth === undefined ? 1 : toInteger(depth); 14593 return baseFlatten(map(collection, iteratee), depth); 14594 } 14595 14596 /** 14597 * Iterates over elements of `collection` and invokes `iteratee` for each element. 14598 * The iteratee is invoked with three arguments: (value, index|key, collection). 14599 * Iteratee functions may exit iteration early by explicitly returning `false`. 14600 * 14601 * **Note:** As with other "Collections" methods, objects with a "length" 14602 * property are iterated like arrays. To avoid this behavior use `_.forIn` 14603 * or `_.forOwn` for object iteration. 14604 * 14605 * @static 14606 * @memberOf _ 14607 * @since 0.1.0 14608 * @alias each 14609 * @category Collection 14610 * @param {Array|Object} collection The collection to iterate over. 14611 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14612 * @returns {Array|Object} Returns `collection`. 14613 * @see _.forEachRight 14614 * @example 14615 * 14616 * _.forEach([1, 2], function(value) { 14617 * console.log(value); 14618 * }); 14619 * // => Logs `1` then `2`. 14620 * 14621 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 14622 * console.log(key); 14623 * }); 14624 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 14625 */ 14626 function forEach(collection, iteratee) { 14627 var func = isArray(collection) ? arrayEach : baseEach; 14628 return func(collection, getIteratee(iteratee, 3)); 14629 } 14630 14631 /** 14632 * This method is like `_.forEach` except that it iterates over elements of 14633 * `collection` from right to left. 14634 * 14635 * @static 14636 * @memberOf _ 14637 * @since 2.0.0 14638 * @alias eachRight 14639 * @category Collection 14640 * @param {Array|Object} collection The collection to iterate over. 14641 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14642 * @returns {Array|Object} Returns `collection`. 14643 * @see _.forEach 14644 * @example 14645 * 14646 * _.forEachRight([1, 2], function(value) { 14647 * console.log(value); 14648 * }); 14649 * // => Logs `2` then `1`. 14650 */ 14651 function forEachRight(collection, iteratee) { 14652 var func = isArray(collection) ? arrayEachRight : baseEachRight; 14653 return func(collection, getIteratee(iteratee, 3)); 14654 } 14655 14656 /** 14657 * Creates an object composed of keys generated from the results of running 14658 * each element of `collection` thru `iteratee`. The order of grouped values 14659 * is determined by the order they occur in `collection`. The corresponding 14660 * value of each key is an array of elements responsible for generating the 14661 * key. The iteratee is invoked with one argument: (value). 14662 * 14663 * @static 14664 * @memberOf _ 14665 * @since 0.1.0 14666 * @category Collection 14667 * @param {Array|Object} collection The collection to iterate over. 14668 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 14669 * @returns {Object} Returns the composed aggregate object. 14670 * @example 14671 * 14672 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 14673 * // => { '4': [4.2], '6': [6.1, 6.3] } 14674 * 14675 * // The `_.property` iteratee shorthand. 14676 * _.groupBy(['one', 'two', 'three'], 'length'); 14677 * // => { '3': ['one', 'two'], '5': ['three'] } 14678 */ 14679 var groupBy = createAggregator(function(result, value, key) { 14680 if (hasOwnProperty.call(result, key)) { 14681 result[key].push(value); 14682 } else { 14683 baseAssignValue(result, key, [value]); 14684 } 14685 }); 14686 14687 /** 14688 * Checks if `value` is in `collection`. If `collection` is a string, it's 14689 * checked for a substring of `value`, otherwise 14690 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 14691 * is used for equality comparisons. If `fromIndex` is negative, it's used as 14692 * the offset from the end of `collection`. 14693 * 14694 * @static 14695 * @memberOf _ 14696 * @since 0.1.0 14697 * @category Collection 14698 * @param {Array|Object|string} collection The collection to inspect. 14699 * @param {*} value The value to search for. 14700 * @param {number} [fromIndex=0] The index to search from. 14701 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 14702 * @returns {boolean} Returns `true` if `value` is found, else `false`. 14703 * @example 14704 * 14705 * _.includes([1, 2, 3], 1); 14706 * // => true 14707 * 14708 * _.includes([1, 2, 3], 1, 2); 14709 * // => false 14710 * 14711 * _.includes({ 'a': 1, 'b': 2 }, 1); 14712 * // => true 14713 * 14714 * _.includes('abcd', 'bc'); 14715 * // => true 14716 */ 14717 function includes(collection, value, fromIndex, guard) { 14718 collection = isArrayLike(collection) ? collection : values(collection); 14719 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 14720 14721 var length = collection.length; 14722 if (fromIndex < 0) { 14723 fromIndex = nativeMax(length + fromIndex, 0); 14724 } 14725 return isString(collection) 14726 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 14727 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 14728 } 14729 14730 /** 14731 * Invokes the method at `path` of each element in `collection`, returning 14732 * an array of the results of each invoked method. Any additional arguments 14733 * are provided to each invoked method. If `path` is a function, it's invoked 14734 * for, and `this` bound to, each element in `collection`. 14735 * 14736 * @static 14737 * @memberOf _ 14738 * @since 4.0.0 14739 * @category Collection 14740 * @param {Array|Object} collection The collection to iterate over. 14741 * @param {Array|Function|string} path The path of the method to invoke or 14742 * the function invoked per iteration. 14743 * @param {...*} [args] The arguments to invoke each method with. 14744 * @returns {Array} Returns the array of results. 14745 * @example 14746 * 14747 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 14748 * // => [[1, 5, 7], [1, 2, 3]] 14749 * 14750 * _.invokeMap([123, 456], String.prototype.split, ''); 14751 * // => [['1', '2', '3'], ['4', '5', '6']] 14752 */ 14753 var invokeMap = baseRest(function(collection, path, args) { 14754 var index = -1, 14755 isFunc = typeof path == 'function', 14756 result = isArrayLike(collection) ? Array(collection.length) : []; 14757 14758 baseEach(collection, function(value) { 14759 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 14760 }); 14761 return result; 14762 }); 14763 14764 /** 14765 * Creates an object composed of keys generated from the results of running 14766 * each element of `collection` thru `iteratee`. The corresponding value of 14767 * each key is the last element responsible for generating the key. The 14768 * iteratee is invoked with one argument: (value). 14769 * 14770 * @static 14771 * @memberOf _ 14772 * @since 4.0.0 14773 * @category Collection 14774 * @param {Array|Object} collection The collection to iterate over. 14775 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 14776 * @returns {Object} Returns the composed aggregate object. 14777 * @example 14778 * 14779 * var array = [ 14780 * { 'dir': 'left', 'code': 97 }, 14781 * { 'dir': 'right', 'code': 100 } 14782 * ]; 14783 * 14784 * _.keyBy(array, function(o) { 14785 * return String.fromCharCode(o.code); 14786 * }); 14787 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 14788 * 14789 * _.keyBy(array, 'dir'); 14790 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 14791 */ 14792 var keyBy = createAggregator(function(result, value, key) { 14793 baseAssignValue(result, key, value); 14794 }); 14795 14796 /** 14797 * Creates an array of values by running each element in `collection` thru 14798 * `iteratee`. The iteratee is invoked with three arguments: 14799 * (value, index|key, collection). 14800 * 14801 * Many lodash methods are guarded to work as iteratees for methods like 14802 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 14803 * 14804 * The guarded methods are: 14805 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 14806 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 14807 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 14808 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 14809 * 14810 * @static 14811 * @memberOf _ 14812 * @since 0.1.0 14813 * @category Collection 14814 * @param {Array|Object} collection The collection to iterate over. 14815 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14816 * @returns {Array} Returns the new mapped array. 14817 * @example 14818 * 14819 * function square(n) { 14820 * return n * n; 14821 * } 14822 * 14823 * _.map([4, 8], square); 14824 * // => [16, 64] 14825 * 14826 * _.map({ 'a': 4, 'b': 8 }, square); 14827 * // => [16, 64] (iteration order is not guaranteed) 14828 * 14829 * var users = [ 14830 * { 'user': 'barney' }, 14831 * { 'user': 'fred' } 14832 * ]; 14833 * 14834 * // The `_.property` iteratee shorthand. 14835 * _.map(users, 'user'); 14836 * // => ['barney', 'fred'] 14837 */ 14838 function map(collection, iteratee) { 14839 var func = isArray(collection) ? arrayMap : baseMap; 14840 return func(collection, getIteratee(iteratee, 3)); 14841 } 14842 14843 /** 14844 * This method is like `_.sortBy` except that it allows specifying the sort 14845 * orders of the iteratees to sort by. If `orders` is unspecified, all values 14846 * are sorted in ascending order. Otherwise, specify an order of "desc" for 14847 * descending or "asc" for ascending sort order of corresponding values. 14848 * 14849 * @static 14850 * @memberOf _ 14851 * @since 4.0.0 14852 * @category Collection 14853 * @param {Array|Object} collection The collection to iterate over. 14854 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 14855 * The iteratees to sort by. 14856 * @param {string[]} [orders] The sort orders of `iteratees`. 14857 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 14858 * @returns {Array} Returns the new sorted array. 14859 * @example 14860 * 14861 * var users = [ 14862 * { 'user': 'fred', 'age': 48 }, 14863 * { 'user': 'barney', 'age': 34 }, 14864 * { 'user': 'fred', 'age': 40 }, 14865 * { 'user': 'barney', 'age': 36 } 14866 * ]; 14867 * 14868 * // Sort by `user` in ascending order and by `age` in descending order. 14869 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 14870 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 14871 */ 14872 function orderBy(collection, iteratees, orders, guard) { 14873 if (collection == null) { 14874 return []; 14875 } 14876 if (!isArray(iteratees)) { 14877 iteratees = iteratees == null ? [] : [iteratees]; 14878 } 14879 orders = guard ? undefined : orders; 14880 if (!isArray(orders)) { 14881 orders = orders == null ? [] : [orders]; 14882 } 14883 return baseOrderBy(collection, iteratees, orders); 14884 } 14885 14886 /** 14887 * Creates an array of elements split into two groups, the first of which 14888 * contains elements `predicate` returns truthy for, the second of which 14889 * contains elements `predicate` returns falsey for. The predicate is 14890 * invoked with one argument: (value). 14891 * 14892 * @static 14893 * @memberOf _ 14894 * @since 3.0.0 14895 * @category Collection 14896 * @param {Array|Object} collection The collection to iterate over. 14897 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14898 * @returns {Array} Returns the array of grouped elements. 14899 * @example 14900 * 14901 * var users = [ 14902 * { 'user': 'barney', 'age': 36, 'active': false }, 14903 * { 'user': 'fred', 'age': 40, 'active': true }, 14904 * { 'user': 'pebbles', 'age': 1, 'active': false } 14905 * ]; 14906 * 14907 * _.partition(users, function(o) { return o.active; }); 14908 * // => objects for [['fred'], ['barney', 'pebbles']] 14909 * 14910 * // The `_.matches` iteratee shorthand. 14911 * _.partition(users, { 'age': 1, 'active': false }); 14912 * // => objects for [['pebbles'], ['barney', 'fred']] 14913 * 14914 * // The `_.matchesProperty` iteratee shorthand. 14915 * _.partition(users, ['active', false]); 14916 * // => objects for [['barney', 'pebbles'], ['fred']] 14917 * 14918 * // The `_.property` iteratee shorthand. 14919 * _.partition(users, 'active'); 14920 * // => objects for [['fred'], ['barney', 'pebbles']] 14921 */ 14922 var partition = createAggregator(function(result, value, key) { 14923 result[key ? 0 : 1].push(value); 14924 }, function() { return [[], []]; }); 14925 14926 /** 14927 * Reduces `collection` to a value which is the accumulated result of running 14928 * each element in `collection` thru `iteratee`, where each successive 14929 * invocation is supplied the return value of the previous. If `accumulator` 14930 * is not given, the first element of `collection` is used as the initial 14931 * value. The iteratee is invoked with four arguments: 14932 * (accumulator, value, index|key, collection). 14933 * 14934 * Many lodash methods are guarded to work as iteratees for methods like 14935 * `_.reduce`, `_.reduceRight`, and `_.transform`. 14936 * 14937 * The guarded methods are: 14938 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 14939 * and `sortBy` 14940 * 14941 * @static 14942 * @memberOf _ 14943 * @since 0.1.0 14944 * @category Collection 14945 * @param {Array|Object} collection The collection to iterate over. 14946 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14947 * @param {*} [accumulator] The initial value. 14948 * @returns {*} Returns the accumulated value. 14949 * @see _.reduceRight 14950 * @example 14951 * 14952 * _.reduce([1, 2], function(sum, n) { 14953 * return sum + n; 14954 * }, 0); 14955 * // => 3 14956 * 14957 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 14958 * (result[value] || (result[value] = [])).push(key); 14959 * return result; 14960 * }, {}); 14961 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 14962 */ 14963 function reduce(collection, iteratee, accumulator) { 14964 var func = isArray(collection) ? arrayReduce : baseReduce, 14965 initAccum = arguments.length < 3; 14966 14967 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 14968 } 14969 14970 /** 14971 * This method is like `_.reduce` except that it iterates over elements of 14972 * `collection` from right to left. 14973 * 14974 * @static 14975 * @memberOf _ 14976 * @since 0.1.0 14977 * @category Collection 14978 * @param {Array|Object} collection The collection to iterate over. 14979 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14980 * @param {*} [accumulator] The initial value. 14981 * @returns {*} Returns the accumulated value. 14982 * @see _.reduce 14983 * @example 14984 * 14985 * var array = [[0, 1], [2, 3], [4, 5]]; 14986 * 14987 * _.reduceRight(array, function(flattened, other) { 14988 * return flattened.concat(other); 14989 * }, []); 14990 * // => [4, 5, 2, 3, 0, 1] 14991 */ 14992 function reduceRight(collection, iteratee, accumulator) { 14993 var func = isArray(collection) ? arrayReduceRight : baseReduce, 14994 initAccum = arguments.length < 3; 14995 14996 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 14997 } 14998 14999 /** 15000 * The opposite of `_.filter`; this method returns the elements of `collection` 15001 * that `predicate` does **not** return truthy for. 15002 * 15003 * @static 15004 * @memberOf _ 15005 * @since 0.1.0 15006 * @category Collection 15007 * @param {Array|Object} collection The collection to iterate over. 15008 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15009 * @returns {Array} Returns the new filtered array. 15010 * @see _.filter 15011 * @example 15012 * 15013 * var users = [ 15014 * { 'user': 'barney', 'age': 36, 'active': false }, 15015 * { 'user': 'fred', 'age': 40, 'active': true } 15016 * ]; 15017 * 15018 * _.reject(users, function(o) { return !o.active; }); 15019 * // => objects for ['fred'] 15020 * 15021 * // The `_.matches` iteratee shorthand. 15022 * _.reject(users, { 'age': 40, 'active': true }); 15023 * // => objects for ['barney'] 15024 * 15025 * // The `_.matchesProperty` iteratee shorthand. 15026 * _.reject(users, ['active', false]); 15027 * // => objects for ['fred'] 15028 * 15029 * // The `_.property` iteratee shorthand. 15030 * _.reject(users, 'active'); 15031 * // => objects for ['barney'] 15032 */ 15033 function reject(collection, predicate) { 15034 var func = isArray(collection) ? arrayFilter : baseFilter; 15035 return func(collection, negate(getIteratee(predicate, 3))); 15036 } 15037 15038 /** 15039 * Gets a random element from `collection`. 15040 * 15041 * @static 15042 * @memberOf _ 15043 * @since 2.0.0 15044 * @category Collection 15045 * @param {Array|Object} collection The collection to sample. 15046 * @returns {*} Returns the random element. 15047 * @example 15048 * 15049 * _.sample([1, 2, 3, 4]); 15050 * // => 2 15051 */ 15052 function sample(collection) { 15053 var func = isArray(collection) ? arraySample : baseSample; 15054 return func(collection); 15055 } 15056 15057 /** 15058 * Gets `n` random elements at unique keys from `collection` up to the 15059 * size of `collection`. 15060 * 15061 * @static 15062 * @memberOf _ 15063 * @since 4.0.0 15064 * @category Collection 15065 * @param {Array|Object} collection The collection to sample. 15066 * @param {number} [n=1] The number of elements to sample. 15067 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15068 * @returns {Array} Returns the random elements. 15069 * @example 15070 * 15071 * _.sampleSize([1, 2, 3], 2); 15072 * // => [3, 1] 15073 * 15074 * _.sampleSize([1, 2, 3], 4); 15075 * // => [2, 3, 1] 15076 */ 15077 function sampleSize(collection, n, guard) { 15078 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 15079 n = 1; 15080 } else { 15081 n = toInteger(n); 15082 } 15083 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 15084 return func(collection, n); 15085 } 15086 15087 /** 15088 * Creates an array of shuffled values, using a version of the 15089 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 15090 * 15091 * @static 15092 * @memberOf _ 15093 * @since 0.1.0 15094 * @category Collection 15095 * @param {Array|Object} collection The collection to shuffle. 15096 * @returns {Array} Returns the new shuffled array. 15097 * @example 15098 * 15099 * _.shuffle([1, 2, 3, 4]); 15100 * // => [4, 1, 3, 2] 15101 */ 15102 function shuffle(collection) { 15103 var func = isArray(collection) ? arrayShuffle : baseShuffle; 15104 return func(collection); 15105 } 15106 15107 /** 15108 * Gets the size of `collection` by returning its length for array-like 15109 * values or the number of own enumerable string keyed properties for objects. 15110 * 15111 * @static 15112 * @memberOf _ 15113 * @since 0.1.0 15114 * @category Collection 15115 * @param {Array|Object|string} collection The collection to inspect. 15116 * @returns {number} Returns the collection size. 15117 * @example 15118 * 15119 * _.size([1, 2, 3]); 15120 * // => 3 15121 * 15122 * _.size({ 'a': 1, 'b': 2 }); 15123 * // => 2 15124 * 15125 * _.size('pebbles'); 15126 * // => 7 15127 */ 15128 function size(collection) { 15129 if (collection == null) { 15130 return 0; 15131 } 15132 if (isArrayLike(collection)) { 15133 return isString(collection) ? stringSize(collection) : collection.length; 15134 } 15135 var tag = getTag(collection); 15136 if (tag == mapTag || tag == setTag) { 15137 return collection.size; 15138 } 15139 return baseKeys(collection).length; 15140 } 15141 15142 /** 15143 * Checks if `predicate` returns truthy for **any** element of `collection`. 15144 * Iteration is stopped once `predicate` returns truthy. The predicate is 15145 * invoked with three arguments: (value, index|key, collection). 15146 * 15147 * @static 15148 * @memberOf _ 15149 * @since 0.1.0 15150 * @category Collection 15151 * @param {Array|Object} collection The collection to iterate over. 15152 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15153 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15154 * @returns {boolean} Returns `true` if any element passes the predicate check, 15155 * else `false`. 15156 * @example 15157 * 15158 * _.some([null, 0, 'yes', false], Boolean); 15159 * // => true 15160 * 15161 * var users = [ 15162 * { 'user': 'barney', 'active': true }, 15163 * { 'user': 'fred', 'active': false } 15164 * ]; 15165 * 15166 * // The `_.matches` iteratee shorthand. 15167 * _.some(users, { 'user': 'barney', 'active': false }); 15168 * // => false 15169 * 15170 * // The `_.matchesProperty` iteratee shorthand. 15171 * _.some(users, ['active', false]); 15172 * // => true 15173 * 15174 * // The `_.property` iteratee shorthand. 15175 * _.some(users, 'active'); 15176 * // => true 15177 */ 15178 function some(collection, predicate, guard) { 15179 var func = isArray(collection) ? arraySome : baseSome; 15180 if (guard && isIterateeCall(collection, predicate, guard)) { 15181 predicate = undefined; 15182 } 15183 return func(collection, getIteratee(predicate, 3)); 15184 } 15185 15186 /** 15187 * Creates an array of elements, sorted in ascending order by the results of 15188 * running each element in a collection thru each iteratee. This method 15189 * performs a stable sort, that is, it preserves the original sort order of 15190 * equal elements. The iteratees are invoked with one argument: (value). 15191 * 15192 * @static 15193 * @memberOf _ 15194 * @since 0.1.0 15195 * @category Collection 15196 * @param {Array|Object} collection The collection to iterate over. 15197 * @param {...(Function|Function[])} [iteratees=[_.identity]] 15198 * The iteratees to sort by. 15199 * @returns {Array} Returns the new sorted array. 15200 * @example 15201 * 15202 * var users = [ 15203 * { 'user': 'fred', 'age': 48 }, 15204 * { 'user': 'barney', 'age': 36 }, 15205 * { 'user': 'fred', 'age': 30 }, 15206 * { 'user': 'barney', 'age': 34 } 15207 * ]; 15208 * 15209 * _.sortBy(users, [function(o) { return o.user; }]); 15210 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] 15211 * 15212 * _.sortBy(users, ['user', 'age']); 15213 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] 15214 */ 15215 var sortBy = baseRest(function(collection, iteratees) { 15216 if (collection == null) { 15217 return []; 15218 } 15219 var length = iteratees.length; 15220 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 15221 iteratees = []; 15222 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 15223 iteratees = [iteratees[0]]; 15224 } 15225 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 15226 }); 15227 15228 /*------------------------------------------------------------------------*/ 15229 15230 /** 15231 * Gets the timestamp of the number of milliseconds that have elapsed since 15232 * the Unix epoch (1 January 1970 00:00:00 UTC). 15233 * 15234 * @static 15235 * @memberOf _ 15236 * @since 2.4.0 15237 * @category Date 15238 * @returns {number} Returns the timestamp. 15239 * @example 15240 * 15241 * _.defer(function(stamp) { 15242 * console.log(_.now() - stamp); 15243 * }, _.now()); 15244 * // => Logs the number of milliseconds it took for the deferred invocation. 15245 */ 15246 var now = ctxNow || function() { 15247 return root.Date.now(); 15248 }; 15249 15250 /*------------------------------------------------------------------------*/ 15251 15252 /** 15253 * The opposite of `_.before`; this method creates a function that invokes 15254 * `func` once it's called `n` or more times. 15255 * 15256 * @static 15257 * @memberOf _ 15258 * @since 0.1.0 15259 * @category Function 15260 * @param {number} n The number of calls before `func` is invoked. 15261 * @param {Function} func The function to restrict. 15262 * @returns {Function} Returns the new restricted function. 15263 * @example 15264 * 15265 * var saves = ['profile', 'settings']; 15266 * 15267 * var done = _.after(saves.length, function() { 15268 * console.log('done saving!'); 15269 * }); 15270 * 15271 * _.forEach(saves, function(type) { 15272 * asyncSave({ 'type': type, 'complete': done }); 15273 * }); 15274 * // => Logs 'done saving!' after the two async saves have completed. 15275 */ 15276 function after(n, func) { 15277 if (typeof func != 'function') { 15278 throw new TypeError(FUNC_ERROR_TEXT); 15279 } 15280 n = toInteger(n); 15281 return function() { 15282 if (--n < 1) { 15283 return func.apply(this, arguments); 15284 } 15285 }; 15286 } 15287 15288 /** 15289 * Creates a function that invokes `func`, with up to `n` arguments, 15290 * ignoring any additional arguments. 15291 * 15292 * @static 15293 * @memberOf _ 15294 * @since 3.0.0 15295 * @category Function 15296 * @param {Function} func The function to cap arguments for. 15297 * @param {number} [n=func.length] The arity cap. 15298 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15299 * @returns {Function} Returns the new capped function. 15300 * @example 15301 * 15302 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 15303 * // => [6, 8, 10] 15304 */ 15305 function ary(func, n, guard) { 15306 n = guard ? undefined : n; 15307 n = (func && n == null) ? func.length : n; 15308 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 15309 } 15310 15311 /** 15312 * Creates a function that invokes `func`, with the `this` binding and arguments 15313 * of the created function, while it's called less than `n` times. Subsequent 15314 * calls to the created function return the result of the last `func` invocation. 15315 * 15316 * @static 15317 * @memberOf _ 15318 * @since 3.0.0 15319 * @category Function 15320 * @param {number} n The number of calls at which `func` is no longer invoked. 15321 * @param {Function} func The function to restrict. 15322 * @returns {Function} Returns the new restricted function. 15323 * @example 15324 * 15325 * jQuery(element).on('click', _.before(5, addContactToList)); 15326 * // => Allows adding up to 4 contacts to the list. 15327 */ 15328 function before(n, func) { 15329 var result; 15330 if (typeof func != 'function') { 15331 throw new TypeError(FUNC_ERROR_TEXT); 15332 } 15333 n = toInteger(n); 15334 return function() { 15335 if (--n > 0) { 15336 result = func.apply(this, arguments); 15337 } 15338 if (n <= 1) { 15339 func = undefined; 15340 } 15341 return result; 15342 }; 15343 } 15344 15345 /** 15346 * Creates a function that invokes `func` with the `this` binding of `thisArg` 15347 * and `partials` prepended to the arguments it receives. 15348 * 15349 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 15350 * may be used as a placeholder for partially applied arguments. 15351 * 15352 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 15353 * property of bound functions. 15354 * 15355 * @static 15356 * @memberOf _ 15357 * @since 0.1.0 15358 * @category Function 15359 * @param {Function} func The function to bind. 15360 * @param {*} thisArg The `this` binding of `func`. 15361 * @param {...*} [partials] The arguments to be partially applied. 15362 * @returns {Function} Returns the new bound function. 15363 * @example 15364 * 15365 * function greet(greeting, punctuation) { 15366 * return greeting + ' ' + this.user + punctuation; 15367 * } 15368 * 15369 * var object = { 'user': 'fred' }; 15370 * 15371 * var bound = _.bind(greet, object, 'hi'); 15372 * bound('!'); 15373 * // => 'hi fred!' 15374 * 15375 * // Bound with placeholders. 15376 * var bound = _.bind(greet, object, _, '!'); 15377 * bound('hi'); 15378 * // => 'hi fred!' 15379 */ 15380 var bind = baseRest(function(func, thisArg, partials) { 15381 var bitmask = WRAP_BIND_FLAG; 15382 if (partials.length) { 15383 var holders = replaceHolders(partials, getHolder(bind)); 15384 bitmask |= WRAP_PARTIAL_FLAG; 15385 } 15386 return createWrap(func, bitmask, thisArg, partials, holders); 15387 }); 15388 15389 /** 15390 * Creates a function that invokes the method at `object[key]` with `partials` 15391 * prepended to the arguments it receives. 15392 * 15393 * This method differs from `_.bind` by allowing bound functions to reference 15394 * methods that may be redefined or don't yet exist. See 15395 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 15396 * for more details. 15397 * 15398 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 15399 * builds, may be used as a placeholder for partially applied arguments. 15400 * 15401 * @static 15402 * @memberOf _ 15403 * @since 0.10.0 15404 * @category Function 15405 * @param {Object} object The object to invoke the method on. 15406 * @param {string} key The key of the method. 15407 * @param {...*} [partials] The arguments to be partially applied. 15408 * @returns {Function} Returns the new bound function. 15409 * @example 15410 * 15411 * var object = { 15412 * 'user': 'fred', 15413 * 'greet': function(greeting, punctuation) { 15414 * return greeting + ' ' + this.user + punctuation; 15415 * } 15416 * }; 15417 * 15418 * var bound = _.bindKey(object, 'greet', 'hi'); 15419 * bound('!'); 15420 * // => 'hi fred!' 15421 * 15422 * object.greet = function(greeting, punctuation) { 15423 * return greeting + 'ya ' + this.user + punctuation; 15424 * }; 15425 * 15426 * bound('!'); 15427 * // => 'hiya fred!' 15428 * 15429 * // Bound with placeholders. 15430 * var bound = _.bindKey(object, 'greet', _, '!'); 15431 * bound('hi'); 15432 * // => 'hiya fred!' 15433 */ 15434 var bindKey = baseRest(function(object, key, partials) { 15435 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 15436 if (partials.length) { 15437 var holders = replaceHolders(partials, getHolder(bindKey)); 15438 bitmask |= WRAP_PARTIAL_FLAG; 15439 } 15440 return createWrap(key, bitmask, object, partials, holders); 15441 }); 15442 15443 /** 15444 * Creates a function that accepts arguments of `func` and either invokes 15445 * `func` returning its result, if at least `arity` number of arguments have 15446 * been provided, or returns a function that accepts the remaining `func` 15447 * arguments, and so on. The arity of `func` may be specified if `func.length` 15448 * is not sufficient. 15449 * 15450 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 15451 * may be used as a placeholder for provided arguments. 15452 * 15453 * **Note:** This method doesn't set the "length" property of curried functions. 15454 * 15455 * @static 15456 * @memberOf _ 15457 * @since 2.0.0 15458 * @category Function 15459 * @param {Function} func The function to curry. 15460 * @param {number} [arity=func.length] The arity of `func`. 15461 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15462 * @returns {Function} Returns the new curried function. 15463 * @example 15464 * 15465 * var abc = function(a, b, c) { 15466 * return [a, b, c]; 15467 * }; 15468 * 15469 * var curried = _.curry(abc); 15470 * 15471 * curried(1)(2)(3); 15472 * // => [1, 2, 3] 15473 * 15474 * curried(1, 2)(3); 15475 * // => [1, 2, 3] 15476 * 15477 * curried(1, 2, 3); 15478 * // => [1, 2, 3] 15479 * 15480 * // Curried with placeholders. 15481 * curried(1)(_, 3)(2); 15482 * // => [1, 2, 3] 15483 */ 15484 function curry(func, arity, guard) { 15485 arity = guard ? undefined : arity; 15486 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 15487 result.placeholder = curry.placeholder; 15488 return result; 15489 } 15490 15491 /** 15492 * This method is like `_.curry` except that arguments are applied to `func` 15493 * in the manner of `_.partialRight` instead of `_.partial`. 15494 * 15495 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 15496 * builds, may be used as a placeholder for provided arguments. 15497 * 15498 * **Note:** This method doesn't set the "length" property of curried functions. 15499 * 15500 * @static 15501 * @memberOf _ 15502 * @since 3.0.0 15503 * @category Function 15504 * @param {Function} func The function to curry. 15505 * @param {number} [arity=func.length] The arity of `func`. 15506 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 15507 * @returns {Function} Returns the new curried function. 15508 * @example 15509 * 15510 * var abc = function(a, b, c) { 15511 * return [a, b, c]; 15512 * }; 15513 * 15514 * var curried = _.curryRight(abc); 15515 * 15516 * curried(3)(2)(1); 15517 * // => [1, 2, 3] 15518 * 15519 * curried(2, 3)(1); 15520 * // => [1, 2, 3] 15521 * 15522 * curried(1, 2, 3); 15523 * // => [1, 2, 3] 15524 * 15525 * // Curried with placeholders. 15526 * curried(3)(1, _)(2); 15527 * // => [1, 2, 3] 15528 */ 15529 function curryRight(func, arity, guard) { 15530 arity = guard ? undefined : arity; 15531 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 15532 result.placeholder = curryRight.placeholder; 15533 return result; 15534 } 15535 15536 /** 15537 * Creates a debounced function that delays invoking `func` until after `wait` 15538 * milliseconds have elapsed since the last time the debounced function was 15539 * invoked. The debounced function comes with a `cancel` method to cancel 15540 * delayed `func` invocations and a `flush` method to immediately invoke them. 15541 * Provide `options` to indicate whether `func` should be invoked on the 15542 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 15543 * with the last arguments provided to the debounced function. Subsequent 15544 * calls to the debounced function return the result of the last `func` 15545 * invocation. 15546 * 15547 * **Note:** If `leading` and `trailing` options are `true`, `func` is 15548 * invoked on the trailing edge of the timeout only if the debounced function 15549 * is invoked more than once during the `wait` timeout. 15550 * 15551 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 15552 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 15553 * 15554 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 15555 * for details over the differences between `_.debounce` and `_.throttle`. 15556 * 15557 * @static 15558 * @memberOf _ 15559 * @since 0.1.0 15560 * @category Function 15561 * @param {Function} func The function to debounce. 15562 * @param {number} [wait=0] The number of milliseconds to delay. 15563 * @param {Object} [options={}] The options object. 15564 * @param {boolean} [options.leading=false] 15565 * Specify invoking on the leading edge of the timeout. 15566 * @param {number} [options.maxWait] 15567 * The maximum time `func` is allowed to be delayed before it's invoked. 15568 * @param {boolean} [options.trailing=true] 15569 * Specify invoking on the trailing edge of the timeout. 15570 * @returns {Function} Returns the new debounced function. 15571 * @example 15572 * 15573 * // Avoid costly calculations while the window size is in flux. 15574 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 15575 * 15576 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 15577 * jQuery(element).on('click', _.debounce(sendMail, 300, { 15578 * 'leading': true, 15579 * 'trailing': false 15580 * })); 15581 * 15582 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 15583 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 15584 * var source = new EventSource('/stream'); 15585 * jQuery(source).on('message', debounced); 15586 * 15587 * // Cancel the trailing debounced invocation. 15588 * jQuery(window).on('popstate', debounced.cancel); 15589 */ 15590 function debounce(func, wait, options) { 15591 var lastArgs, 15592 lastThis, 15593 maxWait, 15594 result, 15595 timerId, 15596 lastCallTime, 15597 lastInvokeTime = 0, 15598 leading = false, 15599 maxing = false, 15600 trailing = true; 15601 15602 if (typeof func != 'function') { 15603 throw new TypeError(FUNC_ERROR_TEXT); 15604 } 15605 wait = toNumber(wait) || 0; 15606 if (isObject(options)) { 15607 leading = !!options.leading; 15608 maxing = 'maxWait' in options; 15609 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 15610 trailing = 'trailing' in options ? !!options.trailing : trailing; 15611 } 15612 15613 function invokeFunc(time) { 15614 var args = lastArgs, 15615 thisArg = lastThis; 15616 15617 lastArgs = lastThis = undefined; 15618 lastInvokeTime = time; 15619 result = func.apply(thisArg, args); 15620 return result; 15621 } 15622 15623 function leadingEdge(time) { 15624 // Reset any `maxWait` timer. 15625 lastInvokeTime = time; 15626 // Start the timer for the trailing edge. 15627 timerId = setTimeout(timerExpired, wait); 15628 // Invoke the leading edge. 15629 return leading ? invokeFunc(time) : result; 15630 } 15631 15632 function remainingWait(time) { 15633 var timeSinceLastCall = time - lastCallTime, 15634 timeSinceLastInvoke = time - lastInvokeTime, 15635 timeWaiting = wait - timeSinceLastCall; 15636 15637 return maxing 15638 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 15639 : timeWaiting; 15640 } 15641 15642 function shouldInvoke(time) { 15643 var timeSinceLastCall = time - lastCallTime, 15644 timeSinceLastInvoke = time - lastInvokeTime; 15645 15646 // Either this is the first call, activity has stopped and we're at the 15647 // trailing edge, the system time has gone backwards and we're treating 15648 // it as the trailing edge, or we've hit the `maxWait` limit. 15649 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 15650 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 15651 } 15652 15653 function timerExpired() { 15654 var time = now(); 15655 if (shouldInvoke(time)) { 15656 return trailingEdge(time); 15657 } 15658 // Restart the timer. 15659 timerId = setTimeout(timerExpired, remainingWait(time)); 15660 } 15661 15662 function trailingEdge(time) { 15663 timerId = undefined; 15664 15665 // Only invoke if we have `lastArgs` which means `func` has been 15666 // debounced at least once. 15667 if (trailing && lastArgs) { 15668 return invokeFunc(time); 15669 } 15670 lastArgs = lastThis = undefined; 15671 return result; 15672 } 15673 15674 function cancel() { 15675 if (timerId !== undefined) { 15676 clearTimeout(timerId); 15677 } 15678 lastInvokeTime = 0; 15679 lastArgs = lastCallTime = lastThis = timerId = undefined; 15680 } 15681 15682 function flush() { 15683 return timerId === undefined ? result : trailingEdge(now()); 15684 } 15685 15686 function debounced() { 15687 var time = now(), 15688 isInvoking = shouldInvoke(time); 15689 15690 lastArgs = arguments; 15691 lastThis = this; 15692 lastCallTime = time; 15693 15694 if (isInvoking) { 15695 if (timerId === undefined) { 15696 return leadingEdge(lastCallTime); 15697 } 15698 if (maxing) { 15699 // Handle invocations in a tight loop. 15700 clearTimeout(timerId); 15701 timerId = setTimeout(timerExpired, wait); 15702 return invokeFunc(lastCallTime); 15703 } 15704 } 15705 if (timerId === undefined) { 15706 timerId = setTimeout(timerExpired, wait); 15707 } 15708 return result; 15709 } 15710 debounced.cancel = cancel; 15711 debounced.flush = flush; 15712 return debounced; 15713 } 15714 15715 /** 15716 * Defers invoking the `func` until the current call stack has cleared. Any 15717 * additional arguments are provided to `func` when it's invoked. 15718 * 15719 * @static 15720 * @memberOf _ 15721 * @since 0.1.0 15722 * @category Function 15723 * @param {Function} func The function to defer. 15724 * @param {...*} [args] The arguments to invoke `func` with. 15725 * @returns {number} Returns the timer id. 15726 * @example 15727 * 15728 * _.defer(function(text) { 15729 * console.log(text); 15730 * }, 'deferred'); 15731 * // => Logs 'deferred' after one millisecond. 15732 */ 15733 var defer = baseRest(function(func, args) { 15734 return baseDelay(func, 1, args); 15735 }); 15736 15737 /** 15738 * Invokes `func` after `wait` milliseconds. Any additional arguments are 15739 * provided to `func` when it's invoked. 15740 * 15741 * @static 15742 * @memberOf _ 15743 * @since 0.1.0 15744 * @category Function 15745 * @param {Function} func The function to delay. 15746 * @param {number} wait The number of milliseconds to delay invocation. 15747 * @param {...*} [args] The arguments to invoke `func` with. 15748 * @returns {number} Returns the timer id. 15749 * @example 15750 * 15751 * _.delay(function(text) { 15752 * console.log(text); 15753 * }, 1000, 'later'); 15754 * // => Logs 'later' after one second. 15755 */ 15756 var delay = baseRest(function(func, wait, args) { 15757 return baseDelay(func, toNumber(wait) || 0, args); 15758 }); 15759 15760 /** 15761 * Creates a function that invokes `func` with arguments reversed. 15762 * 15763 * @static 15764 * @memberOf _ 15765 * @since 4.0.0 15766 * @category Function 15767 * @param {Function} func The function to flip arguments for. 15768 * @returns {Function} Returns the new flipped function. 15769 * @example 15770 * 15771 * var flipped = _.flip(function() { 15772 * return _.toArray(arguments); 15773 * }); 15774 * 15775 * flipped('a', 'b', 'c', 'd'); 15776 * // => ['d', 'c', 'b', 'a'] 15777 */ 15778 function flip(func) { 15779 return createWrap(func, WRAP_FLIP_FLAG); 15780 } 15781 15782 /** 15783 * Creates a function that memoizes the result of `func`. If `resolver` is 15784 * provided, it determines the cache key for storing the result based on the 15785 * arguments provided to the memoized function. By default, the first argument 15786 * provided to the memoized function is used as the map cache key. The `func` 15787 * is invoked with the `this` binding of the memoized function. 15788 * 15789 * **Note:** The cache is exposed as the `cache` property on the memoized 15790 * function. Its creation may be customized by replacing the `_.memoize.Cache` 15791 * constructor with one whose instances implement the 15792 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 15793 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 15794 * 15795 * @static 15796 * @memberOf _ 15797 * @since 0.1.0 15798 * @category Function 15799 * @param {Function} func The function to have its output memoized. 15800 * @param {Function} [resolver] The function to resolve the cache key. 15801 * @returns {Function} Returns the new memoized function. 15802 * @example 15803 * 15804 * var object = { 'a': 1, 'b': 2 }; 15805 * var other = { 'c': 3, 'd': 4 }; 15806 * 15807 * var values = _.memoize(_.values); 15808 * values(object); 15809 * // => [1, 2] 15810 * 15811 * values(other); 15812 * // => [3, 4] 15813 * 15814 * object.a = 2; 15815 * values(object); 15816 * // => [1, 2] 15817 * 15818 * // Modify the result cache. 15819 * values.cache.set(object, ['a', 'b']); 15820 * values(object); 15821 * // => ['a', 'b'] 15822 * 15823 * // Replace `_.memoize.Cache`. 15824 * _.memoize.Cache = WeakMap; 15825 */ 15826 function memoize(func, resolver) { 15827 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 15828 throw new TypeError(FUNC_ERROR_TEXT); 15829 } 15830 var memoized = function() { 15831 var args = arguments, 15832 key = resolver ? resolver.apply(this, args) : args[0], 15833 cache = memoized.cache; 15834 15835 if (cache.has(key)) { 15836 return cache.get(key); 15837 } 15838 var result = func.apply(this, args); 15839 memoized.cache = cache.set(key, result) || cache; 15840 return result; 15841 }; 15842 memoized.cache = new (memoize.Cache || MapCache); 15843 return memoized; 15844 } 15845 15846 // Expose `MapCache`. 15847 memoize.Cache = MapCache; 15848 15849 /** 15850 * Creates a function that negates the result of the predicate `func`. The 15851 * `func` predicate is invoked with the `this` binding and arguments of the 15852 * created function. 15853 * 15854 * @static 15855 * @memberOf _ 15856 * @since 3.0.0 15857 * @category Function 15858 * @param {Function} predicate The predicate to negate. 15859 * @returns {Function} Returns the new negated function. 15860 * @example 15861 * 15862 * function isEven(n) { 15863 * return n % 2 == 0; 15864 * } 15865 * 15866 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 15867 * // => [1, 3, 5] 15868 */ 15869 function negate(predicate) { 15870 if (typeof predicate != 'function') { 15871 throw new TypeError(FUNC_ERROR_TEXT); 15872 } 15873 return function() { 15874 var args = arguments; 15875 switch (args.length) { 15876 case 0: return !predicate.call(this); 15877 case 1: return !predicate.call(this, args[0]); 15878 case 2: return !predicate.call(this, args[0], args[1]); 15879 case 3: return !predicate.call(this, args[0], args[1], args[2]); 15880 } 15881 return !predicate.apply(this, args); 15882 }; 15883 } 15884 15885 /** 15886 * Creates a function that is restricted to invoking `func` once. Repeat calls 15887 * to the function return the value of the first invocation. The `func` is 15888 * invoked with the `this` binding and arguments of the created function. 15889 * 15890 * @static 15891 * @memberOf _ 15892 * @since 0.1.0 15893 * @category Function 15894 * @param {Function} func The function to restrict. 15895 * @returns {Function} Returns the new restricted function. 15896 * @example 15897 * 15898 * var initialize = _.once(createApplication); 15899 * initialize(); 15900 * initialize(); 15901 * // => `createApplication` is invoked once 15902 */ 15903 function once(func) { 15904 return before(2, func); 15905 } 15906 15907 /** 15908 * Creates a function that invokes `func` with its arguments transformed. 15909 * 15910 * @static 15911 * @since 4.0.0 15912 * @memberOf _ 15913 * @category Function 15914 * @param {Function} func The function to wrap. 15915 * @param {...(Function|Function[])} [transforms=[_.identity]] 15916 * The argument transforms. 15917 * @returns {Function} Returns the new function. 15918 * @example 15919 * 15920 * function doubled(n) { 15921 * return n * 2; 15922 * } 15923 * 15924 * function square(n) { 15925 * return n * n; 15926 * } 15927 * 15928 * var func = _.overArgs(function(x, y) { 15929 * return [x, y]; 15930 * }, [square, doubled]); 15931 * 15932 * func(9, 3); 15933 * // => [81, 6] 15934 * 15935 * func(10, 5); 15936 * // => [100, 10] 15937 */ 15938 var overArgs = castRest(function(func, transforms) { 15939 transforms = (transforms.length == 1 && isArray(transforms[0])) 15940 ? arrayMap(transforms[0], baseUnary(getIteratee())) 15941 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 15942 15943 var funcsLength = transforms.length; 15944 return baseRest(function(args) { 15945 var index = -1, 15946 length = nativeMin(args.length, funcsLength); 15947 15948 while (++index < length) { 15949 args[index] = transforms[index].call(this, args[index]); 15950 } 15951 return apply(func, this, args); 15952 }); 15953 }); 15954 15955 /** 15956 * Creates a function that invokes `func` with `partials` prepended to the 15957 * arguments it receives. This method is like `_.bind` except it does **not** 15958 * alter the `this` binding. 15959 * 15960 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 15961 * builds, may be used as a placeholder for partially applied arguments. 15962 * 15963 * **Note:** This method doesn't set the "length" property of partially 15964 * applied functions. 15965 * 15966 * @static 15967 * @memberOf _ 15968 * @since 0.2.0 15969 * @category Function 15970 * @param {Function} func The function to partially apply arguments to. 15971 * @param {...*} [partials] The arguments to be partially applied. 15972 * @returns {Function} Returns the new partially applied function. 15973 * @example 15974 * 15975 * function greet(greeting, name) { 15976 * return greeting + ' ' + name; 15977 * } 15978 * 15979 * var sayHelloTo = _.partial(greet, 'hello'); 15980 * sayHelloTo('fred'); 15981 * // => 'hello fred' 15982 * 15983 * // Partially applied with placeholders. 15984 * var greetFred = _.partial(greet, _, 'fred'); 15985 * greetFred('hi'); 15986 * // => 'hi fred' 15987 */ 15988 var partial = baseRest(function(func, partials) { 15989 var holders = replaceHolders(partials, getHolder(partial)); 15990 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 15991 }); 15992 15993 /** 15994 * This method is like `_.partial` except that partially applied arguments 15995 * are appended to the arguments it receives. 15996 * 15997 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 15998 * builds, may be used as a placeholder for partially applied arguments. 15999 * 16000 * **Note:** This method doesn't set the "length" property of partially 16001 * applied functions. 16002 * 16003 * @static 16004 * @memberOf _ 16005 * @since 1.0.0 16006 * @category Function 16007 * @param {Function} func The function to partially apply arguments to. 16008 * @param {...*} [partials] The arguments to be partially applied. 16009 * @returns {Function} Returns the new partially applied function. 16010 * @example 16011 * 16012 * function greet(greeting, name) { 16013 * return greeting + ' ' + name; 16014 * } 16015 * 16016 * var greetFred = _.partialRight(greet, 'fred'); 16017 * greetFred('hi'); 16018 * // => 'hi fred' 16019 * 16020 * // Partially applied with placeholders. 16021 * var sayHelloTo = _.partialRight(greet, 'hello', _); 16022 * sayHelloTo('fred'); 16023 * // => 'hello fred' 16024 */ 16025 var partialRight = baseRest(function(func, partials) { 16026 var holders = replaceHolders(partials, getHolder(partialRight)); 16027 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 16028 }); 16029 16030 /** 16031 * Creates a function that invokes `func` with arguments arranged according 16032 * to the specified `indexes` where the argument value at the first index is 16033 * provided as the first argument, the argument value at the second index is 16034 * provided as the second argument, and so on. 16035 * 16036 * @static 16037 * @memberOf _ 16038 * @since 3.0.0 16039 * @category Function 16040 * @param {Function} func The function to rearrange arguments for. 16041 * @param {...(number|number[])} indexes The arranged argument indexes. 16042 * @returns {Function} Returns the new function. 16043 * @example 16044 * 16045 * var rearged = _.rearg(function(a, b, c) { 16046 * return [a, b, c]; 16047 * }, [2, 0, 1]); 16048 * 16049 * rearged('b', 'c', 'a') 16050 * // => ['a', 'b', 'c'] 16051 */ 16052 var rearg = flatRest(function(func, indexes) { 16053 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 16054 }); 16055 16056 /** 16057 * Creates a function that invokes `func` with the `this` binding of the 16058 * created function and arguments from `start` and beyond provided as 16059 * an array. 16060 * 16061 * **Note:** This method is based on the 16062 * [rest parameter](https://mdn.io/rest_parameters). 16063 * 16064 * @static 16065 * @memberOf _ 16066 * @since 4.0.0 16067 * @category Function 16068 * @param {Function} func The function to apply a rest parameter to. 16069 * @param {number} [start=func.length-1] The start position of the rest parameter. 16070 * @returns {Function} Returns the new function. 16071 * @example 16072 * 16073 * var say = _.rest(function(what, names) { 16074 * return what + ' ' + _.initial(names).join(', ') + 16075 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 16076 * }); 16077 * 16078 * say('hello', 'fred', 'barney', 'pebbles'); 16079 * // => 'hello fred, barney, & pebbles' 16080 */ 16081 function rest(func, start) { 16082 if (typeof func != 'function') { 16083 throw new TypeError(FUNC_ERROR_TEXT); 16084 } 16085 start = start === undefined ? start : toInteger(start); 16086 return baseRest(func, start); 16087 } 16088 16089 /** 16090 * Creates a function that invokes `func` with the `this` binding of the 16091 * create function and an array of arguments much like 16092 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 16093 * 16094 * **Note:** This method is based on the 16095 * [spread operator](https://mdn.io/spread_operator). 16096 * 16097 * @static 16098 * @memberOf _ 16099 * @since 3.2.0 16100 * @category Function 16101 * @param {Function} func The function to spread arguments over. 16102 * @param {number} [start=0] The start position of the spread. 16103 * @returns {Function} Returns the new function. 16104 * @example 16105 * 16106 * var say = _.spread(function(who, what) { 16107 * return who + ' says ' + what; 16108 * }); 16109 * 16110 * say(['fred', 'hello']); 16111 * // => 'fred says hello' 16112 * 16113 * var numbers = Promise.all([ 16114 * Promise.resolve(40), 16115 * Promise.resolve(36) 16116 * ]); 16117 * 16118 * numbers.then(_.spread(function(x, y) { 16119 * return x + y; 16120 * })); 16121 * // => a Promise of 76 16122 */ 16123 function spread(func, start) { 16124 if (typeof func != 'function') { 16125 throw new TypeError(FUNC_ERROR_TEXT); 16126 } 16127 start = start == null ? 0 : nativeMax(toInteger(start), 0); 16128 return baseRest(function(args) { 16129 var array = args[start], 16130 otherArgs = castSlice(args, 0, start); 16131 16132 if (array) { 16133 arrayPush(otherArgs, array); 16134 } 16135 return apply(func, this, otherArgs); 16136 }); 16137 } 16138 16139 /** 16140 * Creates a throttled function that only invokes `func` at most once per 16141 * every `wait` milliseconds. The throttled function comes with a `cancel` 16142 * method to cancel delayed `func` invocations and a `flush` method to 16143 * immediately invoke them. Provide `options` to indicate whether `func` 16144 * should be invoked on the leading and/or trailing edge of the `wait` 16145 * timeout. The `func` is invoked with the last arguments provided to the 16146 * throttled function. Subsequent calls to the throttled function return the 16147 * result of the last `func` invocation. 16148 * 16149 * **Note:** If `leading` and `trailing` options are `true`, `func` is 16150 * invoked on the trailing edge of the timeout only if the throttled function 16151 * is invoked more than once during the `wait` timeout. 16152 * 16153 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 16154 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 16155 * 16156 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 16157 * for details over the differences between `_.throttle` and `_.debounce`. 16158 * 16159 * @static 16160 * @memberOf _ 16161 * @since 0.1.0 16162 * @category Function 16163 * @param {Function} func The function to throttle. 16164 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 16165 * @param {Object} [options={}] The options object. 16166 * @param {boolean} [options.leading=true] 16167 * Specify invoking on the leading edge of the timeout. 16168 * @param {boolean} [options.trailing=true] 16169 * Specify invoking on the trailing edge of the timeout. 16170 * @returns {Function} Returns the new throttled function. 16171 * @example 16172 * 16173 * // Avoid excessively updating the position while scrolling. 16174 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 16175 * 16176 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 16177 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 16178 * jQuery(element).on('click', throttled); 16179 * 16180 * // Cancel the trailing throttled invocation. 16181 * jQuery(window).on('popstate', throttled.cancel); 16182 */ 16183 function throttle(func, wait, options) { 16184 var leading = true, 16185 trailing = true; 16186 16187 if (typeof func != 'function') { 16188 throw new TypeError(FUNC_ERROR_TEXT); 16189 } 16190 if (isObject(options)) { 16191 leading = 'leading' in options ? !!options.leading : leading; 16192 trailing = 'trailing' in options ? !!options.trailing : trailing; 16193 } 16194 return debounce(func, wait, { 16195 'leading': leading, 16196 'maxWait': wait, 16197 'trailing': trailing 16198 }); 16199 } 16200 16201 /** 16202 * Creates a function that accepts up to one argument, ignoring any 16203 * additional arguments. 16204 * 16205 * @static 16206 * @memberOf _ 16207 * @since 4.0.0 16208 * @category Function 16209 * @param {Function} func The function to cap arguments for. 16210 * @returns {Function} Returns the new capped function. 16211 * @example 16212 * 16213 * _.map(['6', '8', '10'], _.unary(parseInt)); 16214 * // => [6, 8, 10] 16215 */ 16216 function unary(func) { 16217 return ary(func, 1); 16218 } 16219 16220 /** 16221 * Creates a function that provides `value` to `wrapper` as its first 16222 * argument. Any additional arguments provided to the function are appended 16223 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 16224 * binding of the created function. 16225 * 16226 * @static 16227 * @memberOf _ 16228 * @since 0.1.0 16229 * @category Function 16230 * @param {*} value The value to wrap. 16231 * @param {Function} [wrapper=identity] The wrapper function. 16232 * @returns {Function} Returns the new function. 16233 * @example 16234 * 16235 * var p = _.wrap(_.escape, function(func, text) { 16236 * return '<p>' + func(text) + '</p>'; 16237 * }); 16238 * 16239 * p('fred, barney, & pebbles'); 16240 * // => '<p>fred, barney, & pebbles</p>' 16241 */ 16242 function wrap(value, wrapper) { 16243 return partial(castFunction(wrapper), value); 16244 } 16245 16246 /*------------------------------------------------------------------------*/ 16247 16248 /** 16249 * Casts `value` as an array if it's not one. 16250 * 16251 * @static 16252 * @memberOf _ 16253 * @since 4.4.0 16254 * @category Lang 16255 * @param {*} value The value to inspect. 16256 * @returns {Array} Returns the cast array. 16257 * @example 16258 * 16259 * _.castArray(1); 16260 * // => [1] 16261 * 16262 * _.castArray({ 'a': 1 }); 16263 * // => [{ 'a': 1 }] 16264 * 16265 * _.castArray('abc'); 16266 * // => ['abc'] 16267 * 16268 * _.castArray(null); 16269 * // => [null] 16270 * 16271 * _.castArray(undefined); 16272 * // => [undefined] 16273 * 16274 * _.castArray(); 16275 * // => [] 16276 * 16277 * var array = [1, 2, 3]; 16278 * console.log(_.castArray(array) === array); 16279 * // => true 16280 */ 16281 function castArray() { 16282 if (!arguments.length) { 16283 return []; 16284 } 16285 var value = arguments[0]; 16286 return isArray(value) ? value : [value]; 16287 } 16288 16289 /** 16290 * Creates a shallow clone of `value`. 16291 * 16292 * **Note:** This method is loosely based on the 16293 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 16294 * and supports cloning arrays, array buffers, booleans, date objects, maps, 16295 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 16296 * arrays. The own enumerable properties of `arguments` objects are cloned 16297 * as plain objects. An empty object is returned for uncloneable values such 16298 * as error objects, functions, DOM nodes, and WeakMaps. 16299 * 16300 * @static 16301 * @memberOf _ 16302 * @since 0.1.0 16303 * @category Lang 16304 * @param {*} value The value to clone. 16305 * @returns {*} Returns the cloned value. 16306 * @see _.cloneDeep 16307 * @example 16308 * 16309 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 16310 * 16311 * var shallow = _.clone(objects); 16312 * console.log(shallow[0] === objects[0]); 16313 * // => true 16314 */ 16315 function clone(value) { 16316 return baseClone(value, CLONE_SYMBOLS_FLAG); 16317 } 16318 16319 /** 16320 * This method is like `_.clone` except that it accepts `customizer` which 16321 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 16322 * cloning is handled by the method instead. The `customizer` is invoked with 16323 * up to four arguments; (value [, index|key, object, stack]). 16324 * 16325 * @static 16326 * @memberOf _ 16327 * @since 4.0.0 16328 * @category Lang 16329 * @param {*} value The value to clone. 16330 * @param {Function} [customizer] The function to customize cloning. 16331 * @returns {*} Returns the cloned value. 16332 * @see _.cloneDeepWith 16333 * @example 16334 * 16335 * function customizer(value) { 16336 * if (_.isElement(value)) { 16337 * return value.cloneNode(false); 16338 * } 16339 * } 16340 * 16341 * var el = _.cloneWith(document.body, customizer); 16342 * 16343 * console.log(el === document.body); 16344 * // => false 16345 * console.log(el.nodeName); 16346 * // => 'BODY' 16347 * console.log(el.childNodes.length); 16348 * // => 0 16349 */ 16350 function cloneWith(value, customizer) { 16351 customizer = typeof customizer == 'function' ? customizer : undefined; 16352 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 16353 } 16354 16355 /** 16356 * This method is like `_.clone` except that it recursively clones `value`. 16357 * 16358 * @static 16359 * @memberOf _ 16360 * @since 1.0.0 16361 * @category Lang 16362 * @param {*} value The value to recursively clone. 16363 * @returns {*} Returns the deep cloned value. 16364 * @see _.clone 16365 * @example 16366 * 16367 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 16368 * 16369 * var deep = _.cloneDeep(objects); 16370 * console.log(deep[0] === objects[0]); 16371 * // => false 16372 */ 16373 function cloneDeep(value) { 16374 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 16375 } 16376 16377 /** 16378 * This method is like `_.cloneWith` except that it recursively clones `value`. 16379 * 16380 * @static 16381 * @memberOf _ 16382 * @since 4.0.0 16383 * @category Lang 16384 * @param {*} value The value to recursively clone. 16385 * @param {Function} [customizer] The function to customize cloning. 16386 * @returns {*} Returns the deep cloned value. 16387 * @see _.cloneWith 16388 * @example 16389 * 16390 * function customizer(value) { 16391 * if (_.isElement(value)) { 16392 * return value.cloneNode(true); 16393 * } 16394 * } 16395 * 16396 * var el = _.cloneDeepWith(document.body, customizer); 16397 * 16398 * console.log(el === document.body); 16399 * // => false 16400 * console.log(el.nodeName); 16401 * // => 'BODY' 16402 * console.log(el.childNodes.length); 16403 * // => 20 16404 */ 16405 function cloneDeepWith(value, customizer) { 16406 customizer = typeof customizer == 'function' ? customizer : undefined; 16407 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 16408 } 16409 16410 /** 16411 * Checks if `object` conforms to `source` by invoking the predicate 16412 * properties of `source` with the corresponding property values of `object`. 16413 * 16414 * **Note:** This method is equivalent to `_.conforms` when `source` is 16415 * partially applied. 16416 * 16417 * @static 16418 * @memberOf _ 16419 * @since 4.14.0 16420 * @category Lang 16421 * @param {Object} object The object to inspect. 16422 * @param {Object} source The object of property predicates to conform to. 16423 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 16424 * @example 16425 * 16426 * var object = { 'a': 1, 'b': 2 }; 16427 * 16428 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 16429 * // => true 16430 * 16431 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 16432 * // => false 16433 */ 16434 function conformsTo(object, source) { 16435 return source == null || baseConformsTo(object, source, keys(source)); 16436 } 16437 16438 /** 16439 * Performs a 16440 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 16441 * comparison between two values to determine if they are equivalent. 16442 * 16443 * @static 16444 * @memberOf _ 16445 * @since 4.0.0 16446 * @category Lang 16447 * @param {*} value The value to compare. 16448 * @param {*} other The other value to compare. 16449 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 16450 * @example 16451 * 16452 * var object = { 'a': 1 }; 16453 * var other = { 'a': 1 }; 16454 * 16455 * _.eq(object, object); 16456 * // => true 16457 * 16458 * _.eq(object, other); 16459 * // => false 16460 * 16461 * _.eq('a', 'a'); 16462 * // => true 16463 * 16464 * _.eq('a', Object('a')); 16465 * // => false 16466 * 16467 * _.eq(NaN, NaN); 16468 * // => true 16469 */ 16470 function eq(value, other) { 16471 return value === other || (value !== value && other !== other); 16472 } 16473 16474 /** 16475 * Checks if `value` is greater than `other`. 16476 * 16477 * @static 16478 * @memberOf _ 16479 * @since 3.9.0 16480 * @category Lang 16481 * @param {*} value The value to compare. 16482 * @param {*} other The other value to compare. 16483 * @returns {boolean} Returns `true` if `value` is greater than `other`, 16484 * else `false`. 16485 * @see _.lt 16486 * @example 16487 * 16488 * _.gt(3, 1); 16489 * // => true 16490 * 16491 * _.gt(3, 3); 16492 * // => false 16493 * 16494 * _.gt(1, 3); 16495 * // => false 16496 */ 16497 var gt = createRelationalOperation(baseGt); 16498 16499 /** 16500 * Checks if `value` is greater than or equal to `other`. 16501 * 16502 * @static 16503 * @memberOf _ 16504 * @since 3.9.0 16505 * @category Lang 16506 * @param {*} value The value to compare. 16507 * @param {*} other The other value to compare. 16508 * @returns {boolean} Returns `true` if `value` is greater than or equal to 16509 * `other`, else `false`. 16510 * @see _.lte 16511 * @example 16512 * 16513 * _.gte(3, 1); 16514 * // => true 16515 * 16516 * _.gte(3, 3); 16517 * // => true 16518 * 16519 * _.gte(1, 3); 16520 * // => false 16521 */ 16522 var gte = createRelationalOperation(function(value, other) { 16523 return value >= other; 16524 }); 16525 16526 /** 16527 * Checks if `value` is likely an `arguments` object. 16528 * 16529 * @static 16530 * @memberOf _ 16531 * @since 0.1.0 16532 * @category Lang 16533 * @param {*} value The value to check. 16534 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 16535 * else `false`. 16536 * @example 16537 * 16538 * _.isArguments(function() { return arguments; }()); 16539 * // => true 16540 * 16541 * _.isArguments([1, 2, 3]); 16542 * // => false 16543 */ 16544 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 16545 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 16546 !propertyIsEnumerable.call(value, 'callee'); 16547 }; 16548 16549 /** 16550 * Checks if `value` is classified as an `Array` object. 16551 * 16552 * @static 16553 * @memberOf _ 16554 * @since 0.1.0 16555 * @category Lang 16556 * @param {*} value The value to check. 16557 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 16558 * @example 16559 * 16560 * _.isArray([1, 2, 3]); 16561 * // => true 16562 * 16563 * _.isArray(document.body.children); 16564 * // => false 16565 * 16566 * _.isArray('abc'); 16567 * // => false 16568 * 16569 * _.isArray(_.noop); 16570 * // => false 16571 */ 16572 var isArray = Array.isArray; 16573 16574 /** 16575 * Checks if `value` is classified as an `ArrayBuffer` object. 16576 * 16577 * @static 16578 * @memberOf _ 16579 * @since 4.3.0 16580 * @category Lang 16581 * @param {*} value The value to check. 16582 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 16583 * @example 16584 * 16585 * _.isArrayBuffer(new ArrayBuffer(2)); 16586 * // => true 16587 * 16588 * _.isArrayBuffer(new Array(2)); 16589 * // => false 16590 */ 16591 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 16592 16593 /** 16594 * Checks if `value` is array-like. A value is considered array-like if it's 16595 * not a function and has a `value.length` that's an integer greater than or 16596 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 16597 * 16598 * @static 16599 * @memberOf _ 16600 * @since 4.0.0 16601 * @category Lang 16602 * @param {*} value The value to check. 16603 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 16604 * @example 16605 * 16606 * _.isArrayLike([1, 2, 3]); 16607 * // => true 16608 * 16609 * _.isArrayLike(document.body.children); 16610 * // => true 16611 * 16612 * _.isArrayLike('abc'); 16613 * // => true 16614 * 16615 * _.isArrayLike(_.noop); 16616 * // => false 16617 */ 16618 function isArrayLike(value) { 16619 return value != null && isLength(value.length) && !isFunction(value); 16620 } 16621 16622 /** 16623 * This method is like `_.isArrayLike` except that it also checks if `value` 16624 * is an object. 16625 * 16626 * @static 16627 * @memberOf _ 16628 * @since 4.0.0 16629 * @category Lang 16630 * @param {*} value The value to check. 16631 * @returns {boolean} Returns `true` if `value` is an array-like object, 16632 * else `false`. 16633 * @example 16634 * 16635 * _.isArrayLikeObject([1, 2, 3]); 16636 * // => true 16637 * 16638 * _.isArrayLikeObject(document.body.children); 16639 * // => true 16640 * 16641 * _.isArrayLikeObject('abc'); 16642 * // => false 16643 * 16644 * _.isArrayLikeObject(_.noop); 16645 * // => false 16646 */ 16647 function isArrayLikeObject(value) { 16648 return isObjectLike(value) && isArrayLike(value); 16649 } 16650 16651 /** 16652 * Checks if `value` is classified as a boolean primitive or object. 16653 * 16654 * @static 16655 * @memberOf _ 16656 * @since 0.1.0 16657 * @category Lang 16658 * @param {*} value The value to check. 16659 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 16660 * @example 16661 * 16662 * _.isBoolean(false); 16663 * // => true 16664 * 16665 * _.isBoolean(null); 16666 * // => false 16667 */ 16668 function isBoolean(value) { 16669 return value === true || value === false || 16670 (isObjectLike(value) && baseGetTag(value) == boolTag); 16671 } 16672 16673 /** 16674 * Checks if `value` is a buffer. 16675 * 16676 * @static 16677 * @memberOf _ 16678 * @since 4.3.0 16679 * @category Lang 16680 * @param {*} value The value to check. 16681 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 16682 * @example 16683 * 16684 * _.isBuffer(new Buffer(2)); 16685 * // => true 16686 * 16687 * _.isBuffer(new Uint8Array(2)); 16688 * // => false 16689 */ 16690 var isBuffer = nativeIsBuffer || stubFalse; 16691 16692 /** 16693 * Checks if `value` is classified as a `Date` object. 16694 * 16695 * @static 16696 * @memberOf _ 16697 * @since 0.1.0 16698 * @category Lang 16699 * @param {*} value The value to check. 16700 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 16701 * @example 16702 * 16703 * _.isDate(new Date); 16704 * // => true 16705 * 16706 * _.isDate('Mon April 23 2012'); 16707 * // => false 16708 */ 16709 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 16710 16711 /** 16712 * Checks if `value` is likely a DOM element. 16713 * 16714 * @static 16715 * @memberOf _ 16716 * @since 0.1.0 16717 * @category Lang 16718 * @param {*} value The value to check. 16719 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 16720 * @example 16721 * 16722 * _.isElement(document.body); 16723 * // => true 16724 * 16725 * _.isElement('<body>'); 16726 * // => false 16727 */ 16728 function isElement(value) { 16729 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 16730 } 16731 16732 /** 16733 * Checks if `value` is an empty object, collection, map, or set. 16734 * 16735 * Objects are considered empty if they have no own enumerable string keyed 16736 * properties. 16737 * 16738 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 16739 * jQuery-like collections are considered empty if they have a `length` of `0`. 16740 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 16741 * 16742 * @static 16743 * @memberOf _ 16744 * @since 0.1.0 16745 * @category Lang 16746 * @param {*} value The value to check. 16747 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 16748 * @example 16749 * 16750 * _.isEmpty(null); 16751 * // => true 16752 * 16753 * _.isEmpty(true); 16754 * // => true 16755 * 16756 * _.isEmpty(1); 16757 * // => true 16758 * 16759 * _.isEmpty([1, 2, 3]); 16760 * // => false 16761 * 16762 * _.isEmpty({ 'a': 1 }); 16763 * // => false 16764 */ 16765 function isEmpty(value) { 16766 if (value == null) { 16767 return true; 16768 } 16769 if (isArrayLike(value) && 16770 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 16771 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 16772 return !value.length; 16773 } 16774 var tag = getTag(value); 16775 if (tag == mapTag || tag == setTag) { 16776 return !value.size; 16777 } 16778 if (isPrototype(value)) { 16779 return !baseKeys(value).length; 16780 } 16781 for (var key in value) { 16782 if (hasOwnProperty.call(value, key)) { 16783 return false; 16784 } 16785 } 16786 return true; 16787 } 16788 16789 /** 16790 * Performs a deep comparison between two values to determine if they are 16791 * equivalent. 16792 * 16793 * **Note:** This method supports comparing arrays, array buffers, booleans, 16794 * date objects, error objects, maps, numbers, `Object` objects, regexes, 16795 * sets, strings, symbols, and typed arrays. `Object` objects are compared 16796 * by their own, not inherited, enumerable properties. Functions and DOM 16797 * nodes are compared by strict equality, i.e. `===`. 16798 * 16799 * @static 16800 * @memberOf _ 16801 * @since 0.1.0 16802 * @category Lang 16803 * @param {*} value The value to compare. 16804 * @param {*} other The other value to compare. 16805 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 16806 * @example 16807 * 16808 * var object = { 'a': 1 }; 16809 * var other = { 'a': 1 }; 16810 * 16811 * _.isEqual(object, other); 16812 * // => true 16813 * 16814 * object === other; 16815 * // => false 16816 */ 16817 function isEqual(value, other) { 16818 return baseIsEqual(value, other); 16819 } 16820 16821 /** 16822 * This method is like `_.isEqual` except that it accepts `customizer` which 16823 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 16824 * are handled by the method instead. The `customizer` is invoked with up to 16825 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 16826 * 16827 * @static 16828 * @memberOf _ 16829 * @since 4.0.0 16830 * @category Lang 16831 * @param {*} value The value to compare. 16832 * @param {*} other The other value to compare. 16833 * @param {Function} [customizer] The function to customize comparisons. 16834 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 16835 * @example 16836 * 16837 * function isGreeting(value) { 16838 * return /^h(?:i|ello)$/.test(value); 16839 * } 16840 * 16841 * function customizer(objValue, othValue) { 16842 * if (isGreeting(objValue) && isGreeting(othValue)) { 16843 * return true; 16844 * } 16845 * } 16846 * 16847 * var array = ['hello', 'goodbye']; 16848 * var other = ['hi', 'goodbye']; 16849 * 16850 * _.isEqualWith(array, other, customizer); 16851 * // => true 16852 */ 16853 function isEqualWith(value, other, customizer) { 16854 customizer = typeof customizer == 'function' ? customizer : undefined; 16855 var result = customizer ? customizer(value, other) : undefined; 16856 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 16857 } 16858 16859 /** 16860 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 16861 * `SyntaxError`, `TypeError`, or `URIError` object. 16862 * 16863 * @static 16864 * @memberOf _ 16865 * @since 3.0.0 16866 * @category Lang 16867 * @param {*} value The value to check. 16868 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 16869 * @example 16870 * 16871 * _.isError(new Error); 16872 * // => true 16873 * 16874 * _.isError(Error); 16875 * // => false 16876 */ 16877 function isError(value) { 16878 if (!isObjectLike(value)) { 16879 return false; 16880 } 16881 var tag = baseGetTag(value); 16882 return tag == errorTag || tag == domExcTag || 16883 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 16884 } 16885 16886 /** 16887 * Checks if `value` is a finite primitive number. 16888 * 16889 * **Note:** This method is based on 16890 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 16891 * 16892 * @static 16893 * @memberOf _ 16894 * @since 0.1.0 16895 * @category Lang 16896 * @param {*} value The value to check. 16897 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 16898 * @example 16899 * 16900 * _.isFinite(3); 16901 * // => true 16902 * 16903 * _.isFinite(Number.MIN_VALUE); 16904 * // => true 16905 * 16906 * _.isFinite(Infinity); 16907 * // => false 16908 * 16909 * _.isFinite('3'); 16910 * // => false 16911 */ 16912 function isFinite(value) { 16913 return typeof value == 'number' && nativeIsFinite(value); 16914 } 16915 16916 /** 16917 * Checks if `value` is classified as a `Function` object. 16918 * 16919 * @static 16920 * @memberOf _ 16921 * @since 0.1.0 16922 * @category Lang 16923 * @param {*} value The value to check. 16924 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 16925 * @example 16926 * 16927 * _.isFunction(_); 16928 * // => true 16929 * 16930 * _.isFunction(/abc/); 16931 * // => false 16932 */ 16933 function isFunction(value) { 16934 if (!isObject(value)) { 16935 return false; 16936 } 16937 // The use of `Object#toString` avoids issues with the `typeof` operator 16938 // in Safari 9 which returns 'object' for typed arrays and other constructors. 16939 var tag = baseGetTag(value); 16940 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 16941 } 16942 16943 /** 16944 * Checks if `value` is an integer. 16945 * 16946 * **Note:** This method is based on 16947 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 16948 * 16949 * @static 16950 * @memberOf _ 16951 * @since 4.0.0 16952 * @category Lang 16953 * @param {*} value The value to check. 16954 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 16955 * @example 16956 * 16957 * _.isInteger(3); 16958 * // => true 16959 * 16960 * _.isInteger(Number.MIN_VALUE); 16961 * // => false 16962 * 16963 * _.isInteger(Infinity); 16964 * // => false 16965 * 16966 * _.isInteger('3'); 16967 * // => false 16968 */ 16969 function isInteger(value) { 16970 return typeof value == 'number' && value == toInteger(value); 16971 } 16972 16973 /** 16974 * Checks if `value` is a valid array-like length. 16975 * 16976 * **Note:** This method is loosely based on 16977 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 16978 * 16979 * @static 16980 * @memberOf _ 16981 * @since 4.0.0 16982 * @category Lang 16983 * @param {*} value The value to check. 16984 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 16985 * @example 16986 * 16987 * _.isLength(3); 16988 * // => true 16989 * 16990 * _.isLength(Number.MIN_VALUE); 16991 * // => false 16992 * 16993 * _.isLength(Infinity); 16994 * // => false 16995 * 16996 * _.isLength('3'); 16997 * // => false 16998 */ 16999 function isLength(value) { 17000 return typeof value == 'number' && 17001 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 17002 } 17003 17004 /** 17005 * Checks if `value` is the 17006 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 17007 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 17008 * 17009 * @static 17010 * @memberOf _ 17011 * @since 0.1.0 17012 * @category Lang 17013 * @param {*} value The value to check. 17014 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 17015 * @example 17016 * 17017 * _.isObject({}); 17018 * // => true 17019 * 17020 * _.isObject([1, 2, 3]); 17021 * // => true 17022 * 17023 * _.isObject(_.noop); 17024 * // => true 17025 * 17026 * _.isObject(null); 17027 * // => false 17028 */ 17029 function isObject(value) { 17030 var type = typeof value; 17031 return value != null && (type == 'object' || type == 'function'); 17032 } 17033 17034 /** 17035 * Checks if `value` is object-like. A value is object-like if it's not `null` 17036 * and has a `typeof` result of "object". 17037 * 17038 * @static 17039 * @memberOf _ 17040 * @since 4.0.0 17041 * @category Lang 17042 * @param {*} value The value to check. 17043 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 17044 * @example 17045 * 17046 * _.isObjectLike({}); 17047 * // => true 17048 * 17049 * _.isObjectLike([1, 2, 3]); 17050 * // => true 17051 * 17052 * _.isObjectLike(_.noop); 17053 * // => false 17054 * 17055 * _.isObjectLike(null); 17056 * // => false 17057 */ 17058 function isObjectLike(value) { 17059 return value != null && typeof value == 'object'; 17060 } 17061 17062 /** 17063 * Checks if `value` is classified as a `Map` object. 17064 * 17065 * @static 17066 * @memberOf _ 17067 * @since 4.3.0 17068 * @category Lang 17069 * @param {*} value The value to check. 17070 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 17071 * @example 17072 * 17073 * _.isMap(new Map); 17074 * // => true 17075 * 17076 * _.isMap(new WeakMap); 17077 * // => false 17078 */ 17079 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 17080 17081 /** 17082 * Performs a partial deep comparison between `object` and `source` to 17083 * determine if `object` contains equivalent property values. 17084 * 17085 * **Note:** This method is equivalent to `_.matches` when `source` is 17086 * partially applied. 17087 * 17088 * Partial comparisons will match empty array and empty object `source` 17089 * values against any array or object value, respectively. See `_.isEqual` 17090 * for a list of supported value comparisons. 17091 * 17092 * @static 17093 * @memberOf _ 17094 * @since 3.0.0 17095 * @category Lang 17096 * @param {Object} object The object to inspect. 17097 * @param {Object} source The object of property values to match. 17098 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 17099 * @example 17100 * 17101 * var object = { 'a': 1, 'b': 2 }; 17102 * 17103 * _.isMatch(object, { 'b': 2 }); 17104 * // => true 17105 * 17106 * _.isMatch(object, { 'b': 1 }); 17107 * // => false 17108 */ 17109 function isMatch(object, source) { 17110 return object === source || baseIsMatch(object, source, getMatchData(source)); 17111 } 17112 17113 /** 17114 * This method is like `_.isMatch` except that it accepts `customizer` which 17115 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 17116 * are handled by the method instead. The `customizer` is invoked with five 17117 * arguments: (objValue, srcValue, index|key, object, source). 17118 * 17119 * @static 17120 * @memberOf _ 17121 * @since 4.0.0 17122 * @category Lang 17123 * @param {Object} object The object to inspect. 17124 * @param {Object} source The object of property values to match. 17125 * @param {Function} [customizer] The function to customize comparisons. 17126 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 17127 * @example 17128 * 17129 * function isGreeting(value) { 17130 * return /^h(?:i|ello)$/.test(value); 17131 * } 17132 * 17133 * function customizer(objValue, srcValue) { 17134 * if (isGreeting(objValue) && isGreeting(srcValue)) { 17135 * return true; 17136 * } 17137 * } 17138 * 17139 * var object = { 'greeting': 'hello' }; 17140 * var source = { 'greeting': 'hi' }; 17141 * 17142 * _.isMatchWith(object, source, customizer); 17143 * // => true 17144 */ 17145 function isMatchWith(object, source, customizer) { 17146 customizer = typeof customizer == 'function' ? customizer : undefined; 17147 return baseIsMatch(object, source, getMatchData(source), customizer); 17148 } 17149 17150 /** 17151 * Checks if `value` is `NaN`. 17152 * 17153 * **Note:** This method is based on 17154 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 17155 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 17156 * `undefined` and other non-number values. 17157 * 17158 * @static 17159 * @memberOf _ 17160 * @since 0.1.0 17161 * @category Lang 17162 * @param {*} value The value to check. 17163 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 17164 * @example 17165 * 17166 * _.isNaN(NaN); 17167 * // => true 17168 * 17169 * _.isNaN(new Number(NaN)); 17170 * // => true 17171 * 17172 * isNaN(undefined); 17173 * // => true 17174 * 17175 * _.isNaN(undefined); 17176 * // => false 17177 */ 17178 function isNaN(value) { 17179 // An `NaN` primitive is the only value that is not equal to itself. 17180 // Perform the `toStringTag` check first to avoid errors with some 17181 // ActiveX objects in IE. 17182 return isNumber(value) && value != +value; 17183 } 17184 17185 /** 17186 * Checks if `value` is a pristine native function. 17187 * 17188 * **Note:** This method can't reliably detect native functions in the presence 17189 * of the core-js package because core-js circumvents this kind of detection. 17190 * Despite multiple requests, the core-js maintainer has made it clear: any 17191 * attempt to fix the detection will be obstructed. As a result, we're left 17192 * with little choice but to throw an error. Unfortunately, this also affects 17193 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 17194 * which rely on core-js. 17195 * 17196 * @static 17197 * @memberOf _ 17198 * @since 3.0.0 17199 * @category Lang 17200 * @param {*} value The value to check. 17201 * @returns {boolean} Returns `true` if `value` is a native function, 17202 * else `false`. 17203 * @example 17204 * 17205 * _.isNative(Array.prototype.push); 17206 * // => true 17207 * 17208 * _.isNative(_); 17209 * // => false 17210 */ 17211 function isNative(value) { 17212 if (isMaskable(value)) { 17213 throw new Error(CORE_ERROR_TEXT); 17214 } 17215 return baseIsNative(value); 17216 } 17217 17218 /** 17219 * Checks if `value` is `null`. 17220 * 17221 * @static 17222 * @memberOf _ 17223 * @since 0.1.0 17224 * @category Lang 17225 * @param {*} value The value to check. 17226 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 17227 * @example 17228 * 17229 * _.isNull(null); 17230 * // => true 17231 * 17232 * _.isNull(void 0); 17233 * // => false 17234 */ 17235 function isNull(value) { 17236 return value === null; 17237 } 17238 17239 /** 17240 * Checks if `value` is `null` or `undefined`. 17241 * 17242 * @static 17243 * @memberOf _ 17244 * @since 4.0.0 17245 * @category Lang 17246 * @param {*} value The value to check. 17247 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 17248 * @example 17249 * 17250 * _.isNil(null); 17251 * // => true 17252 * 17253 * _.isNil(void 0); 17254 * // => true 17255 * 17256 * _.isNil(NaN); 17257 * // => false 17258 */ 17259 function isNil(value) { 17260 return value == null; 17261 } 17262 17263 /** 17264 * Checks if `value` is classified as a `Number` primitive or object. 17265 * 17266 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 17267 * classified as numbers, use the `_.isFinite` method. 17268 * 17269 * @static 17270 * @memberOf _ 17271 * @since 0.1.0 17272 * @category Lang 17273 * @param {*} value The value to check. 17274 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 17275 * @example 17276 * 17277 * _.isNumber(3); 17278 * // => true 17279 * 17280 * _.isNumber(Number.MIN_VALUE); 17281 * // => true 17282 * 17283 * _.isNumber(Infinity); 17284 * // => true 17285 * 17286 * _.isNumber('3'); 17287 * // => false 17288 */ 17289 function isNumber(value) { 17290 return typeof value == 'number' || 17291 (isObjectLike(value) && baseGetTag(value) == numberTag); 17292 } 17293 17294 /** 17295 * Checks if `value` is a plain object, that is, an object created by the 17296 * `Object` constructor or one with a `[[Prototype]]` of `null`. 17297 * 17298 * @static 17299 * @memberOf _ 17300 * @since 0.8.0 17301 * @category Lang 17302 * @param {*} value The value to check. 17303 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 17304 * @example 17305 * 17306 * function Foo() { 17307 * this.a = 1; 17308 * } 17309 * 17310 * _.isPlainObject(new Foo); 17311 * // => false 17312 * 17313 * _.isPlainObject([1, 2, 3]); 17314 * // => false 17315 * 17316 * _.isPlainObject({ 'x': 0, 'y': 0 }); 17317 * // => true 17318 * 17319 * _.isPlainObject(Object.create(null)); 17320 * // => true 17321 */ 17322 function isPlainObject(value) { 17323 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 17324 return false; 17325 } 17326 var proto = getPrototype(value); 17327 if (proto === null) { 17328 return true; 17329 } 17330 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 17331 return typeof Ctor == 'function' && Ctor instanceof Ctor && 17332 funcToString.call(Ctor) == objectCtorString; 17333 } 17334 17335 /** 17336 * Checks if `value` is classified as a `RegExp` object. 17337 * 17338 * @static 17339 * @memberOf _ 17340 * @since 0.1.0 17341 * @category Lang 17342 * @param {*} value The value to check. 17343 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 17344 * @example 17345 * 17346 * _.isRegExp(/abc/); 17347 * // => true 17348 * 17349 * _.isRegExp('/abc/'); 17350 * // => false 17351 */ 17352 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 17353 17354 /** 17355 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 17356 * double precision number which isn't the result of a rounded unsafe integer. 17357 * 17358 * **Note:** This method is based on 17359 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 17360 * 17361 * @static 17362 * @memberOf _ 17363 * @since 4.0.0 17364 * @category Lang 17365 * @param {*} value The value to check. 17366 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 17367 * @example 17368 * 17369 * _.isSafeInteger(3); 17370 * // => true 17371 * 17372 * _.isSafeInteger(Number.MIN_VALUE); 17373 * // => false 17374 * 17375 * _.isSafeInteger(Infinity); 17376 * // => false 17377 * 17378 * _.isSafeInteger('3'); 17379 * // => false 17380 */ 17381 function isSafeInteger(value) { 17382 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 17383 } 17384 17385 /** 17386 * Checks if `value` is classified as a `Set` object. 17387 * 17388 * @static 17389 * @memberOf _ 17390 * @since 4.3.0 17391 * @category Lang 17392 * @param {*} value The value to check. 17393 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 17394 * @example 17395 * 17396 * _.isSet(new Set); 17397 * // => true 17398 * 17399 * _.isSet(new WeakSet); 17400 * // => false 17401 */ 17402 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 17403 17404 /** 17405 * Checks if `value` is classified as a `String` primitive or object. 17406 * 17407 * @static 17408 * @since 0.1.0 17409 * @memberOf _ 17410 * @category Lang 17411 * @param {*} value The value to check. 17412 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 17413 * @example 17414 * 17415 * _.isString('abc'); 17416 * // => true 17417 * 17418 * _.isString(1); 17419 * // => false 17420 */ 17421 function isString(value) { 17422 return typeof value == 'string' || 17423 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 17424 } 17425 17426 /** 17427 * Checks if `value` is classified as a `Symbol` primitive or object. 17428 * 17429 * @static 17430 * @memberOf _ 17431 * @since 4.0.0 17432 * @category Lang 17433 * @param {*} value The value to check. 17434 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 17435 * @example 17436 * 17437 * _.isSymbol(Symbol.iterator); 17438 * // => true 17439 * 17440 * _.isSymbol('abc'); 17441 * // => false 17442 */ 17443 function isSymbol(value) { 17444 return typeof value == 'symbol' || 17445 (isObjectLike(value) && baseGetTag(value) == symbolTag); 17446 } 17447 17448 /** 17449 * Checks if `value` is classified as a typed array. 17450 * 17451 * @static 17452 * @memberOf _ 17453 * @since 3.0.0 17454 * @category Lang 17455 * @param {*} value The value to check. 17456 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 17457 * @example 17458 * 17459 * _.isTypedArray(new Uint8Array); 17460 * // => true 17461 * 17462 * _.isTypedArray([]); 17463 * // => false 17464 */ 17465 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 17466 17467 /** 17468 * Checks if `value` is `undefined`. 17469 * 17470 * @static 17471 * @since 0.1.0 17472 * @memberOf _ 17473 * @category Lang 17474 * @param {*} value The value to check. 17475 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 17476 * @example 17477 * 17478 * _.isUndefined(void 0); 17479 * // => true 17480 * 17481 * _.isUndefined(null); 17482 * // => false 17483 */ 17484 function isUndefined(value) { 17485 return value === undefined; 17486 } 17487 17488 /** 17489 * Checks if `value` is classified as a `WeakMap` object. 17490 * 17491 * @static 17492 * @memberOf _ 17493 * @since 4.3.0 17494 * @category Lang 17495 * @param {*} value The value to check. 17496 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 17497 * @example 17498 * 17499 * _.isWeakMap(new WeakMap); 17500 * // => true 17501 * 17502 * _.isWeakMap(new Map); 17503 * // => false 17504 */ 17505 function isWeakMap(value) { 17506 return isObjectLike(value) && getTag(value) == weakMapTag; 17507 } 17508 17509 /** 17510 * Checks if `value` is classified as a `WeakSet` object. 17511 * 17512 * @static 17513 * @memberOf _ 17514 * @since 4.3.0 17515 * @category Lang 17516 * @param {*} value The value to check. 17517 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 17518 * @example 17519 * 17520 * _.isWeakSet(new WeakSet); 17521 * // => true 17522 * 17523 * _.isWeakSet(new Set); 17524 * // => false 17525 */ 17526 function isWeakSet(value) { 17527 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 17528 } 17529 17530 /** 17531 * Checks if `value` is less than `other`. 17532 * 17533 * @static 17534 * @memberOf _ 17535 * @since 3.9.0 17536 * @category Lang 17537 * @param {*} value The value to compare. 17538 * @param {*} other The other value to compare. 17539 * @returns {boolean} Returns `true` if `value` is less than `other`, 17540 * else `false`. 17541 * @see _.gt 17542 * @example 17543 * 17544 * _.lt(1, 3); 17545 * // => true 17546 * 17547 * _.lt(3, 3); 17548 * // => false 17549 * 17550 * _.lt(3, 1); 17551 * // => false 17552 */ 17553 var lt = createRelationalOperation(baseLt); 17554 17555 /** 17556 * Checks if `value` is less than or equal to `other`. 17557 * 17558 * @static 17559 * @memberOf _ 17560 * @since 3.9.0 17561 * @category Lang 17562 * @param {*} value The value to compare. 17563 * @param {*} other The other value to compare. 17564 * @returns {boolean} Returns `true` if `value` is less than or equal to 17565 * `other`, else `false`. 17566 * @see _.gte 17567 * @example 17568 * 17569 * _.lte(1, 3); 17570 * // => true 17571 * 17572 * _.lte(3, 3); 17573 * // => true 17574 * 17575 * _.lte(3, 1); 17576 * // => false 17577 */ 17578 var lte = createRelationalOperation(function(value, other) { 17579 return value <= other; 17580 }); 17581 17582 /** 17583 * Converts `value` to an array. 17584 * 17585 * @static 17586 * @since 0.1.0 17587 * @memberOf _ 17588 * @category Lang 17589 * @param {*} value The value to convert. 17590 * @returns {Array} Returns the converted array. 17591 * @example 17592 * 17593 * _.toArray({ 'a': 1, 'b': 2 }); 17594 * // => [1, 2] 17595 * 17596 * _.toArray('abc'); 17597 * // => ['a', 'b', 'c'] 17598 * 17599 * _.toArray(1); 17600 * // => [] 17601 * 17602 * _.toArray(null); 17603 * // => [] 17604 */ 17605 function toArray(value) { 17606 if (!value) { 17607 return []; 17608 } 17609 if (isArrayLike(value)) { 17610 return isString(value) ? stringToArray(value) : copyArray(value); 17611 } 17612 if (symIterator && value[symIterator]) { 17613 return iteratorToArray(value[symIterator]()); 17614 } 17615 var tag = getTag(value), 17616 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 17617 17618 return func(value); 17619 } 17620 17621 /** 17622 * Converts `value` to a finite number. 17623 * 17624 * @static 17625 * @memberOf _ 17626 * @since 4.12.0 17627 * @category Lang 17628 * @param {*} value The value to convert. 17629 * @returns {number} Returns the converted number. 17630 * @example 17631 * 17632 * _.toFinite(3.2); 17633 * // => 3.2 17634 * 17635 * _.toFinite(Number.MIN_VALUE); 17636 * // => 5e-324 17637 * 17638 * _.toFinite(Infinity); 17639 * // => 1.7976931348623157e+308 17640 * 17641 * _.toFinite('3.2'); 17642 * // => 3.2 17643 */ 17644 function toFinite(value) { 17645 if (!value) { 17646 return value === 0 ? value : 0; 17647 } 17648 value = toNumber(value); 17649 if (value === INFINITY || value === -INFINITY) { 17650 var sign = (value < 0 ? -1 : 1); 17651 return sign * MAX_INTEGER; 17652 } 17653 return value === value ? value : 0; 17654 } 17655 17656 /** 17657 * Converts `value` to an integer. 17658 * 17659 * **Note:** This method is loosely based on 17660 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 17661 * 17662 * @static 17663 * @memberOf _ 17664 * @since 4.0.0 17665 * @category Lang 17666 * @param {*} value The value to convert. 17667 * @returns {number} Returns the converted integer. 17668 * @example 17669 * 17670 * _.toInteger(3.2); 17671 * // => 3 17672 * 17673 * _.toInteger(Number.MIN_VALUE); 17674 * // => 0 17675 * 17676 * _.toInteger(Infinity); 17677 * // => 1.7976931348623157e+308 17678 * 17679 * _.toInteger('3.2'); 17680 * // => 3 17681 */ 17682 function toInteger(value) { 17683 var result = toFinite(value), 17684 remainder = result % 1; 17685 17686 return result === result ? (remainder ? result - remainder : result) : 0; 17687 } 17688 17689 /** 17690 * Converts `value` to an integer suitable for use as the length of an 17691 * array-like object. 17692 * 17693 * **Note:** This method is based on 17694 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 17695 * 17696 * @static 17697 * @memberOf _ 17698 * @since 4.0.0 17699 * @category Lang 17700 * @param {*} value The value to convert. 17701 * @returns {number} Returns the converted integer. 17702 * @example 17703 * 17704 * _.toLength(3.2); 17705 * // => 3 17706 * 17707 * _.toLength(Number.MIN_VALUE); 17708 * // => 0 17709 * 17710 * _.toLength(Infinity); 17711 * // => 4294967295 17712 * 17713 * _.toLength('3.2'); 17714 * // => 3 17715 */ 17716 function toLength(value) { 17717 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 17718 } 17719 17720 /** 17721 * Converts `value` to a number. 17722 * 17723 * @static 17724 * @memberOf _ 17725 * @since 4.0.0 17726 * @category Lang 17727 * @param {*} value The value to process. 17728 * @returns {number} Returns the number. 17729 * @example 17730 * 17731 * _.toNumber(3.2); 17732 * // => 3.2 17733 * 17734 * _.toNumber(Number.MIN_VALUE); 17735 * // => 5e-324 17736 * 17737 * _.toNumber(Infinity); 17738 * // => Infinity 17739 * 17740 * _.toNumber('3.2'); 17741 * // => 3.2 17742 */ 17743 function toNumber(value) { 17744 if (typeof value == 'number') { 17745 return value; 17746 } 17747 if (isSymbol(value)) { 17748 return NAN; 17749 } 17750 if (isObject(value)) { 17751 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 17752 value = isObject(other) ? (other + '') : other; 17753 } 17754 if (typeof value != 'string') { 17755 return value === 0 ? value : +value; 17756 } 17757 value = baseTrim(value); 17758 var isBinary = reIsBinary.test(value); 17759 return (isBinary || reIsOctal.test(value)) 17760 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 17761 : (reIsBadHex.test(value) ? NAN : +value); 17762 } 17763 17764 /** 17765 * Converts `value` to a plain object flattening inherited enumerable string 17766 * keyed properties of `value` to own properties of the plain object. 17767 * 17768 * @static 17769 * @memberOf _ 17770 * @since 3.0.0 17771 * @category Lang 17772 * @param {*} value The value to convert. 17773 * @returns {Object} Returns the converted plain object. 17774 * @example 17775 * 17776 * function Foo() { 17777 * this.b = 2; 17778 * } 17779 * 17780 * Foo.prototype.c = 3; 17781 * 17782 * _.assign({ 'a': 1 }, new Foo); 17783 * // => { 'a': 1, 'b': 2 } 17784 * 17785 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 17786 * // => { 'a': 1, 'b': 2, 'c': 3 } 17787 */ 17788 function toPlainObject(value) { 17789 return copyObject(value, keysIn(value)); 17790 } 17791 17792 /** 17793 * Converts `value` to a safe integer. A safe integer can be compared and 17794 * represented correctly. 17795 * 17796 * @static 17797 * @memberOf _ 17798 * @since 4.0.0 17799 * @category Lang 17800 * @param {*} value The value to convert. 17801 * @returns {number} Returns the converted integer. 17802 * @example 17803 * 17804 * _.toSafeInteger(3.2); 17805 * // => 3 17806 * 17807 * _.toSafeInteger(Number.MIN_VALUE); 17808 * // => 0 17809 * 17810 * _.toSafeInteger(Infinity); 17811 * // => 9007199254740991 17812 * 17813 * _.toSafeInteger('3.2'); 17814 * // => 3 17815 */ 17816 function toSafeInteger(value) { 17817 return value 17818 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 17819 : (value === 0 ? value : 0); 17820 } 17821 17822 /** 17823 * Converts `value` to a string. An empty string is returned for `null` 17824 * and `undefined` values. The sign of `-0` is preserved. 17825 * 17826 * @static 17827 * @memberOf _ 17828 * @since 4.0.0 17829 * @category Lang 17830 * @param {*} value The value to convert. 17831 * @returns {string} Returns the converted string. 17832 * @example 17833 * 17834 * _.toString(null); 17835 * // => '' 17836 * 17837 * _.toString(-0); 17838 * // => '-0' 17839 * 17840 * _.toString([1, 2, 3]); 17841 * // => '1,2,3' 17842 */ 17843 function toString(value) { 17844 return value == null ? '' : baseToString(value); 17845 } 17846 17847 /*------------------------------------------------------------------------*/ 17848 17849 /** 17850 * Assigns own enumerable string keyed properties of source objects to the 17851 * destination object. Source objects are applied from left to right. 17852 * Subsequent sources overwrite property assignments of previous sources. 17853 * 17854 * **Note:** This method mutates `object` and is loosely based on 17855 * [`Object.assign`](https://mdn.io/Object/assign). 17856 * 17857 * @static 17858 * @memberOf _ 17859 * @since 0.10.0 17860 * @category Object 17861 * @param {Object} object The destination object. 17862 * @param {...Object} [sources] The source objects. 17863 * @returns {Object} Returns `object`. 17864 * @see _.assignIn 17865 * @example 17866 * 17867 * function Foo() { 17868 * this.a = 1; 17869 * } 17870 * 17871 * function Bar() { 17872 * this.c = 3; 17873 * } 17874 * 17875 * Foo.prototype.b = 2; 17876 * Bar.prototype.d = 4; 17877 * 17878 * _.assign({ 'a': 0 }, new Foo, new Bar); 17879 * // => { 'a': 1, 'c': 3 } 17880 */ 17881 var assign = createAssigner(function(object, source) { 17882 if (isPrototype(source) || isArrayLike(source)) { 17883 copyObject(source, keys(source), object); 17884 return; 17885 } 17886 for (var key in source) { 17887 if (hasOwnProperty.call(source, key)) { 17888 assignValue(object, key, source[key]); 17889 } 17890 } 17891 }); 17892 17893 /** 17894 * This method is like `_.assign` except that it iterates over own and 17895 * inherited source properties. 17896 * 17897 * **Note:** This method mutates `object`. 17898 * 17899 * @static 17900 * @memberOf _ 17901 * @since 4.0.0 17902 * @alias extend 17903 * @category Object 17904 * @param {Object} object The destination object. 17905 * @param {...Object} [sources] The source objects. 17906 * @returns {Object} Returns `object`. 17907 * @see _.assign 17908 * @example 17909 * 17910 * function Foo() { 17911 * this.a = 1; 17912 * } 17913 * 17914 * function Bar() { 17915 * this.c = 3; 17916 * } 17917 * 17918 * Foo.prototype.b = 2; 17919 * Bar.prototype.d = 4; 17920 * 17921 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 17922 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 17923 */ 17924 var assignIn = createAssigner(function(object, source) { 17925 copyObject(source, keysIn(source), object); 17926 }); 17927 17928 /** 17929 * This method is like `_.assignIn` except that it accepts `customizer` 17930 * which is invoked to produce the assigned values. If `customizer` returns 17931 * `undefined`, assignment is handled by the method instead. The `customizer` 17932 * is invoked with five arguments: (objValue, srcValue, key, object, source). 17933 * 17934 * **Note:** This method mutates `object`. 17935 * 17936 * @static 17937 * @memberOf _ 17938 * @since 4.0.0 17939 * @alias extendWith 17940 * @category Object 17941 * @param {Object} object The destination object. 17942 * @param {...Object} sources The source objects. 17943 * @param {Function} [customizer] The function to customize assigned values. 17944 * @returns {Object} Returns `object`. 17945 * @see _.assignWith 17946 * @example 17947 * 17948 * function customizer(objValue, srcValue) { 17949 * return _.isUndefined(objValue) ? srcValue : objValue; 17950 * } 17951 * 17952 * var defaults = _.partialRight(_.assignInWith, customizer); 17953 * 17954 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 17955 * // => { 'a': 1, 'b': 2 } 17956 */ 17957 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 17958 copyObject(source, keysIn(source), object, customizer); 17959 }); 17960 17961 /** 17962 * This method is like `_.assign` except that it accepts `customizer` 17963 * which is invoked to produce the assigned values. If `customizer` returns 17964 * `undefined`, assignment is handled by the method instead. The `customizer` 17965 * is invoked with five arguments: (objValue, srcValue, key, object, source). 17966 * 17967 * **Note:** This method mutates `object`. 17968 * 17969 * @static 17970 * @memberOf _ 17971 * @since 4.0.0 17972 * @category Object 17973 * @param {Object} object The destination object. 17974 * @param {...Object} sources The source objects. 17975 * @param {Function} [customizer] The function to customize assigned values. 17976 * @returns {Object} Returns `object`. 17977 * @see _.assignInWith 17978 * @example 17979 * 17980 * function customizer(objValue, srcValue) { 17981 * return _.isUndefined(objValue) ? srcValue : objValue; 17982 * } 17983 * 17984 * var defaults = _.partialRight(_.assignWith, customizer); 17985 * 17986 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 17987 * // => { 'a': 1, 'b': 2 } 17988 */ 17989 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 17990 copyObject(source, keys(source), object, customizer); 17991 }); 17992 17993 /** 17994 * Creates an array of values corresponding to `paths` of `object`. 17995 * 17996 * @static 17997 * @memberOf _ 17998 * @since 1.0.0 17999 * @category Object 18000 * @param {Object} object The object to iterate over. 18001 * @param {...(string|string[])} [paths] The property paths to pick. 18002 * @returns {Array} Returns the picked values. 18003 * @example 18004 * 18005 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 18006 * 18007 * _.at(object, ['a[0].b.c', 'a[1]']); 18008 * // => [3, 4] 18009 */ 18010 var at = flatRest(baseAt); 18011 18012 /** 18013 * Creates an object that inherits from the `prototype` object. If a 18014 * `properties` object is given, its own enumerable string keyed properties 18015 * are assigned to the created object. 18016 * 18017 * @static 18018 * @memberOf _ 18019 * @since 2.3.0 18020 * @category Object 18021 * @param {Object} prototype The object to inherit from. 18022 * @param {Object} [properties] The properties to assign to the object. 18023 * @returns {Object} Returns the new object. 18024 * @example 18025 * 18026 * function Shape() { 18027 * this.x = 0; 18028 * this.y = 0; 18029 * } 18030 * 18031 * function Circle() { 18032 * Shape.call(this); 18033 * } 18034 * 18035 * Circle.prototype = _.create(Shape.prototype, { 18036 * 'constructor': Circle 18037 * }); 18038 * 18039 * var circle = new Circle; 18040 * circle instanceof Circle; 18041 * // => true 18042 * 18043 * circle instanceof Shape; 18044 * // => true 18045 */ 18046 function create(prototype, properties) { 18047 var result = baseCreate(prototype); 18048 return properties == null ? result : baseAssign(result, properties); 18049 } 18050 18051 /** 18052 * Assigns own and inherited enumerable string keyed properties of source 18053 * objects to the destination object for all destination properties that 18054 * resolve to `undefined`. Source objects are applied from left to right. 18055 * Once a property is set, additional values of the same property are ignored. 18056 * 18057 * **Note:** This method mutates `object`. 18058 * 18059 * @static 18060 * @since 0.1.0 18061 * @memberOf _ 18062 * @category Object 18063 * @param {Object} object The destination object. 18064 * @param {...Object} [sources] The source objects. 18065 * @returns {Object} Returns `object`. 18066 * @see _.defaultsDeep 18067 * @example 18068 * 18069 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 18070 * // => { 'a': 1, 'b': 2 } 18071 */ 18072 var defaults = baseRest(function(object, sources) { 18073 object = Object(object); 18074 18075 var index = -1; 18076 var length = sources.length; 18077 var guard = length > 2 ? sources[2] : undefined; 18078 18079 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 18080 length = 1; 18081 } 18082 18083 while (++index < length) { 18084 var source = sources[index]; 18085 var props = keysIn(source); 18086 var propsIndex = -1; 18087 var propsLength = props.length; 18088 18089 while (++propsIndex < propsLength) { 18090 var key = props[propsIndex]; 18091 var value = object[key]; 18092 18093 if (value === undefined || 18094 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 18095 object[key] = source[key]; 18096 } 18097 } 18098 } 18099 18100 return object; 18101 }); 18102 18103 /** 18104 * This method is like `_.defaults` except that it recursively assigns 18105 * default properties. 18106 * 18107 * **Note:** This method mutates `object`. 18108 * 18109 * @static 18110 * @memberOf _ 18111 * @since 3.10.0 18112 * @category Object 18113 * @param {Object} object The destination object. 18114 * @param {...Object} [sources] The source objects. 18115 * @returns {Object} Returns `object`. 18116 * @see _.defaults 18117 * @example 18118 * 18119 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 18120 * // => { 'a': { 'b': 2, 'c': 3 } } 18121 */ 18122 var defaultsDeep = baseRest(function(args) { 18123 args.push(undefined, customDefaultsMerge); 18124 return apply(mergeWith, undefined, args); 18125 }); 18126 18127 /** 18128 * This method is like `_.find` except that it returns the key of the first 18129 * element `predicate` returns truthy for instead of the element itself. 18130 * 18131 * @static 18132 * @memberOf _ 18133 * @since 1.1.0 18134 * @category Object 18135 * @param {Object} object The object to inspect. 18136 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18137 * @returns {string|undefined} Returns the key of the matched element, 18138 * else `undefined`. 18139 * @example 18140 * 18141 * var users = { 18142 * 'barney': { 'age': 36, 'active': true }, 18143 * 'fred': { 'age': 40, 'active': false }, 18144 * 'pebbles': { 'age': 1, 'active': true } 18145 * }; 18146 * 18147 * _.findKey(users, function(o) { return o.age < 40; }); 18148 * // => 'barney' (iteration order is not guaranteed) 18149 * 18150 * // The `_.matches` iteratee shorthand. 18151 * _.findKey(users, { 'age': 1, 'active': true }); 18152 * // => 'pebbles' 18153 * 18154 * // The `_.matchesProperty` iteratee shorthand. 18155 * _.findKey(users, ['active', false]); 18156 * // => 'fred' 18157 * 18158 * // The `_.property` iteratee shorthand. 18159 * _.findKey(users, 'active'); 18160 * // => 'barney' 18161 */ 18162 function findKey(object, predicate) { 18163 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 18164 } 18165 18166 /** 18167 * This method is like `_.findKey` except that it iterates over elements of 18168 * a collection in the opposite order. 18169 * 18170 * @static 18171 * @memberOf _ 18172 * @since 2.0.0 18173 * @category Object 18174 * @param {Object} object The object to inspect. 18175 * @param {Function} [predicate=_.identity] The function invoked per iteration. 18176 * @returns {string|undefined} Returns the key of the matched element, 18177 * else `undefined`. 18178 * @example 18179 * 18180 * var users = { 18181 * 'barney': { 'age': 36, 'active': true }, 18182 * 'fred': { 'age': 40, 'active': false }, 18183 * 'pebbles': { 'age': 1, 'active': true } 18184 * }; 18185 * 18186 * _.findLastKey(users, function(o) { return o.age < 40; }); 18187 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 18188 * 18189 * // The `_.matches` iteratee shorthand. 18190 * _.findLastKey(users, { 'age': 36, 'active': true }); 18191 * // => 'barney' 18192 * 18193 * // The `_.matchesProperty` iteratee shorthand. 18194 * _.findLastKey(users, ['active', false]); 18195 * // => 'fred' 18196 * 18197 * // The `_.property` iteratee shorthand. 18198 * _.findLastKey(users, 'active'); 18199 * // => 'pebbles' 18200 */ 18201 function findLastKey(object, predicate) { 18202 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 18203 } 18204 18205 /** 18206 * Iterates over own and inherited enumerable string keyed properties of an 18207 * object and invokes `iteratee` for each property. The iteratee is invoked 18208 * with three arguments: (value, key, object). Iteratee functions may exit 18209 * iteration early by explicitly returning `false`. 18210 * 18211 * @static 18212 * @memberOf _ 18213 * @since 0.3.0 18214 * @category Object 18215 * @param {Object} object The object to iterate over. 18216 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18217 * @returns {Object} Returns `object`. 18218 * @see _.forInRight 18219 * @example 18220 * 18221 * function Foo() { 18222 * this.a = 1; 18223 * this.b = 2; 18224 * } 18225 * 18226 * Foo.prototype.c = 3; 18227 * 18228 * _.forIn(new Foo, function(value, key) { 18229 * console.log(key); 18230 * }); 18231 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 18232 */ 18233 function forIn(object, iteratee) { 18234 return object == null 18235 ? object 18236 : baseFor(object, getIteratee(iteratee, 3), keysIn); 18237 } 18238 18239 /** 18240 * This method is like `_.forIn` except that it iterates over properties of 18241 * `object` in the opposite order. 18242 * 18243 * @static 18244 * @memberOf _ 18245 * @since 2.0.0 18246 * @category Object 18247 * @param {Object} object The object to iterate over. 18248 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18249 * @returns {Object} Returns `object`. 18250 * @see _.forIn 18251 * @example 18252 * 18253 * function Foo() { 18254 * this.a = 1; 18255 * this.b = 2; 18256 * } 18257 * 18258 * Foo.prototype.c = 3; 18259 * 18260 * _.forInRight(new Foo, function(value, key) { 18261 * console.log(key); 18262 * }); 18263 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 18264 */ 18265 function forInRight(object, iteratee) { 18266 return object == null 18267 ? object 18268 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 18269 } 18270 18271 /** 18272 * Iterates over own enumerable string keyed properties of an object and 18273 * invokes `iteratee` for each property. The iteratee is invoked with three 18274 * arguments: (value, key, object). Iteratee functions may exit iteration 18275 * early by explicitly returning `false`. 18276 * 18277 * @static 18278 * @memberOf _ 18279 * @since 0.3.0 18280 * @category Object 18281 * @param {Object} object The object to iterate over. 18282 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18283 * @returns {Object} Returns `object`. 18284 * @see _.forOwnRight 18285 * @example 18286 * 18287 * function Foo() { 18288 * this.a = 1; 18289 * this.b = 2; 18290 * } 18291 * 18292 * Foo.prototype.c = 3; 18293 * 18294 * _.forOwn(new Foo, function(value, key) { 18295 * console.log(key); 18296 * }); 18297 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 18298 */ 18299 function forOwn(object, iteratee) { 18300 return object && baseForOwn(object, getIteratee(iteratee, 3)); 18301 } 18302 18303 /** 18304 * This method is like `_.forOwn` except that it iterates over properties of 18305 * `object` in the opposite order. 18306 * 18307 * @static 18308 * @memberOf _ 18309 * @since 2.0.0 18310 * @category Object 18311 * @param {Object} object The object to iterate over. 18312 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18313 * @returns {Object} Returns `object`. 18314 * @see _.forOwn 18315 * @example 18316 * 18317 * function Foo() { 18318 * this.a = 1; 18319 * this.b = 2; 18320 * } 18321 * 18322 * Foo.prototype.c = 3; 18323 * 18324 * _.forOwnRight(new Foo, function(value, key) { 18325 * console.log(key); 18326 * }); 18327 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 18328 */ 18329 function forOwnRight(object, iteratee) { 18330 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 18331 } 18332 18333 /** 18334 * Creates an array of function property names from own enumerable properties 18335 * of `object`. 18336 * 18337 * @static 18338 * @since 0.1.0 18339 * @memberOf _ 18340 * @category Object 18341 * @param {Object} object The object to inspect. 18342 * @returns {Array} Returns the function names. 18343 * @see _.functionsIn 18344 * @example 18345 * 18346 * function Foo() { 18347 * this.a = _.constant('a'); 18348 * this.b = _.constant('b'); 18349 * } 18350 * 18351 * Foo.prototype.c = _.constant('c'); 18352 * 18353 * _.functions(new Foo); 18354 * // => ['a', 'b'] 18355 */ 18356 function functions(object) { 18357 return object == null ? [] : baseFunctions(object, keys(object)); 18358 } 18359 18360 /** 18361 * Creates an array of function property names from own and inherited 18362 * enumerable properties of `object`. 18363 * 18364 * @static 18365 * @memberOf _ 18366 * @since 4.0.0 18367 * @category Object 18368 * @param {Object} object The object to inspect. 18369 * @returns {Array} Returns the function names. 18370 * @see _.functions 18371 * @example 18372 * 18373 * function Foo() { 18374 * this.a = _.constant('a'); 18375 * this.b = _.constant('b'); 18376 * } 18377 * 18378 * Foo.prototype.c = _.constant('c'); 18379 * 18380 * _.functionsIn(new Foo); 18381 * // => ['a', 'b', 'c'] 18382 */ 18383 function functionsIn(object) { 18384 return object == null ? [] : baseFunctions(object, keysIn(object)); 18385 } 18386 18387 /** 18388 * Gets the value at `path` of `object`. If the resolved value is 18389 * `undefined`, the `defaultValue` is returned in its place. 18390 * 18391 * @static 18392 * @memberOf _ 18393 * @since 3.7.0 18394 * @category Object 18395 * @param {Object} object The object to query. 18396 * @param {Array|string} path The path of the property to get. 18397 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 18398 * @returns {*} Returns the resolved value. 18399 * @example 18400 * 18401 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 18402 * 18403 * _.get(object, 'a[0].b.c'); 18404 * // => 3 18405 * 18406 * _.get(object, ['a', '0', 'b', 'c']); 18407 * // => 3 18408 * 18409 * _.get(object, 'a.b.c', 'default'); 18410 * // => 'default' 18411 */ 18412 function get(object, path, defaultValue) { 18413 var result = object == null ? undefined : baseGet(object, path); 18414 return result === undefined ? defaultValue : result; 18415 } 18416 18417 /** 18418 * Checks if `path` is a direct property of `object`. 18419 * 18420 * @static 18421 * @since 0.1.0 18422 * @memberOf _ 18423 * @category Object 18424 * @param {Object} object The object to query. 18425 * @param {Array|string} path The path to check. 18426 * @returns {boolean} Returns `true` if `path` exists, else `false`. 18427 * @example 18428 * 18429 * var object = { 'a': { 'b': 2 } }; 18430 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 18431 * 18432 * _.has(object, 'a'); 18433 * // => true 18434 * 18435 * _.has(object, 'a.b'); 18436 * // => true 18437 * 18438 * _.has(object, ['a', 'b']); 18439 * // => true 18440 * 18441 * _.has(other, 'a'); 18442 * // => false 18443 */ 18444 function has(object, path) { 18445 return object != null && hasPath(object, path, baseHas); 18446 } 18447 18448 /** 18449 * Checks if `path` is a direct or inherited property of `object`. 18450 * 18451 * @static 18452 * @memberOf _ 18453 * @since 4.0.0 18454 * @category Object 18455 * @param {Object} object The object to query. 18456 * @param {Array|string} path The path to check. 18457 * @returns {boolean} Returns `true` if `path` exists, else `false`. 18458 * @example 18459 * 18460 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 18461 * 18462 * _.hasIn(object, 'a'); 18463 * // => true 18464 * 18465 * _.hasIn(object, 'a.b'); 18466 * // => true 18467 * 18468 * _.hasIn(object, ['a', 'b']); 18469 * // => true 18470 * 18471 * _.hasIn(object, 'b'); 18472 * // => false 18473 */ 18474 function hasIn(object, path) { 18475 return object != null && hasPath(object, path, baseHasIn); 18476 } 18477 18478 /** 18479 * Creates an object composed of the inverted keys and values of `object`. 18480 * If `object` contains duplicate values, subsequent values overwrite 18481 * property assignments of previous values. 18482 * 18483 * @static 18484 * @memberOf _ 18485 * @since 0.7.0 18486 * @category Object 18487 * @param {Object} object The object to invert. 18488 * @returns {Object} Returns the new inverted object. 18489 * @example 18490 * 18491 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 18492 * 18493 * _.invert(object); 18494 * // => { '1': 'c', '2': 'b' } 18495 */ 18496 var invert = createInverter(function(result, value, key) { 18497 if (value != null && 18498 typeof value.toString != 'function') { 18499 value = nativeObjectToString.call(value); 18500 } 18501 18502 result[value] = key; 18503 }, constant(identity)); 18504 18505 /** 18506 * This method is like `_.invert` except that the inverted object is generated 18507 * from the results of running each element of `object` thru `iteratee`. The 18508 * corresponding inverted value of each inverted key is an array of keys 18509 * responsible for generating the inverted value. The iteratee is invoked 18510 * with one argument: (value). 18511 * 18512 * @static 18513 * @memberOf _ 18514 * @since 4.1.0 18515 * @category Object 18516 * @param {Object} object The object to invert. 18517 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18518 * @returns {Object} Returns the new inverted object. 18519 * @example 18520 * 18521 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 18522 * 18523 * _.invertBy(object); 18524 * // => { '1': ['a', 'c'], '2': ['b'] } 18525 * 18526 * _.invertBy(object, function(value) { 18527 * return 'group' + value; 18528 * }); 18529 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 18530 */ 18531 var invertBy = createInverter(function(result, value, key) { 18532 if (value != null && 18533 typeof value.toString != 'function') { 18534 value = nativeObjectToString.call(value); 18535 } 18536 18537 if (hasOwnProperty.call(result, value)) { 18538 result[value].push(key); 18539 } else { 18540 result[value] = [key]; 18541 } 18542 }, getIteratee); 18543 18544 /** 18545 * Invokes the method at `path` of `object`. 18546 * 18547 * @static 18548 * @memberOf _ 18549 * @since 4.0.0 18550 * @category Object 18551 * @param {Object} object The object to query. 18552 * @param {Array|string} path The path of the method to invoke. 18553 * @param {...*} [args] The arguments to invoke the method with. 18554 * @returns {*} Returns the result of the invoked method. 18555 * @example 18556 * 18557 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 18558 * 18559 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 18560 * // => [2, 3] 18561 */ 18562 var invoke = baseRest(baseInvoke); 18563 18564 /** 18565 * Creates an array of the own enumerable property names of `object`. 18566 * 18567 * **Note:** Non-object values are coerced to objects. See the 18568 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 18569 * for more details. 18570 * 18571 * @static 18572 * @since 0.1.0 18573 * @memberOf _ 18574 * @category Object 18575 * @param {Object} object The object to query. 18576 * @returns {Array} Returns the array of property names. 18577 * @example 18578 * 18579 * function Foo() { 18580 * this.a = 1; 18581 * this.b = 2; 18582 * } 18583 * 18584 * Foo.prototype.c = 3; 18585 * 18586 * _.keys(new Foo); 18587 * // => ['a', 'b'] (iteration order is not guaranteed) 18588 * 18589 * _.keys('hi'); 18590 * // => ['0', '1'] 18591 */ 18592 function keys(object) { 18593 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 18594 } 18595 18596 /** 18597 * Creates an array of the own and inherited enumerable property names of `object`. 18598 * 18599 * **Note:** Non-object values are coerced to objects. 18600 * 18601 * @static 18602 * @memberOf _ 18603 * @since 3.0.0 18604 * @category Object 18605 * @param {Object} object The object to query. 18606 * @returns {Array} Returns the array of property names. 18607 * @example 18608 * 18609 * function Foo() { 18610 * this.a = 1; 18611 * this.b = 2; 18612 * } 18613 * 18614 * Foo.prototype.c = 3; 18615 * 18616 * _.keysIn(new Foo); 18617 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 18618 */ 18619 function keysIn(object) { 18620 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 18621 } 18622 18623 /** 18624 * The opposite of `_.mapValues`; this method creates an object with the 18625 * same values as `object` and keys generated by running each own enumerable 18626 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 18627 * with three arguments: (value, key, object). 18628 * 18629 * @static 18630 * @memberOf _ 18631 * @since 3.8.0 18632 * @category Object 18633 * @param {Object} object The object to iterate over. 18634 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18635 * @returns {Object} Returns the new mapped object. 18636 * @see _.mapValues 18637 * @example 18638 * 18639 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 18640 * return key + value; 18641 * }); 18642 * // => { 'a1': 1, 'b2': 2 } 18643 */ 18644 function mapKeys(object, iteratee) { 18645 var result = {}; 18646 iteratee = getIteratee(iteratee, 3); 18647 18648 baseForOwn(object, function(value, key, object) { 18649 baseAssignValue(result, iteratee(value, key, object), value); 18650 }); 18651 return result; 18652 } 18653 18654 /** 18655 * Creates an object with the same keys as `object` and values generated 18656 * by running each own enumerable string keyed property of `object` thru 18657 * `iteratee`. The iteratee is invoked with three arguments: 18658 * (value, key, object). 18659 * 18660 * @static 18661 * @memberOf _ 18662 * @since 2.4.0 18663 * @category Object 18664 * @param {Object} object The object to iterate over. 18665 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18666 * @returns {Object} Returns the new mapped object. 18667 * @see _.mapKeys 18668 * @example 18669 * 18670 * var users = { 18671 * 'fred': { 'user': 'fred', 'age': 40 }, 18672 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 18673 * }; 18674 * 18675 * _.mapValues(users, function(o) { return o.age; }); 18676 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 18677 * 18678 * // The `_.property` iteratee shorthand. 18679 * _.mapValues(users, 'age'); 18680 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 18681 */ 18682 function mapValues(object, iteratee) { 18683 var result = {}; 18684 iteratee = getIteratee(iteratee, 3); 18685 18686 baseForOwn(object, function(value, key, object) { 18687 baseAssignValue(result, key, iteratee(value, key, object)); 18688 }); 18689 return result; 18690 } 18691 18692 /** 18693 * This method is like `_.assign` except that it recursively merges own and 18694 * inherited enumerable string keyed properties of source objects into the 18695 * destination object. Source properties that resolve to `undefined` are 18696 * skipped if a destination value exists. Array and plain object properties 18697 * are merged recursively. Other objects and value types are overridden by 18698 * assignment. Source objects are applied from left to right. Subsequent 18699 * sources overwrite property assignments of previous sources. 18700 * 18701 * **Note:** This method mutates `object`. 18702 * 18703 * @static 18704 * @memberOf _ 18705 * @since 0.5.0 18706 * @category Object 18707 * @param {Object} object The destination object. 18708 * @param {...Object} [sources] The source objects. 18709 * @returns {Object} Returns `object`. 18710 * @example 18711 * 18712 * var object = { 18713 * 'a': [{ 'b': 2 }, { 'd': 4 }] 18714 * }; 18715 * 18716 * var other = { 18717 * 'a': [{ 'c': 3 }, { 'e': 5 }] 18718 * }; 18719 * 18720 * _.merge(object, other); 18721 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 18722 */ 18723 var merge = createAssigner(function(object, source, srcIndex) { 18724 baseMerge(object, source, srcIndex); 18725 }); 18726 18727 /** 18728 * This method is like `_.merge` except that it accepts `customizer` which 18729 * is invoked to produce the merged values of the destination and source 18730 * properties. If `customizer` returns `undefined`, merging is handled by the 18731 * method instead. The `customizer` is invoked with six arguments: 18732 * (objValue, srcValue, key, object, source, stack). 18733 * 18734 * **Note:** This method mutates `object`. 18735 * 18736 * @static 18737 * @memberOf _ 18738 * @since 4.0.0 18739 * @category Object 18740 * @param {Object} object The destination object. 18741 * @param {...Object} sources The source objects. 18742 * @param {Function} customizer The function to customize assigned values. 18743 * @returns {Object} Returns `object`. 18744 * @example 18745 * 18746 * function customizer(objValue, srcValue) { 18747 * if (_.isArray(objValue)) { 18748 * return objValue.concat(srcValue); 18749 * } 18750 * } 18751 * 18752 * var object = { 'a': [1], 'b': [2] }; 18753 * var other = { 'a': [3], 'b': [4] }; 18754 * 18755 * _.mergeWith(object, other, customizer); 18756 * // => { 'a': [1, 3], 'b': [2, 4] } 18757 */ 18758 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 18759 baseMerge(object, source, srcIndex, customizer); 18760 }); 18761 18762 /** 18763 * The opposite of `_.pick`; this method creates an object composed of the 18764 * own and inherited enumerable property paths of `object` that are not omitted. 18765 * 18766 * **Note:** This method is considerably slower than `_.pick`. 18767 * 18768 * @static 18769 * @since 0.1.0 18770 * @memberOf _ 18771 * @category Object 18772 * @param {Object} object The source object. 18773 * @param {...(string|string[])} [paths] The property paths to omit. 18774 * @returns {Object} Returns the new object. 18775 * @example 18776 * 18777 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 18778 * 18779 * _.omit(object, ['a', 'c']); 18780 * // => { 'b': '2' } 18781 */ 18782 var omit = flatRest(function(object, paths) { 18783 var result = {}; 18784 if (object == null) { 18785 return result; 18786 } 18787 var isDeep = false; 18788 paths = arrayMap(paths, function(path) { 18789 path = castPath(path, object); 18790 isDeep || (isDeep = path.length > 1); 18791 return path; 18792 }); 18793 copyObject(object, getAllKeysIn(object), result); 18794 if (isDeep) { 18795 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 18796 } 18797 var length = paths.length; 18798 while (length--) { 18799 baseUnset(result, paths[length]); 18800 } 18801 return result; 18802 }); 18803 18804 /** 18805 * The opposite of `_.pickBy`; this method creates an object composed of 18806 * the own and inherited enumerable string keyed properties of `object` that 18807 * `predicate` doesn't return truthy for. The predicate is invoked with two 18808 * arguments: (value, key). 18809 * 18810 * @static 18811 * @memberOf _ 18812 * @since 4.0.0 18813 * @category Object 18814 * @param {Object} object The source object. 18815 * @param {Function} [predicate=_.identity] The function invoked per property. 18816 * @returns {Object} Returns the new object. 18817 * @example 18818 * 18819 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 18820 * 18821 * _.omitBy(object, _.isNumber); 18822 * // => { 'b': '2' } 18823 */ 18824 function omitBy(object, predicate) { 18825 return pickBy(object, negate(getIteratee(predicate))); 18826 } 18827 18828 /** 18829 * Creates an object composed of the picked `object` properties. 18830 * 18831 * @static 18832 * @since 0.1.0 18833 * @memberOf _ 18834 * @category Object 18835 * @param {Object} object The source object. 18836 * @param {...(string|string[])} [paths] The property paths to pick. 18837 * @returns {Object} Returns the new object. 18838 * @example 18839 * 18840 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 18841 * 18842 * _.pick(object, ['a', 'c']); 18843 * // => { 'a': 1, 'c': 3 } 18844 */ 18845 var pick = flatRest(function(object, paths) { 18846 return object == null ? {} : basePick(object, paths); 18847 }); 18848 18849 /** 18850 * Creates an object composed of the `object` properties `predicate` returns 18851 * truthy for. The predicate is invoked with two arguments: (value, key). 18852 * 18853 * @static 18854 * @memberOf _ 18855 * @since 4.0.0 18856 * @category Object 18857 * @param {Object} object The source object. 18858 * @param {Function} [predicate=_.identity] The function invoked per property. 18859 * @returns {Object} Returns the new object. 18860 * @example 18861 * 18862 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 18863 * 18864 * _.pickBy(object, _.isNumber); 18865 * // => { 'a': 1, 'c': 3 } 18866 */ 18867 function pickBy(object, predicate) { 18868 if (object == null) { 18869 return {}; 18870 } 18871 var props = arrayMap(getAllKeysIn(object), function(prop) { 18872 return [prop]; 18873 }); 18874 predicate = getIteratee(predicate); 18875 return basePickBy(object, props, function(value, path) { 18876 return predicate(value, path[0]); 18877 }); 18878 } 18879 18880 /** 18881 * This method is like `_.get` except that if the resolved value is a 18882 * function it's invoked with the `this` binding of its parent object and 18883 * its result is returned. 18884 * 18885 * @static 18886 * @since 0.1.0 18887 * @memberOf _ 18888 * @category Object 18889 * @param {Object} object The object to query. 18890 * @param {Array|string} path The path of the property to resolve. 18891 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 18892 * @returns {*} Returns the resolved value. 18893 * @example 18894 * 18895 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 18896 * 18897 * _.result(object, 'a[0].b.c1'); 18898 * // => 3 18899 * 18900 * _.result(object, 'a[0].b.c2'); 18901 * // => 4 18902 * 18903 * _.result(object, 'a[0].b.c3', 'default'); 18904 * // => 'default' 18905 * 18906 * _.result(object, 'a[0].b.c3', _.constant('default')); 18907 * // => 'default' 18908 */ 18909 function result(object, path, defaultValue) { 18910 path = castPath(path, object); 18911 18912 var index = -1, 18913 length = path.length; 18914 18915 // Ensure the loop is entered when path is empty. 18916 if (!length) { 18917 length = 1; 18918 object = undefined; 18919 } 18920 while (++index < length) { 18921 var value = object == null ? undefined : object[toKey(path[index])]; 18922 if (value === undefined) { 18923 index = length; 18924 value = defaultValue; 18925 } 18926 object = isFunction(value) ? value.call(object) : value; 18927 } 18928 return object; 18929 } 18930 18931 /** 18932 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 18933 * it's created. Arrays are created for missing index properties while objects 18934 * are created for all other missing properties. Use `_.setWith` to customize 18935 * `path` creation. 18936 * 18937 * **Note:** This method mutates `object`. 18938 * 18939 * @static 18940 * @memberOf _ 18941 * @since 3.7.0 18942 * @category Object 18943 * @param {Object} object The object to modify. 18944 * @param {Array|string} path The path of the property to set. 18945 * @param {*} value The value to set. 18946 * @returns {Object} Returns `object`. 18947 * @example 18948 * 18949 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 18950 * 18951 * _.set(object, 'a[0].b.c', 4); 18952 * console.log(object.a[0].b.c); 18953 * // => 4 18954 * 18955 * _.set(object, ['x', '0', 'y', 'z'], 5); 18956 * console.log(object.x[0].y.z); 18957 * // => 5 18958 */ 18959 function set(object, path, value) { 18960 return object == null ? object : baseSet(object, path, value); 18961 } 18962 18963 /** 18964 * This method is like `_.set` except that it accepts `customizer` which is 18965 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 18966 * path creation is handled by the method instead. The `customizer` is invoked 18967 * with three arguments: (nsValue, key, nsObject). 18968 * 18969 * **Note:** This method mutates `object`. 18970 * 18971 * @static 18972 * @memberOf _ 18973 * @since 4.0.0 18974 * @category Object 18975 * @param {Object} object The object to modify. 18976 * @param {Array|string} path The path of the property to set. 18977 * @param {*} value The value to set. 18978 * @param {Function} [customizer] The function to customize assigned values. 18979 * @returns {Object} Returns `object`. 18980 * @example 18981 * 18982 * var object = {}; 18983 * 18984 * _.setWith(object, '[0][1]', 'a', Object); 18985 * // => { '0': { '1': 'a' } } 18986 */ 18987 function setWith(object, path, value, customizer) { 18988 customizer = typeof customizer == 'function' ? customizer : undefined; 18989 return object == null ? object : baseSet(object, path, value, customizer); 18990 } 18991 18992 /** 18993 * Creates an array of own enumerable string keyed-value pairs for `object` 18994 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 18995 * entries are returned. 18996 * 18997 * @static 18998 * @memberOf _ 18999 * @since 4.0.0 19000 * @alias entries 19001 * @category Object 19002 * @param {Object} object The object to query. 19003 * @returns {Array} Returns the key-value pairs. 19004 * @example 19005 * 19006 * function Foo() { 19007 * this.a = 1; 19008 * this.b = 2; 19009 * } 19010 * 19011 * Foo.prototype.c = 3; 19012 * 19013 * _.toPairs(new Foo); 19014 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 19015 */ 19016 var toPairs = createToPairs(keys); 19017 19018 /** 19019 * Creates an array of own and inherited enumerable string keyed-value pairs 19020 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 19021 * or set, its entries are returned. 19022 * 19023 * @static 19024 * @memberOf _ 19025 * @since 4.0.0 19026 * @alias entriesIn 19027 * @category Object 19028 * @param {Object} object The object to query. 19029 * @returns {Array} Returns the key-value pairs. 19030 * @example 19031 * 19032 * function Foo() { 19033 * this.a = 1; 19034 * this.b = 2; 19035 * } 19036 * 19037 * Foo.prototype.c = 3; 19038 * 19039 * _.toPairsIn(new Foo); 19040 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 19041 */ 19042 var toPairsIn = createToPairs(keysIn); 19043 19044 /** 19045 * An alternative to `_.reduce`; this method transforms `object` to a new 19046 * `accumulator` object which is the result of running each of its own 19047 * enumerable string keyed properties thru `iteratee`, with each invocation 19048 * potentially mutating the `accumulator` object. If `accumulator` is not 19049 * provided, a new object with the same `[[Prototype]]` will be used. The 19050 * iteratee is invoked with four arguments: (accumulator, value, key, object). 19051 * Iteratee functions may exit iteration early by explicitly returning `false`. 19052 * 19053 * @static 19054 * @memberOf _ 19055 * @since 1.3.0 19056 * @category Object 19057 * @param {Object} object The object to iterate over. 19058 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 19059 * @param {*} [accumulator] The custom accumulator value. 19060 * @returns {*} Returns the accumulated value. 19061 * @example 19062 * 19063 * _.transform([2, 3, 4], function(result, n) { 19064 * result.push(n *= n); 19065 * return n % 2 == 0; 19066 * }, []); 19067 * // => [4, 9] 19068 * 19069 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 19070 * (result[value] || (result[value] = [])).push(key); 19071 * }, {}); 19072 * // => { '1': ['a', 'c'], '2': ['b'] } 19073 */ 19074 function transform(object, iteratee, accumulator) { 19075 var isArr = isArray(object), 19076 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 19077 19078 iteratee = getIteratee(iteratee, 4); 19079 if (accumulator == null) { 19080 var Ctor = object && object.constructor; 19081 if (isArrLike) { 19082 accumulator = isArr ? new Ctor : []; 19083 } 19084 else if (isObject(object)) { 19085 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 19086 } 19087 else { 19088 accumulator = {}; 19089 } 19090 } 19091 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 19092 return iteratee(accumulator, value, index, object); 19093 }); 19094 return accumulator; 19095 } 19096 19097 /** 19098 * Removes the property at `path` of `object`. 19099 * 19100 * **Note:** This method mutates `object`. 19101 * 19102 * @static 19103 * @memberOf _ 19104 * @since 4.0.0 19105 * @category Object 19106 * @param {Object} object The object to modify. 19107 * @param {Array|string} path The path of the property to unset. 19108 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 19109 * @example 19110 * 19111 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 19112 * _.unset(object, 'a[0].b.c'); 19113 * // => true 19114 * 19115 * console.log(object); 19116 * // => { 'a': [{ 'b': {} }] }; 19117 * 19118 * _.unset(object, ['a', '0', 'b', 'c']); 19119 * // => true 19120 * 19121 * console.log(object); 19122 * // => { 'a': [{ 'b': {} }] }; 19123 */ 19124 function unset(object, path) { 19125 return object == null ? true : baseUnset(object, path); 19126 } 19127 19128 /** 19129 * This method is like `_.set` except that accepts `updater` to produce the 19130 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 19131 * is invoked with one argument: (value). 19132 * 19133 * **Note:** This method mutates `object`. 19134 * 19135 * @static 19136 * @memberOf _ 19137 * @since 4.6.0 19138 * @category Object 19139 * @param {Object} object The object to modify. 19140 * @param {Array|string} path The path of the property to set. 19141 * @param {Function} updater The function to produce the updated value. 19142 * @returns {Object} Returns `object`. 19143 * @example 19144 * 19145 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 19146 * 19147 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 19148 * console.log(object.a[0].b.c); 19149 * // => 9 19150 * 19151 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 19152 * console.log(object.x[0].y.z); 19153 * // => 0 19154 */ 19155 function update(object, path, updater) { 19156 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 19157 } 19158 19159 /** 19160 * This method is like `_.update` except that it accepts `customizer` which is 19161 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 19162 * path creation is handled by the method instead. The `customizer` is invoked 19163 * with three arguments: (nsValue, key, nsObject). 19164 * 19165 * **Note:** This method mutates `object`. 19166 * 19167 * @static 19168 * @memberOf _ 19169 * @since 4.6.0 19170 * @category Object 19171 * @param {Object} object The object to modify. 19172 * @param {Array|string} path The path of the property to set. 19173 * @param {Function} updater The function to produce the updated value. 19174 * @param {Function} [customizer] The function to customize assigned values. 19175 * @returns {Object} Returns `object`. 19176 * @example 19177 * 19178 * var object = {}; 19179 * 19180 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 19181 * // => { '0': { '1': 'a' } } 19182 */ 19183 function updateWith(object, path, updater, customizer) { 19184 customizer = typeof customizer == 'function' ? customizer : undefined; 19185 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 19186 } 19187 19188 /** 19189 * Creates an array of the own enumerable string keyed property values of `object`. 19190 * 19191 * **Note:** Non-object values are coerced to objects. 19192 * 19193 * @static 19194 * @since 0.1.0 19195 * @memberOf _ 19196 * @category Object 19197 * @param {Object} object The object to query. 19198 * @returns {Array} Returns the array of property values. 19199 * @example 19200 * 19201 * function Foo() { 19202 * this.a = 1; 19203 * this.b = 2; 19204 * } 19205 * 19206 * Foo.prototype.c = 3; 19207 * 19208 * _.values(new Foo); 19209 * // => [1, 2] (iteration order is not guaranteed) 19210 * 19211 * _.values('hi'); 19212 * // => ['h', 'i'] 19213 */ 19214 function values(object) { 19215 return object == null ? [] : baseValues(object, keys(object)); 19216 } 19217 19218 /** 19219 * Creates an array of the own and inherited enumerable string keyed property 19220 * values of `object`. 19221 * 19222 * **Note:** Non-object values are coerced to objects. 19223 * 19224 * @static 19225 * @memberOf _ 19226 * @since 3.0.0 19227 * @category Object 19228 * @param {Object} object The object to query. 19229 * @returns {Array} Returns the array of property values. 19230 * @example 19231 * 19232 * function Foo() { 19233 * this.a = 1; 19234 * this.b = 2; 19235 * } 19236 * 19237 * Foo.prototype.c = 3; 19238 * 19239 * _.valuesIn(new Foo); 19240 * // => [1, 2, 3] (iteration order is not guaranteed) 19241 */ 19242 function valuesIn(object) { 19243 return object == null ? [] : baseValues(object, keysIn(object)); 19244 } 19245 19246 /*------------------------------------------------------------------------*/ 19247 19248 /** 19249 * Clamps `number` within the inclusive `lower` and `upper` bounds. 19250 * 19251 * @static 19252 * @memberOf _ 19253 * @since 4.0.0 19254 * @category Number 19255 * @param {number} number The number to clamp. 19256 * @param {number} [lower] The lower bound. 19257 * @param {number} upper The upper bound. 19258 * @returns {number} Returns the clamped number. 19259 * @example 19260 * 19261 * _.clamp(-10, -5, 5); 19262 * // => -5 19263 * 19264 * _.clamp(10, -5, 5); 19265 * // => 5 19266 */ 19267 function clamp(number, lower, upper) { 19268 if (upper === undefined) { 19269 upper = lower; 19270 lower = undefined; 19271 } 19272 if (upper !== undefined) { 19273 upper = toNumber(upper); 19274 upper = upper === upper ? upper : 0; 19275 } 19276 if (lower !== undefined) { 19277 lower = toNumber(lower); 19278 lower = lower === lower ? lower : 0; 19279 } 19280 return baseClamp(toNumber(number), lower, upper); 19281 } 19282 19283 /** 19284 * Checks if `n` is between `start` and up to, but not including, `end`. If 19285 * `end` is not specified, it's set to `start` with `start` then set to `0`. 19286 * If `start` is greater than `end` the params are swapped to support 19287 * negative ranges. 19288 * 19289 * @static 19290 * @memberOf _ 19291 * @since 3.3.0 19292 * @category Number 19293 * @param {number} number The number to check. 19294 * @param {number} [start=0] The start of the range. 19295 * @param {number} end The end of the range. 19296 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 19297 * @see _.range, _.rangeRight 19298 * @example 19299 * 19300 * _.inRange(3, 2, 4); 19301 * // => true 19302 * 19303 * _.inRange(4, 8); 19304 * // => true 19305 * 19306 * _.inRange(4, 2); 19307 * // => false 19308 * 19309 * _.inRange(2, 2); 19310 * // => false 19311 * 19312 * _.inRange(1.2, 2); 19313 * // => true 19314 * 19315 * _.inRange(5.2, 4); 19316 * // => false 19317 * 19318 * _.inRange(-3, -2, -6); 19319 * // => true 19320 */ 19321 function inRange(number, start, end) { 19322 start = toFinite(start); 19323 if (end === undefined) { 19324 end = start; 19325 start = 0; 19326 } else { 19327 end = toFinite(end); 19328 } 19329 number = toNumber(number); 19330 return baseInRange(number, start, end); 19331 } 19332 19333 /** 19334 * Produces a random number between the inclusive `lower` and `upper` bounds. 19335 * If only one argument is provided a number between `0` and the given number 19336 * is returned. If `floating` is `true`, or either `lower` or `upper` are 19337 * floats, a floating-point number is returned instead of an integer. 19338 * 19339 * **Note:** JavaScript follows the IEEE-754 standard for resolving 19340 * floating-point values which can produce unexpected results. 19341 * 19342 * @static 19343 * @memberOf _ 19344 * @since 0.7.0 19345 * @category Number 19346 * @param {number} [lower=0] The lower bound. 19347 * @param {number} [upper=1] The upper bound. 19348 * @param {boolean} [floating] Specify returning a floating-point number. 19349 * @returns {number} Returns the random number. 19350 * @example 19351 * 19352 * _.random(0, 5); 19353 * // => an integer between 0 and 5 19354 * 19355 * _.random(5); 19356 * // => also an integer between 0 and 5 19357 * 19358 * _.random(5, true); 19359 * // => a floating-point number between 0 and 5 19360 * 19361 * _.random(1.2, 5.2); 19362 * // => a floating-point number between 1.2 and 5.2 19363 */ 19364 function random(lower, upper, floating) { 19365 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 19366 upper = floating = undefined; 19367 } 19368 if (floating === undefined) { 19369 if (typeof upper == 'boolean') { 19370 floating = upper; 19371 upper = undefined; 19372 } 19373 else if (typeof lower == 'boolean') { 19374 floating = lower; 19375 lower = undefined; 19376 } 19377 } 19378 if (lower === undefined && upper === undefined) { 19379 lower = 0; 19380 upper = 1; 19381 } 19382 else { 19383 lower = toFinite(lower); 19384 if (upper === undefined) { 19385 upper = lower; 19386 lower = 0; 19387 } else { 19388 upper = toFinite(upper); 19389 } 19390 } 19391 if (lower > upper) { 19392 var temp = lower; 19393 lower = upper; 19394 upper = temp; 19395 } 19396 if (floating || lower % 1 || upper % 1) { 19397 var rand = nativeRandom(); 19398 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 19399 } 19400 return baseRandom(lower, upper); 19401 } 19402 19403 /*------------------------------------------------------------------------*/ 19404 19405 /** 19406 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 19407 * 19408 * @static 19409 * @memberOf _ 19410 * @since 3.0.0 19411 * @category String 19412 * @param {string} [string=''] The string to convert. 19413 * @returns {string} Returns the camel cased string. 19414 * @example 19415 * 19416 * _.camelCase('Foo Bar'); 19417 * // => 'fooBar' 19418 * 19419 * _.camelCase('--foo-bar--'); 19420 * // => 'fooBar' 19421 * 19422 * _.camelCase('__FOO_BAR__'); 19423 * // => 'fooBar' 19424 */ 19425 var camelCase = createCompounder(function(result, word, index) { 19426 word = word.toLowerCase(); 19427 return result + (index ? capitalize(word) : word); 19428 }); 19429 19430 /** 19431 * Converts the first character of `string` to upper case and the remaining 19432 * to lower case. 19433 * 19434 * @static 19435 * @memberOf _ 19436 * @since 3.0.0 19437 * @category String 19438 * @param {string} [string=''] The string to capitalize. 19439 * @returns {string} Returns the capitalized string. 19440 * @example 19441 * 19442 * _.capitalize('FRED'); 19443 * // => 'Fred' 19444 */ 19445 function capitalize(string) { 19446 return upperFirst(toString(string).toLowerCase()); 19447 } 19448 19449 /** 19450 * Deburrs `string` by converting 19451 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 19452 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 19453 * letters to basic Latin letters and removing 19454 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 19455 * 19456 * @static 19457 * @memberOf _ 19458 * @since 3.0.0 19459 * @category String 19460 * @param {string} [string=''] The string to deburr. 19461 * @returns {string} Returns the deburred string. 19462 * @example 19463 * 19464 * _.deburr('déjàvu'); 19465 * // => 'deja vu' 19466 */ 19467 function deburr(string) { 19468 string = toString(string); 19469 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 19470 } 19471 19472 /** 19473 * Checks if `string` ends with the given target string. 19474 * 19475 * @static 19476 * @memberOf _ 19477 * @since 3.0.0 19478 * @category String 19479 * @param {string} [string=''] The string to inspect. 19480 * @param {string} [target] The string to search for. 19481 * @param {number} [position=string.length] The position to search up to. 19482 * @returns {boolean} Returns `true` if `string` ends with `target`, 19483 * else `false`. 19484 * @example 19485 * 19486 * _.endsWith('abc', 'c'); 19487 * // => true 19488 * 19489 * _.endsWith('abc', 'b'); 19490 * // => false 19491 * 19492 * _.endsWith('abc', 'b', 2); 19493 * // => true 19494 */ 19495 function endsWith(string, target, position) { 19496 string = toString(string); 19497 target = baseToString(target); 19498 19499 var length = string.length; 19500 position = position === undefined 19501 ? length 19502 : baseClamp(toInteger(position), 0, length); 19503 19504 var end = position; 19505 position -= target.length; 19506 return position >= 0 && string.slice(position, end) == target; 19507 } 19508 19509 /** 19510 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 19511 * corresponding HTML entities. 19512 * 19513 * **Note:** No other characters are escaped. To escape additional 19514 * characters use a third-party library like [_he_](https://mths.be/he). 19515 * 19516 * Though the ">" character is escaped for symmetry, characters like 19517 * ">" and "/" don't need escaping in HTML and have no special meaning 19518 * unless they're part of a tag or unquoted attribute value. See 19519 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 19520 * (under "semi-related fun fact") for more details. 19521 * 19522 * When working with HTML you should always 19523 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 19524 * XSS vectors. 19525 * 19526 * @static 19527 * @since 0.1.0 19528 * @memberOf _ 19529 * @category String 19530 * @param {string} [string=''] The string to escape. 19531 * @returns {string} Returns the escaped string. 19532 * @example 19533 * 19534 * _.escape('fred, barney, & pebbles'); 19535 * // => 'fred, barney, & pebbles' 19536 */ 19537 function escape(string) { 19538 string = toString(string); 19539 return (string && reHasUnescapedHtml.test(string)) 19540 ? string.replace(reUnescapedHtml, escapeHtmlChar) 19541 : string; 19542 } 19543 19544 /** 19545 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 19546 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 19547 * 19548 * @static 19549 * @memberOf _ 19550 * @since 3.0.0 19551 * @category String 19552 * @param {string} [string=''] The string to escape. 19553 * @returns {string} Returns the escaped string. 19554 * @example 19555 * 19556 * _.escapeRegExp('[lodash](https://lodash.com/)'); 19557 * // => '\[lodash\]\(https://lodash\.com/\)' 19558 */ 19559 function escapeRegExp(string) { 19560 string = toString(string); 19561 return (string && reHasRegExpChar.test(string)) 19562 ? string.replace(reRegExpChar, '\\$&') 19563 : string; 19564 } 19565 19566 /** 19567 * Converts `string` to 19568 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 19569 * 19570 * @static 19571 * @memberOf _ 19572 * @since 3.0.0 19573 * @category String 19574 * @param {string} [string=''] The string to convert. 19575 * @returns {string} Returns the kebab cased string. 19576 * @example 19577 * 19578 * _.kebabCase('Foo Bar'); 19579 * // => 'foo-bar' 19580 * 19581 * _.kebabCase('fooBar'); 19582 * // => 'foo-bar' 19583 * 19584 * _.kebabCase('__FOO_BAR__'); 19585 * // => 'foo-bar' 19586 */ 19587 var kebabCase = createCompounder(function(result, word, index) { 19588 return result + (index ? '-' : '') + word.toLowerCase(); 19589 }); 19590 19591 /** 19592 * Converts `string`, as space separated words, to lower case. 19593 * 19594 * @static 19595 * @memberOf _ 19596 * @since 4.0.0 19597 * @category String 19598 * @param {string} [string=''] The string to convert. 19599 * @returns {string} Returns the lower cased string. 19600 * @example 19601 * 19602 * _.lowerCase('--Foo-Bar--'); 19603 * // => 'foo bar' 19604 * 19605 * _.lowerCase('fooBar'); 19606 * // => 'foo bar' 19607 * 19608 * _.lowerCase('__FOO_BAR__'); 19609 * // => 'foo bar' 19610 */ 19611 var lowerCase = createCompounder(function(result, word, index) { 19612 return result + (index ? ' ' : '') + word.toLowerCase(); 19613 }); 19614 19615 /** 19616 * Converts the first character of `string` to lower case. 19617 * 19618 * @static 19619 * @memberOf _ 19620 * @since 4.0.0 19621 * @category String 19622 * @param {string} [string=''] The string to convert. 19623 * @returns {string} Returns the converted string. 19624 * @example 19625 * 19626 * _.lowerFirst('Fred'); 19627 * // => 'fred' 19628 * 19629 * _.lowerFirst('FRED'); 19630 * // => 'fRED' 19631 */ 19632 var lowerFirst = createCaseFirst('toLowerCase'); 19633 19634 /** 19635 * Pads `string` on the left and right sides if it's shorter than `length`. 19636 * Padding characters are truncated if they can't be evenly divided by `length`. 19637 * 19638 * @static 19639 * @memberOf _ 19640 * @since 3.0.0 19641 * @category String 19642 * @param {string} [string=''] The string to pad. 19643 * @param {number} [length=0] The padding length. 19644 * @param {string} [chars=' '] The string used as padding. 19645 * @returns {string} Returns the padded string. 19646 * @example 19647 * 19648 * _.pad('abc', 8); 19649 * // => ' abc ' 19650 * 19651 * _.pad('abc', 8, '_-'); 19652 * // => '_-abc_-_' 19653 * 19654 * _.pad('abc', 3); 19655 * // => 'abc' 19656 */ 19657 function pad(string, length, chars) { 19658 string = toString(string); 19659 length = toInteger(length); 19660 19661 var strLength = length ? stringSize(string) : 0; 19662 if (!length || strLength >= length) { 19663 return string; 19664 } 19665 var mid = (length - strLength) / 2; 19666 return ( 19667 createPadding(nativeFloor(mid), chars) + 19668 string + 19669 createPadding(nativeCeil(mid), chars) 19670 ); 19671 } 19672 19673 /** 19674 * Pads `string` on the right side if it's shorter than `length`. Padding 19675 * characters are truncated if they exceed `length`. 19676 * 19677 * @static 19678 * @memberOf _ 19679 * @since 4.0.0 19680 * @category String 19681 * @param {string} [string=''] The string to pad. 19682 * @param {number} [length=0] The padding length. 19683 * @param {string} [chars=' '] The string used as padding. 19684 * @returns {string} Returns the padded string. 19685 * @example 19686 * 19687 * _.padEnd('abc', 6); 19688 * // => 'abc ' 19689 * 19690 * _.padEnd('abc', 6, '_-'); 19691 * // => 'abc_-_' 19692 * 19693 * _.padEnd('abc', 3); 19694 * // => 'abc' 19695 */ 19696 function padEnd(string, length, chars) { 19697 string = toString(string); 19698 length = toInteger(length); 19699 19700 var strLength = length ? stringSize(string) : 0; 19701 return (length && strLength < length) 19702 ? (string + createPadding(length - strLength, chars)) 19703 : string; 19704 } 19705 19706 /** 19707 * Pads `string` on the left side if it's shorter than `length`. Padding 19708 * characters are truncated if they exceed `length`. 19709 * 19710 * @static 19711 * @memberOf _ 19712 * @since 4.0.0 19713 * @category String 19714 * @param {string} [string=''] The string to pad. 19715 * @param {number} [length=0] The padding length. 19716 * @param {string} [chars=' '] The string used as padding. 19717 * @returns {string} Returns the padded string. 19718 * @example 19719 * 19720 * _.padStart('abc', 6); 19721 * // => ' abc' 19722 * 19723 * _.padStart('abc', 6, '_-'); 19724 * // => '_-_abc' 19725 * 19726 * _.padStart('abc', 3); 19727 * // => 'abc' 19728 */ 19729 function padStart(string, length, chars) { 19730 string = toString(string); 19731 length = toInteger(length); 19732 19733 var strLength = length ? stringSize(string) : 0; 19734 return (length && strLength < length) 19735 ? (createPadding(length - strLength, chars) + string) 19736 : string; 19737 } 19738 19739 /** 19740 * Converts `string` to an integer of the specified radix. If `radix` is 19741 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 19742 * hexadecimal, in which case a `radix` of `16` is used. 19743 * 19744 * **Note:** This method aligns with the 19745 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 19746 * 19747 * @static 19748 * @memberOf _ 19749 * @since 1.1.0 19750 * @category String 19751 * @param {string} string The string to convert. 19752 * @param {number} [radix=10] The radix to interpret `value` by. 19753 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19754 * @returns {number} Returns the converted integer. 19755 * @example 19756 * 19757 * _.parseInt('08'); 19758 * // => 8 19759 * 19760 * _.map(['6', '08', '10'], _.parseInt); 19761 * // => [6, 8, 10] 19762 */ 19763 function parseInt(string, radix, guard) { 19764 if (guard || radix == null) { 19765 radix = 0; 19766 } else if (radix) { 19767 radix = +radix; 19768 } 19769 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 19770 } 19771 19772 /** 19773 * Repeats the given string `n` times. 19774 * 19775 * @static 19776 * @memberOf _ 19777 * @since 3.0.0 19778 * @category String 19779 * @param {string} [string=''] The string to repeat. 19780 * @param {number} [n=1] The number of times to repeat the string. 19781 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19782 * @returns {string} Returns the repeated string. 19783 * @example 19784 * 19785 * _.repeat('*', 3); 19786 * // => '***' 19787 * 19788 * _.repeat('abc', 2); 19789 * // => 'abcabc' 19790 * 19791 * _.repeat('abc', 0); 19792 * // => '' 19793 */ 19794 function repeat(string, n, guard) { 19795 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 19796 n = 1; 19797 } else { 19798 n = toInteger(n); 19799 } 19800 return baseRepeat(toString(string), n); 19801 } 19802 19803 /** 19804 * Replaces matches for `pattern` in `string` with `replacement`. 19805 * 19806 * **Note:** This method is based on 19807 * [`String#replace`](https://mdn.io/String/replace). 19808 * 19809 * @static 19810 * @memberOf _ 19811 * @since 4.0.0 19812 * @category String 19813 * @param {string} [string=''] The string to modify. 19814 * @param {RegExp|string} pattern The pattern to replace. 19815 * @param {Function|string} replacement The match replacement. 19816 * @returns {string} Returns the modified string. 19817 * @example 19818 * 19819 * _.replace('Hi Fred', 'Fred', 'Barney'); 19820 * // => 'Hi Barney' 19821 */ 19822 function replace() { 19823 var args = arguments, 19824 string = toString(args[0]); 19825 19826 return args.length < 3 ? string : string.replace(args[1], args[2]); 19827 } 19828 19829 /** 19830 * Converts `string` to 19831 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 19832 * 19833 * @static 19834 * @memberOf _ 19835 * @since 3.0.0 19836 * @category String 19837 * @param {string} [string=''] The string to convert. 19838 * @returns {string} Returns the snake cased string. 19839 * @example 19840 * 19841 * _.snakeCase('Foo Bar'); 19842 * // => 'foo_bar' 19843 * 19844 * _.snakeCase('fooBar'); 19845 * // => 'foo_bar' 19846 * 19847 * _.snakeCase('--FOO-BAR--'); 19848 * // => 'foo_bar' 19849 */ 19850 var snakeCase = createCompounder(function(result, word, index) { 19851 return result + (index ? '_' : '') + word.toLowerCase(); 19852 }); 19853 19854 /** 19855 * Splits `string` by `separator`. 19856 * 19857 * **Note:** This method is based on 19858 * [`String#split`](https://mdn.io/String/split). 19859 * 19860 * @static 19861 * @memberOf _ 19862 * @since 4.0.0 19863 * @category String 19864 * @param {string} [string=''] The string to split. 19865 * @param {RegExp|string} separator The separator pattern to split by. 19866 * @param {number} [limit] The length to truncate results to. 19867 * @returns {Array} Returns the string segments. 19868 * @example 19869 * 19870 * _.split('a-b-c', '-', 2); 19871 * // => ['a', 'b'] 19872 */ 19873 function split(string, separator, limit) { 19874 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 19875 separator = limit = undefined; 19876 } 19877 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 19878 if (!limit) { 19879 return []; 19880 } 19881 string = toString(string); 19882 if (string && ( 19883 typeof separator == 'string' || 19884 (separator != null && !isRegExp(separator)) 19885 )) { 19886 separator = baseToString(separator); 19887 if (!separator && hasUnicode(string)) { 19888 return castSlice(stringToArray(string), 0, limit); 19889 } 19890 } 19891 return string.split(separator, limit); 19892 } 19893 19894 /** 19895 * Converts `string` to 19896 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 19897 * 19898 * @static 19899 * @memberOf _ 19900 * @since 3.1.0 19901 * @category String 19902 * @param {string} [string=''] The string to convert. 19903 * @returns {string} Returns the start cased string. 19904 * @example 19905 * 19906 * _.startCase('--foo-bar--'); 19907 * // => 'Foo Bar' 19908 * 19909 * _.startCase('fooBar'); 19910 * // => 'Foo Bar' 19911 * 19912 * _.startCase('__FOO_BAR__'); 19913 * // => 'FOO BAR' 19914 */ 19915 var startCase = createCompounder(function(result, word, index) { 19916 return result + (index ? ' ' : '') + upperFirst(word); 19917 }); 19918 19919 /** 19920 * Checks if `string` starts with the given target string. 19921 * 19922 * @static 19923 * @memberOf _ 19924 * @since 3.0.0 19925 * @category String 19926 * @param {string} [string=''] The string to inspect. 19927 * @param {string} [target] The string to search for. 19928 * @param {number} [position=0] The position to search from. 19929 * @returns {boolean} Returns `true` if `string` starts with `target`, 19930 * else `false`. 19931 * @example 19932 * 19933 * _.startsWith('abc', 'a'); 19934 * // => true 19935 * 19936 * _.startsWith('abc', 'b'); 19937 * // => false 19938 * 19939 * _.startsWith('abc', 'b', 1); 19940 * // => true 19941 */ 19942 function startsWith(string, target, position) { 19943 string = toString(string); 19944 position = position == null 19945 ? 0 19946 : baseClamp(toInteger(position), 0, string.length); 19947 19948 target = baseToString(target); 19949 return string.slice(position, position + target.length) == target; 19950 } 19951 19952 /** 19953 * Creates a compiled template function that can interpolate data properties 19954 * in "interpolate" delimiters, HTML-escape interpolated data properties in 19955 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 19956 * properties may be accessed as free variables in the template. If a setting 19957 * object is given, it takes precedence over `_.templateSettings` values. 19958 * 19959 * **Note:** In the development build `_.template` utilizes 19960 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 19961 * for easier debugging. 19962 * 19963 * For more information on precompiling templates see 19964 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 19965 * 19966 * For more information on Chrome extension sandboxes see 19967 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 19968 * 19969 * @static 19970 * @since 0.1.0 19971 * @memberOf _ 19972 * @category String 19973 * @param {string} [string=''] The template string. 19974 * @param {Object} [options={}] The options object. 19975 * @param {RegExp} [options.escape=_.templateSettings.escape] 19976 * The HTML "escape" delimiter. 19977 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 19978 * The "evaluate" delimiter. 19979 * @param {Object} [options.imports=_.templateSettings.imports] 19980 * An object to import into the template as free variables. 19981 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 19982 * The "interpolate" delimiter. 19983 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 19984 * The sourceURL of the compiled template. 19985 * @param {string} [options.variable='obj'] 19986 * The data object variable name. 19987 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 19988 * @returns {Function} Returns the compiled template function. 19989 * @example 19990 * 19991 * // Use the "interpolate" delimiter to create a compiled template. 19992 * var compiled = _.template('hello <%= user %>!'); 19993 * compiled({ 'user': 'fred' }); 19994 * // => 'hello fred!' 19995 * 19996 * // Use the HTML "escape" delimiter to escape data property values. 19997 * var compiled = _.template('<b><%- value %></b>'); 19998 * compiled({ 'value': '<script>' }); 19999 * // => '<b><script></b>' 20000 * 20001 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 20002 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 20003 * compiled({ 'users': ['fred', 'barney'] }); 20004 * // => '<li>fred</li><li>barney</li>' 20005 * 20006 * // Use the internal `print` function in "evaluate" delimiters. 20007 * var compiled = _.template('<% print("hello " + user); %>!'); 20008 * compiled({ 'user': 'barney' }); 20009 * // => 'hello barney!' 20010 * 20011 * // Use the ES template literal delimiter as an "interpolate" delimiter. 20012 * // Disable support by replacing the "interpolate" delimiter. 20013 * var compiled = _.template('hello ${ user }!'); 20014 * compiled({ 'user': 'pebbles' }); 20015 * // => 'hello pebbles!' 20016 * 20017 * // Use backslashes to treat delimiters as plain text. 20018 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 20019 * compiled({ 'value': 'ignored' }); 20020 * // => '<%- value %>' 20021 * 20022 * // Use the `imports` option to import `jQuery` as `jq`. 20023 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 20024 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 20025 * compiled({ 'users': ['fred', 'barney'] }); 20026 * // => '<li>fred</li><li>barney</li>' 20027 * 20028 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 20029 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 20030 * compiled(data); 20031 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 20032 * 20033 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 20034 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 20035 * compiled.source; 20036 * // => function(data) { 20037 * // var __t, __p = ''; 20038 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 20039 * // return __p; 20040 * // } 20041 * 20042 * // Use custom template delimiters. 20043 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 20044 * var compiled = _.template('hello {{ user }}!'); 20045 * compiled({ 'user': 'mustache' }); 20046 * // => 'hello mustache!' 20047 * 20048 * // Use the `source` property to inline compiled templates for meaningful 20049 * // line numbers in error messages and stack traces. 20050 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 20051 * var JST = {\ 20052 * "main": ' + _.template(mainText).source + '\ 20053 * };\ 20054 * '); 20055 */ 20056 function template(string, options, guard) { 20057 // Based on John Resig's `tmpl` implementation 20058 // (http://ejohn.org/blog/javascript-micro-templating/) 20059 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 20060 var settings = lodash.templateSettings; 20061 20062 if (guard && isIterateeCall(string, options, guard)) { 20063 options = undefined; 20064 } 20065 string = toString(string); 20066 options = assignInWith({}, options, settings, customDefaultsAssignIn); 20067 20068 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 20069 importsKeys = keys(imports), 20070 importsValues = baseValues(imports, importsKeys); 20071 20072 var isEscaping, 20073 isEvaluating, 20074 index = 0, 20075 interpolate = options.interpolate || reNoMatch, 20076 source = "__p += '"; 20077 20078 // Compile the regexp to match each delimiter. 20079 var reDelimiters = RegExp( 20080 (options.escape || reNoMatch).source + '|' + 20081 interpolate.source + '|' + 20082 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 20083 (options.evaluate || reNoMatch).source + '|$' 20084 , 'g'); 20085 20086 // Use a sourceURL for easier debugging. 20087 // The sourceURL gets injected into the source that's eval-ed, so be careful 20088 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in 20089 // and escape the comment, thus injecting code that gets evaled. 20090 var sourceURL = '//# sourceURL=' + 20091 (hasOwnProperty.call(options, 'sourceURL') 20092 ? (options.sourceURL + '').replace(/\s/g, ' ') 20093 : ('lodash.templateSources[' + (++templateCounter) + ']') 20094 ) + '\n'; 20095 20096 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 20097 interpolateValue || (interpolateValue = esTemplateValue); 20098 20099 // Escape characters that can't be included in string literals. 20100 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 20101 20102 // Replace delimiters with snippets. 20103 if (escapeValue) { 20104 isEscaping = true; 20105 source += "' +\n__e(" + escapeValue + ") +\n'"; 20106 } 20107 if (evaluateValue) { 20108 isEvaluating = true; 20109 source += "';\n" + evaluateValue + ";\n__p += '"; 20110 } 20111 if (interpolateValue) { 20112 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 20113 } 20114 index = offset + match.length; 20115 20116 // The JS engine embedded in Adobe products needs `match` returned in 20117 // order to produce the correct `offset` value. 20118 return match; 20119 }); 20120 20121 source += "';\n"; 20122 20123 // If `variable` is not specified wrap a with-statement around the generated 20124 // code to add the data object to the top of the scope chain. 20125 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 20126 if (!variable) { 20127 source = 'with (obj) {\n' + source + '\n}\n'; 20128 } 20129 // Throw an error if a forbidden character was found in `variable`, to prevent 20130 // potential command injection attacks. 20131 else if (reForbiddenIdentifierChars.test(variable)) { 20132 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); 20133 } 20134 20135 // Cleanup code by stripping empty strings. 20136 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 20137 .replace(reEmptyStringMiddle, '$1') 20138 .replace(reEmptyStringTrailing, '$1;'); 20139 20140 // Frame code as the function body. 20141 source = 'function(' + (variable || 'obj') + ') {\n' + 20142 (variable 20143 ? '' 20144 : 'obj || (obj = {});\n' 20145 ) + 20146 "var __t, __p = ''" + 20147 (isEscaping 20148 ? ', __e = _.escape' 20149 : '' 20150 ) + 20151 (isEvaluating 20152 ? ', __j = Array.prototype.join;\n' + 20153 "function print() { __p += __j.call(arguments, '') }\n" 20154 : ';\n' 20155 ) + 20156 source + 20157 'return __p\n}'; 20158 20159 var result = attempt(function() { 20160 return Function(importsKeys, sourceURL + 'return ' + source) 20161 .apply(undefined, importsValues); 20162 }); 20163 20164 // Provide the compiled function's source by its `toString` method or 20165 // the `source` property as a convenience for inlining compiled templates. 20166 result.source = source; 20167 if (isError(result)) { 20168 throw result; 20169 } 20170 return result; 20171 } 20172 20173 /** 20174 * Converts `string`, as a whole, to lower case just like 20175 * [String#toLowerCase](https://mdn.io/toLowerCase). 20176 * 20177 * @static 20178 * @memberOf _ 20179 * @since 4.0.0 20180 * @category String 20181 * @param {string} [string=''] The string to convert. 20182 * @returns {string} Returns the lower cased string. 20183 * @example 20184 * 20185 * _.toLower('--Foo-Bar--'); 20186 * // => '--foo-bar--' 20187 * 20188 * _.toLower('fooBar'); 20189 * // => 'foobar' 20190 * 20191 * _.toLower('__FOO_BAR__'); 20192 * // => '__foo_bar__' 20193 */ 20194 function toLower(value) { 20195 return toString(value).toLowerCase(); 20196 } 20197 20198 /** 20199 * Converts `string`, as a whole, to upper case just like 20200 * [String#toUpperCase](https://mdn.io/toUpperCase). 20201 * 20202 * @static 20203 * @memberOf _ 20204 * @since 4.0.0 20205 * @category String 20206 * @param {string} [string=''] The string to convert. 20207 * @returns {string} Returns the upper cased string. 20208 * @example 20209 * 20210 * _.toUpper('--foo-bar--'); 20211 * // => '--FOO-BAR--' 20212 * 20213 * _.toUpper('fooBar'); 20214 * // => 'FOOBAR' 20215 * 20216 * _.toUpper('__foo_bar__'); 20217 * // => '__FOO_BAR__' 20218 */ 20219 function toUpper(value) { 20220 return toString(value).toUpperCase(); 20221 } 20222 20223 /** 20224 * Removes leading and trailing whitespace or specified characters from `string`. 20225 * 20226 * @static 20227 * @memberOf _ 20228 * @since 3.0.0 20229 * @category String 20230 * @param {string} [string=''] The string to trim. 20231 * @param {string} [chars=whitespace] The characters to trim. 20232 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20233 * @returns {string} Returns the trimmed string. 20234 * @example 20235 * 20236 * _.trim(' abc '); 20237 * // => 'abc' 20238 * 20239 * _.trim('-_-abc-_-', '_-'); 20240 * // => 'abc' 20241 * 20242 * _.map([' foo ', ' bar '], _.trim); 20243 * // => ['foo', 'bar'] 20244 */ 20245 function trim(string, chars, guard) { 20246 string = toString(string); 20247 if (string && (guard || chars === undefined)) { 20248 return baseTrim(string); 20249 } 20250 if (!string || !(chars = baseToString(chars))) { 20251 return string; 20252 } 20253 var strSymbols = stringToArray(string), 20254 chrSymbols = stringToArray(chars), 20255 start = charsStartIndex(strSymbols, chrSymbols), 20256 end = charsEndIndex(strSymbols, chrSymbols) + 1; 20257 20258 return castSlice(strSymbols, start, end).join(''); 20259 } 20260 20261 /** 20262 * Removes trailing whitespace or specified characters from `string`. 20263 * 20264 * @static 20265 * @memberOf _ 20266 * @since 4.0.0 20267 * @category String 20268 * @param {string} [string=''] The string to trim. 20269 * @param {string} [chars=whitespace] The characters to trim. 20270 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20271 * @returns {string} Returns the trimmed string. 20272 * @example 20273 * 20274 * _.trimEnd(' abc '); 20275 * // => ' abc' 20276 * 20277 * _.trimEnd('-_-abc-_-', '_-'); 20278 * // => '-_-abc' 20279 */ 20280 function trimEnd(string, chars, guard) { 20281 string = toString(string); 20282 if (string && (guard || chars === undefined)) { 20283 return string.slice(0, trimmedEndIndex(string) + 1); 20284 } 20285 if (!string || !(chars = baseToString(chars))) { 20286 return string; 20287 } 20288 var strSymbols = stringToArray(string), 20289 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 20290 20291 return castSlice(strSymbols, 0, end).join(''); 20292 } 20293 20294 /** 20295 * Removes leading whitespace or specified characters from `string`. 20296 * 20297 * @static 20298 * @memberOf _ 20299 * @since 4.0.0 20300 * @category String 20301 * @param {string} [string=''] The string to trim. 20302 * @param {string} [chars=whitespace] The characters to trim. 20303 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20304 * @returns {string} Returns the trimmed string. 20305 * @example 20306 * 20307 * _.trimStart(' abc '); 20308 * // => 'abc ' 20309 * 20310 * _.trimStart('-_-abc-_-', '_-'); 20311 * // => 'abc-_-' 20312 */ 20313 function trimStart(string, chars, guard) { 20314 string = toString(string); 20315 if (string && (guard || chars === undefined)) { 20316 return string.replace(reTrimStart, ''); 20317 } 20318 if (!string || !(chars = baseToString(chars))) { 20319 return string; 20320 } 20321 var strSymbols = stringToArray(string), 20322 start = charsStartIndex(strSymbols, stringToArray(chars)); 20323 20324 return castSlice(strSymbols, start).join(''); 20325 } 20326 20327 /** 20328 * Truncates `string` if it's longer than the given maximum string length. 20329 * The last characters of the truncated string are replaced with the omission 20330 * string which defaults to "...". 20331 * 20332 * @static 20333 * @memberOf _ 20334 * @since 4.0.0 20335 * @category String 20336 * @param {string} [string=''] The string to truncate. 20337 * @param {Object} [options={}] The options object. 20338 * @param {number} [options.length=30] The maximum string length. 20339 * @param {string} [options.omission='...'] The string to indicate text is omitted. 20340 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 20341 * @returns {string} Returns the truncated string. 20342 * @example 20343 * 20344 * _.truncate('hi-diddly-ho there, neighborino'); 20345 * // => 'hi-diddly-ho there, neighbo...' 20346 * 20347 * _.truncate('hi-diddly-ho there, neighborino', { 20348 * 'length': 24, 20349 * 'separator': ' ' 20350 * }); 20351 * // => 'hi-diddly-ho there,...' 20352 * 20353 * _.truncate('hi-diddly-ho there, neighborino', { 20354 * 'length': 24, 20355 * 'separator': /,? +/ 20356 * }); 20357 * // => 'hi-diddly-ho there...' 20358 * 20359 * _.truncate('hi-diddly-ho there, neighborino', { 20360 * 'omission': ' [...]' 20361 * }); 20362 * // => 'hi-diddly-ho there, neig [...]' 20363 */ 20364 function truncate(string, options) { 20365 var length = DEFAULT_TRUNC_LENGTH, 20366 omission = DEFAULT_TRUNC_OMISSION; 20367 20368 if (isObject(options)) { 20369 var separator = 'separator' in options ? options.separator : separator; 20370 length = 'length' in options ? toInteger(options.length) : length; 20371 omission = 'omission' in options ? baseToString(options.omission) : omission; 20372 } 20373 string = toString(string); 20374 20375 var strLength = string.length; 20376 if (hasUnicode(string)) { 20377 var strSymbols = stringToArray(string); 20378 strLength = strSymbols.length; 20379 } 20380 if (length >= strLength) { 20381 return string; 20382 } 20383 var end = length - stringSize(omission); 20384 if (end < 1) { 20385 return omission; 20386 } 20387 var result = strSymbols 20388 ? castSlice(strSymbols, 0, end).join('') 20389 : string.slice(0, end); 20390 20391 if (separator === undefined) { 20392 return result + omission; 20393 } 20394 if (strSymbols) { 20395 end += (result.length - end); 20396 } 20397 if (isRegExp(separator)) { 20398 if (string.slice(end).search(separator)) { 20399 var match, 20400 substring = result; 20401 20402 if (!separator.global) { 20403 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 20404 } 20405 separator.lastIndex = 0; 20406 while ((match = separator.exec(substring))) { 20407 var newEnd = match.index; 20408 } 20409 result = result.slice(0, newEnd === undefined ? end : newEnd); 20410 } 20411 } else if (string.indexOf(baseToString(separator), end) != end) { 20412 var index = result.lastIndexOf(separator); 20413 if (index > -1) { 20414 result = result.slice(0, index); 20415 } 20416 } 20417 return result + omission; 20418 } 20419 20420 /** 20421 * The inverse of `_.escape`; this method converts the HTML entities 20422 * `&`, `<`, `>`, `"`, and `'` in `string` to 20423 * their corresponding characters. 20424 * 20425 * **Note:** No other HTML entities are unescaped. To unescape additional 20426 * HTML entities use a third-party library like [_he_](https://mths.be/he). 20427 * 20428 * @static 20429 * @memberOf _ 20430 * @since 0.6.0 20431 * @category String 20432 * @param {string} [string=''] The string to unescape. 20433 * @returns {string} Returns the unescaped string. 20434 * @example 20435 * 20436 * _.unescape('fred, barney, & pebbles'); 20437 * // => 'fred, barney, & pebbles' 20438 */ 20439 function unescape(string) { 20440 string = toString(string); 20441 return (string && reHasEscapedHtml.test(string)) 20442 ? string.replace(reEscapedHtml, unescapeHtmlChar) 20443 : string; 20444 } 20445 20446 /** 20447 * Converts `string`, as space separated words, to upper case. 20448 * 20449 * @static 20450 * @memberOf _ 20451 * @since 4.0.0 20452 * @category String 20453 * @param {string} [string=''] The string to convert. 20454 * @returns {string} Returns the upper cased string. 20455 * @example 20456 * 20457 * _.upperCase('--foo-bar'); 20458 * // => 'FOO BAR' 20459 * 20460 * _.upperCase('fooBar'); 20461 * // => 'FOO BAR' 20462 * 20463 * _.upperCase('__foo_bar__'); 20464 * // => 'FOO BAR' 20465 */ 20466 var upperCase = createCompounder(function(result, word, index) { 20467 return result + (index ? ' ' : '') + word.toUpperCase(); 20468 }); 20469 20470 /** 20471 * Converts the first character of `string` to upper case. 20472 * 20473 * @static 20474 * @memberOf _ 20475 * @since 4.0.0 20476 * @category String 20477 * @param {string} [string=''] The string to convert. 20478 * @returns {string} Returns the converted string. 20479 * @example 20480 * 20481 * _.upperFirst('fred'); 20482 * // => 'Fred' 20483 * 20484 * _.upperFirst('FRED'); 20485 * // => 'FRED' 20486 */ 20487 var upperFirst = createCaseFirst('toUpperCase'); 20488 20489 /** 20490 * Splits `string` into an array of its words. 20491 * 20492 * @static 20493 * @memberOf _ 20494 * @since 3.0.0 20495 * @category String 20496 * @param {string} [string=''] The string to inspect. 20497 * @param {RegExp|string} [pattern] The pattern to match words. 20498 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 20499 * @returns {Array} Returns the words of `string`. 20500 * @example 20501 * 20502 * _.words('fred, barney, & pebbles'); 20503 * // => ['fred', 'barney', 'pebbles'] 20504 * 20505 * _.words('fred, barney, & pebbles', /[^, ]+/g); 20506 * // => ['fred', 'barney', '&', 'pebbles'] 20507 */ 20508 function words(string, pattern, guard) { 20509 string = toString(string); 20510 pattern = guard ? undefined : pattern; 20511 20512 if (pattern === undefined) { 20513 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 20514 } 20515 return string.match(pattern) || []; 20516 } 20517 20518 /*------------------------------------------------------------------------*/ 20519 20520 /** 20521 * Attempts to invoke `func`, returning either the result or the caught error 20522 * object. Any additional arguments are provided to `func` when it's invoked. 20523 * 20524 * @static 20525 * @memberOf _ 20526 * @since 3.0.0 20527 * @category Util 20528 * @param {Function} func The function to attempt. 20529 * @param {...*} [args] The arguments to invoke `func` with. 20530 * @returns {*} Returns the `func` result or error object. 20531 * @example 20532 * 20533 * // Avoid throwing errors for invalid selectors. 20534 * var elements = _.attempt(function(selector) { 20535 * return document.querySelectorAll(selector); 20536 * }, '>_>'); 20537 * 20538 * if (_.isError(elements)) { 20539 * elements = []; 20540 * } 20541 */ 20542 var attempt = baseRest(function(func, args) { 20543 try { 20544 return apply(func, undefined, args); 20545 } catch (e) { 20546 return isError(e) ? e : new Error(e); 20547 } 20548 }); 20549 20550 /** 20551 * Binds methods of an object to the object itself, overwriting the existing 20552 * method. 20553 * 20554 * **Note:** This method doesn't set the "length" property of bound functions. 20555 * 20556 * @static 20557 * @since 0.1.0 20558 * @memberOf _ 20559 * @category Util 20560 * @param {Object} object The object to bind and assign the bound methods to. 20561 * @param {...(string|string[])} methodNames The object method names to bind. 20562 * @returns {Object} Returns `object`. 20563 * @example 20564 * 20565 * var view = { 20566 * 'label': 'docs', 20567 * 'click': function() { 20568 * console.log('clicked ' + this.label); 20569 * } 20570 * }; 20571 * 20572 * _.bindAll(view, ['click']); 20573 * jQuery(element).on('click', view.click); 20574 * // => Logs 'clicked docs' when clicked. 20575 */ 20576 var bindAll = flatRest(function(object, methodNames) { 20577 arrayEach(methodNames, function(key) { 20578 key = toKey(key); 20579 baseAssignValue(object, key, bind(object[key], object)); 20580 }); 20581 return object; 20582 }); 20583 20584 /** 20585 * Creates a function that iterates over `pairs` and invokes the corresponding 20586 * function of the first predicate to return truthy. The predicate-function 20587 * pairs are invoked with the `this` binding and arguments of the created 20588 * function. 20589 * 20590 * @static 20591 * @memberOf _ 20592 * @since 4.0.0 20593 * @category Util 20594 * @param {Array} pairs The predicate-function pairs. 20595 * @returns {Function} Returns the new composite function. 20596 * @example 20597 * 20598 * var func = _.cond([ 20599 * [_.matches({ 'a': 1 }), _.constant('matches A')], 20600 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 20601 * [_.stubTrue, _.constant('no match')] 20602 * ]); 20603 * 20604 * func({ 'a': 1, 'b': 2 }); 20605 * // => 'matches A' 20606 * 20607 * func({ 'a': 0, 'b': 1 }); 20608 * // => 'matches B' 20609 * 20610 * func({ 'a': '1', 'b': '2' }); 20611 * // => 'no match' 20612 */ 20613 function cond(pairs) { 20614 var length = pairs == null ? 0 : pairs.length, 20615 toIteratee = getIteratee(); 20616 20617 pairs = !length ? [] : arrayMap(pairs, function(pair) { 20618 if (typeof pair[1] != 'function') { 20619 throw new TypeError(FUNC_ERROR_TEXT); 20620 } 20621 return [toIteratee(pair[0]), pair[1]]; 20622 }); 20623 20624 return baseRest(function(args) { 20625 var index = -1; 20626 while (++index < length) { 20627 var pair = pairs[index]; 20628 if (apply(pair[0], this, args)) { 20629 return apply(pair[1], this, args); 20630 } 20631 } 20632 }); 20633 } 20634 20635 /** 20636 * Creates a function that invokes the predicate properties of `source` with 20637 * the corresponding property values of a given object, returning `true` if 20638 * all predicates return truthy, else `false`. 20639 * 20640 * **Note:** The created function is equivalent to `_.conformsTo` with 20641 * `source` partially applied. 20642 * 20643 * @static 20644 * @memberOf _ 20645 * @since 4.0.0 20646 * @category Util 20647 * @param {Object} source The object of property predicates to conform to. 20648 * @returns {Function} Returns the new spec function. 20649 * @example 20650 * 20651 * var objects = [ 20652 * { 'a': 2, 'b': 1 }, 20653 * { 'a': 1, 'b': 2 } 20654 * ]; 20655 * 20656 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 20657 * // => [{ 'a': 1, 'b': 2 }] 20658 */ 20659 function conforms(source) { 20660 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 20661 } 20662 20663 /** 20664 * Creates a function that returns `value`. 20665 * 20666 * @static 20667 * @memberOf _ 20668 * @since 2.4.0 20669 * @category Util 20670 * @param {*} value The value to return from the new function. 20671 * @returns {Function} Returns the new constant function. 20672 * @example 20673 * 20674 * var objects = _.times(2, _.constant({ 'a': 1 })); 20675 * 20676 * console.log(objects); 20677 * // => [{ 'a': 1 }, { 'a': 1 }] 20678 * 20679 * console.log(objects[0] === objects[1]); 20680 * // => true 20681 */ 20682 function constant(value) { 20683 return function() { 20684 return value; 20685 }; 20686 } 20687 20688 /** 20689 * Checks `value` to determine whether a default value should be returned in 20690 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 20691 * or `undefined`. 20692 * 20693 * @static 20694 * @memberOf _ 20695 * @since 4.14.0 20696 * @category Util 20697 * @param {*} value The value to check. 20698 * @param {*} defaultValue The default value. 20699 * @returns {*} Returns the resolved value. 20700 * @example 20701 * 20702 * _.defaultTo(1, 10); 20703 * // => 1 20704 * 20705 * _.defaultTo(undefined, 10); 20706 * // => 10 20707 */ 20708 function defaultTo(value, defaultValue) { 20709 return (value == null || value !== value) ? defaultValue : value; 20710 } 20711 20712 /** 20713 * Creates a function that returns the result of invoking the given functions 20714 * with the `this` binding of the created function, where each successive 20715 * invocation is supplied the return value of the previous. 20716 * 20717 * @static 20718 * @memberOf _ 20719 * @since 3.0.0 20720 * @category Util 20721 * @param {...(Function|Function[])} [funcs] The functions to invoke. 20722 * @returns {Function} Returns the new composite function. 20723 * @see _.flowRight 20724 * @example 20725 * 20726 * function square(n) { 20727 * return n * n; 20728 * } 20729 * 20730 * var addSquare = _.flow([_.add, square]); 20731 * addSquare(1, 2); 20732 * // => 9 20733 */ 20734 var flow = createFlow(); 20735 20736 /** 20737 * This method is like `_.flow` except that it creates a function that 20738 * invokes the given functions from right to left. 20739 * 20740 * @static 20741 * @since 3.0.0 20742 * @memberOf _ 20743 * @category Util 20744 * @param {...(Function|Function[])} [funcs] The functions to invoke. 20745 * @returns {Function} Returns the new composite function. 20746 * @see _.flow 20747 * @example 20748 * 20749 * function square(n) { 20750 * return n * n; 20751 * } 20752 * 20753 * var addSquare = _.flowRight([square, _.add]); 20754 * addSquare(1, 2); 20755 * // => 9 20756 */ 20757 var flowRight = createFlow(true); 20758 20759 /** 20760 * This method returns the first argument it receives. 20761 * 20762 * @static 20763 * @since 0.1.0 20764 * @memberOf _ 20765 * @category Util 20766 * @param {*} value Any value. 20767 * @returns {*} Returns `value`. 20768 * @example 20769 * 20770 * var object = { 'a': 1 }; 20771 * 20772 * console.log(_.identity(object) === object); 20773 * // => true 20774 */ 20775 function identity(value) { 20776 return value; 20777 } 20778 20779 /** 20780 * Creates a function that invokes `func` with the arguments of the created 20781 * function. If `func` is a property name, the created function returns the 20782 * property value for a given element. If `func` is an array or object, the 20783 * created function returns `true` for elements that contain the equivalent 20784 * source properties, otherwise it returns `false`. 20785 * 20786 * @static 20787 * @since 4.0.0 20788 * @memberOf _ 20789 * @category Util 20790 * @param {*} [func=_.identity] The value to convert to a callback. 20791 * @returns {Function} Returns the callback. 20792 * @example 20793 * 20794 * var users = [ 20795 * { 'user': 'barney', 'age': 36, 'active': true }, 20796 * { 'user': 'fred', 'age': 40, 'active': false } 20797 * ]; 20798 * 20799 * // The `_.matches` iteratee shorthand. 20800 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 20801 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 20802 * 20803 * // The `_.matchesProperty` iteratee shorthand. 20804 * _.filter(users, _.iteratee(['user', 'fred'])); 20805 * // => [{ 'user': 'fred', 'age': 40 }] 20806 * 20807 * // The `_.property` iteratee shorthand. 20808 * _.map(users, _.iteratee('user')); 20809 * // => ['barney', 'fred'] 20810 * 20811 * // Create custom iteratee shorthands. 20812 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 20813 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 20814 * return func.test(string); 20815 * }; 20816 * }); 20817 * 20818 * _.filter(['abc', 'def'], /ef/); 20819 * // => ['def'] 20820 */ 20821 function iteratee(func) { 20822 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 20823 } 20824 20825 /** 20826 * Creates a function that performs a partial deep comparison between a given 20827 * object and `source`, returning `true` if the given object has equivalent 20828 * property values, else `false`. 20829 * 20830 * **Note:** The created function is equivalent to `_.isMatch` with `source` 20831 * partially applied. 20832 * 20833 * Partial comparisons will match empty array and empty object `source` 20834 * values against any array or object value, respectively. See `_.isEqual` 20835 * for a list of supported value comparisons. 20836 * 20837 * **Note:** Multiple values can be checked by combining several matchers 20838 * using `_.overSome` 20839 * 20840 * @static 20841 * @memberOf _ 20842 * @since 3.0.0 20843 * @category Util 20844 * @param {Object} source The object of property values to match. 20845 * @returns {Function} Returns the new spec function. 20846 * @example 20847 * 20848 * var objects = [ 20849 * { 'a': 1, 'b': 2, 'c': 3 }, 20850 * { 'a': 4, 'b': 5, 'c': 6 } 20851 * ]; 20852 * 20853 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 20854 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 20855 * 20856 * // Checking for several possible values 20857 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); 20858 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 20859 */ 20860 function matches(source) { 20861 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 20862 } 20863 20864 /** 20865 * Creates a function that performs a partial deep comparison between the 20866 * value at `path` of a given object to `srcValue`, returning `true` if the 20867 * object value is equivalent, else `false`. 20868 * 20869 * **Note:** Partial comparisons will match empty array and empty object 20870 * `srcValue` values against any array or object value, respectively. See 20871 * `_.isEqual` for a list of supported value comparisons. 20872 * 20873 * **Note:** Multiple values can be checked by combining several matchers 20874 * using `_.overSome` 20875 * 20876 * @static 20877 * @memberOf _ 20878 * @since 3.2.0 20879 * @category Util 20880 * @param {Array|string} path The path of the property to get. 20881 * @param {*} srcValue The value to match. 20882 * @returns {Function} Returns the new spec function. 20883 * @example 20884 * 20885 * var objects = [ 20886 * { 'a': 1, 'b': 2, 'c': 3 }, 20887 * { 'a': 4, 'b': 5, 'c': 6 } 20888 * ]; 20889 * 20890 * _.find(objects, _.matchesProperty('a', 4)); 20891 * // => { 'a': 4, 'b': 5, 'c': 6 } 20892 * 20893 * // Checking for several possible values 20894 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); 20895 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 20896 */ 20897 function matchesProperty(path, srcValue) { 20898 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 20899 } 20900 20901 /** 20902 * Creates a function that invokes the method at `path` of a given object. 20903 * Any additional arguments are provided to the invoked method. 20904 * 20905 * @static 20906 * @memberOf _ 20907 * @since 3.7.0 20908 * @category Util 20909 * @param {Array|string} path The path of the method to invoke. 20910 * @param {...*} [args] The arguments to invoke the method with. 20911 * @returns {Function} Returns the new invoker function. 20912 * @example 20913 * 20914 * var objects = [ 20915 * { 'a': { 'b': _.constant(2) } }, 20916 * { 'a': { 'b': _.constant(1) } } 20917 * ]; 20918 * 20919 * _.map(objects, _.method('a.b')); 20920 * // => [2, 1] 20921 * 20922 * _.map(objects, _.method(['a', 'b'])); 20923 * // => [2, 1] 20924 */ 20925 var method = baseRest(function(path, args) { 20926 return function(object) { 20927 return baseInvoke(object, path, args); 20928 }; 20929 }); 20930 20931 /** 20932 * The opposite of `_.method`; this method creates a function that invokes 20933 * the method at a given path of `object`. Any additional arguments are 20934 * provided to the invoked method. 20935 * 20936 * @static 20937 * @memberOf _ 20938 * @since 3.7.0 20939 * @category Util 20940 * @param {Object} object The object to query. 20941 * @param {...*} [args] The arguments to invoke the method with. 20942 * @returns {Function} Returns the new invoker function. 20943 * @example 20944 * 20945 * var array = _.times(3, _.constant), 20946 * object = { 'a': array, 'b': array, 'c': array }; 20947 * 20948 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 20949 * // => [2, 0] 20950 * 20951 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 20952 * // => [2, 0] 20953 */ 20954 var methodOf = baseRest(function(object, args) { 20955 return function(path) { 20956 return baseInvoke(object, path, args); 20957 }; 20958 }); 20959 20960 /** 20961 * Adds all own enumerable string keyed function properties of a source 20962 * object to the destination object. If `object` is a function, then methods 20963 * are added to its prototype as well. 20964 * 20965 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 20966 * avoid conflicts caused by modifying the original. 20967 * 20968 * @static 20969 * @since 0.1.0 20970 * @memberOf _ 20971 * @category Util 20972 * @param {Function|Object} [object=lodash] The destination object. 20973 * @param {Object} source The object of functions to add. 20974 * @param {Object} [options={}] The options object. 20975 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 20976 * @returns {Function|Object} Returns `object`. 20977 * @example 20978 * 20979 * function vowels(string) { 20980 * return _.filter(string, function(v) { 20981 * return /[aeiou]/i.test(v); 20982 * }); 20983 * } 20984 * 20985 * _.mixin({ 'vowels': vowels }); 20986 * _.vowels('fred'); 20987 * // => ['e'] 20988 * 20989 * _('fred').vowels().value(); 20990 * // => ['e'] 20991 * 20992 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 20993 * _('fred').vowels(); 20994 * // => ['e'] 20995 */ 20996 function mixin(object, source, options) { 20997 var props = keys(source), 20998 methodNames = baseFunctions(source, props); 20999 21000 if (options == null && 21001 !(isObject(source) && (methodNames.length || !props.length))) { 21002 options = source; 21003 source = object; 21004 object = this; 21005 methodNames = baseFunctions(source, keys(source)); 21006 } 21007 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 21008 isFunc = isFunction(object); 21009 21010 arrayEach(methodNames, function(methodName) { 21011 var func = source[methodName]; 21012 object[methodName] = func; 21013 if (isFunc) { 21014 object.prototype[methodName] = function() { 21015 var chainAll = this.__chain__; 21016 if (chain || chainAll) { 21017 var result = object(this.__wrapped__), 21018 actions = result.__actions__ = copyArray(this.__actions__); 21019 21020 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 21021 result.__chain__ = chainAll; 21022 return result; 21023 } 21024 return func.apply(object, arrayPush([this.value()], arguments)); 21025 }; 21026 } 21027 }); 21028 21029 return object; 21030 } 21031 21032 /** 21033 * Reverts the `_` variable to its previous value and returns a reference to 21034 * the `lodash` function. 21035 * 21036 * @static 21037 * @since 0.1.0 21038 * @memberOf _ 21039 * @category Util 21040 * @returns {Function} Returns the `lodash` function. 21041 * @example 21042 * 21043 * var lodash = _.noConflict(); 21044 */ 21045 function noConflict() { 21046 if (root._ === this) { 21047 root._ = oldDash; 21048 } 21049 return this; 21050 } 21051 21052 /** 21053 * This method returns `undefined`. 21054 * 21055 * @static 21056 * @memberOf _ 21057 * @since 2.3.0 21058 * @category Util 21059 * @example 21060 * 21061 * _.times(2, _.noop); 21062 * // => [undefined, undefined] 21063 */ 21064 function noop() { 21065 // No operation performed. 21066 } 21067 21068 /** 21069 * Creates a function that gets the argument at index `n`. If `n` is negative, 21070 * the nth argument from the end is returned. 21071 * 21072 * @static 21073 * @memberOf _ 21074 * @since 4.0.0 21075 * @category Util 21076 * @param {number} [n=0] The index of the argument to return. 21077 * @returns {Function} Returns the new pass-thru function. 21078 * @example 21079 * 21080 * var func = _.nthArg(1); 21081 * func('a', 'b', 'c', 'd'); 21082 * // => 'b' 21083 * 21084 * var func = _.nthArg(-2); 21085 * func('a', 'b', 'c', 'd'); 21086 * // => 'c' 21087 */ 21088 function nthArg(n) { 21089 n = toInteger(n); 21090 return baseRest(function(args) { 21091 return baseNth(args, n); 21092 }); 21093 } 21094 21095 /** 21096 * Creates a function that invokes `iteratees` with the arguments it receives 21097 * and returns their results. 21098 * 21099 * @static 21100 * @memberOf _ 21101 * @since 4.0.0 21102 * @category Util 21103 * @param {...(Function|Function[])} [iteratees=[_.identity]] 21104 * The iteratees to invoke. 21105 * @returns {Function} Returns the new function. 21106 * @example 21107 * 21108 * var func = _.over([Math.max, Math.min]); 21109 * 21110 * func(1, 2, 3, 4); 21111 * // => [4, 1] 21112 */ 21113 var over = createOver(arrayMap); 21114 21115 /** 21116 * Creates a function that checks if **all** of the `predicates` return 21117 * truthy when invoked with the arguments it receives. 21118 * 21119 * Following shorthands are possible for providing predicates. 21120 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 21121 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 21122 * 21123 * @static 21124 * @memberOf _ 21125 * @since 4.0.0 21126 * @category Util 21127 * @param {...(Function|Function[])} [predicates=[_.identity]] 21128 * The predicates to check. 21129 * @returns {Function} Returns the new function. 21130 * @example 21131 * 21132 * var func = _.overEvery([Boolean, isFinite]); 21133 * 21134 * func('1'); 21135 * // => true 21136 * 21137 * func(null); 21138 * // => false 21139 * 21140 * func(NaN); 21141 * // => false 21142 */ 21143 var overEvery = createOver(arrayEvery); 21144 21145 /** 21146 * Creates a function that checks if **any** of the `predicates` return 21147 * truthy when invoked with the arguments it receives. 21148 * 21149 * Following shorthands are possible for providing predicates. 21150 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 21151 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 21152 * 21153 * @static 21154 * @memberOf _ 21155 * @since 4.0.0 21156 * @category Util 21157 * @param {...(Function|Function[])} [predicates=[_.identity]] 21158 * The predicates to check. 21159 * @returns {Function} Returns the new function. 21160 * @example 21161 * 21162 * var func = _.overSome([Boolean, isFinite]); 21163 * 21164 * func('1'); 21165 * // => true 21166 * 21167 * func(null); 21168 * // => true 21169 * 21170 * func(NaN); 21171 * // => false 21172 * 21173 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) 21174 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) 21175 */ 21176 var overSome = createOver(arraySome); 21177 21178 /** 21179 * Creates a function that returns the value at `path` of a given object. 21180 * 21181 * @static 21182 * @memberOf _ 21183 * @since 2.4.0 21184 * @category Util 21185 * @param {Array|string} path The path of the property to get. 21186 * @returns {Function} Returns the new accessor function. 21187 * @example 21188 * 21189 * var objects = [ 21190 * { 'a': { 'b': 2 } }, 21191 * { 'a': { 'b': 1 } } 21192 * ]; 21193 * 21194 * _.map(objects, _.property('a.b')); 21195 * // => [2, 1] 21196 * 21197 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 21198 * // => [1, 2] 21199 */ 21200 function property(path) { 21201 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 21202 } 21203 21204 /** 21205 * The opposite of `_.property`; this method creates a function that returns 21206 * the value at a given path of `object`. 21207 * 21208 * @static 21209 * @memberOf _ 21210 * @since 3.0.0 21211 * @category Util 21212 * @param {Object} object The object to query. 21213 * @returns {Function} Returns the new accessor function. 21214 * @example 21215 * 21216 * var array = [0, 1, 2], 21217 * object = { 'a': array, 'b': array, 'c': array }; 21218 * 21219 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 21220 * // => [2, 0] 21221 * 21222 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 21223 * // => [2, 0] 21224 */ 21225 function propertyOf(object) { 21226 return function(path) { 21227 return object == null ? undefined : baseGet(object, path); 21228 }; 21229 } 21230 21231 /** 21232 * Creates an array of numbers (positive and/or negative) progressing from 21233 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 21234 * `start` is specified without an `end` or `step`. If `end` is not specified, 21235 * it's set to `start` with `start` then set to `0`. 21236 * 21237 * **Note:** JavaScript follows the IEEE-754 standard for resolving 21238 * floating-point values which can produce unexpected results. 21239 * 21240 * @static 21241 * @since 0.1.0 21242 * @memberOf _ 21243 * @category Util 21244 * @param {number} [start=0] The start of the range. 21245 * @param {number} end The end of the range. 21246 * @param {number} [step=1] The value to increment or decrement by. 21247 * @returns {Array} Returns the range of numbers. 21248 * @see _.inRange, _.rangeRight 21249 * @example 21250 * 21251 * _.range(4); 21252 * // => [0, 1, 2, 3] 21253 * 21254 * _.range(-4); 21255 * // => [0, -1, -2, -3] 21256 * 21257 * _.range(1, 5); 21258 * // => [1, 2, 3, 4] 21259 * 21260 * _.range(0, 20, 5); 21261 * // => [0, 5, 10, 15] 21262 * 21263 * _.range(0, -4, -1); 21264 * // => [0, -1, -2, -3] 21265 * 21266 * _.range(1, 4, 0); 21267 * // => [1, 1, 1] 21268 * 21269 * _.range(0); 21270 * // => [] 21271 */ 21272 var range = createRange(); 21273 21274 /** 21275 * This method is like `_.range` except that it populates values in 21276 * descending order. 21277 * 21278 * @static 21279 * @memberOf _ 21280 * @since 4.0.0 21281 * @category Util 21282 * @param {number} [start=0] The start of the range. 21283 * @param {number} end The end of the range. 21284 * @param {number} [step=1] The value to increment or decrement by. 21285 * @returns {Array} Returns the range of numbers. 21286 * @see _.inRange, _.range 21287 * @example 21288 * 21289 * _.rangeRight(4); 21290 * // => [3, 2, 1, 0] 21291 * 21292 * _.rangeRight(-4); 21293 * // => [-3, -2, -1, 0] 21294 * 21295 * _.rangeRight(1, 5); 21296 * // => [4, 3, 2, 1] 21297 * 21298 * _.rangeRight(0, 20, 5); 21299 * // => [15, 10, 5, 0] 21300 * 21301 * _.rangeRight(0, -4, -1); 21302 * // => [-3, -2, -1, 0] 21303 * 21304 * _.rangeRight(1, 4, 0); 21305 * // => [1, 1, 1] 21306 * 21307 * _.rangeRight(0); 21308 * // => [] 21309 */ 21310 var rangeRight = createRange(true); 21311 21312 /** 21313 * This method returns a new empty array. 21314 * 21315 * @static 21316 * @memberOf _ 21317 * @since 4.13.0 21318 * @category Util 21319 * @returns {Array} Returns the new empty array. 21320 * @example 21321 * 21322 * var arrays = _.times(2, _.stubArray); 21323 * 21324 * console.log(arrays); 21325 * // => [[], []] 21326 * 21327 * console.log(arrays[0] === arrays[1]); 21328 * // => false 21329 */ 21330 function stubArray() { 21331 return []; 21332 } 21333 21334 /** 21335 * This method returns `false`. 21336 * 21337 * @static 21338 * @memberOf _ 21339 * @since 4.13.0 21340 * @category Util 21341 * @returns {boolean} Returns `false`. 21342 * @example 21343 * 21344 * _.times(2, _.stubFalse); 21345 * // => [false, false] 21346 */ 21347 function stubFalse() { 21348 return false; 21349 } 21350 21351 /** 21352 * This method returns a new empty object. 21353 * 21354 * @static 21355 * @memberOf _ 21356 * @since 4.13.0 21357 * @category Util 21358 * @returns {Object} Returns the new empty object. 21359 * @example 21360 * 21361 * var objects = _.times(2, _.stubObject); 21362 * 21363 * console.log(objects); 21364 * // => [{}, {}] 21365 * 21366 * console.log(objects[0] === objects[1]); 21367 * // => false 21368 */ 21369 function stubObject() { 21370 return {}; 21371 } 21372 21373 /** 21374 * This method returns an empty string. 21375 * 21376 * @static 21377 * @memberOf _ 21378 * @since 4.13.0 21379 * @category Util 21380 * @returns {string} Returns the empty string. 21381 * @example 21382 * 21383 * _.times(2, _.stubString); 21384 * // => ['', ''] 21385 */ 21386 function stubString() { 21387 return ''; 21388 } 21389 21390 /** 21391 * This method returns `true`. 21392 * 21393 * @static 21394 * @memberOf _ 21395 * @since 4.13.0 21396 * @category Util 21397 * @returns {boolean} Returns `true`. 21398 * @example 21399 * 21400 * _.times(2, _.stubTrue); 21401 * // => [true, true] 21402 */ 21403 function stubTrue() { 21404 return true; 21405 } 21406 21407 /** 21408 * Invokes the iteratee `n` times, returning an array of the results of 21409 * each invocation. The iteratee is invoked with one argument; (index). 21410 * 21411 * @static 21412 * @since 0.1.0 21413 * @memberOf _ 21414 * @category Util 21415 * @param {number} n The number of times to invoke `iteratee`. 21416 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 21417 * @returns {Array} Returns the array of results. 21418 * @example 21419 * 21420 * _.times(3, String); 21421 * // => ['0', '1', '2'] 21422 * 21423 * _.times(4, _.constant(0)); 21424 * // => [0, 0, 0, 0] 21425 */ 21426 function times(n, iteratee) { 21427 n = toInteger(n); 21428 if (n < 1 || n > MAX_SAFE_INTEGER) { 21429 return []; 21430 } 21431 var index = MAX_ARRAY_LENGTH, 21432 length = nativeMin(n, MAX_ARRAY_LENGTH); 21433 21434 iteratee = getIteratee(iteratee); 21435 n -= MAX_ARRAY_LENGTH; 21436 21437 var result = baseTimes(length, iteratee); 21438 while (++index < n) { 21439 iteratee(index); 21440 } 21441 return result; 21442 } 21443 21444 /** 21445 * Converts `value` to a property path array. 21446 * 21447 * @static 21448 * @memberOf _ 21449 * @since 4.0.0 21450 * @category Util 21451 * @param {*} value The value to convert. 21452 * @returns {Array} Returns the new property path array. 21453 * @example 21454 * 21455 * _.toPath('a.b.c'); 21456 * // => ['a', 'b', 'c'] 21457 * 21458 * _.toPath('a[0].b.c'); 21459 * // => ['a', '0', 'b', 'c'] 21460 */ 21461 function toPath(value) { 21462 if (isArray(value)) { 21463 return arrayMap(value, toKey); 21464 } 21465 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 21466 } 21467 21468 /** 21469 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 21470 * 21471 * @static 21472 * @since 0.1.0 21473 * @memberOf _ 21474 * @category Util 21475 * @param {string} [prefix=''] The value to prefix the ID with. 21476 * @returns {string} Returns the unique ID. 21477 * @example 21478 * 21479 * _.uniqueId('contact_'); 21480 * // => 'contact_104' 21481 * 21482 * _.uniqueId(); 21483 * // => '105' 21484 */ 21485 function uniqueId(prefix) { 21486 var id = ++idCounter; 21487 return toString(prefix) + id; 21488 } 21489 21490 /*------------------------------------------------------------------------*/ 21491 21492 /** 21493 * Adds two numbers. 21494 * 21495 * @static 21496 * @memberOf _ 21497 * @since 3.4.0 21498 * @category Math 21499 * @param {number} augend The first number in an addition. 21500 * @param {number} addend The second number in an addition. 21501 * @returns {number} Returns the total. 21502 * @example 21503 * 21504 * _.add(6, 4); 21505 * // => 10 21506 */ 21507 var add = createMathOperation(function(augend, addend) { 21508 return augend + addend; 21509 }, 0); 21510 21511 /** 21512 * Computes `number` rounded up to `precision`. 21513 * 21514 * @static 21515 * @memberOf _ 21516 * @since 3.10.0 21517 * @category Math 21518 * @param {number} number The number to round up. 21519 * @param {number} [precision=0] The precision to round up to. 21520 * @returns {number} Returns the rounded up number. 21521 * @example 21522 * 21523 * _.ceil(4.006); 21524 * // => 5 21525 * 21526 * _.ceil(6.004, 2); 21527 * // => 6.01 21528 * 21529 * _.ceil(6040, -2); 21530 * // => 6100 21531 */ 21532 var ceil = createRound('ceil'); 21533 21534 /** 21535 * Divide two numbers. 21536 * 21537 * @static 21538 * @memberOf _ 21539 * @since 4.7.0 21540 * @category Math 21541 * @param {number} dividend The first number in a division. 21542 * @param {number} divisor The second number in a division. 21543 * @returns {number} Returns the quotient. 21544 * @example 21545 * 21546 * _.divide(6, 4); 21547 * // => 1.5 21548 */ 21549 var divide = createMathOperation(function(dividend, divisor) { 21550 return dividend / divisor; 21551 }, 1); 21552 21553 /** 21554 * Computes `number` rounded down to `precision`. 21555 * 21556 * @static 21557 * @memberOf _ 21558 * @since 3.10.0 21559 * @category Math 21560 * @param {number} number The number to round down. 21561 * @param {number} [precision=0] The precision to round down to. 21562 * @returns {number} Returns the rounded down number. 21563 * @example 21564 * 21565 * _.floor(4.006); 21566 * // => 4 21567 * 21568 * _.floor(0.046, 2); 21569 * // => 0.04 21570 * 21571 * _.floor(4060, -2); 21572 * // => 4000 21573 */ 21574 var floor = createRound('floor'); 21575 21576 /** 21577 * Computes the maximum value of `array`. If `array` is empty or falsey, 21578 * `undefined` is returned. 21579 * 21580 * @static 21581 * @since 0.1.0 21582 * @memberOf _ 21583 * @category Math 21584 * @param {Array} array The array to iterate over. 21585 * @returns {*} Returns the maximum value. 21586 * @example 21587 * 21588 * _.max([4, 2, 8, 6]); 21589 * // => 8 21590 * 21591 * _.max([]); 21592 * // => undefined 21593 */ 21594 function max(array) { 21595 return (array && array.length) 21596 ? baseExtremum(array, identity, baseGt) 21597 : undefined; 21598 } 21599 21600 /** 21601 * This method is like `_.max` except that it accepts `iteratee` which is 21602 * invoked for each element in `array` to generate the criterion by which 21603 * the value is ranked. The iteratee is invoked with one argument: (value). 21604 * 21605 * @static 21606 * @memberOf _ 21607 * @since 4.0.0 21608 * @category Math 21609 * @param {Array} array The array to iterate over. 21610 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21611 * @returns {*} Returns the maximum value. 21612 * @example 21613 * 21614 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 21615 * 21616 * _.maxBy(objects, function(o) { return o.n; }); 21617 * // => { 'n': 2 } 21618 * 21619 * // The `_.property` iteratee shorthand. 21620 * _.maxBy(objects, 'n'); 21621 * // => { 'n': 2 } 21622 */ 21623 function maxBy(array, iteratee) { 21624 return (array && array.length) 21625 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 21626 : undefined; 21627 } 21628 21629 /** 21630 * Computes the mean of the values in `array`. 21631 * 21632 * @static 21633 * @memberOf _ 21634 * @since 4.0.0 21635 * @category Math 21636 * @param {Array} array The array to iterate over. 21637 * @returns {number} Returns the mean. 21638 * @example 21639 * 21640 * _.mean([4, 2, 8, 6]); 21641 * // => 5 21642 */ 21643 function mean(array) { 21644 return baseMean(array, identity); 21645 } 21646 21647 /** 21648 * This method is like `_.mean` except that it accepts `iteratee` which is 21649 * invoked for each element in `array` to generate the value to be averaged. 21650 * The iteratee is invoked with one argument: (value). 21651 * 21652 * @static 21653 * @memberOf _ 21654 * @since 4.7.0 21655 * @category Math 21656 * @param {Array} array The array to iterate over. 21657 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21658 * @returns {number} Returns the mean. 21659 * @example 21660 * 21661 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 21662 * 21663 * _.meanBy(objects, function(o) { return o.n; }); 21664 * // => 5 21665 * 21666 * // The `_.property` iteratee shorthand. 21667 * _.meanBy(objects, 'n'); 21668 * // => 5 21669 */ 21670 function meanBy(array, iteratee) { 21671 return baseMean(array, getIteratee(iteratee, 2)); 21672 } 21673 21674 /** 21675 * Computes the minimum value of `array`. If `array` is empty or falsey, 21676 * `undefined` is returned. 21677 * 21678 * @static 21679 * @since 0.1.0 21680 * @memberOf _ 21681 * @category Math 21682 * @param {Array} array The array to iterate over. 21683 * @returns {*} Returns the minimum value. 21684 * @example 21685 * 21686 * _.min([4, 2, 8, 6]); 21687 * // => 2 21688 * 21689 * _.min([]); 21690 * // => undefined 21691 */ 21692 function min(array) { 21693 return (array && array.length) 21694 ? baseExtremum(array, identity, baseLt) 21695 : undefined; 21696 } 21697 21698 /** 21699 * This method is like `_.min` except that it accepts `iteratee` which is 21700 * invoked for each element in `array` to generate the criterion by which 21701 * the value is ranked. The iteratee is invoked with one argument: (value). 21702 * 21703 * @static 21704 * @memberOf _ 21705 * @since 4.0.0 21706 * @category Math 21707 * @param {Array} array The array to iterate over. 21708 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21709 * @returns {*} Returns the minimum value. 21710 * @example 21711 * 21712 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 21713 * 21714 * _.minBy(objects, function(o) { return o.n; }); 21715 * // => { 'n': 1 } 21716 * 21717 * // The `_.property` iteratee shorthand. 21718 * _.minBy(objects, 'n'); 21719 * // => { 'n': 1 } 21720 */ 21721 function minBy(array, iteratee) { 21722 return (array && array.length) 21723 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 21724 : undefined; 21725 } 21726 21727 /** 21728 * Multiply two numbers. 21729 * 21730 * @static 21731 * @memberOf _ 21732 * @since 4.7.0 21733 * @category Math 21734 * @param {number} multiplier The first number in a multiplication. 21735 * @param {number} multiplicand The second number in a multiplication. 21736 * @returns {number} Returns the product. 21737 * @example 21738 * 21739 * _.multiply(6, 4); 21740 * // => 24 21741 */ 21742 var multiply = createMathOperation(function(multiplier, multiplicand) { 21743 return multiplier * multiplicand; 21744 }, 1); 21745 21746 /** 21747 * Computes `number` rounded to `precision`. 21748 * 21749 * @static 21750 * @memberOf _ 21751 * @since 3.10.0 21752 * @category Math 21753 * @param {number} number The number to round. 21754 * @param {number} [precision=0] The precision to round to. 21755 * @returns {number} Returns the rounded number. 21756 * @example 21757 * 21758 * _.round(4.006); 21759 * // => 4 21760 * 21761 * _.round(4.006, 2); 21762 * // => 4.01 21763 * 21764 * _.round(4060, -2); 21765 * // => 4100 21766 */ 21767 var round = createRound('round'); 21768 21769 /** 21770 * Subtract two numbers. 21771 * 21772 * @static 21773 * @memberOf _ 21774 * @since 4.0.0 21775 * @category Math 21776 * @param {number} minuend The first number in a subtraction. 21777 * @param {number} subtrahend The second number in a subtraction. 21778 * @returns {number} Returns the difference. 21779 * @example 21780 * 21781 * _.subtract(6, 4); 21782 * // => 2 21783 */ 21784 var subtract = createMathOperation(function(minuend, subtrahend) { 21785 return minuend - subtrahend; 21786 }, 0); 21787 21788 /** 21789 * Computes the sum of the values in `array`. 21790 * 21791 * @static 21792 * @memberOf _ 21793 * @since 3.4.0 21794 * @category Math 21795 * @param {Array} array The array to iterate over. 21796 * @returns {number} Returns the sum. 21797 * @example 21798 * 21799 * _.sum([4, 2, 8, 6]); 21800 * // => 20 21801 */ 21802 function sum(array) { 21803 return (array && array.length) 21804 ? baseSum(array, identity) 21805 : 0; 21806 } 21807 21808 /** 21809 * This method is like `_.sum` except that it accepts `iteratee` which is 21810 * invoked for each element in `array` to generate the value to be summed. 21811 * The iteratee is invoked with one argument: (value). 21812 * 21813 * @static 21814 * @memberOf _ 21815 * @since 4.0.0 21816 * @category Math 21817 * @param {Array} array The array to iterate over. 21818 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 21819 * @returns {number} Returns the sum. 21820 * @example 21821 * 21822 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 21823 * 21824 * _.sumBy(objects, function(o) { return o.n; }); 21825 * // => 20 21826 * 21827 * // The `_.property` iteratee shorthand. 21828 * _.sumBy(objects, 'n'); 21829 * // => 20 21830 */ 21831 function sumBy(array, iteratee) { 21832 return (array && array.length) 21833 ? baseSum(array, getIteratee(iteratee, 2)) 21834 : 0; 21835 } 21836 21837 /*------------------------------------------------------------------------*/ 21838 21839 // Add methods that return wrapped values in chain sequences. 21840 lodash.after = after; 21841 lodash.ary = ary; 21842 lodash.assign = assign; 21843 lodash.assignIn = assignIn; 21844 lodash.assignInWith = assignInWith; 21845 lodash.assignWith = assignWith; 21846 lodash.at = at; 21847 lodash.before = before; 21848 lodash.bind = bind; 21849 lodash.bindAll = bindAll; 21850 lodash.bindKey = bindKey; 21851 lodash.castArray = castArray; 21852 lodash.chain = chain; 21853 lodash.chunk = chunk; 21854 lodash.compact = compact; 21855 lodash.concat = concat; 21856 lodash.cond = cond; 21857 lodash.conforms = conforms; 21858 lodash.constant = constant; 21859 lodash.countBy = countBy; 21860 lodash.create = create; 21861 lodash.curry = curry; 21862 lodash.curryRight = curryRight; 21863 lodash.debounce = debounce; 21864 lodash.defaults = defaults; 21865 lodash.defaultsDeep = defaultsDeep; 21866 lodash.defer = defer; 21867 lodash.delay = delay; 21868 lodash.difference = difference; 21869 lodash.differenceBy = differenceBy; 21870 lodash.differenceWith = differenceWith; 21871 lodash.drop = drop; 21872 lodash.dropRight = dropRight; 21873 lodash.dropRightWhile = dropRightWhile; 21874 lodash.dropWhile = dropWhile; 21875 lodash.fill = fill; 21876 lodash.filter = filter; 21877 lodash.flatMap = flatMap; 21878 lodash.flatMapDeep = flatMapDeep; 21879 lodash.flatMapDepth = flatMapDepth; 21880 lodash.flatten = flatten; 21881 lodash.flattenDeep = flattenDeep; 21882 lodash.flattenDepth = flattenDepth; 21883 lodash.flip = flip; 21884 lodash.flow = flow; 21885 lodash.flowRight = flowRight; 21886 lodash.fromPairs = fromPairs; 21887 lodash.functions = functions; 21888 lodash.functionsIn = functionsIn; 21889 lodash.groupBy = groupBy; 21890 lodash.initial = initial; 21891 lodash.intersection = intersection; 21892 lodash.intersectionBy = intersectionBy; 21893 lodash.intersectionWith = intersectionWith; 21894 lodash.invert = invert; 21895 lodash.invertBy = invertBy; 21896 lodash.invokeMap = invokeMap; 21897 lodash.iteratee = iteratee; 21898 lodash.keyBy = keyBy; 21899 lodash.keys = keys; 21900 lodash.keysIn = keysIn; 21901 lodash.map = map; 21902 lodash.mapKeys = mapKeys; 21903 lodash.mapValues = mapValues; 21904 lodash.matches = matches; 21905 lodash.matchesProperty = matchesProperty; 21906 lodash.memoize = memoize; 21907 lodash.merge = merge; 21908 lodash.mergeWith = mergeWith; 21909 lodash.method = method; 21910 lodash.methodOf = methodOf; 21911 lodash.mixin = mixin; 21912 lodash.negate = negate; 21913 lodash.nthArg = nthArg; 21914 lodash.omit = omit; 21915 lodash.omitBy = omitBy; 21916 lodash.once = once; 21917 lodash.orderBy = orderBy; 21918 lodash.over = over; 21919 lodash.overArgs = overArgs; 21920 lodash.overEvery = overEvery; 21921 lodash.overSome = overSome; 21922 lodash.partial = partial; 21923 lodash.partialRight = partialRight; 21924 lodash.partition = partition; 21925 lodash.pick = pick; 21926 lodash.pickBy = pickBy; 21927 lodash.property = property; 21928 lodash.propertyOf = propertyOf; 21929 lodash.pull = pull; 21930 lodash.pullAll = pullAll; 21931 lodash.pullAllBy = pullAllBy; 21932 lodash.pullAllWith = pullAllWith; 21933 lodash.pullAt = pullAt; 21934 lodash.range = range; 21935 lodash.rangeRight = rangeRight; 21936 lodash.rearg = rearg; 21937 lodash.reject = reject; 21938 lodash.remove = remove; 21939 lodash.rest = rest; 21940 lodash.reverse = reverse; 21941 lodash.sampleSize = sampleSize; 21942 lodash.set = set; 21943 lodash.setWith = setWith; 21944 lodash.shuffle = shuffle; 21945 lodash.slice = slice; 21946 lodash.sortBy = sortBy; 21947 lodash.sortedUniq = sortedUniq; 21948 lodash.sortedUniqBy = sortedUniqBy; 21949 lodash.split = split; 21950 lodash.spread = spread; 21951 lodash.tail = tail; 21952 lodash.take = take; 21953 lodash.takeRight = takeRight; 21954 lodash.takeRightWhile = takeRightWhile; 21955 lodash.takeWhile = takeWhile; 21956 lodash.tap = tap; 21957 lodash.throttle = throttle; 21958 lodash.thru = thru; 21959 lodash.toArray = toArray; 21960 lodash.toPairs = toPairs; 21961 lodash.toPairsIn = toPairsIn; 21962 lodash.toPath = toPath; 21963 lodash.toPlainObject = toPlainObject; 21964 lodash.transform = transform; 21965 lodash.unary = unary; 21966 lodash.union = union; 21967 lodash.unionBy = unionBy; 21968 lodash.unionWith = unionWith; 21969 lodash.uniq = uniq; 21970 lodash.uniqBy = uniqBy; 21971 lodash.uniqWith = uniqWith; 21972 lodash.unset = unset; 21973 lodash.unzip = unzip; 21974 lodash.unzipWith = unzipWith; 21975 lodash.update = update; 21976 lodash.updateWith = updateWith; 21977 lodash.values = values; 21978 lodash.valuesIn = valuesIn; 21979 lodash.without = without; 21980 lodash.words = words; 21981 lodash.wrap = wrap; 21982 lodash.xor = xor; 21983 lodash.xorBy = xorBy; 21984 lodash.xorWith = xorWith; 21985 lodash.zip = zip; 21986 lodash.zipObject = zipObject; 21987 lodash.zipObjectDeep = zipObjectDeep; 21988 lodash.zipWith = zipWith; 21989 21990 // Add aliases. 21991 lodash.entries = toPairs; 21992 lodash.entriesIn = toPairsIn; 21993 lodash.extend = assignIn; 21994 lodash.extendWith = assignInWith; 21995 21996 // Add methods to `lodash.prototype`. 21997 mixin(lodash, lodash); 21998 21999 /*------------------------------------------------------------------------*/ 22000 22001 // Add methods that return unwrapped values in chain sequences. 22002 lodash.add = add; 22003 lodash.attempt = attempt; 22004 lodash.camelCase = camelCase; 22005 lodash.capitalize = capitalize; 22006 lodash.ceil = ceil; 22007 lodash.clamp = clamp; 22008 lodash.clone = clone; 22009 lodash.cloneDeep = cloneDeep; 22010 lodash.cloneDeepWith = cloneDeepWith; 22011 lodash.cloneWith = cloneWith; 22012 lodash.conformsTo = conformsTo; 22013 lodash.deburr = deburr; 22014 lodash.defaultTo = defaultTo; 22015 lodash.divide = divide; 22016 lodash.endsWith = endsWith; 22017 lodash.eq = eq; 22018 lodash.escape = escape; 22019 lodash.escapeRegExp = escapeRegExp; 22020 lodash.every = every; 22021 lodash.find = find; 22022 lodash.findIndex = findIndex; 22023 lodash.findKey = findKey; 22024 lodash.findLast = findLast; 22025 lodash.findLastIndex = findLastIndex; 22026 lodash.findLastKey = findLastKey; 22027 lodash.floor = floor; 22028 lodash.forEach = forEach; 22029 lodash.forEachRight = forEachRight; 22030 lodash.forIn = forIn; 22031 lodash.forInRight = forInRight; 22032 lodash.forOwn = forOwn; 22033 lodash.forOwnRight = forOwnRight; 22034 lodash.get = get; 22035 lodash.gt = gt; 22036 lodash.gte = gte; 22037 lodash.has = has; 22038 lodash.hasIn = hasIn; 22039 lodash.head = head; 22040 lodash.identity = identity; 22041 lodash.includes = includes; 22042 lodash.indexOf = indexOf; 22043 lodash.inRange = inRange; 22044 lodash.invoke = invoke; 22045 lodash.isArguments = isArguments; 22046 lodash.isArray = isArray; 22047 lodash.isArrayBuffer = isArrayBuffer; 22048 lodash.isArrayLike = isArrayLike; 22049 lodash.isArrayLikeObject = isArrayLikeObject; 22050 lodash.isBoolean = isBoolean; 22051 lodash.isBuffer = isBuffer; 22052 lodash.isDate = isDate; 22053 lodash.isElement = isElement; 22054 lodash.isEmpty = isEmpty; 22055 lodash.isEqual = isEqual; 22056 lodash.isEqualWith = isEqualWith; 22057 lodash.isError = isError; 22058 lodash.isFinite = isFinite; 22059 lodash.isFunction = isFunction; 22060 lodash.isInteger = isInteger; 22061 lodash.isLength = isLength; 22062 lodash.isMap = isMap; 22063 lodash.isMatch = isMatch; 22064 lodash.isMatchWith = isMatchWith; 22065 lodash.isNaN = isNaN; 22066 lodash.isNative = isNative; 22067 lodash.isNil = isNil; 22068 lodash.isNull = isNull; 22069 lodash.isNumber = isNumber; 22070 lodash.isObject = isObject; 22071 lodash.isObjectLike = isObjectLike; 22072 lodash.isPlainObject = isPlainObject; 22073 lodash.isRegExp = isRegExp; 22074 lodash.isSafeInteger = isSafeInteger; 22075 lodash.isSet = isSet; 22076 lodash.isString = isString; 22077 lodash.isSymbol = isSymbol; 22078 lodash.isTypedArray = isTypedArray; 22079 lodash.isUndefined = isUndefined; 22080 lodash.isWeakMap = isWeakMap; 22081 lodash.isWeakSet = isWeakSet; 22082 lodash.join = join; 22083 lodash.kebabCase = kebabCase; 22084 lodash.last = last; 22085 lodash.lastIndexOf = lastIndexOf; 22086 lodash.lowerCase = lowerCase; 22087 lodash.lowerFirst = lowerFirst; 22088 lodash.lt = lt; 22089 lodash.lte = lte; 22090 lodash.max = max; 22091 lodash.maxBy = maxBy; 22092 lodash.mean = mean; 22093 lodash.meanBy = meanBy; 22094 lodash.min = min; 22095 lodash.minBy = minBy; 22096 lodash.stubArray = stubArray; 22097 lodash.stubFalse = stubFalse; 22098 lodash.stubObject = stubObject; 22099 lodash.stubString = stubString; 22100 lodash.stubTrue = stubTrue; 22101 lodash.multiply = multiply; 22102 lodash.nth = nth; 22103 lodash.noConflict = noConflict; 22104 lodash.noop = noop; 22105 lodash.now = now; 22106 lodash.pad = pad; 22107 lodash.padEnd = padEnd; 22108 lodash.padStart = padStart; 22109 lodash.parseInt = parseInt; 22110 lodash.random = random; 22111 lodash.reduce = reduce; 22112 lodash.reduceRight = reduceRight; 22113 lodash.repeat = repeat; 22114 lodash.replace = replace; 22115 lodash.result = result; 22116 lodash.round = round; 22117 lodash.runInContext = runInContext; 22118 lodash.sample = sample; 22119 lodash.size = size; 22120 lodash.snakeCase = snakeCase; 22121 lodash.some = some; 22122 lodash.sortedIndex = sortedIndex; 22123 lodash.sortedIndexBy = sortedIndexBy; 22124 lodash.sortedIndexOf = sortedIndexOf; 22125 lodash.sortedLastIndex = sortedLastIndex; 22126 lodash.sortedLastIndexBy = sortedLastIndexBy; 22127 lodash.sortedLastIndexOf = sortedLastIndexOf; 22128 lodash.startCase = startCase; 22129 lodash.startsWith = startsWith; 22130 lodash.subtract = subtract; 22131 lodash.sum = sum; 22132 lodash.sumBy = sumBy; 22133 lodash.template = template; 22134 lodash.times = times; 22135 lodash.toFinite = toFinite; 22136 lodash.toInteger = toInteger; 22137 lodash.toLength = toLength; 22138 lodash.toLower = toLower; 22139 lodash.toNumber = toNumber; 22140 lodash.toSafeInteger = toSafeInteger; 22141 lodash.toString = toString; 22142 lodash.toUpper = toUpper; 22143 lodash.trim = trim; 22144 lodash.trimEnd = trimEnd; 22145 lodash.trimStart = trimStart; 22146 lodash.truncate = truncate; 22147 lodash.unescape = unescape; 22148 lodash.uniqueId = uniqueId; 22149 lodash.upperCase = upperCase; 22150 lodash.upperFirst = upperFirst; 22151 22152 // Add aliases. 22153 lodash.each = forEach; 22154 lodash.eachRight = forEachRight; 22155 lodash.first = head; 22156 22157 mixin(lodash, (function() { 22158 var source = {}; 22159 baseForOwn(lodash, function(func, methodName) { 22160 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 22161 source[methodName] = func; 22162 } 22163 }); 22164 return source; 22165 }()), { 'chain': false }); 22166 22167 /*------------------------------------------------------------------------*/ 22168 22169 /** 22170 * The semantic version number. 22171 * 22172 * @static 22173 * @memberOf _ 22174 * @type {string} 22175 */ 22176 lodash.VERSION = VERSION; 22177 22178 // Assign default placeholders. 22179 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 22180 lodash[methodName].placeholder = lodash; 22181 }); 22182 22183 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 22184 arrayEach(['drop', 'take'], function(methodName, index) { 22185 LazyWrapper.prototype[methodName] = function(n) { 22186 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 22187 22188 var result = (this.__filtered__ && !index) 22189 ? new LazyWrapper(this) 22190 : this.clone(); 22191 22192 if (result.__filtered__) { 22193 result.__takeCount__ = nativeMin(n, result.__takeCount__); 22194 } else { 22195 result.__views__.push({ 22196 'size': nativeMin(n, MAX_ARRAY_LENGTH), 22197 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 22198 }); 22199 } 22200 return result; 22201 }; 22202 22203 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 22204 return this.reverse()[methodName](n).reverse(); 22205 }; 22206 }); 22207 22208 // Add `LazyWrapper` methods that accept an `iteratee` value. 22209 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 22210 var type = index + 1, 22211 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 22212 22213 LazyWrapper.prototype[methodName] = function(iteratee) { 22214 var result = this.clone(); 22215 result.__iteratees__.push({ 22216 'iteratee': getIteratee(iteratee, 3), 22217 'type': type 22218 }); 22219 result.__filtered__ = result.__filtered__ || isFilter; 22220 return result; 22221 }; 22222 }); 22223 22224 // Add `LazyWrapper` methods for `_.head` and `_.last`. 22225 arrayEach(['head', 'last'], function(methodName, index) { 22226 var takeName = 'take' + (index ? 'Right' : ''); 22227 22228 LazyWrapper.prototype[methodName] = function() { 22229 return this[takeName](1).value()[0]; 22230 }; 22231 }); 22232 22233 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 22234 arrayEach(['initial', 'tail'], function(methodName, index) { 22235 var dropName = 'drop' + (index ? '' : 'Right'); 22236 22237 LazyWrapper.prototype[methodName] = function() { 22238 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 22239 }; 22240 }); 22241 22242 LazyWrapper.prototype.compact = function() { 22243 return this.filter(identity); 22244 }; 22245 22246 LazyWrapper.prototype.find = function(predicate) { 22247 return this.filter(predicate).head(); 22248 }; 22249 22250 LazyWrapper.prototype.findLast = function(predicate) { 22251 return this.reverse().find(predicate); 22252 }; 22253 22254 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 22255 if (typeof path == 'function') { 22256 return new LazyWrapper(this); 22257 } 22258 return this.map(function(value) { 22259 return baseInvoke(value, path, args); 22260 }); 22261 }); 22262 22263 LazyWrapper.prototype.reject = function(predicate) { 22264 return this.filter(negate(getIteratee(predicate))); 22265 }; 22266 22267 LazyWrapper.prototype.slice = function(start, end) { 22268 start = toInteger(start); 22269 22270 var result = this; 22271 if (result.__filtered__ && (start > 0 || end < 0)) { 22272 return new LazyWrapper(result); 22273 } 22274 if (start < 0) { 22275 result = result.takeRight(-start); 22276 } else if (start) { 22277 result = result.drop(start); 22278 } 22279 if (end !== undefined) { 22280 end = toInteger(end); 22281 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 22282 } 22283 return result; 22284 }; 22285 22286 LazyWrapper.prototype.takeRightWhile = function(predicate) { 22287 return this.reverse().takeWhile(predicate).reverse(); 22288 }; 22289 22290 LazyWrapper.prototype.toArray = function() { 22291 return this.take(MAX_ARRAY_LENGTH); 22292 }; 22293 22294 // Add `LazyWrapper` methods to `lodash.prototype`. 22295 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 22296 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 22297 isTaker = /^(?:head|last)$/.test(methodName), 22298 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 22299 retUnwrapped = isTaker || /^find/.test(methodName); 22300 22301 if (!lodashFunc) { 22302 return; 22303 } 22304 lodash.prototype[methodName] = function() { 22305 var value = this.__wrapped__, 22306 args = isTaker ? [1] : arguments, 22307 isLazy = value instanceof LazyWrapper, 22308 iteratee = args[0], 22309 useLazy = isLazy || isArray(value); 22310 22311 var interceptor = function(value) { 22312 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 22313 return (isTaker && chainAll) ? result[0] : result; 22314 }; 22315 22316 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 22317 // Avoid lazy use if the iteratee has a "length" value other than `1`. 22318 isLazy = useLazy = false; 22319 } 22320 var chainAll = this.__chain__, 22321 isHybrid = !!this.__actions__.length, 22322 isUnwrapped = retUnwrapped && !chainAll, 22323 onlyLazy = isLazy && !isHybrid; 22324 22325 if (!retUnwrapped && useLazy) { 22326 value = onlyLazy ? value : new LazyWrapper(this); 22327 var result = func.apply(value, args); 22328 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 22329 return new LodashWrapper(result, chainAll); 22330 } 22331 if (isUnwrapped && onlyLazy) { 22332 return func.apply(this, args); 22333 } 22334 result = this.thru(interceptor); 22335 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 22336 }; 22337 }); 22338 22339 // Add `Array` methods to `lodash.prototype`. 22340 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 22341 var func = arrayProto[methodName], 22342 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 22343 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 22344 22345 lodash.prototype[methodName] = function() { 22346 var args = arguments; 22347 if (retUnwrapped && !this.__chain__) { 22348 var value = this.value(); 22349 return func.apply(isArray(value) ? value : [], args); 22350 } 22351 return this[chainName](function(value) { 22352 return func.apply(isArray(value) ? value : [], args); 22353 }); 22354 }; 22355 }); 22356 22357 // Map minified method names to their real names. 22358 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 22359 var lodashFunc = lodash[methodName]; 22360 if (lodashFunc) { 22361 var key = lodashFunc.name + ''; 22362 if (!hasOwnProperty.call(realNames, key)) { 22363 realNames[key] = []; 22364 } 22365 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 22366 } 22367 }); 22368 22369 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 22370 'name': 'wrapper', 22371 'func': undefined 22372 }]; 22373 22374 // Add methods to `LazyWrapper`. 22375 LazyWrapper.prototype.clone = lazyClone; 22376 LazyWrapper.prototype.reverse = lazyReverse; 22377 LazyWrapper.prototype.value = lazyValue; 22378 22379 // Add chain sequence methods to the `lodash` wrapper. 22380 lodash.prototype.at = wrapperAt; 22381 lodash.prototype.chain = wrapperChain; 22382 lodash.prototype.commit = wrapperCommit; 22383 lodash.prototype.next = wrapperNext; 22384 lodash.prototype.plant = wrapperPlant; 22385 lodash.prototype.reverse = wrapperReverse; 22386 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 22387 22388 // Add lazy aliases. 22389 lodash.prototype.first = lodash.prototype.head; 22390 22391 if (symIterator) { 22392 lodash.prototype[symIterator] = wrapperToIterator; 22393 } 22394 return lodash; 22395 }); 22396 22397 /*--------------------------------------------------------------------------*/ 22398 22399 // Export lodash. 22400 var _ = runInContext(); 22401 22402 // Some AMD build optimizers, like r.js, check for condition patterns like: 22403 if (true) { 22404 // Expose Lodash on the global object to prevent errors when Lodash is 22405 // loaded by a script tag in the presence of an AMD loader. 22406 // See http://requirejs.org/docs/errors.html#mismatch for more details. 22407 // Use `_.noConflict` to remove Lodash from the global object. 22408 root._ = _; 22409 22410 // Define as an anonymous module so, through path mapping, it can be 22411 // referenced as the "underscore" module. 22412 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 22413 return _; 22414 }).call(exports, __webpack_require__, exports, module), 22415 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 22416 } 22417 // Check for `exports` after `define` in case a build optimizer adds it. 22418 else {} 22419}.call(this)); 22420 22421 22422/***/ }), 22423
vendor: 5,633 bytes, lines 22424-22616
22424/***/ "./node_modules/process/browser.js": 22425/*!*****************************************!*\ 22426 !*** ./node_modules/process/browser.js ***! 22427 \*****************************************/ 22428/***/ ((module) => { 22429 22430// shim for using process in browser 22431var process = module.exports = {}; 22432 22433// cached from whatever global is present so that test runners that stub it 22434// don't break things. But we need to wrap it in a try catch in case it is 22435// wrapped in strict mode code which doesn't define any globals. It's inside a 22436// function because try/catches deoptimize in certain engines. 22437 22438var cachedSetTimeout; 22439var cachedClearTimeout; 22440 22441function defaultSetTimout() { 22442 throw new Error('setTimeout has not been defined'); 22443} 22444function defaultClearTimeout () { 22445 throw new Error('clearTimeout has not been defined'); 22446} 22447(function () { 22448 try { 22449 if (typeof setTimeout === 'function') { 22450 cachedSetTimeout = setTimeout; 22451 } else { 22452 cachedSetTimeout = defaultSetTimout; 22453 } 22454 } catch (e) { 22455 cachedSetTimeout = defaultSetTimout; 22456 } 22457 try { 22458 if (typeof clearTimeout === 'function') { 22459 cachedClearTimeout = clearTimeout; 22460 } else { 22461 cachedClearTimeout = defaultClearTimeout; 22462 } 22463 } catch (e) { 22464 cachedClearTimeout = defaultClearTimeout; 22465 } 22466} ()) 22467function runTimeout(fun) { 22468 if (cachedSetTimeout === setTimeout) { 22469 //normal enviroments in sane situations 22470 return setTimeout(fun, 0); 22471 } 22472 // if setTimeout wasn't available but was latter defined 22473 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 22474 cachedSetTimeout = setTimeout; 22475 return setTimeout(fun, 0); 22476 } 22477 try { 22478 // when when somebody has screwed with setTimeout but no I.E. maddness 22479 return cachedSetTimeout(fun, 0); 22480 } catch(e){ 22481 try { 22482 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 22483 return cachedSetTimeout.call(null, fun, 0); 22484 } catch(e){ 22485 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error 22486 return cachedSetTimeout.call(this, fun, 0); 22487 } 22488 } 22489 22490 22491} 22492function runClearTimeout(marker) { 22493 if (cachedClearTimeout === clearTimeout) { 22494 //normal enviroments in sane situations 22495 return clearTimeout(marker); 22496 } 22497 // if clearTimeout wasn't available but was latter defined 22498 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 22499 cachedClearTimeout = clearTimeout; 22500 return clearTimeout(marker); 22501 } 22502 try { 22503 // when when somebody has screwed with setTimeout but no I.E. maddness 22504 return cachedClearTimeout(marker); 22505 } catch (e){ 22506 try { 22507 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 22508 return cachedClearTimeout.call(null, marker); 22509 } catch (e){ 22510 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. 22511 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 22512 return cachedClearTimeout.call(this, marker); 22513 } 22514 } 22515 22516 22517 22518} 22519var queue = []; 22520var draining = false; 22521var currentQueue; 22522var queueIndex = -1; 22523 22524function cleanUpNextTick() { 22525 if (!draining || !currentQueue) { 22526 return; 22527 } 22528 draining = false; 22529 if (currentQueue.length) { 22530 queue = currentQueue.concat(queue); 22531 } else { 22532 queueIndex = -1; 22533 } 22534 if (queue.length) { 22535 drainQueue(); 22536 } 22537} 22538 22539function drainQueue() { 22540 if (draining) { 22541 return; 22542 } 22543 var timeout = runTimeout(cleanUpNextTick); 22544 draining = true; 22545 22546 var len = queue.length; 22547 while(len) { 22548 currentQueue = queue; 22549 queue = []; 22550 while (++queueIndex < len) { 22551 if (currentQueue) { 22552 currentQueue[queueIndex].run(); 22553 } 22554 } 22555 queueIndex = -1; 22556 len = queue.length; 22557 } 22558 currentQueue = null; 22559 draining = false; 22560 runClearTimeout(timeout); 22561} 22562 22563process.nextTick = function (fun) { 22564 var args = new Array(arguments.length - 1); 22565 if (arguments.length > 1) { 22566 for (var i = 1; i < arguments.length; i++) { 22567 args[i - 1] = arguments[i]; 22568 } 22569 } 22570 queue.push(new Item(fun, args)); 22571 if (queue.length === 1 && !draining) { 22572 runTimeout(drainQueue); 22573 } 22574}; 22575 22576// v8 likes predictible objects 22577function Item(fun, array) { 22578 this.fun = fun; 22579 this.array = array; 22580} 22581Item.prototype.run = function () { 22582 this.fun.apply(null, this.array); 22583}; 22584process.title = 'browser'; 22585process.browser = true; 22586process.env = {}; 22587process.argv = []; 22588process.version = ''; // empty string to avoid regexp issues 22589process.versions = {}; 22590 22591function noop() {} 22592 22593process.on = noop; 22594process.addListener = noop; 22595process.once = noop; 22596process.off = noop; 22597process.removeListener = noop; 22598process.removeAllListeners = noop; 22599process.emit = noop; 22600process.prependListener = noop; 22601process.prependOnceListener = noop; 22602 22603process.listeners = function (name) { return [] } 22604 22605process.binding = function (name) { 22606 throw new Error('process.binding is not supported'); 22607}; 22608 22609process.cwd = function () { return '/' }; 22610process.chdir = function (dir) { 22611 throw new Error('process.chdir is not supported'); 22612}; 22613process.umask = function() { return 0; }; 22614 22615 22616/***/ })
vendor: 3,984 bytes, lines 22616-22718
22616 22617 22618/******/ }); 22619/************************************************************************/ 22620/******/ // The module cache 22621/******/ var __webpack_module_cache__ = {}; 22622/******/ 22623/******/ // The require function 22624/******/ function __webpack_require__(moduleId) { 22625/******/ // Check if module is in cache 22626/******/ var cachedModule = __webpack_module_cache__[moduleId]; 22627/******/ if (cachedModule !== undefined) { 22628/******/ return cachedModule.exports; 22629/******/ } 22630/******/ // Create a new module (and put it into the cache) 22631/******/ var module = __webpack_module_cache__[moduleId] = { 22632/******/ id: moduleId, 22633/******/ loaded: false, 22634/******/ exports: {} 22635/******/ }; 22636/******/ 22637/******/ // Execute the module function 22638/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 22639/******/ 22640/******/ // Flag the module as loaded 22641/******/ module.loaded = true; 22642/******/ 22643/******/ // Return the exports of the module 22644/******/ return module.exports; 22645/******/ } 22646/******/ 22647/************************************************************************/ 22648/******/ /* webpack/runtime/define property getters */ 22649/******/ (() => { 22650/******/ // define getter functions for harmony exports 22651/******/ __webpack_require__.d = (exports, definition) => { 22652/******/ for(var key in definition) { 22653/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 22654/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 22655/******/ } 22656/******/ } 22657/******/ }; 22658/******/ })(); 22659/******/ 22660/******/ /* webpack/runtime/global */ 22661/******/ (() => { 22662/******/ __webpack_require__.g = (function() { 22663/******/ if (typeof globalThis === 'object') return globalThis; 22664/******/ try { 22665/******/ return this || new Function('return this')(); 22666/******/ } catch (e) { 22667/******/ if (typeof window === 'object') return window; 22668/******/ } 22669/******/ })(); 22670/******/ })(); 22671/******/ 22672/******/ /* webpack/runtime/hasOwnProperty shorthand */ 22673/******/ (() => { 22674/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 22675/******/ })(); 22676/******/ 22677/******/ /* webpack/runtime/make namespace object */ 22678/******/ (() => { 22679/******/ // define __esModule on exports 22680/******/ __webpack_require__.r = (exports) => { 22681/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 22682/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 22683/******/ } 22684/******/ Object.defineProperty(exports, '__esModule', { value: true }); 22685/******/ }; 22686/******/ })(); 22687/******/ 22688/******/ /* webpack/runtime/node module decorator */ 22689/******/ (() => { 22690/******/ __webpack_require__.nmd = (module) => { 22691/******/ module.paths = []; 22692/******/ if (!module.children) module.children = []; 22693/******/ return module; 22694/******/ }; 22695/******/ })(); 22696/******/ 22697/************************************************************************/ 22698var __webpack_exports__ = {}; 22699// This entry need to be wrapped in an IIFE because it need to be in strict mode. 22700(() => { 22701"use strict"; 22702/*!**********************************!*\ 22703 !*** ./resources/js/frontend.js ***! 22704 \**********************************/ 22705__webpack_require__.r(__webpack_exports__); 22706/* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js"); 22707/* harmony import */ var _alpinejs_collapse__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @alpinejs/collapse */ "./node_modules/@alpinejs/collapse/dist/module.esm.js"); 22708__webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js"); 22709 22710 22711 22712alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].plugin(_alpinejs_collapse__WEBPACK_IMPORTED_MODULE_1__["default"]); 22713window.Alpine = alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"]; 22714alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].start(); 22715})(); 22716 22717/******/ })() 22718;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.