vendor: 2,408 bytes, lines 1-67
1/******/ (function(modules) { // webpackBootstrap 2/******/ // The module cache 3/******/ var installedModules = {}; 4/******/ 5/******/ // The require function 6/******/ function __webpack_require__(moduleId) { 7/******/ 8/******/ // Check if module is in cache 9/******/ if(installedModules[moduleId]) { 10/******/ return installedModules[moduleId].exports; 11/******/ } 12/******/ // Create a new module (and put it into the cache) 13/******/ var module = installedModules[moduleId] = { 14/******/ i: moduleId, 15/******/ l: false, 16/******/ exports: {} 17/******/ }; 18/******/ 19/******/ // Execute the module function 20/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21/******/ 22/******/ // Flag the module as loaded 23/******/ module.l = true; 24/******/ 25/******/ // Return the exports of the module 26/******/ return module.exports; 27/******/ } 28/******/ 29/******/ 30/******/ // expose the modules object (__webpack_modules__) 31/******/ __webpack_require__.m = modules; 32/******/ 33/******/ // expose the module cache 34/******/ __webpack_require__.c = installedModules; 35/******/ 36/******/ // define getter function for harmony exports 37/******/ __webpack_require__.d = function(exports, name, getter) { 38/******/ if(!__webpack_require__.o(exports, name)) { 39/******/ Object.defineProperty(exports, name, { 40/******/ configurable: false, 41/******/ enumerable: true, 42/******/ get: getter 43/******/ }); 44/******/ } 45/******/ }; 46/******/ 47/******/ // getDefaultExport function for compatibility with non-harmony modules 48/******/ __webpack_require__.n = function(module) { 49/******/ var getter = module && module.__esModule ? 50/******/ function getDefault() { return module['default']; } : 51/******/ function getModuleExports() { return module; }; 52/******/ __webpack_require__.d(getter, 'a', getter); 53/******/ return getter; 54/******/ }; 55/******/ 56/******/ // Object.prototype.hasOwnProperty.call 57/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58/******/ 59/******/ // __webpack_public_path__ 60/******/ __webpack_require__.p = "/"; 61/******/ 62/******/ // Load entry module and return exports 63/******/ return __webpack_require__(__webpack_require__.s = 0); 64/******/ }) 65/************************************************************************/ 66/******/ ({ 67
68/***/ "./core/mokyklos/cookie_policy-plugin/resources/js/europeCookie.js": 69/***/ (function(module, __webpack_exports__, __webpack_require__) { 70 71"use strict"; 72Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); 73var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 74 75function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 76 77var EuropeCookie = function () { 78 function EuropeCookie() { 79 var expires = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 80 81 _classCallCheck(this, EuropeCookie); 82 83 this.cookieName = 'europeCookie2'; 84 this.cookieNameHide = 'europeCookieHide'; 85 this.cookieWrapper = '#europeCookieWrapper'; 86 this.cookieCloser = '#europeCookieClose'; 87 this.cookieHide = '#europeCookieHide'; 88 this.cookieForm = '#europeCookieForm'; 89 this.cookieStatistics = '#europeCookieStatistics'; 90 this.cookieMarketing = '#europeCookieMarketing'; 91 this.cookiePreferences = { 92 statistics: 1, 93 marketing: 1 94 }; 95 expires = 365; 96 if (expires) { 97 this.expires = expires; 98 } 99 this.cookieWrapper = $(this.cookieWrapper); 100 this.cookieCloser = $(this.cookieCloser); 101 this.cookieHide = $(this.cookieHide); 102 this.cookieForm = $(this.cookieForm); 103 this.cookieStatistics = $(this.cookieStatistics); 104 this.cookieMarketing = $(this.cookieMarketing); 105 106 if (!this.exists()) { 107 this.displayCookieBlock(); 108 } 109 110 this.bindOnChange(); 111 this.bindOnSubmit(); 112 this.bindAgreeAll(); 113 this.initializeEuropeCookie(); 114 } 115 116 _createClass(EuropeCookie, [{ 117 key: 'initializeEuropeCookie', 118 value: function initializeEuropeCookie() { 119 var cookiePreferences = Cookies.get('europeCookie2'); 120 121 // if cookie preferences exist, parse the JSON string into an object 122 if (cookiePreferences) { 123 var parsedPreferences = JSON.parse(cookiePreferences); 124 125 // access the statistics and marketing preferences 126 var statisticsPreference = parsedPreferences.statistics; 127 var marketingPreference = parsedPreferences.marketing; 128 129 $('input[name=europeCookieStatistics][value="' + statisticsPreference + '"]').prop('checked', true); 130 $('input[name=europeCookieMarketing][value="' + marketingPreference + '"]').prop('checked', true); 131 } else { 132 $('input[name=europeCookieStatistics][value="1"]').prop('checked', false); 133 $('input[name=europeCookieMarketing][value="1"]').prop('checked', false); 134 } 135 } 136 }, { 137 key: 'bindOnChange', 138 value: function bindOnChange() { 139 this.cookieCloser.on('click', function (event) { 140 event.preventDefault(); 141 this.remember(); 142 }.bind(this)); 143 144 this.cookieHide.on('click', function (event) { 145 event.preventDefault(); 146 this.hide(); 147 }.bind(this)); 148 } 149 }, { 150 key: 'bindOnSubmit', 151 value: function bindOnSubmit() { 152 this.cookieForm.on('submit', function (event) { 153 event.preventDefault(); 154 155 var statisticsCheckedValue = $('input[name=europeCookieStatistics]:checked').val(); 156 var marketingCheckedValue = $('input[name=europeCookieMarketing]:checked').val(); 157 158 this.cookiePreferences.statistics = statisticsCheckedValue; 159 this.cookiePreferences.marketing = marketingCheckedValue; 160 161 $('.cookie-updated').css('display', 'block'); 162 $('html, body').animate({ 163 scrollTop: $('.cookie-updated').offset().top - ($(window).height() - $('.cookie-updated').outerHeight()) / 2 164 }, 'fast'); 165 166 this.remember(); 167 }.bind(this)); 168 } 169 }, {
170 key: 'bindAgreeAll', 171 value: function bindAgreeAll() { 172 var agreeAll = $('#europeCookieAgreeAll'); 173 if (agreeAll) { 174 agreeAll.on('click', function (event) { 175 event.preventDefault(); 176 this.remember(); 177 }.bind(this)); 178 } 179 } 180 }, { 181 key: 'displayCookieBlock', 182 value: function displayCookieBlock() { 183 this.cookieWrapper.css('display', 'block'); 184 } 185 }, { 186 key: 'exists', 187 value: function exists() { 188 if (Cookies.get(this.cookieName) || Cookies.get(this.cookieNameHide)) { 189 return true; 190 } 191 return false; 192 } 193 }, { 194 key: 'remember', 195 value: function remember() { 196 Cookies.set(this.cookieName, JSON.stringify(this.cookiePreferences), { 197 expires: this.expires, 198 path: '/', 199 domain: document.domain 200 }); 201 this.cookieWrapper.css('display', 'none'); 202 } 203 }, { 204 key: 'hide', 205 value: function hide() { 206 // nustatome kad vartotojas NESUTIKO 207 this.cookiePreferences.statistics = 0; 208 this.cookiePreferences.marketing = 0; 209 210 // uždedame pagrindinį GDPR cookie su nesutikimu 211 Cookies.set(this.cookieName, JSON.stringify(this.cookiePreferences), { 212 expires: this.expires, 213 path: '/', 214 domain: document.domain 215 }); 216 217 // papildomai trumpalaikis skirtas tik paslÄpimui 218 Cookies.set(this.cookieNameHide, JSON.stringify(this.cookiePreferences), { 219 expires: 0.04, // valanda 220 path: '/', 221 domain: document.domain 222 }); 223 224 this.cookieWrapper.css('display', 'none'); 225 } 226 }]); 227 228 return EuropeCookie; 229}(); 230 231/* harmony default export */ __webpack_exports__["default"] = (EuropeCookie); 232 233/***/ }), 234
vendor: 183 bytes, lines 235-241
235/***/ "./node_modules/axios/index.js": 236/***/ (function(module, exports, __webpack_require__) { 237 238module.exports = __webpack_require__("./node_modules/axios/lib/axios.js"); 239 240/***/ }), 241
vendor: 6,566 bytes, lines 242-429
242/***/ "./node_modules/axios/lib/adapters/xhr.js": 243/***/ (function(module, exports, __webpack_require__) { 244 245"use strict"; 246 247 248var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 249var settle = __webpack_require__("./node_modules/axios/lib/core/settle.js"); 250var buildURL = __webpack_require__("./node_modules/axios/lib/helpers/buildURL.js"); 251var parseHeaders = __webpack_require__("./node_modules/axios/lib/helpers/parseHeaders.js"); 252var isURLSameOrigin = __webpack_require__("./node_modules/axios/lib/helpers/isURLSameOrigin.js"); 253var createError = __webpack_require__("./node_modules/axios/lib/core/createError.js"); 254var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__("./node_modules/axios/lib/helpers/btoa.js"); 255 256module.exports = function xhrAdapter(config) { 257 return new Promise(function dispatchXhrRequest(resolve, reject) { 258 var requestData = config.data; 259 var requestHeaders = config.headers; 260 261 if (utils.isFormData(requestData)) { 262 delete requestHeaders['Content-Type']; // Let the browser set it 263 } 264 265 var request = new XMLHttpRequest(); 266 var loadEvent = 'onreadystatechange'; 267 var xDomain = false; 268 269 // For IE 8/9 CORS support 270 // Only supports POST and GET calls and doesn't returns the response headers. 271 // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest. 272 if ("development" !== 'test' && 273 typeof window !== 'undefined' && 274 window.XDomainRequest && !('withCredentials' in request) && 275 !isURLSameOrigin(config.url)) { 276 request = new window.XDomainRequest(); 277 loadEvent = 'onload'; 278 xDomain = true; 279 request.onprogress = function handleProgress() {}; 280 request.ontimeout = function handleTimeout() {}; 281 } 282 283 // HTTP basic authentication 284 if (config.auth) { 285 var username = config.auth.username || ''; 286 var password = config.auth.password || ''; 287 requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); 288 } 289 290 request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true); 291 292 // Set the request timeout in MS 293 request.timeout = config.timeout; 294 295 // Listen for ready state 296 request[loadEvent] = function handleLoad() { 297 if (!request || (request.readyState !== 4 && !xDomain)) { 298 return; 299 } 300 301 // The request errored out and we didn't get a response, this will be 302 // handled by onerror instead 303 // With one exception: request that using file: protocol, most browsers 304 // will return status as 0 even though it's a successful request 305 if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { 306 return; 307 } 308 309 // Prepare the response 310 var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; 311 var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; 312 var response = { 313 data: responseData, 314 // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201) 315 status: request.status === 1223 ? 204 : request.status, 316 statusText: request.status === 1223 ? 'No Content' : request.statusText, 317 headers: responseHeaders, 318 config: config, 319 request: request 320 }; 321 322 settle(resolve, reject, response); 323 324 // Clean up request 325 request = null; 326 }; 327 328 // Handle low level network errors 329 request.onerror = function handleError() { 330 // Real errors are hidden from us by the browser 331 // onerror should only fire if it's a network error 332 reject(createError('Network Error', config, null, request)); 333 334 // Clean up request 335 request = null; 336 }; 337 338 // Handle timeout 339 request.ontimeout = function handleTimeout() { 340 reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', 341 request)); 342 343 // Clean up request 344 request = null; 345 }; 346 347 // Add xsrf header 348 // This is only done if running in a standard browser environment. 349 // Specifically not if we're in a web worker, or react-native. 350 if (utils.isStandardBrowserEnv()) { 351 var cookies = __webpack_require__("./node_modules/axios/lib/helpers/cookies.js"); 352 353 // Add xsrf header 354 var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? 355 cookies.read(config.xsrfCookieName) : 356 undefined; 357 358 if (xsrfValue) { 359 requestHeaders[config.xsrfHeaderName] = xsrfValue; 360 } 361 } 362 363 // Add headers to the request 364 if ('setRequestHeader' in request) { 365 utils.forEach(requestHeaders, function setRequestHeader(val, key) { 366 if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { 367 // Remove Content-Type if data is undefined 368 delete requestHeaders[key]; 369 } else { 370 // Otherwise add header to the request 371 request.setRequestHeader(key, val); 372 } 373 }); 374 } 375 376 // Add withCredentials to request if needed 377 if (config.withCredentials) { 378 request.withCredentials = true; 379 } 380 381 // Add responseType to request if needed 382 if (config.responseType) { 383 try { 384 request.responseType = config.responseType; 385 } catch (e) { 386 // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. 387 // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. 388 if (config.responseType !== 'json') { 389 throw e; 390 } 391 } 392 } 393 394 // Handle progress if needed 395 if (typeof config.onDownloadProgress === 'function') { 396 request.addEventListener('progress', config.onDownloadProgress); 397 } 398 399 // Not all browsers support upload events 400 if (typeof config.onUploadProgress === 'function' && request.upload) { 401 request.upload.addEventListener('progress', config.onUploadProgress); 402 } 403 404 if (config.cancelToken) { 405 // Handle cancellation 406 config.cancelToken.promise.then(function onCanceled(cancel) { 407 if (!request) { 408 return; 409 } 410 411 request.abort(); 412 reject(cancel); 413 // Clean up request 414 request = null; 415 }); 416 } 417 418 if (requestData === undefined) { 419 requestData = null; 420 } 421 422 // Send the request 423 request.send(requestData); 424 }); 425}; 426 427 428/***/ }), 429
vendor: 1,786 bytes, lines 430-489
430/***/ "./node_modules/axios/lib/axios.js": 431/***/ (function(module, exports, __webpack_require__) { 432 433"use strict"; 434 435 436var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 437var bind = __webpack_require__("./node_modules/axios/lib/helpers/bind.js"); 438var Axios = __webpack_require__("./node_modules/axios/lib/core/Axios.js"); 439var defaults = __webpack_require__("./node_modules/axios/lib/defaults.js"); 440 441/** 442 * Create an instance of Axios 443 * 444 * @param {Object} defaultConfig The default config for the instance 445 * @return {Axios} A new instance of Axios 446 */ 447function createInstance(defaultConfig) { 448 var context = new Axios(defaultConfig); 449 var instance = bind(Axios.prototype.request, context); 450 451 // Copy axios.prototype to instance 452 utils.extend(instance, Axios.prototype, context); 453 454 // Copy context to instance 455 utils.extend(instance, context); 456 457 return instance; 458} 459 460// Create the default instance to be exported 461var axios = createInstance(defaults); 462 463// Expose Axios class to allow class inheritance 464axios.Axios = Axios; 465 466// Factory for creating new instances 467axios.create = function create(instanceConfig) { 468 return createInstance(utils.merge(defaults, instanceConfig)); 469}; 470 471// Expose Cancel & CancelToken 472axios.Cancel = __webpack_require__("./node_modules/axios/lib/cancel/Cancel.js"); 473axios.CancelToken = __webpack_require__("./node_modules/axios/lib/cancel/CancelToken.js"); 474axios.isCancel = __webpack_require__("./node_modules/axios/lib/cancel/isCancel.js"); 475 476// Expose all/spread 477axios.all = function all(promises) { 478 return Promise.all(promises); 479}; 480axios.spread = __webpack_require__("./node_modules/axios/lib/helpers/spread.js"); 481 482module.exports = axios; 483 484// Allow use of default import syntax in TypeScript 485module.exports.default = axios; 486 487 488/***/ }), 489
vendor: 507 bytes, lines 490-516
490/***/ "./node_modules/axios/lib/cancel/Cancel.js": 491/***/ (function(module, exports, __webpack_require__) { 492 493"use strict"; 494 495 496/** 497 * A `Cancel` is an object that is thrown when an operation is canceled. 498 * 499 * @class 500 * @param {string=} message The message. 501 */ 502function Cancel(message) { 503 this.message = message; 504} 505 506Cancel.prototype.toString = function toString() { 507 return 'Cancel' + (this.message ? ': ' + this.message : ''); 508}; 509 510Cancel.prototype.__CANCEL__ = true; 511 512module.exports = Cancel; 513 514 515/***/ }), 516
vendor: 1,412 bytes, lines 517-581
517/***/ "./node_modules/axios/lib/cancel/CancelToken.js": 518/***/ (function(module, exports, __webpack_require__) { 519 520"use strict"; 521 522 523var Cancel = __webpack_require__("./node_modules/axios/lib/cancel/Cancel.js"); 524 525/** 526 * A `CancelToken` is an object that can be used to request cancellation of an operation. 527 * 528 * @class 529 * @param {Function} executor The executor function. 530 */ 531function CancelToken(executor) { 532 if (typeof executor !== 'function') { 533 throw new TypeError('executor must be a function.'); 534 } 535 536 var resolvePromise; 537 this.promise = new Promise(function promiseExecutor(resolve) { 538 resolvePromise = resolve; 539 }); 540 541 var token = this; 542 executor(function cancel(message) { 543 if (token.reason) { 544 // Cancellation has already been requested 545 return; 546 } 547 548 token.reason = new Cancel(message); 549 resolvePromise(token.reason); 550 }); 551} 552 553/** 554 * Throws a `Cancel` if cancellation has been requested. 555 */ 556CancelToken.prototype.throwIfRequested = function throwIfRequested() { 557 if (this.reason) { 558 throw this.reason; 559 } 560}; 561 562/** 563 * Returns an object that contains a new `CancelToken` and a function that, when called, 564 * cancels the `CancelToken`. 565 */ 566CancelToken.source = function source() { 567 var cancel; 568 var token = new CancelToken(function executor(c) { 569 cancel = c; 570 }); 571 return { 572 token: token, 573 cancel: cancel 574 }; 575}; 576 577module.exports = CancelToken; 578 579 580/***/ }), 581
vendor: 226 bytes, lines 582-594
582/***/ "./node_modules/axios/lib/cancel/isCancel.js": 583/***/ (function(module, exports, __webpack_require__) { 584 585"use strict"; 586 587 588module.exports = function isCancel(value) { 589 return !!(value && value.__CANCEL__); 590}; 591 592 593/***/ }), 594
vendor: 2,462 bytes, lines 595-681
595/***/ "./node_modules/axios/lib/core/Axios.js": 596/***/ (function(module, exports, __webpack_require__) { 597 598"use strict"; 599 600 601var defaults = __webpack_require__("./node_modules/axios/lib/defaults.js"); 602var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 603var InterceptorManager = __webpack_require__("./node_modules/axios/lib/core/InterceptorManager.js"); 604var dispatchRequest = __webpack_require__("./node_modules/axios/lib/core/dispatchRequest.js"); 605 606/** 607 * Create a new instance of Axios 608 * 609 * @param {Object} instanceConfig The default config for the instance 610 */ 611function Axios(instanceConfig) { 612 this.defaults = instanceConfig; 613 this.interceptors = { 614 request: new InterceptorManager(), 615 response: new InterceptorManager() 616 }; 617} 618 619/** 620 * Dispatch a request 621 * 622 * @param {Object} config The config specific for this request (merged with this.defaults) 623 */ 624Axios.prototype.request = function request(config) { 625 /*eslint no-param-reassign:0*/ 626 // Allow for axios('example/url'[, config]) a la fetch API 627 if (typeof config === 'string') { 628 config = utils.merge({ 629 url: arguments[0] 630 }, arguments[1]); 631 } 632 633 config = utils.merge(defaults, {method: 'get'}, this.defaults, config); 634 config.method = config.method.toLowerCase(); 635 636 // Hook up interceptors middleware 637 var chain = [dispatchRequest, undefined]; 638 var promise = Promise.resolve(config); 639 640 this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 641 chain.unshift(interceptor.fulfilled, interceptor.rejected); 642 }); 643 644 this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 645 chain.push(interceptor.fulfilled, interceptor.rejected); 646 }); 647 648 while (chain.length) { 649 promise = promise.then(chain.shift(), chain.shift()); 650 } 651 652 return promise; 653}; 654 655// Provide aliases for supported request methods 656utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 657 /*eslint func-names:0*/ 658 Axios.prototype[method] = function(url, config) { 659 return this.request(utils.merge(config || {}, { 660 method: method, 661 url: url 662 })); 663 }; 664}); 665 666utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 667 /*eslint func-names:0*/ 668 Axios.prototype[method] = function(url, data, config) { 669 return this.request(utils.merge(config || {}, { 670 method: method, 671 url: url, 672 data: data 673 })); 674 }; 675}); 676 677module.exports = Axios; 678 679 680/***/ }), 681
vendor: 1,418 bytes, lines 682-741
682/***/ "./node_modules/axios/lib/core/InterceptorManager.js": 683/***/ (function(module, exports, __webpack_require__) { 684 685"use strict"; 686 687 688var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 689 690function InterceptorManager() { 691 this.handlers = []; 692} 693 694/** 695 * Add a new interceptor to the stack 696 * 697 * @param {Function} fulfilled The function to handle `then` for a `Promise` 698 * @param {Function} rejected The function to handle `reject` for a `Promise` 699 * 700 * @return {Number} An ID used to remove interceptor later 701 */ 702InterceptorManager.prototype.use = function use(fulfilled, rejected) { 703 this.handlers.push({ 704 fulfilled: fulfilled, 705 rejected: rejected 706 }); 707 return this.handlers.length - 1; 708}; 709 710/** 711 * Remove an interceptor from the stack 712 * 713 * @param {Number} id The ID that was returned by `use` 714 */ 715InterceptorManager.prototype.eject = function eject(id) { 716 if (this.handlers[id]) { 717 this.handlers[id] = null; 718 } 719}; 720 721/** 722 * Iterate over all the registered interceptors 723 * 724 * This method is particularly useful for skipping over any 725 * interceptors that may have become `null` calling `eject`. 726 * 727 * @param {Function} fn The function to call for each interceptor 728 */ 729InterceptorManager.prototype.forEach = function forEach(fn) { 730 utils.forEach(this.handlers, function forEachHandler(h) { 731 if (h !== null) { 732 fn(h); 733 } 734 }); 735}; 736 737module.exports = InterceptorManager; 738 739 740/***/ }), 741
vendor: 793 bytes, lines 742-767
742/***/ "./node_modules/axios/lib/core/createError.js": 743/***/ (function(module, exports, __webpack_require__) { 744 745"use strict"; 746 747 748var enhanceError = __webpack_require__("./node_modules/axios/lib/core/enhanceError.js"); 749 750/** 751 * Create an Error with the specified message, config, error code, request and response. 752 * 753 * @param {string} message The error message. 754 * @param {Object} config The config. 755 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 756 * @param {Object} [request] The request. 757 * @param {Object} [response] The response. 758 * @returns {Error} The created error. 759 */ 760module.exports = function createError(message, config, code, request, response) { 761 var error = new Error(message); 762 return enhanceError(error, config, code, request, response); 763}; 764 765 766/***/ }), 767
vendor: 2,550 bytes, lines 768-861
768/***/ "./node_modules/axios/lib/core/dispatchRequest.js": 769/***/ (function(module, exports, __webpack_require__) { 770 771"use strict"; 772 773 774var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 775var transformData = __webpack_require__("./node_modules/axios/lib/core/transformData.js"); 776var isCancel = __webpack_require__("./node_modules/axios/lib/cancel/isCancel.js"); 777var defaults = __webpack_require__("./node_modules/axios/lib/defaults.js"); 778var isAbsoluteURL = __webpack_require__("./node_modules/axios/lib/helpers/isAbsoluteURL.js"); 779var combineURLs = __webpack_require__("./node_modules/axios/lib/helpers/combineURLs.js"); 780 781/** 782 * Throws a `Cancel` if cancellation has been requested. 783 */ 784function throwIfCancellationRequested(config) { 785 if (config.cancelToken) { 786 config.cancelToken.throwIfRequested(); 787 } 788} 789 790/** 791 * Dispatch a request to the server using the configured adapter. 792 * 793 * @param {object} config The config that is to be used for the request 794 * @returns {Promise} The Promise to be fulfilled 795 */ 796module.exports = function dispatchRequest(config) { 797 throwIfCancellationRequested(config); 798 799 // Support baseURL config 800 if (config.baseURL && !isAbsoluteURL(config.url)) { 801 config.url = combineURLs(config.baseURL, config.url); 802 } 803 804 // Ensure headers exist 805 config.headers = config.headers || {}; 806 807 // Transform request data 808 config.data = transformData( 809 config.data, 810 config.headers, 811 config.transformRequest 812 ); 813 814 // Flatten headers 815 config.headers = utils.merge( 816 config.headers.common || {}, 817 config.headers[config.method] || {}, 818 config.headers || {} 819 ); 820 821 utils.forEach( 822 ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 823 function cleanHeaderConfig(method) { 824 delete config.headers[method]; 825 } 826 ); 827 828 var adapter = config.adapter || defaults.adapter; 829 830 return adapter(config).then(function onAdapterResolution(response) { 831 throwIfCancellationRequested(config); 832 833 // Transform response data 834 response.data = transformData( 835 response.data, 836 response.headers, 837 config.transformResponse 838 ); 839 840 return response; 841 }, function onAdapterRejection(reason) { 842 if (!isCancel(reason)) { 843 throwIfCancellationRequested(config); 844 845 // Transform response data 846 if (reason && reason.response) { 847 reason.response.data = transformData( 848 reason.response.data, 849 reason.response.headers, 850 config.transformResponse 851 ); 852 } 853 } 854 855 return Promise.reject(reason); 856 }); 857}; 858 859 860/***/ }), 861
vendor: 718 bytes, lines 862-890
862/***/ "./node_modules/axios/lib/core/enhanceError.js": 863/***/ (function(module, exports, __webpack_require__) { 864 865"use strict"; 866 867 868/** 869 * Update an Error with the specified config, error code, and response. 870 * 871 * @param {Error} error The error to update. 872 * @param {Object} config The config. 873 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 874 * @param {Object} [request] The request. 875 * @param {Object} [response] The response. 876 * @returns {Error} The error. 877 */ 878module.exports = function enhanceError(error, config, code, request, response) { 879 error.config = config; 880 if (code) { 881 error.code = code; 882 } 883 error.request = request; 884 error.response = response; 885 return error; 886}; 887 888 889/***/ }), 890
vendor: 920 bytes, lines 891-924
891/***/ "./node_modules/axios/lib/core/settle.js": 892/***/ (function(module, exports, __webpack_require__) { 893 894"use strict"; 895 896 897var createError = __webpack_require__("./node_modules/axios/lib/core/createError.js"); 898 899/** 900 * Resolve or reject a Promise based on response status. 901 * 902 * @param {Function} resolve A function that resolves the promise. 903 * @param {Function} reject A function that rejects the promise. 904 * @param {object} response The response. 905 */ 906module.exports = function settle(resolve, reject, response) { 907 var validateStatus = response.config.validateStatus; 908 // Note: status is not exposed by XDomainRequest 909 if (!response.status || !validateStatus || validateStatus(response.status)) { 910 resolve(response); 911 } else { 912 reject(createError( 913 'Request failed with status code ' + response.status, 914 response.config, 915 null, 916 response.request, 917 response 918 )); 919 } 920}; 921 922 923/***/ }), 924
vendor: 712 bytes, lines 925-952
925/***/ "./node_modules/axios/lib/core/transformData.js": 926/***/ (function(module, exports, __webpack_require__) { 927 928"use strict"; 929 930 931var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 932 933/** 934 * Transform the data for a request or a response 935 * 936 * @param {Object|String} data The data to be transformed 937 * @param {Array} headers The headers for the request or response 938 * @param {Array|Function} fns A single function or Array of functions 939 * @returns {*} The resulting transformed data 940 */ 941module.exports = function transformData(data, headers, fns) { 942 /*eslint no-param-reassign:0*/ 943 utils.forEach(fns, function transform(fn) { 944 data = fn(data, headers); 945 }); 946 947 return data; 948}; 949 950 951/***/ }), 952
vendor: 2,849 bytes, lines 953-1057
953/***/ "./node_modules/axios/lib/defaults.js": 954/***/ (function(module, exports, __webpack_require__) { 955 956"use strict"; 957/* WEBPACK VAR INJECTION */(function(process) { 958 959var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 960var normalizeHeaderName = __webpack_require__("./node_modules/axios/lib/helpers/normalizeHeaderName.js"); 961 962var DEFAULT_CONTENT_TYPE = { 963 'Content-Type': 'application/x-www-form-urlencoded' 964}; 965 966function setContentTypeIfUnset(headers, value) { 967 if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 968 headers['Content-Type'] = value; 969 } 970} 971 972function getDefaultAdapter() { 973 var adapter; 974 if (typeof XMLHttpRequest !== 'undefined') { 975 // For browsers use XHR adapter 976 adapter = __webpack_require__("./node_modules/axios/lib/adapters/xhr.js"); 977 } else if (typeof process !== 'undefined') { 978 // For node use HTTP adapter 979 adapter = __webpack_require__("./node_modules/axios/lib/adapters/xhr.js"); 980 } 981 return adapter; 982} 983 984var defaults = { 985 adapter: getDefaultAdapter(), 986 987 transformRequest: [function transformRequest(data, headers) { 988 normalizeHeaderName(headers, 'Content-Type'); 989 if (utils.isFormData(data) || 990 utils.isArrayBuffer(data) || 991 utils.isBuffer(data) || 992 utils.isStream(data) || 993 utils.isFile(data) || 994 utils.isBlob(data) 995 ) { 996 return data; 997 } 998 if (utils.isArrayBufferView(data)) { 999 return data.buffer; 1000 } 1001 if (utils.isURLSearchParams(data)) { 1002 setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 1003 return data.toString(); 1004 } 1005 if (utils.isObject(data)) { 1006 setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); 1007 return JSON.stringify(data); 1008 } 1009 return data; 1010 }], 1011 1012 transformResponse: [function transformResponse(data) { 1013 /*eslint no-param-reassign:0*/ 1014 if (typeof data === 'string') { 1015 try { 1016 data = JSON.parse(data); 1017 } catch (e) { /* Ignore */ } 1018 } 1019 return data; 1020 }], 1021 1022 /** 1023 * A timeout in milliseconds to abort a request. If set to 0 (default) a 1024 * timeout is not created. 1025 */ 1026 timeout: 0, 1027 1028 xsrfCookieName: 'XSRF-TOKEN', 1029 xsrfHeaderName: 'X-XSRF-TOKEN', 1030 1031 maxContentLength: -1, 1032 1033 validateStatus: function validateStatus(status) { 1034 return status >= 200 && status < 300; 1035 } 1036}; 1037 1038defaults.headers = { 1039 common: { 1040 'Accept': 'application/json, text/plain, */*' 1041 } 1042}; 1043 1044utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 1045 defaults.headers[method] = {}; 1046}); 1047 1048utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 1049 defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 1050}); 1051 1052module.exports = defaults; 1053 1054/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/process/browser.js"))) 1055 1056/***/ }), 1057
vendor: 377 bytes, lines 1058-1076
1058/***/ "./node_modules/axios/lib/helpers/bind.js": 1059/***/ (function(module, exports, __webpack_require__) { 1060 1061"use strict"; 1062 1063 1064module.exports = function bind(fn, thisArg) { 1065 return function wrap() { 1066 var args = new Array(arguments.length); 1067 for (var i = 0; i < args.length; i++) { 1068 args[i] = arguments[i]; 1069 } 1070 return fn.apply(thisArg, args); 1071 }; 1072}; 1073 1074 1075/***/ }), 1076
vendor: 1,107 bytes, lines 1077-1120
1077/***/ "./node_modules/axios/lib/helpers/btoa.js": 1078/***/ (function(module, exports, __webpack_require__) { 1079 1080"use strict"; 1081 1082 1083// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js 1084 1085var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 1086 1087function E() { 1088 this.message = 'String contains an invalid character'; 1089} 1090E.prototype = new Error; 1091E.prototype.code = 5; 1092E.prototype.name = 'InvalidCharacterError'; 1093 1094function btoa(input) { 1095 var str = String(input); 1096 var output = ''; 1097 for ( 1098 // initialize result and counter 1099 var block, charCode, idx = 0, map = chars; 1100 // if the next str index does not exist: 1101 // change the mapping table to "=" 1102 // check if d has no fractional digits 1103 str.charAt(idx | 0) || (map = '=', idx % 1); 1104 // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 1105 output += map.charAt(63 & block >> 8 - idx % 1 * 8) 1106 ) { 1107 charCode = str.charCodeAt(idx += 3 / 4); 1108 if (charCode > 0xFF) { 1109 throw new E(); 1110 } 1111 block = block << 8 | charCode; 1112 } 1113 return output; 1114} 1115 1116module.exports = btoa; 1117 1118 1119/***/ }), 1120
vendor: 1,709 bytes, lines 1121-1194
1121/***/ "./node_modules/axios/lib/helpers/buildURL.js": 1122/***/ (function(module, exports, __webpack_require__) { 1123 1124"use strict"; 1125 1126 1127var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 1128 1129function encode(val) { 1130 return encodeURIComponent(val). 1131 replace(/%40/gi, '@'). 1132 replace(/%3A/gi, ':'). 1133 replace(/%24/g, '$'). 1134 replace(/%2C/gi, ','). 1135 replace(/%20/g, '+'). 1136 replace(/%5B/gi, '['). 1137 replace(/%5D/gi, ']'); 1138} 1139 1140/** 1141 * Build a URL by appending params to the end 1142 * 1143 * @param {string} url The base of the url (e.g., http://www.google.com) 1144 * @param {object} [params] The params to be appended 1145 * @returns {string} The formatted url 1146 */ 1147module.exports = function buildURL(url, params, paramsSerializer) { 1148 /*eslint no-param-reassign:0*/ 1149 if (!params) { 1150 return url; 1151 } 1152 1153 var serializedParams; 1154 if (paramsSerializer) { 1155 serializedParams = paramsSerializer(params); 1156 } else if (utils.isURLSearchParams(params)) { 1157 serializedParams = params.toString(); 1158 } else { 1159 var parts = []; 1160 1161 utils.forEach(params, function serialize(val, key) { 1162 if (val === null || typeof val === 'undefined') { 1163 return; 1164 } 1165 1166 if (utils.isArray(val)) { 1167 key = key + '[]'; 1168 } else { 1169 val = [val]; 1170 } 1171 1172 utils.forEach(val, function parseValue(v) { 1173 if (utils.isDate(v)) { 1174 v = v.toISOString(); 1175 } else if (utils.isObject(v)) { 1176 v = JSON.stringify(v); 1177 } 1178 parts.push(encode(key) + '=' + encode(v)); 1179 }); 1180 }); 1181 1182 serializedParams = parts.join('&'); 1183 } 1184 1185 if (serializedParams) { 1186 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 1187 } 1188 1189 return url; 1190}; 1191 1192 1193/***/ }), 1194
vendor: 508 bytes, lines 1195-1216
1195/***/ "./node_modules/axios/lib/helpers/combineURLs.js": 1196/***/ (function(module, exports, __webpack_require__) { 1197 1198"use strict"; 1199 1200 1201/** 1202 * Creates a new URL by combining the specified URLs 1203 * 1204 * @param {string} baseURL The base URL 1205 * @param {string} relativeURL The relative URL 1206 * @returns {string} The combined URL 1207 */ 1208module.exports = function combineURLs(baseURL, relativeURL) { 1209 return relativeURL 1210 ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 1211 : baseURL; 1212}; 1213 1214 1215/***/ }), 1216
vendor: 1,524 bytes, lines 1217-1277
1217/***/ "./node_modules/axios/lib/helpers/cookies.js": 1218/***/ (function(module, exports, __webpack_require__) { 1219 1220"use strict"; 1221 1222 1223var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 1224 1225module.exports = ( 1226 utils.isStandardBrowserEnv() ? 1227 1228 // Standard browser envs support document.cookie 1229 (function standardBrowserEnv() { 1230 return { 1231 write: function write(name, value, expires, path, domain, secure) { 1232 var cookie = []; 1233 cookie.push(name + '=' + encodeURIComponent(value)); 1234 1235 if (utils.isNumber(expires)) { 1236 cookie.push('expires=' + new Date(expires).toGMTString()); 1237 } 1238 1239 if (utils.isString(path)) { 1240 cookie.push('path=' + path); 1241 } 1242 1243 if (utils.isString(domain)) { 1244 cookie.push('domain=' + domain); 1245 } 1246 1247 if (secure === true) { 1248 cookie.push('secure'); 1249 } 1250 1251 document.cookie = cookie.join('; '); 1252 }, 1253 1254 read: function read(name) { 1255 var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 1256 return (match ? decodeURIComponent(match[3]) : null); 1257 }, 1258 1259 remove: function remove(name) { 1260 this.write(name, '', Date.now() - 86400000); 1261 } 1262 }; 1263 })() : 1264 1265 // Non standard browser env (web workers, react-native) lack needed support. 1266 (function nonStandardBrowserEnv() { 1267 return { 1268 write: function write() {}, 1269 read: function read() { return null; }, 1270 remove: function remove() {} 1271 }; 1272 })() 1273); 1274 1275 1276/***/ }), 1277
vendor: 693 bytes, lines 1278-1299
1278/***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js": 1279/***/ (function(module, exports, __webpack_require__) { 1280 1281"use strict"; 1282 1283 1284/** 1285 * Determines whether the specified URL is absolute 1286 * 1287 * @param {string} url The URL to test 1288 * @returns {boolean} True if the specified URL is absolute, otherwise false 1289 */ 1290module.exports = function isAbsoluteURL(url) { 1291 // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). 1292 // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 1293 // by any combination of letters, digits, plus, period, or hyphen. 1294 return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); 1295}; 1296 1297 1298/***/ }), 1299
vendor: 2,412 bytes, lines 1300-1375
1300/***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js": 1301/***/ (function(module, exports, __webpack_require__) { 1302 1303"use strict"; 1304 1305 1306var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 1307 1308module.exports = ( 1309 utils.isStandardBrowserEnv() ? 1310 1311 // Standard browser envs have full support of the APIs needed to test 1312 // whether the request URL is of the same origin as current location. 1313 (function standardBrowserEnv() { 1314 var msie = /(msie|trident)/i.test(navigator.userAgent); 1315 var urlParsingNode = document.createElement('a'); 1316 var originURL; 1317 1318 /** 1319 * Parse a URL to discover it's components 1320 * 1321 * @param {String} url The URL to be parsed 1322 * @returns {Object} 1323 */ 1324 function resolveURL(url) { 1325 var href = url; 1326 1327 if (msie) { 1328 // IE needs attribute set twice to normalize properties 1329 urlParsingNode.setAttribute('href', href); 1330 href = urlParsingNode.href; 1331 } 1332 1333 urlParsingNode.setAttribute('href', href); 1334 1335 // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 1336 return { 1337 href: urlParsingNode.href, 1338 protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 1339 host: urlParsingNode.host, 1340 search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 1341 hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 1342 hostname: urlParsingNode.hostname, 1343 port: urlParsingNode.port, 1344 pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 1345 urlParsingNode.pathname : 1346 '/' + urlParsingNode.pathname 1347 }; 1348 } 1349 1350 originURL = resolveURL(window.location.href); 1351 1352 /** 1353 * Determine if a URL shares the same origin as the current location 1354 * 1355 * @param {String} requestURL The URL to test 1356 * @returns {boolean} True if URL shares the same origin, otherwise false 1357 */ 1358 return function isURLSameOrigin(requestURL) { 1359 var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 1360 return (parsed.protocol === originURL.protocol && 1361 parsed.host === originURL.host); 1362 }; 1363 })() : 1364 1365 // Non standard browser envs (web workers, react-native) lack needed support. 1366 (function nonStandardBrowserEnv() { 1367 return function isURLSameOrigin() { 1368 return true; 1369 }; 1370 })() 1371); 1372 1373 1374/***/ }), 1375
vendor: 530 bytes, lines 1376-1395
1376/***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js": 1377/***/ (function(module, exports, __webpack_require__) { 1378 1379"use strict"; 1380 1381 1382var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 1383 1384module.exports = function normalizeHeaderName(headers, normalizedName) { 1385 utils.forEach(headers, function processHeader(value, name) { 1386 if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 1387 headers[normalizedName] = value; 1388 delete headers[name]; 1389 } 1390 }); 1391}; 1392 1393 1394/***/ }), 1395
vendor: 1,557 bytes, lines 1396-1456
1396/***/ "./node_modules/axios/lib/helpers/parseHeaders.js": 1397/***/ (function(module, exports, __webpack_require__) { 1398 1399"use strict"; 1400 1401 1402var utils = __webpack_require__("./node_modules/axios/lib/utils.js"); 1403 1404// Headers whose duplicates are ignored by node 1405// c.f. https://nodejs.org/api/http.html#http_message_headers 1406var ignoreDuplicateOf = [ 1407 'age', 'authorization', 'content-length', 'content-type', 'etag', 1408 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 1409 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 1410 'referer', 'retry-after', 'user-agent' 1411]; 1412 1413/** 1414 * Parse headers into an object 1415 * 1416 * ``` 1417 * Date: Wed, 27 Aug 2014 08:58:49 GMT 1418 * Content-Type: application/json 1419 * Connection: keep-alive 1420 * Transfer-Encoding: chunked 1421 * ``` 1422 * 1423 * @param {String} headers Headers needing to be parsed 1424 * @returns {Object} Headers parsed into an object 1425 */ 1426module.exports = function parseHeaders(headers) { 1427 var parsed = {}; 1428 var key; 1429 var val; 1430 var i; 1431 1432 if (!headers) { return parsed; } 1433 1434 utils.forEach(headers.split('\n'), function parser(line) { 1435 i = line.indexOf(':'); 1436 key = utils.trim(line.substr(0, i)).toLowerCase(); 1437 val = utils.trim(line.substr(i + 1)); 1438 1439 if (key) { 1440 if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 1441 return; 1442 } 1443 if (key === 'set-cookie') { 1444 parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 1445 } else { 1446 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 1447 } 1448 } 1449 }); 1450 1451 return parsed; 1452}; 1453 1454 1455/***/ }), 1456
vendor: 687 bytes, lines 1457-1491
1457/***/ "./node_modules/axios/lib/helpers/spread.js": 1458/***/ (function(module, exports, __webpack_require__) { 1459 1460"use strict"; 1461 1462 1463/** 1464 * Syntactic sugar for invoking a function and expanding an array for arguments. 1465 * 1466 * Common use case would be to use `Function.prototype.apply`. 1467 * 1468 * ```js 1469 * function f(x, y, z) {} 1470 * var args = [1, 2, 3]; 1471 * f.apply(null, args); 1472 * ``` 1473 * 1474 * With `spread` this example can be re-written. 1475 * 1476 * ```js 1477 * spread(function(x, y, z) {})([1, 2, 3]); 1478 * ``` 1479 * 1480 * @param {Function} callback 1481 * @returns {Function} 1482 */ 1483module.exports = function spread(callback) { 1484 return function wrap(arr) { 1485 return callback.apply(null, arr); 1486 }; 1487}; 1488 1489 1490/***/ }), 1491
vendor: 16,221 bytes, lines 1492-2112
1492/***/ "./node_modules/axios/lib/utils.js": 1493/***/ (function(module, exports, __webpack_require__) { 1494 1495"use strict"; 1496 1497 1498var bind = __webpack_require__("./node_modules/axios/lib/helpers/bind.js"); 1499var isBuffer = __webpack_require__("./node_modules/is-buffer/index.js"); 1500 1501/*global toString:true*/ 1502 1503// utils is a library of generic helper functions non-specific to axios 1504 1505var toString = Object.prototype.toString; 1506 1507/** 1508 * Determine if a value is an Array 1509 * 1510 * @param {Object} val The value to test 1511 * @returns {boolean} True if value is an Array, otherwise false 1512 */ 1513function isArray(val) { 1514 return toString.call(val) === '[object Array]'; 1515} 1516 1517/** 1518 * Determine if a value is an ArrayBuffer 1519 * 1520 * @param {Object} val The value to test 1521 * @returns {boolean} True if value is an ArrayBuffer, otherwise false 1522 */ 1523function isArrayBuffer(val) { 1524 return toString.call(val) === '[object ArrayBuffer]'; 1525} 1526 1527/** 1528 * Determine if a value is a FormData 1529 * 1530 * @param {Object} val The value to test 1531 * @returns {boolean} True if value is an FormData, otherwise false 1532 */ 1533function isFormData(val) { 1534 return (typeof FormData !== 'undefined') && (val instanceof FormData); 1535} 1536 1537/** 1538 * Determine if a value is a view on an ArrayBuffer 1539 * 1540 * @param {Object} val The value to test 1541 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 1542 */ 1543function isArrayBufferView(val) { 1544 var result; 1545 if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 1546 result = ArrayBuffer.isView(val); 1547 } else { 1548 result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); 1549 } 1550 return result; 1551} 1552 1553/** 1554 * Determine if a value is a String 1555 * 1556 * @param {Object} val The value to test 1557 * @returns {boolean} True if value is a String, otherwise false 1558 */ 1559function isString(val) { 1560 return typeof val === 'string'; 1561} 1562 1563/** 1564 * Determine if a value is a Number 1565 * 1566 * @param {Object} val The value to test 1567 * @returns {boolean} True if value is a Number, otherwise false 1568 */ 1569function isNumber(val) { 1570 return typeof val === 'number'; 1571} 1572 1573/** 1574 * Determine if a value is undefined 1575 * 1576 * @param {Object} val The value to test 1577 * @returns {boolean} True if the value is undefined, otherwise false 1578 */ 1579function isUndefined(val) { 1580 return typeof val === 'undefined'; 1581} 1582 1583/** 1584 * Determine if a value is an Object 1585 * 1586 * @param {Object} val The value to test 1587 * @returns {boolean} True if value is an Object, otherwise false 1588 */ 1589function isObject(val) { 1590 return val !== null && typeof val === 'object'; 1591} 1592 1593/** 1594 * Determine if a value is a Date 1595 * 1596 * @param {Object} val The value to test 1597 * @returns {boolean} True if value is a Date, otherwise false 1598 */ 1599function isDate(val) { 1600 return toString.call(val) === '[object Date]'; 1601} 1602 1603/** 1604 * Determine if a value is a File 1605 * 1606 * @param {Object} val The value to test 1607 * @returns {boolean} True if value is a File, otherwise false 1608 */ 1609function isFile(val) { 1610 return toString.call(val) === '[object File]'; 1611} 1612 1613/** 1614 * Determine if a value is a Blob 1615 * 1616 * @param {Object} val The value to test 1617 * @returns {boolean} True if value is a Blob, otherwise false 1618 */ 1619function isBlob(val) { 1620 return toString.call(val) === '[object Blob]'; 1621} 1622 1623/** 1624 * Determine if a value is a Function 1625 * 1626 * @param {Object} val The value to test 1627 * @returns {boolean} True if value is a Function, otherwise false 1628 */ 1629function isFunction(val) { 1630 return toString.call(val) === '[object Function]'; 1631} 1632 1633/** 1634 * Determine if a value is a Stream 1635 * 1636 * @param {Object} val The value to test 1637 * @returns {boolean} True if value is a Stream, otherwise false 1638 */ 1639function isStream(val) { 1640 return isObject(val) && isFunction(val.pipe); 1641} 1642 1643/** 1644 * Determine if a value is a URLSearchParams object 1645 * 1646 * @param {Object} val The value to test 1647 * @returns {boolean} True if value is a URLSearchParams object, otherwise false 1648 */ 1649function isURLSearchParams(val) { 1650 return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; 1651} 1652 1653/** 1654 * Trim excess whitespace off the beginning and end of a string 1655 * 1656 * @param {String} str The String to trim 1657 * @returns {String} The String freed of excess whitespace 1658 */ 1659function trim(str) { 1660 return str.replace(/^\s*/, '').replace(/\s*$/, ''); 1661} 1662 1663/** 1664 * Determine if we're running in a standard browser environment 1665 * 1666 * This allows axios to run in a web worker, and react-native. 1667 * Both environments support XMLHttpRequest, but not fully standard globals. 1668 * 1669 * web workers: 1670 * typeof window -> undefined 1671 * typeof document -> undefined 1672 * 1673 * react-native: 1674 * navigator.product -> 'ReactNative' 1675 */ 1676function isStandardBrowserEnv() { 1677 if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { 1678 return false; 1679 } 1680 return ( 1681 typeof window !== 'undefined' && 1682 typeof document !== 'undefined' 1683 ); 1684} 1685 1686/** 1687 * Iterate over an Array or an Object invoking a function for each item. 1688 * 1689 * If `obj` is an Array callback will be called passing 1690 * the value, index, and complete array for each item. 1691 * 1692 * If 'obj' is an Object callback will be called passing 1693 * the value, key, and complete object for each property. 1694 * 1695 * @param {Object|Array} obj The object to iterate 1696 * @param {Function} fn The callback to invoke for each item 1697 */ 1698function forEach(obj, fn) { 1699 // Don't bother if no value provided 1700 if (obj === null || typeof obj === 'undefined') { 1701 return; 1702 } 1703 1704 // Force an array if not already something iterable 1705 if (typeof obj !== 'object') { 1706 /*eslint no-param-reassign:0*/ 1707 obj = [obj]; 1708 } 1709 1710 if (isArray(obj)) { 1711 // Iterate over array values 1712 for (var i = 0, l = obj.length; i < l; i++) { 1713 fn.call(null, obj[i], i, obj); 1714 } 1715 } else { 1716 // Iterate over object keys 1717 for (var key in obj) { 1718 if (Object.prototype.hasOwnProperty.call(obj, key)) { 1719 fn.call(null, obj[key], key, obj); 1720 } 1721 } 1722 } 1723} 1724 1725/** 1726 * Accepts varargs expecting each argument to be an object, then 1727 * immutably merges the properties of each object and returns result. 1728 * 1729 * When multiple objects contain the same key the later object in 1730 * the arguments list will take precedence. 1731 * 1732 * Example: 1733 * 1734 * ```js 1735 * var result = merge({foo: 123}, {foo: 456}); 1736 * console.log(result.foo); // outputs 456 1737 * ``` 1738 * 1739 * @param {Object} obj1 Object to merge 1740 * @returns {Object} Result of all merge properties 1741 */ 1742function merge(/* obj1, obj2, obj3, ... */) { 1743 var result = {}; 1744 function assignValue(val, key) { 1745 if (typeof result[key] === 'object' && typeof val === 'object') { 1746 result[key] = merge(result[key], val); 1747 } else { 1748 result[key] = val; 1749 } 1750 } 1751 1752 for (var i = 0, l = arguments.length; i < l; i++) { 1753 forEach(arguments[i], assignValue); 1754 } 1755 return result; 1756} 1757 1758/** 1759 * Extends object a by mutably adding to it the properties of object b. 1760 * 1761 * @param {Object} a The object to be extended 1762 * @param {Object} b The object to copy properties from 1763 * @param {Object} thisArg The object to bind function to 1764 * @return {Object} The resulting value of object a 1765 */ 1766function extend(a, b, thisArg) { 1767 forEach(b, function assignValue(val, key) { 1768 if (thisArg && typeof val === 'function') { 1769 a[key] = bind(val, thisArg); 1770 } else { 1771 a[key] = val; 1772 } 1773 }); 1774 return a; 1775} 1776 1777module.exports = { 1778 isArray: isArray, 1779 isArrayBuffer: isArrayBuffer, 1780 isBuffer: isBuffer, 1781 isFormData: isFormData, 1782 isArrayBufferView: isArrayBufferView, 1783 isString: isString, 1784 isNumber: isNumber, 1785 isObject: isObject, 1786 isUndefined: isUndefined, 1787 isDate: isDate, 1788 isFile: isFile, 1789 isBlob: isBlob, 1790 isFunction: isFunction, 1791 isStream: isStream, 1792 isURLSearchParams: isURLSearchParams, 1793 isStandardBrowserEnv: isStandardBrowserEnv, 1794 forEach: forEach, 1795 merge: merge, 1796 extend: extend, 1797 trim: trim 1798}; 1799 1800 1801/***/ }), 1802 1803/***/ "./node_modules/babel-loader/lib/index.js?{\"cacheDirectory\":true,\"presets\":[[\"env\",{\"modules\":false,\"targets\":{\"browsers\":[\"> 2%\"],\"uglify\":true}}]],\"plugins\":[\"transform-object-rest-spread\",[\"transform-runtime\",{\"polyfill\":false,\"helpers\":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/Images.vue": 1804/***/ (function(module, __webpack_exports__, __webpack_require__) { 1805 1806"use strict"; 1807Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); 1808// 1809// 1810// 1811// 1812// 1813// 1814// 1815// 1816// 1817// 1818// 1819// 1820// 1821// 1822// 1823// 1824// 1825// 1826// 1827// 1828// 1829// 1830// 1831// 1832// 1833// 1834// 1835// 1836// 1837// 1838// 1839// 1840// 1841// 1842// 1843// 1844// 1845// 1846// 1847// 1848// 1849// 1850// 1851// 1852// 1853// 1854// 1855// 1856// 1857// 1858// 1859// 1860// 1861// 1862// 1863// 1864// 1865// 1866// 1867// 1868// 1869// 1870// 1871// 1872// 1873// 1874// 1875 1876var errors = { 1877 file_too_big: 'The image size is too big. (%s)', 1878 limit_reached: 'Photo upload limit reached', 1879 invalid_ext: 'Invalid image format. (%s)' 1880}; 1881 1882/* harmony default export */ __webpack_exports__["default"] = ({ 1883 props: { 1884 already_uploaded: { 1885 type: Array, 1886 required: false 1887 }, 1888 photo_upload_url: { type: String, required: true }, 1889 photo_delete_url: { type: String, required: true }, 1890 photo_rotate_url: { type: String, required: true }, 1891 photo_reorder_url: { type: String, required: true } 1892 }, 1893 data: function data() { 1894 return { 1895 uploading: false, 1896 errors: {}, 1897 toUpload: [], 1898 limit: 100, 1899 photos: [] 1900 }; 1901 }, 1902 1903 computed: { 1904 limitReached: function limitReached() { 1905 if (this.photos.length < this.limit) { 1906 return false; 1907 } 1908 1909 return true; 1910 } 1911 }, 1912 created: function created() { 1913 //console.log(this.already_uploaded); 1914 var self = this; 1915 this.already_uploaded.map(function (item) { 1916 self.photos.push(item); 1917 }); 1918 }, 1919 methods: { 1920 triggerInput: function triggerInput() { 1921 $('#photosInput').trigger('click'); 1922 }, 1923 addError: function addError(message) { 1924 console.log(message); 1925 this.errors.push(message); 1926 }, 1927 isNotFirst: function isNotFirst(index) { 1928 return index > 0; 1929 }, 1930 isNotLast: function isNotLast(index) { 1931 return this.photos.length != ++index; 1932 }, 1933 rotateRight: function rotateRight(item) { 1934 var vm = this; 1935 var preserved_thumb = item.thumb_url; 1936 item.thumb_url = Laravel.pixel; 1937 1938 axios.post(sprintf(vm.photo_rotate_url, item.id)).then(function (response) { 1939 console.log('Success ROTATE'); 1940 // todo change actual image src. 1941 item.thumb_url = preserved_thumb + '?timestamp=' + Date.now(); 1942 }).catch(function (error) { 1943 console.log('ERROR ROTATE'); 1944 console.log(error); 1945 }); 1946 }, 1947 itemDelete: function itemDelete(item) { 1948 //console.log('deleting '+item.id); 1949 var vm = this; 1950 1951 this.photos.map(function (value, index) { 1952 if (value.id == item.id) { 1953 vm.photos.splice(index, 1); 1954 } 1955 }); 1956 1957 axios.post(sprintf(vm.photo_delete_url, item.id)).then(function (response) { 1958 console.log('Success DELETE'); 1959 }).catch(function (error) { 1960 console.log('ERROR DELETE'); 1961 console.log(error); 1962 }); 1963 }, 1964 pushLeft: function pushLeft(item) { 1965 var vm = this; 1966 var currentIndex = _.findIndex(vm.photos, function (o) { 1967 return o.id == item.id; 1968 }); 1969 var prevIndex = currentIndex - 1; 1970 var lastIndex = _.findLastIndex(vm.photos); 1971 1972 // if we are moving last item to the right, 1973 // move it to first position 1974 if (prevIndex < 0) { 1975 prevIndex = lastIndex; 1976 } 1977 1978 Vue.swap(this.photos, currentIndex, prevIndex); 1979 1980 axios.post(vm.photo_reorder_url, { photos: this.photos }).then(function (response) { 1981 // console.log('Success'); 1982 }).catch(function (error) { 1983 console.log('ERROR'); 1984 }); 1985 }, 1986 pushRight: function pushRight(item) { 1987 var vm = this; 1988 var currentIndex = _.findIndex(vm.photos, function (o) { 1989 return o.id == item.id; 1990 }); 1991 var nextIndex = currentIndex + 1; 1992 var lastIndex = _.findLastIndex(vm.photos); 1993 1994 // if we are moving first item to the left, 1995 // move it to last position 1996 if (nextIndex > lastIndex) { 1997 nextIndex = 0; 1998 } 1999 2000 Vue.swap(this.photos, currentIndex, nextIndex); 2001 2002 axios.post(vm.photo_reorder_url, { photos: this.photos }).then(function (response) { 2003 //console.log('Success'); 2004 }).catch(function (error) { 2005 console.log('ERROR'); 2006 }); 2007 }, 2008 upload: function upload(event) { 2009 var self = this; 2010 // Reset all errors on fresh upload 2011 self.errors = []; 2012 2013 if (self.limitReached) { 2014 self.addError(errors['limit_reached']); 2015 return; 2016 } 2017 2018 if (!event.target.files.length) { 2019 // no files selected 2020 return; 2021 } 2022 2023 var i = void 0; 2024 var file = void 0; 2025 for (i = 0; i < event.target.files.length; i++) { 2026 file = event.target.files[i]; 2027 2028 // Silly image only filter! 2029 if (file.size / 1024 / 1024 > 10) { 2030 self.addError(sprintf(errors['file_too_big'], file.name)); 2031 } else if (file.type.indexOf('image/') == 0) { 2032 console.log('Adding toUpload[]...'); 2033 self.toUpload.push(event.target.files[i]); 2034 } else { 2035 self.addError(sprintf(errors['invalid_ext'], file.name)); 2036 } 2037 } 2038 2039 // Start the actual upload process 2040 this.processToUploadFiles(); 2041 }, 2042 processToUploadFiles: function processToUploadFiles() { 2043 var $el = $('#photosInput'); 2044 $el.wrap('<form>').closest('form').get(0).reset(); 2045 $el.unwrap(); 2046 2047 var self = this; 2048 if (self.uploading) { 2049 console.log('already uploading... queueing...'); 2050 return; 2051 } 2052 2053 if (self.limitReached) { 2054 // self.addError(errors['limit_reached']); 2055 return; 2056 } 2057 2058 if (!self.toUpload.length) { 2059 console.log('Nothing more to upload...'); 2060 return; 2061 } 2062 2063 self.uploading = true; 2064 2065 var currentFile = _.first(self.toUpload); 2066 2067 // remove first element 2068 self.toUpload.splice(0, 1); 2069 2070 var formData = new FormData(); 2071 formData.append('photos', currentFile); 2072 2073 axios.post(self.photo_upload_url, formData).then(function (response) { 2074 console.log('Success'); 2075 2076 self.photos.push(response.data); 2077 2078 self.uploading = false; 2079 self.processToUploadFiles(); // check to see if there are other files 2080 }).catch(function (error) { 2081 console.log('ERROR'); 2082 console.log(error); 2083 2084 self.uploading = false; 2085 self.processToUploadFiles(); // check to see if there are other files 2086 }); 2087 } 2088 }, 2089 watch: { 2090 uploading: function uploading(newValue) { 2091 Event.dispatch('images-uploading', newValue); 2092 } 2093 } 2094}); 2095 2096/***/ }), 2097 2098/***/ "./node_modules/css-loader/index.js!./node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-52401b6f\",\"scoped\":false,\"hasInlineConfig\":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./resources/assets/js/components/Images.vue": 2099/***/ (function(module, exports, __webpack_require__) { 2100 2101exports = module.exports = __webpack_require__("./node_modules/css-loader/lib/css-base.js")(false); 2102// imports 2103 2104 2105// module 2106exports.push([module.i, "\n.errors {\n color: red;\n}\n\n", ""]); 2107 2108// exports 2109 2110 2111/***/ }), 2112
vendor: 2,360 bytes, lines 2113-2195
2113/***/ "./node_modules/css-loader/lib/css-base.js": 2114/***/ (function(module, exports) { 2115 2116/* 2117 MIT License http://www.opensource.org/licenses/mit-license.php 2118 Author Tobias Koppers @sokra 2119*/ 2120// css base code, injected by the css-loader 2121module.exports = function(useSourceMap) { 2122 var list = []; 2123 2124 // return the list of modules as css string 2125 list.toString = function toString() { 2126 return this.map(function (item) { 2127 var content = cssWithMappingToString(item, useSourceMap); 2128 if(item[2]) { 2129 return "@media " + item[2] + "{" + content + "}"; 2130 } else { 2131 return content; 2132 } 2133 }).join(""); 2134 }; 2135 2136 // import a list of modules into the list 2137 list.i = function(modules, mediaQuery) { 2138 if(typeof modules === "string") 2139 modules = [[null, modules, ""]]; 2140 var alreadyImportedModules = {}; 2141 for(var i = 0; i < this.length; i++) { 2142 var id = this[i][0]; 2143 if(typeof id === "number") 2144 alreadyImportedModules[id] = true; 2145 } 2146 for(i = 0; i < modules.length; i++) { 2147 var item = modules[i]; 2148 // skip already imported module 2149 // this implementation is not 100% perfect for weird media query combinations 2150 // when a module is imported multiple times with different media queries. 2151 // I hope this will never occur (Hey this way we have smaller bundles) 2152 if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { 2153 if(mediaQuery && !item[2]) { 2154 item[2] = mediaQuery; 2155 } else if(mediaQuery) { 2156 item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; 2157 } 2158 list.push(item); 2159 } 2160 } 2161 }; 2162 return list; 2163}; 2164 2165function cssWithMappingToString(item, useSourceMap) { 2166 var content = item[1] || ''; 2167 var cssMapping = item[3]; 2168 if (!cssMapping) { 2169 return content; 2170 } 2171 2172 if (useSourceMap && typeof btoa === 'function') { 2173 var sourceMapping = toComment(cssMapping); 2174 var sourceURLs = cssMapping.sources.map(function (source) { 2175 return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */' 2176 }); 2177 2178 return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); 2179 } 2180 2181 return [content].join('\n'); 2182} 2183 2184// Adapted from convert-source-map (MIT) 2185function toComment(sourceMap) { 2186 // eslint-disable-next-line no-undef 2187 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); 2188 var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; 2189 2190 return '/*# ' + data + ' */'; 2191} 2192 2193 2194/***/ }), 2195
vendor: 790 bytes, lines 2196-2223
2196/***/ "./node_modules/is-buffer/index.js": 2197/***/ (function(module, exports) { 2198 2199/*! 2200 * Determine if an object is a Buffer 2201 * 2202 * @author Feross Aboukhadijeh <https://feross.org> 2203 * @license MIT 2204 */ 2205 2206// The _isBuffer check is for Safari 5-7 support, because it's missing 2207// Object.prototype.constructor. Remove this eventually 2208module.exports = function (obj) { 2209 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) 2210} 2211 2212function isBuffer (obj) { 2213 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) 2214} 2215 2216// For Node v0.10 support. Remove this eventually. 2217function isSlowBuffer (obj) { 2218 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) 2219} 2220 2221 2222/***/ }), 2223
vendor: 4,363 bytes, lines 2224-2399
2224/***/ "./node_modules/js-cookie/src/js.cookie.js": 2225/***/ (function(module, exports, __webpack_require__) { 2226 2227var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 2228 * JavaScript Cookie v2.2.0 2229 * https://github.com/js-cookie/js-cookie 2230 * 2231 * Copyright 2006, 2015 Klaus Hartl & Fagner Brack 2232 * Released under the MIT license 2233 */ 2234;(function (factory) { 2235 var registeredInModuleLoader = false; 2236 if (true) { 2237 !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), 2238 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? 2239 (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : 2240 __WEBPACK_AMD_DEFINE_FACTORY__), 2241 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 2242 registeredInModuleLoader = true; 2243 } 2244 if (true) { 2245 module.exports = factory(); 2246 registeredInModuleLoader = true; 2247 } 2248 if (!registeredInModuleLoader) { 2249 var OldCookies = window.Cookies; 2250 var api = window.Cookies = factory(); 2251 api.noConflict = function () { 2252 window.Cookies = OldCookies; 2253 return api; 2254 }; 2255 } 2256}(function () { 2257 function extend () { 2258 var i = 0; 2259 var result = {}; 2260 for (; i < arguments.length; i++) { 2261 var attributes = arguments[ i ]; 2262 for (var key in attributes) { 2263 result[key] = attributes[key]; 2264 } 2265 } 2266 return result; 2267 } 2268 2269 function init (converter) { 2270 function api (key, value, attributes) { 2271 var result; 2272 if (typeof document === 'undefined') { 2273 return; 2274 } 2275 2276 // Write 2277 2278 if (arguments.length > 1) { 2279 attributes = extend({ 2280 path: '/' 2281 }, api.defaults, attributes); 2282 2283 if (typeof attributes.expires === 'number') { 2284 var expires = new Date(); 2285 expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); 2286 attributes.expires = expires; 2287 } 2288 2289 // We're using "expires" because "max-age" is not supported by IE 2290 attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; 2291 2292 try { 2293 result = JSON.stringify(value); 2294 if (/^[\{\[]/.test(result)) { 2295 value = result; 2296 } 2297 } catch (e) {} 2298 2299 if (!converter.write) { 2300 value = encodeURIComponent(String(value)) 2301 .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); 2302 } else { 2303 value = converter.write(value, key); 2304 } 2305 2306 key = encodeURIComponent(String(key)); 2307 key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); 2308 key = key.replace(/[\(\)]/g, escape); 2309 2310 var stringifiedAttributes = ''; 2311 2312 for (var attributeName in attributes) { 2313 if (!attributes[attributeName]) { 2314 continue; 2315 } 2316 stringifiedAttributes += '; ' + attributeName; 2317 if (attributes[attributeName] === true) { 2318 continue; 2319 } 2320 stringifiedAttributes += '=' + attributes[attributeName]; 2321 } 2322 return (document.cookie = key + '=' + value + stringifiedAttributes); 2323 } 2324 2325 // Read 2326 2327 if (!key) { 2328 result = {}; 2329 } 2330 2331 // To prevent the for loop in the first place assign an empty array 2332 // in case there are no cookies at all. Also prevents odd result when 2333 // calling "get()" 2334 var cookies = document.cookie ? document.cookie.split('; ') : []; 2335 var rdecode = /(%[0-9A-Z]{2})+/g; 2336 var i = 0; 2337 2338 for (; i < cookies.length; i++) { 2339 var parts = cookies[i].split('='); 2340 var cookie = parts.slice(1).join('='); 2341 2342 if (!this.json && cookie.charAt(0) === '"') { 2343 cookie = cookie.slice(1, -1); 2344 } 2345 2346 try { 2347 var name = parts[0].replace(rdecode, decodeURIComponent); 2348 cookie = converter.read ? 2349 converter.read(cookie, name) : converter(cookie, name) || 2350 cookie.replace(rdecode, decodeURIComponent); 2351 2352 if (this.json) { 2353 try { 2354 cookie = JSON.parse(cookie); 2355 } catch (e) {} 2356 } 2357 2358 if (key === name) { 2359 result = cookie; 2360 break; 2361 } 2362 2363 if (!key) { 2364 result[name] = cookie; 2365 } 2366 } catch (e) {} 2367 } 2368 2369 return result; 2370 } 2371 2372 api.set = api; 2373 api.get = function (key) { 2374 return api.call(api, key); 2375 }; 2376 api.getJSON = function () { 2377 return api.apply({ 2378 json: true 2379 }, [].slice.call(arguments)); 2380 }; 2381 api.defaults = {}; 2382 2383 api.remove = function (key, attributes) { 2384 api(key, '', extend(attributes, { 2385 expires: -1 2386 })); 2387 }; 2388 2389 api.withConverter = init; 2390 2391 return api; 2392 } 2393 2394 return init(function () {}); 2395})); 2396 2397 2398/***/ }), 2399
vendor: 540,331 bytes, lines 2400-19513
2400/***/ "./node_modules/lodash/lodash.js": 2401/***/ (function(module, exports, __webpack_require__) { 2402 2403/* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/** 2404 * @license 2405 * Lodash <https://lodash.com/> 2406 * Copyright JS Foundation and other contributors <https://js.foundation/> 2407 * Released under MIT license <https://lodash.com/license> 2408 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 2409 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 2410 */ 2411;(function() { 2412 2413 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 2414 var undefined; 2415 2416 /** Used as the semantic version number. */ 2417 var VERSION = '4.17.10'; 2418 2419 /** Used as the size to enable large array optimizations. */ 2420 var LARGE_ARRAY_SIZE = 200; 2421 2422 /** Error message constants. */ 2423 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 2424 FUNC_ERROR_TEXT = 'Expected a function'; 2425 2426 /** Used to stand-in for `undefined` hash values. */ 2427 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 2428 2429 /** Used as the maximum memoize cache size. */ 2430 var MAX_MEMOIZE_SIZE = 500; 2431 2432 /** Used as the internal argument placeholder. */ 2433 var PLACEHOLDER = '__lodash_placeholder__'; 2434 2435 /** Used to compose bitmasks for cloning. */ 2436 var CLONE_DEEP_FLAG = 1, 2437 CLONE_FLAT_FLAG = 2, 2438 CLONE_SYMBOLS_FLAG = 4; 2439 2440 /** Used to compose bitmasks for value comparisons. */ 2441 var COMPARE_PARTIAL_FLAG = 1, 2442 COMPARE_UNORDERED_FLAG = 2; 2443 2444 /** Used to compose bitmasks for function metadata. */ 2445 var WRAP_BIND_FLAG = 1, 2446 WRAP_BIND_KEY_FLAG = 2, 2447 WRAP_CURRY_BOUND_FLAG = 4, 2448 WRAP_CURRY_FLAG = 8, 2449 WRAP_CURRY_RIGHT_FLAG = 16, 2450 WRAP_PARTIAL_FLAG = 32, 2451 WRAP_PARTIAL_RIGHT_FLAG = 64, 2452 WRAP_ARY_FLAG = 128, 2453 WRAP_REARG_FLAG = 256, 2454 WRAP_FLIP_FLAG = 512; 2455 2456 /** Used as default options for `_.truncate`. */ 2457 var DEFAULT_TRUNC_LENGTH = 30, 2458 DEFAULT_TRUNC_OMISSION = '...'; 2459 2460 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 2461 var HOT_COUNT = 800, 2462 HOT_SPAN = 16; 2463 2464 /** Used to indicate the type of lazy iteratees. */ 2465 var LAZY_FILTER_FLAG = 1, 2466 LAZY_MAP_FLAG = 2, 2467 LAZY_WHILE_FLAG = 3; 2468 2469 /** Used as references for various `Number` constants. */ 2470 var INFINITY = 1 / 0, 2471 MAX_SAFE_INTEGER = 9007199254740991, 2472 MAX_INTEGER = 1.7976931348623157e+308, 2473 NAN = 0 / 0; 2474 2475 /** Used as references for the maximum length and index of an array. */ 2476 var MAX_ARRAY_LENGTH = 4294967295, 2477 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 2478 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 2479 2480 /** Used to associate wrap methods with their bit flags. */ 2481 var wrapFlags = [ 2482 ['ary', WRAP_ARY_FLAG], 2483 ['bind', WRAP_BIND_FLAG], 2484 ['bindKey', WRAP_BIND_KEY_FLAG], 2485 ['curry', WRAP_CURRY_FLAG], 2486 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 2487 ['flip', WRAP_FLIP_FLAG], 2488 ['partial', WRAP_PARTIAL_FLAG], 2489 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 2490 ['rearg', WRAP_REARG_FLAG] 2491 ]; 2492 2493 /** `Object#toString` result references. */ 2494 var argsTag = '[object Arguments]', 2495 arrayTag = '[object Array]', 2496 asyncTag = '[object AsyncFunction]', 2497 boolTag = '[object Boolean]', 2498 dateTag = '[object Date]', 2499 domExcTag = '[object DOMException]', 2500 errorTag = '[object Error]', 2501 funcTag = '[object Function]', 2502 genTag = '[object GeneratorFunction]', 2503 mapTag = '[object Map]', 2504 numberTag = '[object Number]', 2505 nullTag = '[object Null]', 2506 objectTag = '[object Object]', 2507 promiseTag = '[object Promise]', 2508 proxyTag = '[object Proxy]', 2509 regexpTag = '[object RegExp]', 2510 setTag = '[object Set]', 2511 stringTag = '[object String]', 2512 symbolTag = '[object Symbol]', 2513 undefinedTag = '[object Undefined]', 2514 weakMapTag = '[object WeakMap]', 2515 weakSetTag = '[object WeakSet]'; 2516 2517 var arrayBufferTag = '[object ArrayBuffer]', 2518 dataViewTag = '[object DataView]', 2519 float32Tag = '[object Float32Array]', 2520 float64Tag = '[object Float64Array]', 2521 int8Tag = '[object Int8Array]', 2522 int16Tag = '[object Int16Array]', 2523 int32Tag = '[object Int32Array]', 2524 uint8Tag = '[object Uint8Array]', 2525 uint8ClampedTag = '[object Uint8ClampedArray]', 2526 uint16Tag = '[object Uint16Array]', 2527 uint32Tag = '[object Uint32Array]'; 2528 2529 /** Used to match empty string literals in compiled template source. */ 2530 var reEmptyStringLeading = /\b__p \+= '';/g, 2531 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 2532 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 2533 2534 /** Used to match HTML entities and HTML characters. */ 2535 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 2536 reUnescapedHtml = /[&<>"']/g, 2537 reHasEscapedHtml = RegExp(reEscapedHtml.source), 2538 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 2539 2540 /** Used to match template delimiters. */ 2541 var reEscape = /<%-([\s\S]+?)%>/g, 2542 reEvaluate = /<%([\s\S]+?)%>/g, 2543 reInterpolate = /<%=([\s\S]+?)%>/g; 2544 2545 /** Used to match property names within property paths. */ 2546 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 2547 reIsPlainProp = /^\w*$/, 2548 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 2549 2550 /** 2551 * Used to match `RegExp` 2552 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 2553 */ 2554 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 2555 reHasRegExpChar = RegExp(reRegExpChar.source); 2556 2557 /** Used to match leading and trailing whitespace. */ 2558 var reTrim = /^\s+|\s+$/g, 2559 reTrimStart = /^\s+/, 2560 reTrimEnd = /\s+$/; 2561 2562 /** Used to match wrap detail comments. */ 2563 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 2564 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 2565 reSplitDetails = /,? & /; 2566 2567 /** Used to match words composed of alphanumeric characters. */ 2568 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 2569 2570 /** Used to match backslashes in property paths. */ 2571 var reEscapeChar = /\\(\\)?/g; 2572 2573 /** 2574 * Used to match 2575 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 2576 */ 2577 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 2578 2579 /** Used to match `RegExp` flags from their coerced string values. */ 2580 var reFlags = /\w*$/; 2581 2582 /** Used to detect bad signed hexadecimal string values. */ 2583 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 2584 2585 /** Used to detect binary string values. */ 2586 var reIsBinary = /^0b[01]+$/i; 2587 2588 /** Used to detect host constructors (Safari). */ 2589 var reIsHostCtor = /^\[object .+?Constructor\]$/; 2590 2591 /** Used to detect octal string values. */ 2592 var reIsOctal = /^0o[0-7]+$/i; 2593 2594 /** Used to detect unsigned integer values. */ 2595 var reIsUint = /^(?:0|[1-9]\d*)$/; 2596 2597 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 2598 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 2599 2600 /** Used to ensure capturing order of template delimiters. */ 2601 var reNoMatch = /($^)/; 2602 2603 /** Used to match unescaped characters in compiled string literals. */ 2604 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 2605 2606 /** Used to compose unicode character classes. */ 2607 var rsAstralRange = '\\ud800-\\udfff', 2608 rsComboMarksRange = '\\u0300-\\u036f', 2609 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 2610 rsComboSymbolsRange = '\\u20d0-\\u20ff', 2611 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 2612 rsDingbatRange = '\\u2700-\\u27bf', 2613 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 2614 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 2615 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 2616 rsPunctuationRange = '\\u2000-\\u206f', 2617 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', 2618 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 2619 rsVarRange = '\\ufe0e\\ufe0f', 2620 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 2621 2622 /** Used to compose unicode capture groups. */ 2623 var rsApos = "['\u2019]", 2624 rsAstral = '[' + rsAstralRange + ']', 2625 rsBreak = '[' + rsBreakRange + ']', 2626 rsCombo = '[' + rsComboRange + ']', 2627 rsDigits = '\\d+', 2628 rsDingbat = '[' + rsDingbatRange + ']', 2629 rsLower = '[' + rsLowerRange + ']', 2630 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 2631 rsFitz = '\\ud83c[\\udffb-\\udfff]', 2632 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 2633 rsNonAstral = '[^' + rsAstralRange + ']', 2634 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 2635 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 2636 rsUpper = '[' + rsUpperRange + ']', 2637 rsZWJ = '\\u200d'; 2638 2639 /** Used to compose unicode regexes. */ 2640 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 2641 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 2642 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 2643 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 2644 reOptMod = rsModifier + '?', 2645 rsOptVar = '[' + rsVarRange + ']?', 2646 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 2647 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 2648 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 2649 rsSeq = rsOptVar + reOptMod + rsOptJoin, 2650 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 2651 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 2652 2653 /** Used to match apostrophes. */ 2654 var reApos = RegExp(rsApos, 'g'); 2655 2656 /** 2657 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 2658 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 2659 */ 2660 var reComboMark = RegExp(rsCombo, 'g'); 2661 2662 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 2663 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 2664 2665 /** Used to match complex or compound words. */ 2666 var reUnicodeWord = RegExp([ 2667 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 2668 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 2669 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 2670 rsUpper + '+' + rsOptContrUpper, 2671 rsOrdUpper, 2672 rsOrdLower, 2673 rsDigits, 2674 rsEmoji 2675 ].join('|'), 'g'); 2676 2677 /** 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/). */ 2678 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 2679 2680 /** Used to detect strings that need a more robust regexp to match words. */ 2681 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 ]/; 2682 2683 /** Used to assign default `context` object properties. */ 2684 var contextProps = [ 2685 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 2686 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 2687 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 2688 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 2689 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 2690 ]; 2691 2692 /** Used to make template sourceURLs easier to identify. */ 2693 var templateCounter = -1; 2694 2695 /** Used to identify `toStringTag` values of typed arrays. */ 2696 var typedArrayTags = {}; 2697 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 2698 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 2699 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 2700 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 2701 typedArrayTags[uint32Tag] = true; 2702 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 2703 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 2704 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 2705 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 2706 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 2707 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 2708 typedArrayTags[setTag] = typedArrayTags[stringTag] = 2709 typedArrayTags[weakMapTag] = false; 2710 2711 /** Used to identify `toStringTag` values supported by `_.clone`. */ 2712 var cloneableTags = {}; 2713 cloneableTags[argsTag] = cloneableTags[arrayTag] = 2714 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 2715 cloneableTags[boolTag] = cloneableTags[dateTag] = 2716 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 2717 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 2718 cloneableTags[int32Tag] = cloneableTags[mapTag] = 2719 cloneableTags[numberTag] = cloneableTags[objectTag] = 2720 cloneableTags[regexpTag] = cloneableTags[setTag] = 2721 cloneableTags[stringTag] = cloneableTags[symbolTag] = 2722 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 2723 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 2724 cloneableTags[errorTag] = cloneableTags[funcTag] = 2725 cloneableTags[weakMapTag] = false; 2726 2727 /** Used to map Latin Unicode letters to basic Latin letters. */ 2728 var deburredLetters = { 2729 // Latin-1 Supplement block. 2730 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 2731 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 2732 '\xc7': 'C', '\xe7': 'c', 2733 '\xd0': 'D', '\xf0': 'd', 2734 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 2735 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 2736 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 2737 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 2738 '\xd1': 'N', '\xf1': 'n', 2739 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 2740 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 2741 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 2742 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 2743 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 2744 '\xc6': 'Ae', '\xe6': 'ae', 2745 '\xde': 'Th', '\xfe': 'th', 2746 '\xdf': 'ss', 2747 // Latin Extended-A block. 2748 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 2749 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 2750 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 2751 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 2752 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 2753 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 2754 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 2755 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 2756 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 2757 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 2758 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 2759 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 2760 '\u0134': 'J', '\u0135': 'j', 2761 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 2762 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 2763 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 2764 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 2765 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 2766 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 2767 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 2768 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 2769 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 2770 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 2771 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 2772 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 2773 '\u0163': 't', '\u0165': 't', '\u0167': 't', 2774 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 2775 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 2776 '\u0174': 'W', '\u0175': 'w', 2777 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 2778 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 2779 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 2780 '\u0132': 'IJ', '\u0133': 'ij', 2781 '\u0152': 'Oe', '\u0153': 'oe', 2782 '\u0149': "'n", '\u017f': 's' 2783 }; 2784 2785 /** Used to map characters to HTML entities. */ 2786 var htmlEscapes = { 2787 '&': '&', 2788 '<': '<', 2789 '>': '>', 2790 '"': '"', 2791 "'": ''' 2792 }; 2793 2794 /** Used to map HTML entities to characters. */ 2795 var htmlUnescapes = { 2796 '&': '&', 2797 '<': '<', 2798 '>': '>', 2799 '"': '"', 2800 ''': "'" 2801 }; 2802 2803 /** Used to escape characters for inclusion in compiled string literals. */ 2804 var stringEscapes = { 2805 '\\': '\\', 2806 "'": "'", 2807 '\n': 'n', 2808 '\r': 'r', 2809 '\u2028': 'u2028', 2810 '\u2029': 'u2029' 2811 }; 2812 2813 /** Built-in method references without a dependency on `root`. */ 2814 var freeParseFloat = parseFloat, 2815 freeParseInt = parseInt; 2816 2817 /** Detect free variable `global` from Node.js. */ 2818 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 2819 2820 /** Detect free variable `self`. */ 2821 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 2822 2823 /** Used as a reference to the global object. */ 2824 var root = freeGlobal || freeSelf || Function('return this')(); 2825 2826 /** Detect free variable `exports`. */ 2827 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; 2828 2829 /** Detect free variable `module`. */ 2830 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; 2831 2832 /** Detect the popular CommonJS extension `module.exports`. */ 2833 var moduleExports = freeModule && freeModule.exports === freeExports; 2834 2835 /** Detect free variable `process` from Node.js. */ 2836 var freeProcess = moduleExports && freeGlobal.process; 2837 2838 /** Used to access faster Node.js helpers. */ 2839 var nodeUtil = (function() { 2840 try { 2841 // Use `util.types` for Node.js 10+. 2842 var types = freeModule && freeModule.require && freeModule.require('util').types; 2843 2844 if (types) { 2845 return types; 2846 } 2847 2848 // Legacy `process.binding('util')` for Node.js < 10. 2849 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 2850 } catch (e) {} 2851 }()); 2852 2853 /* Node.js helper references. */ 2854 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 2855 nodeIsDate = nodeUtil && nodeUtil.isDate, 2856 nodeIsMap = nodeUtil && nodeUtil.isMap, 2857 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 2858 nodeIsSet = nodeUtil && nodeUtil.isSet, 2859 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 2860 2861 /*--------------------------------------------------------------------------*/ 2862 2863 /** 2864 * A faster alternative to `Function#apply`, this function invokes `func` 2865 * with the `this` binding of `thisArg` and the arguments of `args`. 2866 * 2867 * @private 2868 * @param {Function} func The function to invoke. 2869 * @param {*} thisArg The `this` binding of `func`. 2870 * @param {Array} args The arguments to invoke `func` with. 2871 * @returns {*} Returns the result of `func`. 2872 */ 2873 function apply(func, thisArg, args) { 2874 switch (args.length) { 2875 case 0: return func.call(thisArg); 2876 case 1: return func.call(thisArg, args[0]); 2877 case 2: return func.call(thisArg, args[0], args[1]); 2878 case 3: return func.call(thisArg, args[0], args[1], args[2]); 2879 } 2880 return func.apply(thisArg, args); 2881 } 2882 2883 /** 2884 * A specialized version of `baseAggregator` for arrays. 2885 * 2886 * @private 2887 * @param {Array} [array] The array to iterate over. 2888 * @param {Function} setter The function to set `accumulator` values. 2889 * @param {Function} iteratee The iteratee to transform keys. 2890 * @param {Object} accumulator The initial aggregated object. 2891 * @returns {Function} Returns `accumulator`. 2892 */ 2893 function arrayAggregator(array, setter, iteratee, accumulator) { 2894 var index = -1, 2895 length = array == null ? 0 : array.length; 2896 2897 while (++index < length) { 2898 var value = array[index]; 2899 setter(accumulator, value, iteratee(value), array); 2900 } 2901 return accumulator; 2902 } 2903 2904 /** 2905 * A specialized version of `_.forEach` for arrays without support for 2906 * iteratee shorthands. 2907 * 2908 * @private 2909 * @param {Array} [array] The array to iterate over. 2910 * @param {Function} iteratee The function invoked per iteration. 2911 * @returns {Array} Returns `array`. 2912 */ 2913 function arrayEach(array, iteratee) { 2914 var index = -1, 2915 length = array == null ? 0 : array.length; 2916 2917 while (++index < length) { 2918 if (iteratee(array[index], index, array) === false) { 2919 break; 2920 } 2921 } 2922 return array; 2923 } 2924 2925 /** 2926 * A specialized version of `_.forEachRight` for arrays without support for 2927 * iteratee shorthands. 2928 * 2929 * @private 2930 * @param {Array} [array] The array to iterate over. 2931 * @param {Function} iteratee The function invoked per iteration. 2932 * @returns {Array} Returns `array`. 2933 */ 2934 function arrayEachRight(array, iteratee) { 2935 var length = array == null ? 0 : array.length; 2936 2937 while (length--) { 2938 if (iteratee(array[length], length, array) === false) { 2939 break; 2940 } 2941 } 2942 return array; 2943 } 2944 2945 /** 2946 * A specialized version of `_.every` for arrays without support for 2947 * iteratee shorthands. 2948 * 2949 * @private 2950 * @param {Array} [array] The array to iterate over. 2951 * @param {Function} predicate The function invoked per iteration. 2952 * @returns {boolean} Returns `true` if all elements pass the predicate check, 2953 * else `false`. 2954 */ 2955 function arrayEvery(array, predicate) { 2956 var index = -1, 2957 length = array == null ? 0 : array.length; 2958 2959 while (++index < length) { 2960 if (!predicate(array[index], index, array)) { 2961 return false; 2962 } 2963 } 2964 return true; 2965 } 2966 2967 /** 2968 * A specialized version of `_.filter` for arrays without support for 2969 * iteratee shorthands. 2970 * 2971 * @private 2972 * @param {Array} [array] The array to iterate over. 2973 * @param {Function} predicate The function invoked per iteration. 2974 * @returns {Array} Returns the new filtered array. 2975 */ 2976 function arrayFilter(array, predicate) { 2977 var index = -1, 2978 length = array == null ? 0 : array.length, 2979 resIndex = 0, 2980 result = []; 2981 2982 while (++index < length) { 2983 var value = array[index]; 2984 if (predicate(value, index, array)) { 2985 result[resIndex++] = value; 2986 } 2987 } 2988 return result; 2989 } 2990 2991 /** 2992 * A specialized version of `_.includes` for arrays without support for 2993 * specifying an index to search from. 2994 * 2995 * @private 2996 * @param {Array} [array] The array to inspect. 2997 * @param {*} target The value to search for. 2998 * @returns {boolean} Returns `true` if `target` is found, else `false`. 2999 */ 3000 function arrayIncludes(array, value) { 3001 var length = array == null ? 0 : array.length; 3002 return !!length && baseIndexOf(array, value, 0) > -1; 3003 } 3004 3005 /** 3006 * This function is like `arrayIncludes` except that it accepts a comparator. 3007 * 3008 * @private 3009 * @param {Array} [array] The array to inspect. 3010 * @param {*} target The value to search for. 3011 * @param {Function} comparator The comparator invoked per element. 3012 * @returns {boolean} Returns `true` if `target` is found, else `false`. 3013 */ 3014 function arrayIncludesWith(array, value, comparator) { 3015 var index = -1, 3016 length = array == null ? 0 : array.length; 3017 3018 while (++index < length) { 3019 if (comparator(value, array[index])) { 3020 return true; 3021 } 3022 } 3023 return false; 3024 } 3025 3026 /** 3027 * A specialized version of `_.map` for arrays without support for iteratee 3028 * shorthands. 3029 * 3030 * @private 3031 * @param {Array} [array] The array to iterate over. 3032 * @param {Function} iteratee The function invoked per iteration. 3033 * @returns {Array} Returns the new mapped array. 3034 */ 3035 function arrayMap(array, iteratee) { 3036 var index = -1, 3037 length = array == null ? 0 : array.length, 3038 result = Array(length); 3039 3040 while (++index < length) { 3041 result[index] = iteratee(array[index], index, array); 3042 } 3043 return result; 3044 } 3045 3046 /** 3047 * Appends the elements of `values` to `array`. 3048 * 3049 * @private 3050 * @param {Array} array The array to modify. 3051 * @param {Array} values The values to append. 3052 * @returns {Array} Returns `array`. 3053 */ 3054 function arrayPush(array, values) { 3055 var index = -1, 3056 length = values.length, 3057 offset = array.length; 3058 3059 while (++index < length) { 3060 array[offset + index] = values[index]; 3061 } 3062 return array; 3063 } 3064 3065 /** 3066 * A specialized version of `_.reduce` for arrays without support for 3067 * iteratee shorthands. 3068 * 3069 * @private 3070 * @param {Array} [array] The array to iterate over. 3071 * @param {Function} iteratee The function invoked per iteration. 3072 * @param {*} [accumulator] The initial value. 3073 * @param {boolean} [initAccum] Specify using the first element of `array` as 3074 * the initial value. 3075 * @returns {*} Returns the accumulated value. 3076 */ 3077 function arrayReduce(array, iteratee, accumulator, initAccum) { 3078 var index = -1, 3079 length = array == null ? 0 : array.length; 3080 3081 if (initAccum && length) { 3082 accumulator = array[++index]; 3083 } 3084 while (++index < length) { 3085 accumulator = iteratee(accumulator, array[index], index, array); 3086 } 3087 return accumulator; 3088 } 3089 3090 /** 3091 * A specialized version of `_.reduceRight` for arrays without support for 3092 * iteratee shorthands. 3093 * 3094 * @private 3095 * @param {Array} [array] The array to iterate over. 3096 * @param {Function} iteratee The function invoked per iteration. 3097 * @param {*} [accumulator] The initial value. 3098 * @param {boolean} [initAccum] Specify using the last element of `array` as 3099 * the initial value. 3100 * @returns {*} Returns the accumulated value. 3101 */ 3102 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 3103 var length = array == null ? 0 : array.length; 3104 if (initAccum && length) { 3105 accumulator = array[--length]; 3106 } 3107 while (length--) { 3108 accumulator = iteratee(accumulator, array[length], length, array); 3109 } 3110 return accumulator; 3111 } 3112 3113 /** 3114 * A specialized version of `_.some` for arrays without support for iteratee 3115 * shorthands. 3116 * 3117 * @private 3118 * @param {Array} [array] The array to iterate over. 3119 * @param {Function} predicate The function invoked per iteration. 3120 * @returns {boolean} Returns `true` if any element passes the predicate check, 3121 * else `false`. 3122 */ 3123 function arraySome(array, predicate) { 3124 var index = -1, 3125 length = array == null ? 0 : array.length; 3126 3127 while (++index < length) { 3128 if (predicate(array[index], index, array)) { 3129 return true; 3130 } 3131 } 3132 return false; 3133 } 3134 3135 /** 3136 * Gets the size of an ASCII `string`. 3137 * 3138 * @private 3139 * @param {string} string The string inspect. 3140 * @returns {number} Returns the string size. 3141 */ 3142 var asciiSize = baseProperty('length'); 3143 3144 /** 3145 * Converts an ASCII `string` to an array. 3146 * 3147 * @private 3148 * @param {string} string The string to convert. 3149 * @returns {Array} Returns the converted array. 3150 */ 3151 function asciiToArray(string) { 3152 return string.split(''); 3153 } 3154 3155 /** 3156 * Splits an ASCII `string` into an array of its words. 3157 * 3158 * @private 3159 * @param {string} The string to inspect. 3160 * @returns {Array} Returns the words of `string`. 3161 */ 3162 function asciiWords(string) { 3163 return string.match(reAsciiWord) || []; 3164 } 3165 3166 /** 3167 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 3168 * without support for iteratee shorthands, which iterates over `collection` 3169 * using `eachFunc`. 3170 * 3171 * @private 3172 * @param {Array|Object} collection The collection to inspect. 3173 * @param {Function} predicate The function invoked per iteration. 3174 * @param {Function} eachFunc The function to iterate over `collection`. 3175 * @returns {*} Returns the found element or its key, else `undefined`. 3176 */ 3177 function baseFindKey(collection, predicate, eachFunc) { 3178 var result; 3179 eachFunc(collection, function(value, key, collection) { 3180 if (predicate(value, key, collection)) { 3181 result = key; 3182 return false; 3183 } 3184 }); 3185 return result; 3186 } 3187 3188 /** 3189 * The base implementation of `_.findIndex` and `_.findLastIndex` without 3190 * support for iteratee shorthands. 3191 * 3192 * @private 3193 * @param {Array} array The array to inspect. 3194 * @param {Function} predicate The function invoked per iteration. 3195 * @param {number} fromIndex The index to search from. 3196 * @param {boolean} [fromRight] Specify iterating from right to left. 3197 * @returns {number} Returns the index of the matched value, else `-1`. 3198 */ 3199 function baseFindIndex(array, predicate, fromIndex, fromRight) { 3200 var length = array.length, 3201 index = fromIndex + (fromRight ? 1 : -1); 3202 3203 while ((fromRight ? index-- : ++index < length)) { 3204 if (predicate(array[index], index, array)) { 3205 return index; 3206 } 3207 } 3208 return -1; 3209 } 3210 3211 /** 3212 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 3213 * 3214 * @private 3215 * @param {Array} array The array to inspect. 3216 * @param {*} value The value to search for. 3217 * @param {number} fromIndex The index to search from. 3218 * @returns {number} Returns the index of the matched value, else `-1`. 3219 */ 3220 function baseIndexOf(array, value, fromIndex) { 3221 return value === value 3222 ? strictIndexOf(array, value, fromIndex) 3223 : baseFindIndex(array, baseIsNaN, fromIndex); 3224 } 3225 3226 /** 3227 * This function is like `baseIndexOf` except that it accepts a comparator. 3228 * 3229 * @private 3230 * @param {Array} array The array to inspect. 3231 * @param {*} value The value to search for. 3232 * @param {number} fromIndex The index to search from. 3233 * @param {Function} comparator The comparator invoked per element. 3234 * @returns {number} Returns the index of the matched value, else `-1`. 3235 */ 3236 function baseIndexOfWith(array, value, fromIndex, comparator) { 3237 var index = fromIndex - 1, 3238 length = array.length; 3239 3240 while (++index < length) { 3241 if (comparator(array[index], value)) { 3242 return index; 3243 } 3244 } 3245 return -1; 3246 } 3247 3248 /** 3249 * The base implementation of `_.isNaN` without support for number objects. 3250 * 3251 * @private 3252 * @param {*} value The value to check. 3253 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 3254 */ 3255 function baseIsNaN(value) { 3256 return value !== value; 3257 } 3258 3259 /** 3260 * The base implementation of `_.mean` and `_.meanBy` without support for 3261 * iteratee shorthands. 3262 * 3263 * @private 3264 * @param {Array} array The array to iterate over. 3265 * @param {Function} iteratee The function invoked per iteration. 3266 * @returns {number} Returns the mean. 3267 */ 3268 function baseMean(array, iteratee) { 3269 var length = array == null ? 0 : array.length; 3270 return length ? (baseSum(array, iteratee) / length) : NAN; 3271 } 3272 3273 /** 3274 * The base implementation of `_.property` without support for deep paths. 3275 * 3276 * @private 3277 * @param {string} key The key of the property to get. 3278 * @returns {Function} Returns the new accessor function. 3279 */ 3280 function baseProperty(key) { 3281 return function(object) { 3282 return object == null ? undefined : object[key]; 3283 }; 3284 } 3285 3286 /** 3287 * The base implementation of `_.propertyOf` without support for deep paths. 3288 * 3289 * @private 3290 * @param {Object} object The object to query. 3291 * @returns {Function} Returns the new accessor function. 3292 */ 3293 function basePropertyOf(object) { 3294 return function(key) { 3295 return object == null ? undefined : object[key]; 3296 }; 3297 } 3298 3299 /** 3300 * The base implementation of `_.reduce` and `_.reduceRight`, without support 3301 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 3302 * 3303 * @private 3304 * @param {Array|Object} collection The collection to iterate over. 3305 * @param {Function} iteratee The function invoked per iteration. 3306 * @param {*} accumulator The initial value. 3307 * @param {boolean} initAccum Specify using the first or last element of 3308 * `collection` as the initial value. 3309 * @param {Function} eachFunc The function to iterate over `collection`. 3310 * @returns {*} Returns the accumulated value. 3311 */ 3312 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 3313 eachFunc(collection, function(value, index, collection) { 3314 accumulator = initAccum 3315 ? (initAccum = false, value) 3316 : iteratee(accumulator, value, index, collection); 3317 }); 3318 return accumulator; 3319 } 3320 3321 /** 3322 * The base implementation of `_.sortBy` which uses `comparer` to define the 3323 * sort order of `array` and replaces criteria objects with their corresponding 3324 * values. 3325 * 3326 * @private 3327 * @param {Array} array The array to sort. 3328 * @param {Function} comparer The function to define sort order. 3329 * @returns {Array} Returns `array`. 3330 */ 3331 function baseSortBy(array, comparer) { 3332 var length = array.length; 3333 3334 array.sort(comparer); 3335 while (length--) { 3336 array[length] = array[length].value; 3337 } 3338 return array; 3339 } 3340 3341 /** 3342 * The base implementation of `_.sum` and `_.sumBy` without support for 3343 * iteratee shorthands. 3344 * 3345 * @private 3346 * @param {Array} array The array to iterate over. 3347 * @param {Function} iteratee The function invoked per iteration. 3348 * @returns {number} Returns the sum. 3349 */ 3350 function baseSum(array, iteratee) { 3351 var result, 3352 index = -1, 3353 length = array.length; 3354 3355 while (++index < length) { 3356 var current = iteratee(array[index]); 3357 if (current !== undefined) { 3358 result = result === undefined ? current : (result + current); 3359 } 3360 } 3361 return result; 3362 } 3363 3364 /** 3365 * The base implementation of `_.times` without support for iteratee shorthands 3366 * or max array length checks. 3367 * 3368 * @private 3369 * @param {number} n The number of times to invoke `iteratee`. 3370 * @param {Function} iteratee The function invoked per iteration. 3371 * @returns {Array} Returns the array of results. 3372 */ 3373 function baseTimes(n, iteratee) { 3374 var index = -1, 3375 result = Array(n); 3376 3377 while (++index < n) { 3378 result[index] = iteratee(index); 3379 } 3380 return result; 3381 } 3382 3383 /** 3384 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 3385 * of key-value pairs for `object` corresponding to the property names of `props`. 3386 * 3387 * @private 3388 * @param {Object} object The object to query. 3389 * @param {Array} props The property names to get values for. 3390 * @returns {Object} Returns the key-value pairs. 3391 */ 3392 function baseToPairs(object, props) { 3393 return arrayMap(props, function(key) { 3394 return [key, object[key]]; 3395 }); 3396 } 3397 3398 /** 3399 * The base implementation of `_.unary` without support for storing metadata. 3400 * 3401 * @private 3402 * @param {Function} func The function to cap arguments for. 3403 * @returns {Function} Returns the new capped function. 3404 */ 3405 function baseUnary(func) { 3406 return function(value) { 3407 return func(value); 3408 }; 3409 } 3410 3411 /** 3412 * The base implementation of `_.values` and `_.valuesIn` which creates an 3413 * array of `object` property values corresponding to the property names 3414 * of `props`. 3415 * 3416 * @private 3417 * @param {Object} object The object to query. 3418 * @param {Array} props The property names to get values for. 3419 * @returns {Object} Returns the array of property values. 3420 */ 3421 function baseValues(object, props) { 3422 return arrayMap(props, function(key) { 3423 return object[key]; 3424 }); 3425 } 3426 3427 /** 3428 * Checks if a `cache` value for `key` exists. 3429 * 3430 * @private 3431 * @param {Object} cache The cache to query. 3432 * @param {string} key The key of the entry to check. 3433 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 3434 */ 3435 function cacheHas(cache, key) { 3436 return cache.has(key); 3437 } 3438 3439 /** 3440 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 3441 * that is not found in the character symbols. 3442 * 3443 * @private 3444 * @param {Array} strSymbols The string symbols to inspect. 3445 * @param {Array} chrSymbols The character symbols to find. 3446 * @returns {number} Returns the index of the first unmatched string symbol. 3447 */ 3448 function charsStartIndex(strSymbols, chrSymbols) { 3449 var index = -1, 3450 length = strSymbols.length; 3451 3452 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 3453 return index; 3454 } 3455 3456 /** 3457 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 3458 * that is not found in the character symbols. 3459 * 3460 * @private 3461 * @param {Array} strSymbols The string symbols to inspect. 3462 * @param {Array} chrSymbols The character symbols to find. 3463 * @returns {number} Returns the index of the last unmatched string symbol. 3464 */ 3465 function charsEndIndex(strSymbols, chrSymbols) { 3466 var index = strSymbols.length; 3467 3468 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 3469 return index; 3470 } 3471 3472 /** 3473 * Gets the number of `placeholder` occurrences in `array`. 3474 * 3475 * @private 3476 * @param {Array} array The array to inspect. 3477 * @param {*} placeholder The placeholder to search for. 3478 * @returns {number} Returns the placeholder count. 3479 */ 3480 function countHolders(array, placeholder) { 3481 var length = array.length, 3482 result = 0; 3483 3484 while (length--) { 3485 if (array[length] === placeholder) { 3486 ++result; 3487 } 3488 } 3489 return result; 3490 } 3491 3492 /** 3493 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 3494 * letters to basic Latin letters. 3495 * 3496 * @private 3497 * @param {string} letter The matched letter to deburr. 3498 * @returns {string} Returns the deburred letter. 3499 */ 3500 var deburrLetter = basePropertyOf(deburredLetters); 3501 3502 /** 3503 * Used by `_.escape` to convert characters to HTML entities. 3504 * 3505 * @private 3506 * @param {string} chr The matched character to escape. 3507 * @returns {string} Returns the escaped character. 3508 */ 3509 var escapeHtmlChar = basePropertyOf(htmlEscapes); 3510 3511 /** 3512 * Used by `_.template` to escape characters for inclusion in compiled string literals. 3513 * 3514 * @private 3515 * @param {string} chr The matched character to escape. 3516 * @returns {string} Returns the escaped character. 3517 */ 3518 function escapeStringChar(chr) { 3519 return '\\' + stringEscapes[chr]; 3520 } 3521 3522 /** 3523 * Gets the value at `key` of `object`. 3524 * 3525 * @private 3526 * @param {Object} [object] The object to query. 3527 * @param {string} key The key of the property to get. 3528 * @returns {*} Returns the property value. 3529 */ 3530 function getValue(object, key) { 3531 return object == null ? undefined : object[key]; 3532 } 3533 3534 /** 3535 * Checks if `string` contains Unicode symbols. 3536 * 3537 * @private 3538 * @param {string} string The string to inspect. 3539 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 3540 */ 3541 function hasUnicode(string) { 3542 return reHasUnicode.test(string); 3543 } 3544 3545 /** 3546 * Checks if `string` contains a word composed of Unicode symbols. 3547 * 3548 * @private 3549 * @param {string} string The string to inspect. 3550 * @returns {boolean} Returns `true` if a word is found, else `false`. 3551 */ 3552 function hasUnicodeWord(string) { 3553 return reHasUnicodeWord.test(string); 3554 } 3555 3556 /** 3557 * Converts `iterator` to an array. 3558 * 3559 * @private 3560 * @param {Object} iterator The iterator to convert. 3561 * @returns {Array} Returns the converted array. 3562 */ 3563 function iteratorToArray(iterator) { 3564 var data, 3565 result = []; 3566 3567 while (!(data = iterator.next()).done) { 3568 result.push(data.value); 3569 } 3570 return result; 3571 } 3572 3573 /** 3574 * Converts `map` to its key-value pairs. 3575 * 3576 * @private 3577 * @param {Object} map The map to convert. 3578 * @returns {Array} Returns the key-value pairs. 3579 */ 3580 function mapToArray(map) { 3581 var index = -1, 3582 result = Array(map.size); 3583 3584 map.forEach(function(value, key) { 3585 result[++index] = [key, value]; 3586 }); 3587 return result; 3588 } 3589 3590 /** 3591 * Creates a unary function that invokes `func` with its argument transformed. 3592 * 3593 * @private 3594 * @param {Function} func The function to wrap. 3595 * @param {Function} transform The argument transform. 3596 * @returns {Function} Returns the new function. 3597 */ 3598 function overArg(func, transform) { 3599 return function(arg) { 3600 return func(transform(arg)); 3601 }; 3602 } 3603 3604 /** 3605 * Replaces all `placeholder` elements in `array` with an internal placeholder 3606 * and returns an array of their indexes. 3607 * 3608 * @private 3609 * @param {Array} array The array to modify. 3610 * @param {*} placeholder The placeholder to replace. 3611 * @returns {Array} Returns the new array of placeholder indexes. 3612 */ 3613 function replaceHolders(array, placeholder) { 3614 var index = -1, 3615 length = array.length, 3616 resIndex = 0, 3617 result = []; 3618 3619 while (++index < length) { 3620 var value = array[index]; 3621 if (value === placeholder || value === PLACEHOLDER) { 3622 array[index] = PLACEHOLDER; 3623 result[resIndex++] = index; 3624 } 3625 } 3626 return result; 3627 } 3628 3629 /** 3630 * Gets the value at `key`, unless `key` is "__proto__". 3631 * 3632 * @private 3633 * @param {Object} object The object to query. 3634 * @param {string} key The key of the property to get. 3635 * @returns {*} Returns the property value. 3636 */ 3637 function safeGet(object, key) { 3638 return key == '__proto__' 3639 ? undefined 3640 : object[key]; 3641 } 3642 3643 /** 3644 * Converts `set` to an array of its values. 3645 * 3646 * @private 3647 * @param {Object} set The set to convert. 3648 * @returns {Array} Returns the values. 3649 */ 3650 function setToArray(set) { 3651 var index = -1, 3652 result = Array(set.size); 3653 3654 set.forEach(function(value) { 3655 result[++index] = value; 3656 }); 3657 return result; 3658 } 3659 3660 /** 3661 * Converts `set` to its value-value pairs. 3662 * 3663 * @private 3664 * @param {Object} set The set to convert. 3665 * @returns {Array} Returns the value-value pairs. 3666 */ 3667 function setToPairs(set) { 3668 var index = -1, 3669 result = Array(set.size); 3670 3671 set.forEach(function(value) { 3672 result[++index] = [value, value]; 3673 }); 3674 return result; 3675 } 3676 3677 /** 3678 * A specialized version of `_.indexOf` which performs strict equality 3679 * comparisons of values, i.e. `===`. 3680 * 3681 * @private 3682 * @param {Array} array The array to inspect. 3683 * @param {*} value The value to search for. 3684 * @param {number} fromIndex The index to search from. 3685 * @returns {number} Returns the index of the matched value, else `-1`. 3686 */ 3687 function strictIndexOf(array, value, fromIndex) { 3688 var index = fromIndex - 1, 3689 length = array.length; 3690 3691 while (++index < length) { 3692 if (array[index] === value) { 3693 return index; 3694 } 3695 } 3696 return -1; 3697 } 3698 3699 /** 3700 * A specialized version of `_.lastIndexOf` which performs strict equality 3701 * comparisons of values, i.e. `===`. 3702 * 3703 * @private 3704 * @param {Array} array The array to inspect. 3705 * @param {*} value The value to search for. 3706 * @param {number} fromIndex The index to search from. 3707 * @returns {number} Returns the index of the matched value, else `-1`. 3708 */ 3709 function strictLastIndexOf(array, value, fromIndex) { 3710 var index = fromIndex + 1; 3711 while (index--) { 3712 if (array[index] === value) { 3713 return index; 3714 } 3715 } 3716 return index; 3717 } 3718 3719 /** 3720 * Gets the number of symbols in `string`. 3721 * 3722 * @private 3723 * @param {string} string The string to inspect. 3724 * @returns {number} Returns the string size. 3725 */ 3726 function stringSize(string) { 3727 return hasUnicode(string) 3728 ? unicodeSize(string) 3729 : asciiSize(string); 3730 } 3731 3732 /** 3733 * Converts `string` to an array. 3734 * 3735 * @private 3736 * @param {string} string The string to convert. 3737 * @returns {Array} Returns the converted array. 3738 */ 3739 function stringToArray(string) { 3740 return hasUnicode(string) 3741 ? unicodeToArray(string) 3742 : asciiToArray(string); 3743 } 3744 3745 /** 3746 * Used by `_.unescape` to convert HTML entities to characters. 3747 * 3748 * @private 3749 * @param {string} chr The matched character to unescape. 3750 * @returns {string} Returns the unescaped character. 3751 */ 3752 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 3753 3754 /** 3755 * Gets the size of a Unicode `string`. 3756 * 3757 * @private 3758 * @param {string} string The string inspect. 3759 * @returns {number} Returns the string size. 3760 */ 3761 function unicodeSize(string) { 3762 var result = reUnicode.lastIndex = 0; 3763 while (reUnicode.test(string)) { 3764 ++result; 3765 } 3766 return result; 3767 } 3768 3769 /** 3770 * Converts a Unicode `string` to an array. 3771 * 3772 * @private 3773 * @param {string} string The string to convert. 3774 * @returns {Array} Returns the converted array. 3775 */ 3776 function unicodeToArray(string) { 3777 return string.match(reUnicode) || []; 3778 } 3779 3780 /** 3781 * Splits a Unicode `string` into an array of its words. 3782 * 3783 * @private 3784 * @param {string} The string to inspect. 3785 * @returns {Array} Returns the words of `string`. 3786 */ 3787 function unicodeWords(string) { 3788 return string.match(reUnicodeWord) || []; 3789 } 3790 3791 /*--------------------------------------------------------------------------*/ 3792 3793 /** 3794 * Create a new pristine `lodash` function using the `context` object. 3795 * 3796 * @static 3797 * @memberOf _ 3798 * @since 1.1.0 3799 * @category Util 3800 * @param {Object} [context=root] The context object. 3801 * @returns {Function} Returns a new `lodash` function. 3802 * @example 3803 * 3804 * _.mixin({ 'foo': _.constant('foo') }); 3805 * 3806 * var lodash = _.runInContext(); 3807 * lodash.mixin({ 'bar': lodash.constant('bar') }); 3808 * 3809 * _.isFunction(_.foo); 3810 * // => true 3811 * _.isFunction(_.bar); 3812 * // => false 3813 * 3814 * lodash.isFunction(lodash.foo); 3815 * // => false 3816 * lodash.isFunction(lodash.bar); 3817 * // => true 3818 * 3819 * // Create a suped-up `defer` in Node.js. 3820 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 3821 */ 3822 var runInContext = (function runInContext(context) { 3823 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 3824 3825 /** Built-in constructor references. */ 3826 var Array = context.Array, 3827 Date = context.Date, 3828 Error = context.Error, 3829 Function = context.Function, 3830 Math = context.Math, 3831 Object = context.Object, 3832 RegExp = context.RegExp, 3833 String = context.String, 3834 TypeError = context.TypeError; 3835 3836 /** Used for built-in method references. */ 3837 var arrayProto = Array.prototype, 3838 funcProto = Function.prototype, 3839 objectProto = Object.prototype; 3840 3841 /** Used to detect overreaching core-js shims. */ 3842 var coreJsData = context['__core-js_shared__']; 3843 3844 /** Used to resolve the decompiled source of functions. */ 3845 var funcToString = funcProto.toString; 3846 3847 /** Used to check objects for own properties. */ 3848 var hasOwnProperty = objectProto.hasOwnProperty; 3849 3850 /** Used to generate unique IDs. */ 3851 var idCounter = 0; 3852 3853 /** Used to detect methods masquerading as native. */ 3854 var maskSrcKey = (function() { 3855 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 3856 return uid ? ('Symbol(src)_1.' + uid) : ''; 3857 }()); 3858 3859 /** 3860 * Used to resolve the 3861 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 3862 * of values. 3863 */ 3864 var nativeObjectToString = objectProto.toString; 3865 3866 /** Used to infer the `Object` constructor. */ 3867 var objectCtorString = funcToString.call(Object); 3868 3869 /** Used to restore the original `_` reference in `_.noConflict`. */ 3870 var oldDash = root._; 3871 3872 /** Used to detect if a method is native. */ 3873 var reIsNative = RegExp('^' + 3874 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 3875 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 3876 ); 3877 3878 /** Built-in value references. */ 3879 var Buffer = moduleExports ? context.Buffer : undefined, 3880 Symbol = context.Symbol, 3881 Uint8Array = context.Uint8Array, 3882 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 3883 getPrototype = overArg(Object.getPrototypeOf, Object), 3884 objectCreate = Object.create, 3885 propertyIsEnumerable = objectProto.propertyIsEnumerable, 3886 splice = arrayProto.splice, 3887 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 3888 symIterator = Symbol ? Symbol.iterator : undefined, 3889 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 3890 3891 var defineProperty = (function() { 3892 try { 3893 var func = getNative(Object, 'defineProperty'); 3894 func({}, '', {}); 3895 return func; 3896 } catch (e) {} 3897 }()); 3898 3899 /** Mocked built-ins. */ 3900 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 3901 ctxNow = Date && Date.now !== root.Date.now && Date.now, 3902 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 3903 3904 /* Built-in method references for those with the same name as other `lodash` methods. */ 3905 var nativeCeil = Math.ceil, 3906 nativeFloor = Math.floor, 3907 nativeGetSymbols = Object.getOwnPropertySymbols, 3908 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 3909 nativeIsFinite = context.isFinite, 3910 nativeJoin = arrayProto.join, 3911 nativeKeys = overArg(Object.keys, Object), 3912 nativeMax = Math.max, 3913 nativeMin = Math.min, 3914 nativeNow = Date.now, 3915 nativeParseInt = context.parseInt, 3916 nativeRandom = Math.random, 3917 nativeReverse = arrayProto.reverse; 3918 3919 /* Built-in method references that are verified to be native. */ 3920 var DataView = getNative(context, 'DataView'), 3921 Map = getNative(context, 'Map'), 3922 Promise = getNative(context, 'Promise'), 3923 Set = getNative(context, 'Set'), 3924 WeakMap = getNative(context, 'WeakMap'), 3925 nativeCreate = getNative(Object, 'create'); 3926 3927 /** Used to store function metadata. */ 3928 var metaMap = WeakMap && new WeakMap; 3929 3930 /** Used to lookup unminified function names. */ 3931 var realNames = {}; 3932 3933 /** Used to detect maps, sets, and weakmaps. */ 3934 var dataViewCtorString = toSource(DataView), 3935 mapCtorString = toSource(Map), 3936 promiseCtorString = toSource(Promise), 3937 setCtorString = toSource(Set), 3938 weakMapCtorString = toSource(WeakMap); 3939 3940 /** Used to convert symbols to primitives and strings. */ 3941 var symbolProto = Symbol ? Symbol.prototype : undefined, 3942 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 3943 symbolToString = symbolProto ? symbolProto.toString : undefined; 3944 3945 /*------------------------------------------------------------------------*/ 3946 3947 /** 3948 * Creates a `lodash` object which wraps `value` to enable implicit method 3949 * chain sequences. Methods that operate on and return arrays, collections, 3950 * and functions can be chained together. Methods that retrieve a single value 3951 * or may return a primitive value will automatically end the chain sequence 3952 * and return the unwrapped value. Otherwise, the value must be unwrapped 3953 * with `_#value`. 3954 * 3955 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 3956 * enabled using `_.chain`. 3957 * 3958 * The execution of chained methods is lazy, that is, it's deferred until 3959 * `_#value` is implicitly or explicitly called. 3960 * 3961 * Lazy evaluation allows several methods to support shortcut fusion. 3962 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 3963 * the creation of intermediate arrays and can greatly reduce the number of 3964 * iteratee executions. Sections of a chain sequence qualify for shortcut 3965 * fusion if the section is applied to an array and iteratees accept only 3966 * one argument. The heuristic for whether a section qualifies for shortcut 3967 * fusion is subject to change. 3968 * 3969 * Chaining is supported in custom builds as long as the `_#value` method is 3970 * directly or indirectly included in the build. 3971 * 3972 * In addition to lodash methods, wrappers have `Array` and `String` methods. 3973 * 3974 * The wrapper `Array` methods are: 3975 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 3976 * 3977 * The wrapper `String` methods are: 3978 * `replace` and `split` 3979 * 3980 * The wrapper methods that support shortcut fusion are: 3981 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 3982 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 3983 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 3984 * 3985 * The chainable wrapper methods are: 3986 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 3987 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 3988 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 3989 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 3990 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 3991 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 3992 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 3993 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 3994 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 3995 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 3996 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 3997 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 3998 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 3999 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 4000 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 4001 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 4002 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 4003 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 4004 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 4005 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 4006 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 4007 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 4008 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 4009 * `zipObject`, `zipObjectDeep`, and `zipWith` 4010 * 4011 * The wrapper methods that are **not** chainable by default are: 4012 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 4013 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 4014 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 4015 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 4016 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 4017 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 4018 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 4019 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 4020 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 4021 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 4022 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 4023 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 4024 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 4025 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 4026 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 4027 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 4028 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 4029 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 4030 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 4031 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 4032 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 4033 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 4034 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 4035 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 4036 * `upperFirst`, `value`, and `words` 4037 * 4038 * @name _ 4039 * @constructor 4040 * @category Seq 4041 * @param {*} value The value to wrap in a `lodash` instance. 4042 * @returns {Object} Returns the new `lodash` wrapper instance. 4043 * @example 4044 * 4045 * function square(n) { 4046 * return n * n; 4047 * } 4048 * 4049 * var wrapped = _([1, 2, 3]); 4050 * 4051 * // Returns an unwrapped value. 4052 * wrapped.reduce(_.add); 4053 * // => 6 4054 * 4055 * // Returns a wrapped value. 4056 * var squares = wrapped.map(square); 4057 * 4058 * _.isArray(squares); 4059 * // => false 4060 * 4061 * _.isArray(squares.value()); 4062 * // => true 4063 */ 4064 function lodash(value) { 4065 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 4066 if (value instanceof LodashWrapper) { 4067 return value; 4068 } 4069 if (hasOwnProperty.call(value, '__wrapped__')) { 4070 return wrapperClone(value); 4071 } 4072 } 4073 return new LodashWrapper(value); 4074 } 4075 4076 /** 4077 * The base implementation of `_.create` without support for assigning 4078 * properties to the created object. 4079 * 4080 * @private 4081 * @param {Object} proto The object to inherit from. 4082 * @returns {Object} Returns the new object. 4083 */ 4084 var baseCreate = (function() { 4085 function object() {} 4086 return function(proto) { 4087 if (!isObject(proto)) { 4088 return {}; 4089 } 4090 if (objectCreate) { 4091 return objectCreate(proto); 4092 } 4093 object.prototype = proto; 4094 var result = new object; 4095 object.prototype = undefined; 4096 return result; 4097 }; 4098 }()); 4099 4100 /** 4101 * The function whose prototype chain sequence wrappers inherit from. 4102 * 4103 * @private 4104 */ 4105 function baseLodash() { 4106 // No operation performed. 4107 } 4108 4109 /** 4110 * The base constructor for creating `lodash` wrapper objects. 4111 * 4112 * @private 4113 * @param {*} value The value to wrap. 4114 * @param {boolean} [chainAll] Enable explicit method chain sequences. 4115 */ 4116 function LodashWrapper(value, chainAll) { 4117 this.__wrapped__ = value; 4118 this.__actions__ = []; 4119 this.__chain__ = !!chainAll; 4120 this.__index__ = 0; 4121 this.__values__ = undefined; 4122 } 4123 4124 /** 4125 * By default, the template delimiters used by lodash are like those in 4126 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 4127 * following template settings to use alternative delimiters. 4128 * 4129 * @static 4130 * @memberOf _ 4131 * @type {Object} 4132 */ 4133 lodash.templateSettings = { 4134 4135 /** 4136 * Used to detect `data` property values to be HTML-escaped. 4137 * 4138 * @memberOf _.templateSettings 4139 * @type {RegExp} 4140 */ 4141 'escape': reEscape, 4142 4143 /** 4144 * Used to detect code to be evaluated. 4145 * 4146 * @memberOf _.templateSettings 4147 * @type {RegExp} 4148 */ 4149 'evaluate': reEvaluate, 4150 4151 /** 4152 * Used to detect `data` property values to inject. 4153 * 4154 * @memberOf _.templateSettings 4155 * @type {RegExp} 4156 */ 4157 'interpolate': reInterpolate, 4158 4159 /** 4160 * Used to reference the data object in the template text. 4161 * 4162 * @memberOf _.templateSettings 4163 * @type {string} 4164 */ 4165 'variable': '', 4166 4167 /** 4168 * Used to import variables into the compiled template. 4169 * 4170 * @memberOf _.templateSettings 4171 * @type {Object} 4172 */ 4173 'imports': { 4174 4175 /** 4176 * A reference to the `lodash` function. 4177 * 4178 * @memberOf _.templateSettings.imports 4179 * @type {Function} 4180 */ 4181 '_': lodash 4182 } 4183 }; 4184 4185 // Ensure wrappers are instances of `baseLodash`. 4186 lodash.prototype = baseLodash.prototype; 4187 lodash.prototype.constructor = lodash; 4188 4189 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 4190 LodashWrapper.prototype.constructor = LodashWrapper; 4191 4192 /*------------------------------------------------------------------------*/ 4193 4194 /** 4195 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 4196 * 4197 * @private 4198 * @constructor 4199 * @param {*} value The value to wrap. 4200 */ 4201 function LazyWrapper(value) { 4202 this.__wrapped__ = value; 4203 this.__actions__ = []; 4204 this.__dir__ = 1; 4205 this.__filtered__ = false; 4206 this.__iteratees__ = []; 4207 this.__takeCount__ = MAX_ARRAY_LENGTH; 4208 this.__views__ = []; 4209 } 4210 4211 /** 4212 * Creates a clone of the lazy wrapper object. 4213 * 4214 * @private 4215 * @name clone 4216 * @memberOf LazyWrapper 4217 * @returns {Object} Returns the cloned `LazyWrapper` object. 4218 */ 4219 function lazyClone() { 4220 var result = new LazyWrapper(this.__wrapped__); 4221 result.__actions__ = copyArray(this.__actions__); 4222 result.__dir__ = this.__dir__; 4223 result.__filtered__ = this.__filtered__; 4224 result.__iteratees__ = copyArray(this.__iteratees__); 4225 result.__takeCount__ = this.__takeCount__; 4226 result.__views__ = copyArray(this.__views__); 4227 return result; 4228 } 4229 4230 /** 4231 * Reverses the direction of lazy iteration. 4232 * 4233 * @private 4234 * @name reverse 4235 * @memberOf LazyWrapper 4236 * @returns {Object} Returns the new reversed `LazyWrapper` object. 4237 */ 4238 function lazyReverse() { 4239 if (this.__filtered__) { 4240 var result = new LazyWrapper(this); 4241 result.__dir__ = -1; 4242 result.__filtered__ = true; 4243 } else { 4244 result = this.clone(); 4245 result.__dir__ *= -1; 4246 } 4247 return result; 4248 } 4249 4250 /** 4251 * Extracts the unwrapped value from its lazy wrapper. 4252 * 4253 * @private 4254 * @name value 4255 * @memberOf LazyWrapper 4256 * @returns {*} Returns the unwrapped value. 4257 */ 4258 function lazyValue() { 4259 var array = this.__wrapped__.value(), 4260 dir = this.__dir__, 4261 isArr = isArray(array), 4262 isRight = dir < 0, 4263 arrLength = isArr ? array.length : 0, 4264 view = getView(0, arrLength, this.__views__), 4265 start = view.start, 4266 end = view.end, 4267 length = end - start, 4268 index = isRight ? end : (start - 1), 4269 iteratees = this.__iteratees__, 4270 iterLength = iteratees.length, 4271 resIndex = 0, 4272 takeCount = nativeMin(length, this.__takeCount__); 4273 4274 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 4275 return baseWrapperValue(array, this.__actions__); 4276 } 4277 var result = []; 4278 4279 outer: 4280 while (length-- && resIndex < takeCount) { 4281 index += dir; 4282 4283 var iterIndex = -1, 4284 value = array[index]; 4285 4286 while (++iterIndex < iterLength) { 4287 var data = iteratees[iterIndex], 4288 iteratee = data.iteratee, 4289 type = data.type, 4290 computed = iteratee(value); 4291 4292 if (type == LAZY_MAP_FLAG) { 4293 value = computed; 4294 } else if (!computed) { 4295 if (type == LAZY_FILTER_FLAG) { 4296 continue outer; 4297 } else { 4298 break outer; 4299 } 4300 } 4301 } 4302 result[resIndex++] = value; 4303 } 4304 return result; 4305 } 4306 4307 // Ensure `LazyWrapper` is an instance of `baseLodash`. 4308 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 4309 LazyWrapper.prototype.constructor = LazyWrapper; 4310 4311 /*------------------------------------------------------------------------*/ 4312 4313 /** 4314 * Creates a hash object. 4315 * 4316 * @private 4317 * @constructor 4318 * @param {Array} [entries] The key-value pairs to cache. 4319 */ 4320 function Hash(entries) { 4321 var index = -1, 4322 length = entries == null ? 0 : entries.length; 4323 4324 this.clear(); 4325 while (++index < length) { 4326 var entry = entries[index]; 4327 this.set(entry[0], entry[1]); 4328 } 4329 } 4330 4331 /** 4332 * Removes all key-value entries from the hash. 4333 * 4334 * @private 4335 * @name clear 4336 * @memberOf Hash 4337 */ 4338 function hashClear() { 4339 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 4340 this.size = 0; 4341 } 4342 4343 /** 4344 * Removes `key` and its value from the hash. 4345 * 4346 * @private 4347 * @name delete 4348 * @memberOf Hash 4349 * @param {Object} hash The hash to modify. 4350 * @param {string} key The key of the value to remove. 4351 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4352 */ 4353 function hashDelete(key) { 4354 var result = this.has(key) && delete this.__data__[key]; 4355 this.size -= result ? 1 : 0; 4356 return result; 4357 } 4358 4359 /** 4360 * Gets the hash value for `key`. 4361 * 4362 * @private 4363 * @name get 4364 * @memberOf Hash 4365 * @param {string} key The key of the value to get. 4366 * @returns {*} Returns the entry value. 4367 */ 4368 function hashGet(key) { 4369 var data = this.__data__; 4370 if (nativeCreate) { 4371 var result = data[key]; 4372 return result === HASH_UNDEFINED ? undefined : result; 4373 } 4374 return hasOwnProperty.call(data, key) ? data[key] : undefined; 4375 } 4376 4377 /** 4378 * Checks if a hash value for `key` exists. 4379 * 4380 * @private 4381 * @name has 4382 * @memberOf Hash 4383 * @param {string} key The key of the entry to check. 4384 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4385 */ 4386 function hashHas(key) { 4387 var data = this.__data__; 4388 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 4389 } 4390 4391 /** 4392 * Sets the hash `key` to `value`. 4393 * 4394 * @private 4395 * @name set 4396 * @memberOf Hash 4397 * @param {string} key The key of the value to set. 4398 * @param {*} value The value to set. 4399 * @returns {Object} Returns the hash instance. 4400 */ 4401 function hashSet(key, value) { 4402 var data = this.__data__; 4403 this.size += this.has(key) ? 0 : 1; 4404 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 4405 return this; 4406 } 4407 4408 // Add methods to `Hash`. 4409 Hash.prototype.clear = hashClear; 4410 Hash.prototype['delete'] = hashDelete; 4411 Hash.prototype.get = hashGet; 4412 Hash.prototype.has = hashHas; 4413 Hash.prototype.set = hashSet; 4414 4415 /*------------------------------------------------------------------------*/ 4416 4417 /** 4418 * Creates an list cache object. 4419 * 4420 * @private 4421 * @constructor 4422 * @param {Array} [entries] The key-value pairs to cache. 4423 */ 4424 function ListCache(entries) { 4425 var index = -1, 4426 length = entries == null ? 0 : entries.length; 4427 4428 this.clear(); 4429 while (++index < length) { 4430 var entry = entries[index]; 4431 this.set(entry[0], entry[1]); 4432 } 4433 } 4434 4435 /** 4436 * Removes all key-value entries from the list cache. 4437 * 4438 * @private 4439 * @name clear 4440 * @memberOf ListCache 4441 */ 4442 function listCacheClear() { 4443 this.__data__ = []; 4444 this.size = 0; 4445 } 4446 4447 /** 4448 * Removes `key` and its value from the list cache. 4449 * 4450 * @private 4451 * @name delete 4452 * @memberOf ListCache 4453 * @param {string} key The key of the value to remove. 4454 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4455 */ 4456 function listCacheDelete(key) { 4457 var data = this.__data__, 4458 index = assocIndexOf(data, key); 4459 4460 if (index < 0) { 4461 return false; 4462 } 4463 var lastIndex = data.length - 1; 4464 if (index == lastIndex) { 4465 data.pop(); 4466 } else { 4467 splice.call(data, index, 1); 4468 } 4469 --this.size; 4470 return true; 4471 } 4472 4473 /** 4474 * Gets the list cache value for `key`. 4475 * 4476 * @private 4477 * @name get 4478 * @memberOf ListCache 4479 * @param {string} key The key of the value to get. 4480 * @returns {*} Returns the entry value. 4481 */ 4482 function listCacheGet(key) { 4483 var data = this.__data__, 4484 index = assocIndexOf(data, key); 4485 4486 return index < 0 ? undefined : data[index][1]; 4487 } 4488 4489 /** 4490 * Checks if a list cache value for `key` exists. 4491 * 4492 * @private 4493 * @name has 4494 * @memberOf ListCache 4495 * @param {string} key The key of the entry to check. 4496 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4497 */ 4498 function listCacheHas(key) { 4499 return assocIndexOf(this.__data__, key) > -1; 4500 } 4501 4502 /** 4503 * Sets the list cache `key` to `value`. 4504 * 4505 * @private 4506 * @name set 4507 * @memberOf ListCache 4508 * @param {string} key The key of the value to set. 4509 * @param {*} value The value to set. 4510 * @returns {Object} Returns the list cache instance. 4511 */ 4512 function listCacheSet(key, value) { 4513 var data = this.__data__, 4514 index = assocIndexOf(data, key); 4515 4516 if (index < 0) { 4517 ++this.size; 4518 data.push([key, value]); 4519 } else { 4520 data[index][1] = value; 4521 } 4522 return this; 4523 } 4524 4525 // Add methods to `ListCache`. 4526 ListCache.prototype.clear = listCacheClear; 4527 ListCache.prototype['delete'] = listCacheDelete; 4528 ListCache.prototype.get = listCacheGet; 4529 ListCache.prototype.has = listCacheHas; 4530 ListCache.prototype.set = listCacheSet; 4531 4532 /*------------------------------------------------------------------------*/ 4533 4534 /** 4535 * Creates a map cache object to store key-value pairs. 4536 * 4537 * @private 4538 * @constructor 4539 * @param {Array} [entries] The key-value pairs to cache. 4540 */ 4541 function MapCache(entries) { 4542 var index = -1, 4543 length = entries == null ? 0 : entries.length; 4544 4545 this.clear(); 4546 while (++index < length) { 4547 var entry = entries[index]; 4548 this.set(entry[0], entry[1]); 4549 } 4550 } 4551 4552 /** 4553 * Removes all key-value entries from the map. 4554 * 4555 * @private 4556 * @name clear 4557 * @memberOf MapCache 4558 */ 4559 function mapCacheClear() { 4560 this.size = 0; 4561 this.__data__ = { 4562 'hash': new Hash, 4563 'map': new (Map || ListCache), 4564 'string': new Hash 4565 }; 4566 } 4567 4568 /** 4569 * Removes `key` and its value from the map. 4570 * 4571 * @private 4572 * @name delete 4573 * @memberOf MapCache 4574 * @param {string} key The key of the value to remove. 4575 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4576 */ 4577 function mapCacheDelete(key) { 4578 var result = getMapData(this, key)['delete'](key); 4579 this.size -= result ? 1 : 0; 4580 return result; 4581 } 4582 4583 /** 4584 * Gets the map value for `key`. 4585 * 4586 * @private 4587 * @name get 4588 * @memberOf MapCache 4589 * @param {string} key The key of the value to get. 4590 * @returns {*} Returns the entry value. 4591 */ 4592 function mapCacheGet(key) { 4593 return getMapData(this, key).get(key); 4594 } 4595 4596 /** 4597 * Checks if a map value for `key` exists. 4598 * 4599 * @private 4600 * @name has 4601 * @memberOf MapCache 4602 * @param {string} key The key of the entry to check. 4603 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4604 */ 4605 function mapCacheHas(key) { 4606 return getMapData(this, key).has(key); 4607 } 4608 4609 /** 4610 * Sets the map `key` to `value`. 4611 * 4612 * @private 4613 * @name set 4614 * @memberOf MapCache 4615 * @param {string} key The key of the value to set. 4616 * @param {*} value The value to set. 4617 * @returns {Object} Returns the map cache instance. 4618 */ 4619 function mapCacheSet(key, value) { 4620 var data = getMapData(this, key), 4621 size = data.size; 4622 4623 data.set(key, value); 4624 this.size += data.size == size ? 0 : 1; 4625 return this; 4626 } 4627 4628 // Add methods to `MapCache`. 4629 MapCache.prototype.clear = mapCacheClear; 4630 MapCache.prototype['delete'] = mapCacheDelete; 4631 MapCache.prototype.get = mapCacheGet; 4632 MapCache.prototype.has = mapCacheHas; 4633 MapCache.prototype.set = mapCacheSet; 4634 4635 /*------------------------------------------------------------------------*/ 4636 4637 /** 4638 * 4639 * Creates an array cache object to store unique values. 4640 * 4641 * @private 4642 * @constructor 4643 * @param {Array} [values] The values to cache. 4644 */ 4645 function SetCache(values) { 4646 var index = -1, 4647 length = values == null ? 0 : values.length; 4648 4649 this.__data__ = new MapCache; 4650 while (++index < length) { 4651 this.add(values[index]); 4652 } 4653 } 4654 4655 /** 4656 * Adds `value` to the array cache. 4657 * 4658 * @private 4659 * @name add 4660 * @memberOf SetCache 4661 * @alias push 4662 * @param {*} value The value to cache. 4663 * @returns {Object} Returns the cache instance. 4664 */ 4665 function setCacheAdd(value) { 4666 this.__data__.set(value, HASH_UNDEFINED); 4667 return this; 4668 } 4669 4670 /** 4671 * Checks if `value` is in the array cache. 4672 * 4673 * @private 4674 * @name has 4675 * @memberOf SetCache 4676 * @param {*} value The value to search for. 4677 * @returns {number} Returns `true` if `value` is found, else `false`. 4678 */ 4679 function setCacheHas(value) { 4680 return this.__data__.has(value); 4681 } 4682 4683 // Add methods to `SetCache`. 4684 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 4685 SetCache.prototype.has = setCacheHas; 4686 4687 /*------------------------------------------------------------------------*/ 4688 4689 /** 4690 * Creates a stack cache object to store key-value pairs. 4691 * 4692 * @private 4693 * @constructor 4694 * @param {Array} [entries] The key-value pairs to cache. 4695 */ 4696 function Stack(entries) { 4697 var data = this.__data__ = new ListCache(entries); 4698 this.size = data.size; 4699 } 4700 4701 /** 4702 * Removes all key-value entries from the stack. 4703 * 4704 * @private 4705 * @name clear 4706 * @memberOf Stack 4707 */ 4708 function stackClear() { 4709 this.__data__ = new ListCache; 4710 this.size = 0; 4711 } 4712 4713 /** 4714 * Removes `key` and its value from the stack. 4715 * 4716 * @private 4717 * @name delete 4718 * @memberOf Stack 4719 * @param {string} key The key of the value to remove. 4720 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4721 */ 4722 function stackDelete(key) { 4723 var data = this.__data__, 4724 result = data['delete'](key); 4725 4726 this.size = data.size; 4727 return result; 4728 } 4729 4730 /** 4731 * Gets the stack value for `key`. 4732 * 4733 * @private 4734 * @name get 4735 * @memberOf Stack 4736 * @param {string} key The key of the value to get. 4737 * @returns {*} Returns the entry value. 4738 */ 4739 function stackGet(key) { 4740 return this.__data__.get(key); 4741 } 4742 4743 /** 4744 * Checks if a stack value for `key` exists. 4745 * 4746 * @private 4747 * @name has 4748 * @memberOf Stack 4749 * @param {string} key The key of the entry to check. 4750 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4751 */ 4752 function stackHas(key) { 4753 return this.__data__.has(key); 4754 } 4755 4756 /** 4757 * Sets the stack `key` to `value`. 4758 * 4759 * @private 4760 * @name set 4761 * @memberOf Stack 4762 * @param {string} key The key of the value to set. 4763 * @param {*} value The value to set. 4764 * @returns {Object} Returns the stack cache instance. 4765 */ 4766 function stackSet(key, value) { 4767 var data = this.__data__; 4768 if (data instanceof ListCache) { 4769 var pairs = data.__data__; 4770 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 4771 pairs.push([key, value]); 4772 this.size = ++data.size; 4773 return this; 4774 } 4775 data = this.__data__ = new MapCache(pairs); 4776 } 4777 data.set(key, value); 4778 this.size = data.size; 4779 return this; 4780 } 4781 4782 // Add methods to `Stack`. 4783 Stack.prototype.clear = stackClear; 4784 Stack.prototype['delete'] = stackDelete; 4785 Stack.prototype.get = stackGet; 4786 Stack.prototype.has = stackHas; 4787 Stack.prototype.set = stackSet; 4788 4789 /*------------------------------------------------------------------------*/ 4790 4791 /** 4792 * Creates an array of the enumerable property names of the array-like `value`. 4793 * 4794 * @private 4795 * @param {*} value The value to query. 4796 * @param {boolean} inherited Specify returning inherited property names. 4797 * @returns {Array} Returns the array of property names. 4798 */ 4799 function arrayLikeKeys(value, inherited) { 4800 var isArr = isArray(value), 4801 isArg = !isArr && isArguments(value), 4802 isBuff = !isArr && !isArg && isBuffer(value), 4803 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 4804 skipIndexes = isArr || isArg || isBuff || isType, 4805 result = skipIndexes ? baseTimes(value.length, String) : [], 4806 length = result.length; 4807 4808 for (var key in value) { 4809 if ((inherited || hasOwnProperty.call(value, key)) && 4810 !(skipIndexes && ( 4811 // Safari 9 has enumerable `arguments.length` in strict mode. 4812 key == 'length' || 4813 // Node.js 0.10 has enumerable non-index properties on buffers. 4814 (isBuff && (key == 'offset' || key == 'parent')) || 4815 // PhantomJS 2 has enumerable non-index properties on typed arrays. 4816 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 4817 // Skip index properties. 4818 isIndex(key, length) 4819 ))) { 4820 result.push(key); 4821 } 4822 } 4823 return result; 4824 } 4825 4826 /** 4827 * A specialized version of `_.sample` for arrays. 4828 * 4829 * @private 4830 * @param {Array} array The array to sample. 4831 * @returns {*} Returns the random element. 4832 */ 4833 function arraySample(array) { 4834 var length = array.length; 4835 return length ? array[baseRandom(0, length - 1)] : undefined; 4836 } 4837 4838 /** 4839 * A specialized version of `_.sampleSize` for arrays. 4840 * 4841 * @private 4842 * @param {Array} array The array to sample. 4843 * @param {number} n The number of elements to sample. 4844 * @returns {Array} Returns the random elements. 4845 */ 4846 function arraySampleSize(array, n) { 4847 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 4848 } 4849 4850 /** 4851 * A specialized version of `_.shuffle` for arrays. 4852 * 4853 * @private 4854 * @param {Array} array The array to shuffle. 4855 * @returns {Array} Returns the new shuffled array. 4856 */ 4857 function arrayShuffle(array) { 4858 return shuffleSelf(copyArray(array)); 4859 } 4860 4861 /** 4862 * This function is like `assignValue` except that it doesn't assign 4863 * `undefined` values. 4864 * 4865 * @private 4866 * @param {Object} object The object to modify. 4867 * @param {string} key The key of the property to assign. 4868 * @param {*} value The value to assign. 4869 */ 4870 function assignMergeValue(object, key, value) { 4871 if ((value !== undefined && !eq(object[key], value)) || 4872 (value === undefined && !(key in object))) { 4873 baseAssignValue(object, key, value); 4874 } 4875 } 4876 4877 /** 4878 * Assigns `value` to `key` of `object` if the existing value is not equivalent 4879 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 4880 * for equality comparisons. 4881 * 4882 * @private 4883 * @param {Object} object The object to modify. 4884 * @param {string} key The key of the property to assign. 4885 * @param {*} value The value to assign. 4886 */ 4887 function assignValue(object, key, value) { 4888 var objValue = object[key]; 4889 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 4890 (value === undefined && !(key in object))) { 4891 baseAssignValue(object, key, value); 4892 } 4893 } 4894 4895 /** 4896 * Gets the index at which the `key` is found in `array` of key-value pairs. 4897 * 4898 * @private 4899 * @param {Array} array The array to inspect. 4900 * @param {*} key The key to search for. 4901 * @returns {number} Returns the index of the matched value, else `-1`. 4902 */ 4903 function assocIndexOf(array, key) { 4904 var length = array.length; 4905 while (length--) { 4906 if (eq(array[length][0], key)) { 4907 return length; 4908 } 4909 } 4910 return -1; 4911 } 4912 4913 /** 4914 * Aggregates elements of `collection` on `accumulator` with keys transformed 4915 * by `iteratee` and values set by `setter`. 4916 * 4917 * @private 4918 * @param {Array|Object} collection The collection to iterate over. 4919 * @param {Function} setter The function to set `accumulator` values. 4920 * @param {Function} iteratee The iteratee to transform keys. 4921 * @param {Object} accumulator The initial aggregated object. 4922 * @returns {Function} Returns `accumulator`. 4923 */ 4924 function baseAggregator(collection, setter, iteratee, accumulator) { 4925 baseEach(collection, function(value, key, collection) { 4926 setter(accumulator, value, iteratee(value), collection); 4927 }); 4928 return accumulator; 4929 } 4930 4931 /** 4932 * The base implementation of `_.assign` without support for multiple sources 4933 * or `customizer` functions. 4934 * 4935 * @private 4936 * @param {Object} object The destination object. 4937 * @param {Object} source The source object. 4938 * @returns {Object} Returns `object`. 4939 */ 4940 function baseAssign(object, source) { 4941 return object && copyObject(source, keys(source), object); 4942 } 4943 4944 /** 4945 * The base implementation of `_.assignIn` without support for multiple sources 4946 * or `customizer` functions. 4947 * 4948 * @private 4949 * @param {Object} object The destination object. 4950 * @param {Object} source The source object. 4951 * @returns {Object} Returns `object`. 4952 */ 4953 function baseAssignIn(object, source) { 4954 return object && copyObject(source, keysIn(source), object); 4955 } 4956 4957 /** 4958 * The base implementation of `assignValue` and `assignMergeValue` without 4959 * value checks. 4960 * 4961 * @private 4962 * @param {Object} object The object to modify. 4963 * @param {string} key The key of the property to assign. 4964 * @param {*} value The value to assign. 4965 */ 4966 function baseAssignValue(object, key, value) { 4967 if (key == '__proto__' && defineProperty) { 4968 defineProperty(object, key, { 4969 'configurable': true, 4970 'enumerable': true, 4971 'value': value, 4972 'writable': true 4973 }); 4974 } else { 4975 object[key] = value; 4976 } 4977 } 4978 4979 /** 4980 * The base implementation of `_.at` without support for individual paths. 4981 * 4982 * @private 4983 * @param {Object} object The object to iterate over. 4984 * @param {string[]} paths The property paths to pick. 4985 * @returns {Array} Returns the picked elements. 4986 */ 4987 function baseAt(object, paths) { 4988 var index = -1, 4989 length = paths.length, 4990 result = Array(length), 4991 skip = object == null; 4992 4993 while (++index < length) { 4994 result[index] = skip ? undefined : get(object, paths[index]); 4995 } 4996 return result; 4997 } 4998 4999 /** 5000 * The base implementation of `_.clamp` which doesn't coerce arguments. 5001 * 5002 * @private 5003 * @param {number} number The number to clamp. 5004 * @param {number} [lower] The lower bound. 5005 * @param {number} upper The upper bound. 5006 * @returns {number} Returns the clamped number. 5007 */ 5008 function baseClamp(number, lower, upper) { 5009 if (number === number) { 5010 if (upper !== undefined) { 5011 number = number <= upper ? number : upper; 5012 } 5013 if (lower !== undefined) { 5014 number = number >= lower ? number : lower; 5015 } 5016 } 5017 return number; 5018 } 5019 5020 /** 5021 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 5022 * traversed objects. 5023 * 5024 * @private 5025 * @param {*} value The value to clone. 5026 * @param {boolean} bitmask The bitmask flags. 5027 * 1 - Deep clone 5028 * 2 - Flatten inherited properties 5029 * 4 - Clone symbols 5030 * @param {Function} [customizer] The function to customize cloning. 5031 * @param {string} [key] The key of `value`. 5032 * @param {Object} [object] The parent object of `value`. 5033 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 5034 * @returns {*} Returns the cloned value. 5035 */ 5036 function baseClone(value, bitmask, customizer, key, object, stack) { 5037 var result, 5038 isDeep = bitmask & CLONE_DEEP_FLAG, 5039 isFlat = bitmask & CLONE_FLAT_FLAG, 5040 isFull = bitmask & CLONE_SYMBOLS_FLAG; 5041 5042 if (customizer) { 5043 result = object ? customizer(value, key, object, stack) : customizer(value); 5044 } 5045 if (result !== undefined) { 5046 return result; 5047 } 5048 if (!isObject(value)) { 5049 return value; 5050 } 5051 var isArr = isArray(value); 5052 if (isArr) { 5053 result = initCloneArray(value); 5054 if (!isDeep) { 5055 return copyArray(value, result); 5056 } 5057 } else { 5058 var tag = getTag(value), 5059 isFunc = tag == funcTag || tag == genTag; 5060 5061 if (isBuffer(value)) { 5062 return cloneBuffer(value, isDeep); 5063 } 5064 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 5065 result = (isFlat || isFunc) ? {} : initCloneObject(value); 5066 if (!isDeep) { 5067 return isFlat 5068 ? copySymbolsIn(value, baseAssignIn(result, value)) 5069 : copySymbols(value, baseAssign(result, value)); 5070 } 5071 } else { 5072 if (!cloneableTags[tag]) { 5073 return object ? value : {}; 5074 } 5075 result = initCloneByTag(value, tag, isDeep); 5076 } 5077 } 5078 // Check for circular references and return its corresponding clone. 5079 stack || (stack = new Stack); 5080 var stacked = stack.get(value); 5081 if (stacked) { 5082 return stacked; 5083 } 5084 stack.set(value, result); 5085 5086 if (isSet(value)) { 5087 value.forEach(function(subValue) { 5088 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 5089 }); 5090 5091 return result; 5092 } 5093 5094 if (isMap(value)) { 5095 value.forEach(function(subValue, key) { 5096 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 5097 }); 5098 5099 return result; 5100 } 5101 5102 var keysFunc = isFull 5103 ? (isFlat ? getAllKeysIn : getAllKeys) 5104 : (isFlat ? keysIn : keys); 5105 5106 var props = isArr ? undefined : keysFunc(value); 5107 arrayEach(props || value, function(subValue, key) { 5108 if (props) { 5109 key = subValue; 5110 subValue = value[key]; 5111 } 5112 // Recursively populate clone (susceptible to call stack limits). 5113 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 5114 }); 5115 return result; 5116 } 5117 5118 /** 5119 * The base implementation of `_.conforms` which doesn't clone `source`. 5120 * 5121 * @private 5122 * @param {Object} source The object of property predicates to conform to. 5123 * @returns {Function} Returns the new spec function. 5124 */ 5125 function baseConforms(source) { 5126 var props = keys(source); 5127 return function(object) { 5128 return baseConformsTo(object, source, props); 5129 }; 5130 } 5131 5132 /** 5133 * The base implementation of `_.conformsTo` which accepts `props` to check. 5134 * 5135 * @private 5136 * @param {Object} object The object to inspect. 5137 * @param {Object} source The object of property predicates to conform to. 5138 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 5139 */ 5140 function baseConformsTo(object, source, props) { 5141 var length = props.length; 5142 if (object == null) { 5143 return !length; 5144 } 5145 object = Object(object); 5146 while (length--) { 5147 var key = props[length], 5148 predicate = source[key], 5149 value = object[key]; 5150 5151 if ((value === undefined && !(key in object)) || !predicate(value)) { 5152 return false; 5153 } 5154 } 5155 return true; 5156 } 5157 5158 /** 5159 * The base implementation of `_.delay` and `_.defer` which accepts `args` 5160 * to provide to `func`. 5161 * 5162 * @private 5163 * @param {Function} func The function to delay. 5164 * @param {number} wait The number of milliseconds to delay invocation. 5165 * @param {Array} args The arguments to provide to `func`. 5166 * @returns {number|Object} Returns the timer id or timeout object. 5167 */ 5168 function baseDelay(func, wait, args) { 5169 if (typeof func != 'function') { 5170 throw new TypeError(FUNC_ERROR_TEXT); 5171 } 5172 return setTimeout(function() { func.apply(undefined, args); }, wait); 5173 } 5174 5175 /** 5176 * The base implementation of methods like `_.difference` without support 5177 * for excluding multiple arrays or iteratee shorthands. 5178 * 5179 * @private 5180 * @param {Array} array The array to inspect. 5181 * @param {Array} values The values to exclude. 5182 * @param {Function} [iteratee] The iteratee invoked per element. 5183 * @param {Function} [comparator] The comparator invoked per element. 5184 * @returns {Array} Returns the new array of filtered values. 5185 */ 5186 function baseDifference(array, values, iteratee, comparator) { 5187 var index = -1, 5188 includes = arrayIncludes, 5189 isCommon = true, 5190 length = array.length, 5191 result = [], 5192 valuesLength = values.length; 5193 5194 if (!length) { 5195 return result; 5196 } 5197 if (iteratee) { 5198 values = arrayMap(values, baseUnary(iteratee)); 5199 } 5200 if (comparator) { 5201 includes = arrayIncludesWith; 5202 isCommon = false; 5203 } 5204 else if (values.length >= LARGE_ARRAY_SIZE) { 5205 includes = cacheHas; 5206 isCommon = false; 5207 values = new SetCache(values); 5208 } 5209 outer: 5210 while (++index < length) { 5211 var value = array[index], 5212 computed = iteratee == null ? value : iteratee(value); 5213 5214 value = (comparator || value !== 0) ? value : 0; 5215 if (isCommon && computed === computed) { 5216 var valuesIndex = valuesLength; 5217 while (valuesIndex--) { 5218 if (values[valuesIndex] === computed) { 5219 continue outer; 5220 } 5221 } 5222 result.push(value); 5223 } 5224 else if (!includes(values, computed, comparator)) { 5225 result.push(value); 5226 } 5227 } 5228 return result; 5229 } 5230 5231 /** 5232 * The base implementation of `_.forEach` without support for iteratee shorthands. 5233 * 5234 * @private 5235 * @param {Array|Object} collection The collection to iterate over. 5236 * @param {Function} iteratee The function invoked per iteration. 5237 * @returns {Array|Object} Returns `collection`. 5238 */ 5239 var baseEach = createBaseEach(baseForOwn); 5240 5241 /** 5242 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 5243 * 5244 * @private 5245 * @param {Array|Object} collection The collection to iterate over. 5246 * @param {Function} iteratee The function invoked per iteration. 5247 * @returns {Array|Object} Returns `collection`. 5248 */ 5249 var baseEachRight = createBaseEach(baseForOwnRight, true); 5250 5251 /** 5252 * The base implementation of `_.every` without support for iteratee shorthands. 5253 * 5254 * @private 5255 * @param {Array|Object} collection The collection to iterate over. 5256 * @param {Function} predicate The function invoked per iteration. 5257 * @returns {boolean} Returns `true` if all elements pass the predicate check, 5258 * else `false` 5259 */ 5260 function baseEvery(collection, predicate) { 5261 var result = true; 5262 baseEach(collection, function(value, index, collection) { 5263 result = !!predicate(value, index, collection); 5264 return result; 5265 }); 5266 return result; 5267 } 5268 5269 /** 5270 * The base implementation of methods like `_.max` and `_.min` which accepts a 5271 * `comparator` to determine the extremum value. 5272 * 5273 * @private 5274 * @param {Array} array The array to iterate over. 5275 * @param {Function} iteratee The iteratee invoked per iteration. 5276 * @param {Function} comparator The comparator used to compare values. 5277 * @returns {*} Returns the extremum value. 5278 */ 5279 function baseExtremum(array, iteratee, comparator) { 5280 var index = -1, 5281 length = array.length; 5282 5283 while (++index < length) { 5284 var value = array[index], 5285 current = iteratee(value); 5286 5287 if (current != null && (computed === undefined 5288 ? (current === current && !isSymbol(current)) 5289 : comparator(current, computed) 5290 )) { 5291 var computed = current, 5292 result = value; 5293 } 5294 } 5295 return result; 5296 } 5297 5298 /** 5299 * The base implementation of `_.fill` without an iteratee call guard. 5300 * 5301 * @private 5302 * @param {Array} array The array to fill. 5303 * @param {*} value The value to fill `array` with. 5304 * @param {number} [start=0] The start position. 5305 * @param {number} [end=array.length] The end position. 5306 * @returns {Array} Returns `array`. 5307 */ 5308 function baseFill(array, value, start, end) { 5309 var length = array.length; 5310 5311 start = toInteger(start); 5312 if (start < 0) { 5313 start = -start > length ? 0 : (length + start); 5314 } 5315 end = (end === undefined || end > length) ? length : toInteger(end); 5316 if (end < 0) { 5317 end += length; 5318 } 5319 end = start > end ? 0 : toLength(end); 5320 while (start < end) { 5321 array[start++] = value; 5322 } 5323 return array; 5324 } 5325 5326 /** 5327 * The base implementation of `_.filter` without support for iteratee shorthands. 5328 * 5329 * @private 5330 * @param {Array|Object} collection The collection to iterate over. 5331 * @param {Function} predicate The function invoked per iteration. 5332 * @returns {Array} Returns the new filtered array. 5333 */ 5334 function baseFilter(collection, predicate) { 5335 var result = []; 5336 baseEach(collection, function(value, index, collection) { 5337 if (predicate(value, index, collection)) { 5338 result.push(value); 5339 } 5340 }); 5341 return result; 5342 } 5343 5344 /** 5345 * The base implementation of `_.flatten` with support for restricting flattening. 5346 * 5347 * @private 5348 * @param {Array} array The array to flatten. 5349 * @param {number} depth The maximum recursion depth. 5350 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 5351 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 5352 * @param {Array} [result=[]] The initial result value. 5353 * @returns {Array} Returns the new flattened array. 5354 */ 5355 function baseFlatten(array, depth, predicate, isStrict, result) { 5356 var index = -1, 5357 length = array.length; 5358 5359 predicate || (predicate = isFlattenable); 5360 result || (result = []); 5361 5362 while (++index < length) { 5363 var value = array[index]; 5364 if (depth > 0 && predicate(value)) { 5365 if (depth > 1) { 5366 // Recursively flatten arrays (susceptible to call stack limits). 5367 baseFlatten(value, depth - 1, predicate, isStrict, result); 5368 } else { 5369 arrayPush(result, value); 5370 } 5371 } else if (!isStrict) { 5372 result[result.length] = value; 5373 } 5374 } 5375 return result; 5376 } 5377 5378 /** 5379 * The base implementation of `baseForOwn` which iterates over `object` 5380 * properties returned by `keysFunc` and invokes `iteratee` for each property. 5381 * Iteratee functions may exit iteration early by explicitly returning `false`. 5382 * 5383 * @private 5384 * @param {Object} object The object to iterate over. 5385 * @param {Function} iteratee The function invoked per iteration. 5386 * @param {Function} keysFunc The function to get the keys of `object`. 5387 * @returns {Object} Returns `object`. 5388 */ 5389 var baseFor = createBaseFor(); 5390 5391 /** 5392 * This function is like `baseFor` except that it iterates over properties 5393 * in the opposite order. 5394 * 5395 * @private 5396 * @param {Object} object The object to iterate over. 5397 * @param {Function} iteratee The function invoked per iteration. 5398 * @param {Function} keysFunc The function to get the keys of `object`. 5399 * @returns {Object} Returns `object`. 5400 */ 5401 var baseForRight = createBaseFor(true); 5402 5403 /** 5404 * The base implementation of `_.forOwn` without support for iteratee shorthands. 5405 * 5406 * @private 5407 * @param {Object} object The object to iterate over. 5408 * @param {Function} iteratee The function invoked per iteration. 5409 * @returns {Object} Returns `object`. 5410 */ 5411 function baseForOwn(object, iteratee) { 5412 return object && baseFor(object, iteratee, keys); 5413 } 5414 5415 /** 5416 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 5417 * 5418 * @private 5419 * @param {Object} object The object to iterate over. 5420 * @param {Function} iteratee The function invoked per iteration. 5421 * @returns {Object} Returns `object`. 5422 */ 5423 function baseForOwnRight(object, iteratee) { 5424 return object && baseForRight(object, iteratee, keys); 5425 } 5426 5427 /** 5428 * The base implementation of `_.functions` which creates an array of 5429 * `object` function property names filtered from `props`. 5430 * 5431 * @private 5432 * @param {Object} object The object to inspect. 5433 * @param {Array} props The property names to filter. 5434 * @returns {Array} Returns the function names. 5435 */ 5436 function baseFunctions(object, props) { 5437 return arrayFilter(props, function(key) { 5438 return isFunction(object[key]); 5439 }); 5440 } 5441 5442 /** 5443 * The base implementation of `_.get` without support for default values. 5444 * 5445 * @private 5446 * @param {Object} object The object to query. 5447 * @param {Array|string} path The path of the property to get. 5448 * @returns {*} Returns the resolved value. 5449 */ 5450 function baseGet(object, path) { 5451 path = castPath(path, object); 5452 5453 var index = 0, 5454 length = path.length; 5455 5456 while (object != null && index < length) { 5457 object = object[toKey(path[index++])]; 5458 } 5459 return (index && index == length) ? object : undefined; 5460 } 5461 5462 /** 5463 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 5464 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 5465 * symbols of `object`. 5466 * 5467 * @private 5468 * @param {Object} object The object to query. 5469 * @param {Function} keysFunc The function to get the keys of `object`. 5470 * @param {Function} symbolsFunc The function to get the symbols of `object`. 5471 * @returns {Array} Returns the array of property names and symbols. 5472 */ 5473 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 5474 var result = keysFunc(object); 5475 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 5476 } 5477 5478 /** 5479 * The base implementation of `getTag` without fallbacks for buggy environments. 5480 * 5481 * @private 5482 * @param {*} value The value to query. 5483 * @returns {string} Returns the `toStringTag`. 5484 */ 5485 function baseGetTag(value) { 5486 if (value == null) { 5487 return value === undefined ? undefinedTag : nullTag; 5488 } 5489 return (symToStringTag && symToStringTag in Object(value)) 5490 ? getRawTag(value) 5491 : objectToString(value); 5492 } 5493 5494 /** 5495 * The base implementation of `_.gt` which doesn't coerce arguments. 5496 * 5497 * @private 5498 * @param {*} value The value to compare. 5499 * @param {*} other The other value to compare. 5500 * @returns {boolean} Returns `true` if `value` is greater than `other`, 5501 * else `false`. 5502 */ 5503 function baseGt(value, other) { 5504 return value > other; 5505 } 5506 5507 /** 5508 * The base implementation of `_.has` without support for deep paths. 5509 * 5510 * @private 5511 * @param {Object} [object] The object to query. 5512 * @param {Array|string} key The key to check. 5513 * @returns {boolean} Returns `true` if `key` exists, else `false`. 5514 */ 5515 function baseHas(object, key) { 5516 return object != null && hasOwnProperty.call(object, key); 5517 } 5518 5519 /** 5520 * The base implementation of `_.hasIn` without support for deep paths. 5521 * 5522 * @private 5523 * @param {Object} [object] The object to query. 5524 * @param {Array|string} key The key to check. 5525 * @returns {boolean} Returns `true` if `key` exists, else `false`. 5526 */ 5527 function baseHasIn(object, key) { 5528 return object != null && key in Object(object); 5529 } 5530 5531 /** 5532 * The base implementation of `_.inRange` which doesn't coerce arguments. 5533 * 5534 * @private 5535 * @param {number} number The number to check. 5536 * @param {number} start The start of the range. 5537 * @param {number} end The end of the range. 5538 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 5539 */ 5540 function baseInRange(number, start, end) { 5541 return number >= nativeMin(start, end) && number < nativeMax(start, end); 5542 } 5543 5544 /** 5545 * The base implementation of methods like `_.intersection`, without support 5546 * for iteratee shorthands, that accepts an array of arrays to inspect. 5547 * 5548 * @private 5549 * @param {Array} arrays The arrays to inspect. 5550 * @param {Function} [iteratee] The iteratee invoked per element. 5551 * @param {Function} [comparator] The comparator invoked per element. 5552 * @returns {Array} Returns the new array of shared values. 5553 */ 5554 function baseIntersection(arrays, iteratee, comparator) { 5555 var includes = comparator ? arrayIncludesWith : arrayIncludes, 5556 length = arrays[0].length, 5557 othLength = arrays.length, 5558 othIndex = othLength, 5559 caches = Array(othLength), 5560 maxLength = Infinity, 5561 result = []; 5562 5563 while (othIndex--) { 5564 var array = arrays[othIndex]; 5565 if (othIndex && iteratee) { 5566 array = arrayMap(array, baseUnary(iteratee)); 5567 } 5568 maxLength = nativeMin(array.length, maxLength); 5569 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 5570 ? new SetCache(othIndex && array) 5571 : undefined; 5572 } 5573 array = arrays[0]; 5574 5575 var index = -1, 5576 seen = caches[0]; 5577 5578 outer: 5579 while (++index < length && result.length < maxLength) { 5580 var value = array[index], 5581 computed = iteratee ? iteratee(value) : value; 5582 5583 value = (comparator || value !== 0) ? value : 0; 5584 if (!(seen 5585 ? cacheHas(seen, computed) 5586 : includes(result, computed, comparator) 5587 )) { 5588 othIndex = othLength; 5589 while (--othIndex) { 5590 var cache = caches[othIndex]; 5591 if (!(cache 5592 ? cacheHas(cache, computed) 5593 : includes(arrays[othIndex], computed, comparator)) 5594 ) { 5595 continue outer; 5596 } 5597 } 5598 if (seen) { 5599 seen.push(computed); 5600 } 5601 result.push(value); 5602 } 5603 } 5604 return result; 5605 } 5606 5607 /** 5608 * The base implementation of `_.invert` and `_.invertBy` which inverts 5609 * `object` with values transformed by `iteratee` and set by `setter`. 5610 * 5611 * @private 5612 * @param {Object} object The object to iterate over. 5613 * @param {Function} setter The function to set `accumulator` values. 5614 * @param {Function} iteratee The iteratee to transform values. 5615 * @param {Object} accumulator The initial inverted object. 5616 * @returns {Function} Returns `accumulator`. 5617 */ 5618 function baseInverter(object, setter, iteratee, accumulator) { 5619 baseForOwn(object, function(value, key, object) { 5620 setter(accumulator, iteratee(value), key, object); 5621 }); 5622 return accumulator; 5623 } 5624 5625 /** 5626 * The base implementation of `_.invoke` without support for individual 5627 * method arguments. 5628 * 5629 * @private 5630 * @param {Object} object The object to query. 5631 * @param {Array|string} path The path of the method to invoke. 5632 * @param {Array} args The arguments to invoke the method with. 5633 * @returns {*} Returns the result of the invoked method. 5634 */ 5635 function baseInvoke(object, path, args) { 5636 path = castPath(path, object); 5637 object = parent(object, path); 5638 var func = object == null ? object : object[toKey(last(path))]; 5639 return func == null ? undefined : apply(func, object, args); 5640 } 5641 5642 /** 5643 * The base implementation of `_.isArguments`. 5644 * 5645 * @private 5646 * @param {*} value The value to check. 5647 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 5648 */ 5649 function baseIsArguments(value) { 5650 return isObjectLike(value) && baseGetTag(value) == argsTag; 5651 } 5652 5653 /** 5654 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 5655 * 5656 * @private 5657 * @param {*} value The value to check. 5658 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 5659 */ 5660 function baseIsArrayBuffer(value) { 5661 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 5662 } 5663 5664 /** 5665 * The base implementation of `_.isDate` without Node.js optimizations. 5666 * 5667 * @private 5668 * @param {*} value The value to check. 5669 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 5670 */ 5671 function baseIsDate(value) { 5672 return isObjectLike(value) && baseGetTag(value) == dateTag; 5673 } 5674 5675 /** 5676 * The base implementation of `_.isEqual` which supports partial comparisons 5677 * and tracks traversed objects. 5678 * 5679 * @private 5680 * @param {*} value The value to compare. 5681 * @param {*} other The other value to compare. 5682 * @param {boolean} bitmask The bitmask flags. 5683 * 1 - Unordered comparison 5684 * 2 - Partial comparison 5685 * @param {Function} [customizer] The function to customize comparisons. 5686 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 5687 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 5688 */ 5689 function baseIsEqual(value, other, bitmask, customizer, stack) { 5690 if (value === other) { 5691 return true; 5692 } 5693 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 5694 return value !== value && other !== other; 5695 } 5696 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 5697 } 5698 5699 /** 5700 * A specialized version of `baseIsEqual` for arrays and objects which performs 5701 * deep comparisons and tracks traversed objects enabling objects with circular 5702 * references to be compared. 5703 * 5704 * @private 5705 * @param {Object} object The object to compare. 5706 * @param {Object} other The other object to compare. 5707 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5708 * @param {Function} customizer The function to customize comparisons. 5709 * @param {Function} equalFunc The function to determine equivalents of values. 5710 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 5711 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 5712 */ 5713 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 5714 var objIsArr = isArray(object), 5715 othIsArr = isArray(other), 5716 objTag = objIsArr ? arrayTag : getTag(object), 5717 othTag = othIsArr ? arrayTag : getTag(other); 5718 5719 objTag = objTag == argsTag ? objectTag : objTag; 5720 othTag = othTag == argsTag ? objectTag : othTag; 5721 5722 var objIsObj = objTag == objectTag, 5723 othIsObj = othTag == objectTag, 5724 isSameTag = objTag == othTag; 5725 5726 if (isSameTag && isBuffer(object)) { 5727 if (!isBuffer(other)) { 5728 return false; 5729 } 5730 objIsArr = true; 5731 objIsObj = false; 5732 } 5733 if (isSameTag && !objIsObj) { 5734 stack || (stack = new Stack); 5735 return (objIsArr || isTypedArray(object)) 5736 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 5737 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 5738 } 5739 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 5740 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 5741 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 5742 5743 if (objIsWrapped || othIsWrapped) { 5744 var objUnwrapped = objIsWrapped ? object.value() : object, 5745 othUnwrapped = othIsWrapped ? other.value() : other; 5746 5747 stack || (stack = new Stack); 5748 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 5749 } 5750 } 5751 if (!isSameTag) { 5752 return false; 5753 } 5754 stack || (stack = new Stack); 5755 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 5756 } 5757 5758 /** 5759 * The base implementation of `_.isMap` without Node.js optimizations. 5760 * 5761 * @private 5762 * @param {*} value The value to check. 5763 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 5764 */ 5765 function baseIsMap(value) { 5766 return isObjectLike(value) && getTag(value) == mapTag; 5767 } 5768 5769 /** 5770 * The base implementation of `_.isMatch` without support for iteratee shorthands. 5771 * 5772 * @private 5773 * @param {Object} object The object to inspect. 5774 * @param {Object} source The object of property values to match. 5775 * @param {Array} matchData The property names, values, and compare flags to match. 5776 * @param {Function} [customizer] The function to customize comparisons. 5777 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 5778 */ 5779 function baseIsMatch(object, source, matchData, customizer) { 5780 var index = matchData.length, 5781 length = index, 5782 noCustomizer = !customizer; 5783 5784 if (object == null) { 5785 return !length; 5786 } 5787 object = Object(object); 5788 while (index--) { 5789 var data = matchData[index]; 5790 if ((noCustomizer && data[2]) 5791 ? data[1] !== object[data[0]] 5792 : !(data[0] in object) 5793 ) { 5794 return false; 5795 } 5796 } 5797 while (++index < length) { 5798 data = matchData[index]; 5799 var key = data[0], 5800 objValue = object[key], 5801 srcValue = data[1]; 5802 5803 if (noCustomizer && data[2]) { 5804 if (objValue === undefined && !(key in object)) { 5805 return false; 5806 } 5807 } else { 5808 var stack = new Stack; 5809 if (customizer) { 5810 var result = customizer(objValue, srcValue, key, object, source, stack); 5811 } 5812 if (!(result === undefined 5813 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 5814 : result 5815 )) { 5816 return false; 5817 } 5818 } 5819 } 5820 return true; 5821 } 5822 5823 /** 5824 * The base implementation of `_.isNative` without bad shim checks. 5825 * 5826 * @private 5827 * @param {*} value The value to check. 5828 * @returns {boolean} Returns `true` if `value` is a native function, 5829 * else `false`. 5830 */ 5831 function baseIsNative(value) { 5832 if (!isObject(value) || isMasked(value)) { 5833 return false; 5834 } 5835 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 5836 return pattern.test(toSource(value)); 5837 } 5838 5839 /** 5840 * The base implementation of `_.isRegExp` without Node.js optimizations. 5841 * 5842 * @private 5843 * @param {*} value The value to check. 5844 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 5845 */ 5846 function baseIsRegExp(value) { 5847 return isObjectLike(value) && baseGetTag(value) == regexpTag; 5848 } 5849 5850 /** 5851 * The base implementation of `_.isSet` without Node.js optimizations. 5852 * 5853 * @private 5854 * @param {*} value The value to check. 5855 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 5856 */ 5857 function baseIsSet(value) { 5858 return isObjectLike(value) && getTag(value) == setTag; 5859 } 5860 5861 /** 5862 * The base implementation of `_.isTypedArray` without Node.js optimizations. 5863 * 5864 * @private 5865 * @param {*} value The value to check. 5866 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 5867 */ 5868 function baseIsTypedArray(value) { 5869 return isObjectLike(value) && 5870 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 5871 } 5872 5873 /** 5874 * The base implementation of `_.iteratee`. 5875 * 5876 * @private 5877 * @param {*} [value=_.identity] The value to convert to an iteratee. 5878 * @returns {Function} Returns the iteratee. 5879 */ 5880 function baseIteratee(value) { 5881 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 5882 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 5883 if (typeof value == 'function') { 5884 return value; 5885 } 5886 if (value == null) { 5887 return identity; 5888 } 5889 if (typeof value == 'object') { 5890 return isArray(value) 5891 ? baseMatchesProperty(value[0], value[1]) 5892 : baseMatches(value); 5893 } 5894 return property(value); 5895 } 5896 5897 /** 5898 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 5899 * 5900 * @private 5901 * @param {Object} object The object to query. 5902 * @returns {Array} Returns the array of property names. 5903 */ 5904 function baseKeys(object) { 5905 if (!isPrototype(object)) { 5906 return nativeKeys(object); 5907 } 5908 var result = []; 5909 for (var key in Object(object)) { 5910 if (hasOwnProperty.call(object, key) && key != 'constructor') { 5911 result.push(key); 5912 } 5913 } 5914 return result; 5915 } 5916 5917 /** 5918 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 5919 * 5920 * @private 5921 * @param {Object} object The object to query. 5922 * @returns {Array} Returns the array of property names. 5923 */ 5924 function baseKeysIn(object) { 5925 if (!isObject(object)) { 5926 return nativeKeysIn(object); 5927 } 5928 var isProto = isPrototype(object), 5929 result = []; 5930 5931 for (var key in object) { 5932 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 5933 result.push(key); 5934 } 5935 } 5936 return result; 5937 } 5938 5939 /** 5940 * The base implementation of `_.lt` which doesn't coerce arguments. 5941 * 5942 * @private 5943 * @param {*} value The value to compare. 5944 * @param {*} other The other value to compare. 5945 * @returns {boolean} Returns `true` if `value` is less than `other`, 5946 * else `false`. 5947 */ 5948 function baseLt(value, other) { 5949 return value < other; 5950 } 5951 5952 /** 5953 * The base implementation of `_.map` without support for iteratee shorthands. 5954 * 5955 * @private 5956 * @param {Array|Object} collection The collection to iterate over. 5957 * @param {Function} iteratee The function invoked per iteration. 5958 * @returns {Array} Returns the new mapped array. 5959 */ 5960 function baseMap(collection, iteratee) { 5961 var index = -1, 5962 result = isArrayLike(collection) ? Array(collection.length) : []; 5963 5964 baseEach(collection, function(value, key, collection) { 5965 result[++index] = iteratee(value, key, collection); 5966 }); 5967 return result; 5968 } 5969 5970 /** 5971 * The base implementation of `_.matches` which doesn't clone `source`. 5972 * 5973 * @private 5974 * @param {Object} source The object of property values to match. 5975 * @returns {Function} Returns the new spec function. 5976 */ 5977 function baseMatches(source) { 5978 var matchData = getMatchData(source); 5979 if (matchData.length == 1 && matchData[0][2]) { 5980 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 5981 } 5982 return function(object) { 5983 return object === source || baseIsMatch(object, source, matchData); 5984 }; 5985 } 5986 5987 /** 5988 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 5989 * 5990 * @private 5991 * @param {string} path The path of the property to get. 5992 * @param {*} srcValue The value to match. 5993 * @returns {Function} Returns the new spec function. 5994 */ 5995 function baseMatchesProperty(path, srcValue) { 5996 if (isKey(path) && isStrictComparable(srcValue)) { 5997 return matchesStrictComparable(toKey(path), srcValue); 5998 } 5999 return function(object) { 6000 var objValue = get(object, path); 6001 return (objValue === undefined && objValue === srcValue) 6002 ? hasIn(object, path) 6003 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 6004 }; 6005 } 6006 6007 /** 6008 * The base implementation of `_.merge` without support for multiple sources. 6009 * 6010 * @private 6011 * @param {Object} object The destination object. 6012 * @param {Object} source The source object. 6013 * @param {number} srcIndex The index of `source`. 6014 * @param {Function} [customizer] The function to customize merged values. 6015 * @param {Object} [stack] Tracks traversed source values and their merged 6016 * counterparts. 6017 */ 6018 function baseMerge(object, source, srcIndex, customizer, stack) { 6019 if (object === source) { 6020 return; 6021 } 6022 baseFor(source, function(srcValue, key) { 6023 if (isObject(srcValue)) { 6024 stack || (stack = new Stack); 6025 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 6026 } 6027 else { 6028 var newValue = customizer 6029 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 6030 : undefined; 6031 6032 if (newValue === undefined) { 6033 newValue = srcValue; 6034 } 6035 assignMergeValue(object, key, newValue); 6036 } 6037 }, keysIn); 6038 } 6039 6040 /** 6041 * A specialized version of `baseMerge` for arrays and objects which performs 6042 * deep merges and tracks traversed objects enabling objects with circular 6043 * references to be merged. 6044 * 6045 * @private 6046 * @param {Object} object The destination object. 6047 * @param {Object} source The source object. 6048 * @param {string} key The key of the value to merge. 6049 * @param {number} srcIndex The index of `source`. 6050 * @param {Function} mergeFunc The function to merge values. 6051 * @param {Function} [customizer] The function to customize assigned values. 6052 * @param {Object} [stack] Tracks traversed source values and their merged 6053 * counterparts. 6054 */ 6055 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 6056 var objValue = safeGet(object, key), 6057 srcValue = safeGet(source, key), 6058 stacked = stack.get(srcValue); 6059 6060 if (stacked) { 6061 assignMergeValue(object, key, stacked); 6062 return; 6063 } 6064 var newValue = customizer 6065 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 6066 : undefined; 6067 6068 var isCommon = newValue === undefined; 6069 6070 if (isCommon) { 6071 var isArr = isArray(srcValue), 6072 isBuff = !isArr && isBuffer(srcValue), 6073 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 6074 6075 newValue = srcValue; 6076 if (isArr || isBuff || isTyped) { 6077 if (isArray(objValue)) { 6078 newValue = objValue; 6079 } 6080 else if (isArrayLikeObject(objValue)) { 6081 newValue = copyArray(objValue); 6082 } 6083 else if (isBuff) { 6084 isCommon = false; 6085 newValue = cloneBuffer(srcValue, true); 6086 } 6087 else if (isTyped) { 6088 isCommon = false; 6089 newValue = cloneTypedArray(srcValue, true); 6090 } 6091 else { 6092 newValue = []; 6093 } 6094 } 6095 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 6096 newValue = objValue; 6097 if (isArguments(objValue)) { 6098 newValue = toPlainObject(objValue); 6099 } 6100 else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { 6101 newValue = initCloneObject(srcValue); 6102 } 6103 } 6104 else { 6105 isCommon = false; 6106 } 6107 } 6108 if (isCommon) { 6109 // Recursively merge objects and arrays (susceptible to call stack limits). 6110 stack.set(srcValue, newValue); 6111 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 6112 stack['delete'](srcValue); 6113 } 6114 assignMergeValue(object, key, newValue); 6115 } 6116 6117 /** 6118 * The base implementation of `_.nth` which doesn't coerce arguments. 6119 * 6120 * @private 6121 * @param {Array} array The array to query. 6122 * @param {number} n The index of the element to return. 6123 * @returns {*} Returns the nth element of `array`. 6124 */ 6125 function baseNth(array, n) { 6126 var length = array.length; 6127 if (!length) { 6128 return; 6129 } 6130 n += n < 0 ? length : 0; 6131 return isIndex(n, length) ? array[n] : undefined; 6132 } 6133 6134 /** 6135 * The base implementation of `_.orderBy` without param guards. 6136 * 6137 * @private 6138 * @param {Array|Object} collection The collection to iterate over. 6139 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 6140 * @param {string[]} orders The sort orders of `iteratees`. 6141 * @returns {Array} Returns the new sorted array. 6142 */ 6143 function baseOrderBy(collection, iteratees, orders) { 6144 var index = -1; 6145 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); 6146 6147 var result = baseMap(collection, function(value, key, collection) { 6148 var criteria = arrayMap(iteratees, function(iteratee) { 6149 return iteratee(value); 6150 }); 6151 return { 'criteria': criteria, 'index': ++index, 'value': value }; 6152 }); 6153 6154 return baseSortBy(result, function(object, other) { 6155 return compareMultiple(object, other, orders); 6156 }); 6157 } 6158 6159 /** 6160 * The base implementation of `_.pick` without support for individual 6161 * property identifiers. 6162 * 6163 * @private 6164 * @param {Object} object The source object. 6165 * @param {string[]} paths The property paths to pick. 6166 * @returns {Object} Returns the new object. 6167 */ 6168 function basePick(object, paths) { 6169 return basePickBy(object, paths, function(value, path) { 6170 return hasIn(object, path); 6171 }); 6172 } 6173 6174 /** 6175 * The base implementation of `_.pickBy` without support for iteratee shorthands. 6176 * 6177 * @private 6178 * @param {Object} object The source object. 6179 * @param {string[]} paths The property paths to pick. 6180 * @param {Function} predicate The function invoked per property. 6181 * @returns {Object} Returns the new object. 6182 */ 6183 function basePickBy(object, paths, predicate) { 6184 var index = -1, 6185 length = paths.length, 6186 result = {}; 6187 6188 while (++index < length) { 6189 var path = paths[index], 6190 value = baseGet(object, path); 6191 6192 if (predicate(value, path)) { 6193 baseSet(result, castPath(path, object), value); 6194 } 6195 } 6196 return result; 6197 } 6198 6199 /** 6200 * A specialized version of `baseProperty` which supports deep paths. 6201 * 6202 * @private 6203 * @param {Array|string} path The path of the property to get. 6204 * @returns {Function} Returns the new accessor function. 6205 */ 6206 function basePropertyDeep(path) { 6207 return function(object) { 6208 return baseGet(object, path); 6209 }; 6210 } 6211 6212 /** 6213 * The base implementation of `_.pullAllBy` without support for iteratee 6214 * shorthands. 6215 * 6216 * @private 6217 * @param {Array} array The array to modify. 6218 * @param {Array} values The values to remove. 6219 * @param {Function} [iteratee] The iteratee invoked per element. 6220 * @param {Function} [comparator] The comparator invoked per element. 6221 * @returns {Array} Returns `array`. 6222 */ 6223 function basePullAll(array, values, iteratee, comparator) { 6224 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 6225 index = -1, 6226 length = values.length, 6227 seen = array; 6228 6229 if (array === values) { 6230 values = copyArray(values); 6231 } 6232 if (iteratee) { 6233 seen = arrayMap(array, baseUnary(iteratee)); 6234 } 6235 while (++index < length) { 6236 var fromIndex = 0, 6237 value = values[index], 6238 computed = iteratee ? iteratee(value) : value; 6239 6240 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 6241 if (seen !== array) { 6242 splice.call(seen, fromIndex, 1); 6243 } 6244 splice.call(array, fromIndex, 1); 6245 } 6246 } 6247 return array; 6248 } 6249 6250 /** 6251 * The base implementation of `_.pullAt` without support for individual 6252 * indexes or capturing the removed elements. 6253 * 6254 * @private 6255 * @param {Array} array The array to modify. 6256 * @param {number[]} indexes The indexes of elements to remove. 6257 * @returns {Array} Returns `array`. 6258 */ 6259 function basePullAt(array, indexes) { 6260 var length = array ? indexes.length : 0, 6261 lastIndex = length - 1; 6262 6263 while (length--) { 6264 var index = indexes[length]; 6265 if (length == lastIndex || index !== previous) { 6266 var previous = index; 6267 if (isIndex(index)) { 6268 splice.call(array, index, 1); 6269 } else { 6270 baseUnset(array, index); 6271 } 6272 } 6273 } 6274 return array; 6275 } 6276 6277 /** 6278 * The base implementation of `_.random` without support for returning 6279 * floating-point numbers. 6280 * 6281 * @private 6282 * @param {number} lower The lower bound. 6283 * @param {number} upper The upper bound. 6284 * @returns {number} Returns the random number. 6285 */ 6286 function baseRandom(lower, upper) { 6287 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 6288 } 6289 6290 /** 6291 * The base implementation of `_.range` and `_.rangeRight` which doesn't 6292 * coerce arguments. 6293 * 6294 * @private 6295 * @param {number} start The start of the range. 6296 * @param {number} end The end of the range. 6297 * @param {number} step The value to increment or decrement by. 6298 * @param {boolean} [fromRight] Specify iterating from right to left. 6299 * @returns {Array} Returns the range of numbers. 6300 */ 6301 function baseRange(start, end, step, fromRight) { 6302 var index = -1, 6303 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 6304 result = Array(length); 6305 6306 while (length--) { 6307 result[fromRight ? length : ++index] = start; 6308 start += step; 6309 } 6310 return result; 6311 } 6312 6313 /** 6314 * The base implementation of `_.repeat` which doesn't coerce arguments. 6315 * 6316 * @private 6317 * @param {string} string The string to repeat. 6318 * @param {number} n The number of times to repeat the string. 6319 * @returns {string} Returns the repeated string. 6320 */ 6321 function baseRepeat(string, n) { 6322 var result = ''; 6323 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 6324 return result; 6325 } 6326 // Leverage the exponentiation by squaring algorithm for a faster repeat. 6327 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 6328 do { 6329 if (n % 2) { 6330 result += string; 6331 } 6332 n = nativeFloor(n / 2); 6333 if (n) { 6334 string += string; 6335 } 6336 } while (n); 6337 6338 return result; 6339 } 6340 6341 /** 6342 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 6343 * 6344 * @private 6345 * @param {Function} func The function to apply a rest parameter to. 6346 * @param {number} [start=func.length-1] The start position of the rest parameter. 6347 * @returns {Function} Returns the new function. 6348 */ 6349 function baseRest(func, start) { 6350 return setToString(overRest(func, start, identity), func + ''); 6351 } 6352 6353 /** 6354 * The base implementation of `_.sample`. 6355 * 6356 * @private 6357 * @param {Array|Object} collection The collection to sample. 6358 * @returns {*} Returns the random element. 6359 */ 6360 function baseSample(collection) { 6361 return arraySample(values(collection)); 6362 } 6363 6364 /** 6365 * The base implementation of `_.sampleSize` without param guards. 6366 * 6367 * @private 6368 * @param {Array|Object} collection The collection to sample. 6369 * @param {number} n The number of elements to sample. 6370 * @returns {Array} Returns the random elements. 6371 */ 6372 function baseSampleSize(collection, n) { 6373 var array = values(collection); 6374 return shuffleSelf(array, baseClamp(n, 0, array.length)); 6375 } 6376 6377 /** 6378 * The base implementation of `_.set`. 6379 * 6380 * @private 6381 * @param {Object} object The object to modify. 6382 * @param {Array|string} path The path of the property to set. 6383 * @param {*} value The value to set. 6384 * @param {Function} [customizer] The function to customize path creation. 6385 * @returns {Object} Returns `object`. 6386 */ 6387 function baseSet(object, path, value, customizer) { 6388 if (!isObject(object)) { 6389 return object; 6390 } 6391 path = castPath(path, object); 6392 6393 var index = -1, 6394 length = path.length, 6395 lastIndex = length - 1, 6396 nested = object; 6397 6398 while (nested != null && ++index < length) { 6399 var key = toKey(path[index]), 6400 newValue = value; 6401 6402 if (index != lastIndex) { 6403 var objValue = nested[key]; 6404 newValue = customizer ? customizer(objValue, key, nested) : undefined; 6405 if (newValue === undefined) { 6406 newValue = isObject(objValue) 6407 ? objValue 6408 : (isIndex(path[index + 1]) ? [] : {}); 6409 } 6410 } 6411 assignValue(nested, key, newValue); 6412 nested = nested[key]; 6413 } 6414 return object; 6415 } 6416 6417 /** 6418 * The base implementation of `setData` without support for hot loop shorting. 6419 * 6420 * @private 6421 * @param {Function} func The function to associate metadata with. 6422 * @param {*} data The metadata. 6423 * @returns {Function} Returns `func`. 6424 */ 6425 var baseSetData = !metaMap ? identity : function(func, data) { 6426 metaMap.set(func, data); 6427 return func; 6428 }; 6429 6430 /** 6431 * The base implementation of `setToString` without support for hot loop shorting. 6432 * 6433 * @private 6434 * @param {Function} func The function to modify. 6435 * @param {Function} string The `toString` result. 6436 * @returns {Function} Returns `func`. 6437 */ 6438 var baseSetToString = !defineProperty ? identity : function(func, string) { 6439 return defineProperty(func, 'toString', { 6440 'configurable': true, 6441 'enumerable': false, 6442 'value': constant(string), 6443 'writable': true 6444 }); 6445 }; 6446 6447 /** 6448 * The base implementation of `_.shuffle`. 6449 * 6450 * @private 6451 * @param {Array|Object} collection The collection to shuffle. 6452 * @returns {Array} Returns the new shuffled array. 6453 */ 6454 function baseShuffle(collection) { 6455 return shuffleSelf(values(collection)); 6456 } 6457 6458 /** 6459 * The base implementation of `_.slice` without an iteratee call guard. 6460 * 6461 * @private 6462 * @param {Array} array The array to slice. 6463 * @param {number} [start=0] The start position. 6464 * @param {number} [end=array.length] The end position. 6465 * @returns {Array} Returns the slice of `array`. 6466 */ 6467 function baseSlice(array, start, end) { 6468 var index = -1, 6469 length = array.length; 6470 6471 if (start < 0) { 6472 start = -start > length ? 0 : (length + start); 6473 } 6474 end = end > length ? length : end; 6475 if (end < 0) { 6476 end += length; 6477 } 6478 length = start > end ? 0 : ((end - start) >>> 0); 6479 start >>>= 0; 6480 6481 var result = Array(length); 6482 while (++index < length) { 6483 result[index] = array[index + start]; 6484 } 6485 return result; 6486 } 6487 6488 /** 6489 * The base implementation of `_.some` without support for iteratee shorthands. 6490 * 6491 * @private 6492 * @param {Array|Object} collection The collection to iterate over. 6493 * @param {Function} predicate The function invoked per iteration. 6494 * @returns {boolean} Returns `true` if any element passes the predicate check, 6495 * else `false`. 6496 */ 6497 function baseSome(collection, predicate) { 6498 var result; 6499 6500 baseEach(collection, function(value, index, collection) { 6501 result = predicate(value, index, collection); 6502 return !result; 6503 }); 6504 return !!result; 6505 } 6506 6507 /** 6508 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 6509 * performs a binary search of `array` to determine the index at which `value` 6510 * should be inserted into `array` in order to maintain its sort order. 6511 * 6512 * @private 6513 * @param {Array} array The sorted array to inspect. 6514 * @param {*} value The value to evaluate. 6515 * @param {boolean} [retHighest] Specify returning the highest qualified index. 6516 * @returns {number} Returns the index at which `value` should be inserted 6517 * into `array`. 6518 */ 6519 function baseSortedIndex(array, value, retHighest) { 6520 var low = 0, 6521 high = array == null ? low : array.length; 6522 6523 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 6524 while (low < high) { 6525 var mid = (low + high) >>> 1, 6526 computed = array[mid]; 6527 6528 if (computed !== null && !isSymbol(computed) && 6529 (retHighest ? (computed <= value) : (computed < value))) { 6530 low = mid + 1; 6531 } else { 6532 high = mid; 6533 } 6534 } 6535 return high; 6536 } 6537 return baseSortedIndexBy(array, value, identity, retHighest); 6538 } 6539 6540 /** 6541 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 6542 * which invokes `iteratee` for `value` and each element of `array` to compute 6543 * their sort ranking. The iteratee is invoked with one argument; (value). 6544 * 6545 * @private 6546 * @param {Array} array The sorted array to inspect. 6547 * @param {*} value The value to evaluate. 6548 * @param {Function} iteratee The iteratee invoked per element. 6549 * @param {boolean} [retHighest] Specify returning the highest qualified index. 6550 * @returns {number} Returns the index at which `value` should be inserted 6551 * into `array`. 6552 */ 6553 function baseSortedIndexBy(array, value, iteratee, retHighest) { 6554 value = iteratee(value); 6555 6556 var low = 0, 6557 high = array == null ? 0 : array.length, 6558 valIsNaN = value !== value, 6559 valIsNull = value === null, 6560 valIsSymbol = isSymbol(value), 6561 valIsUndefined = value === undefined; 6562 6563 while (low < high) { 6564 var mid = nativeFloor((low + high) / 2), 6565 computed = iteratee(array[mid]), 6566 othIsDefined = computed !== undefined, 6567 othIsNull = computed === null, 6568 othIsReflexive = computed === computed, 6569 othIsSymbol = isSymbol(computed); 6570 6571 if (valIsNaN) { 6572 var setLow = retHighest || othIsReflexive; 6573 } else if (valIsUndefined) { 6574 setLow = othIsReflexive && (retHighest || othIsDefined); 6575 } else if (valIsNull) { 6576 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 6577 } else if (valIsSymbol) { 6578 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 6579 } else if (othIsNull || othIsSymbol) { 6580 setLow = false; 6581 } else { 6582 setLow = retHighest ? (computed <= value) : (computed < value); 6583 } 6584 if (setLow) { 6585 low = mid + 1; 6586 } else { 6587 high = mid; 6588 } 6589 } 6590 return nativeMin(high, MAX_ARRAY_INDEX); 6591 } 6592 6593 /** 6594 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 6595 * support for iteratee shorthands. 6596 * 6597 * @private 6598 * @param {Array} array The array to inspect. 6599 * @param {Function} [iteratee] The iteratee invoked per element. 6600 * @returns {Array} Returns the new duplicate free array. 6601 */ 6602 function baseSortedUniq(array, iteratee) { 6603 var index = -1, 6604 length = array.length, 6605 resIndex = 0, 6606 result = []; 6607 6608 while (++index < length) { 6609 var value = array[index], 6610 computed = iteratee ? iteratee(value) : value; 6611 6612 if (!index || !eq(computed, seen)) { 6613 var seen = computed; 6614 result[resIndex++] = value === 0 ? 0 : value; 6615 } 6616 } 6617 return result; 6618 } 6619 6620 /** 6621 * The base implementation of `_.toNumber` which doesn't ensure correct 6622 * conversions of binary, hexadecimal, or octal string values. 6623 * 6624 * @private 6625 * @param {*} value The value to process. 6626 * @returns {number} Returns the number. 6627 */ 6628 function baseToNumber(value) { 6629 if (typeof value == 'number') { 6630 return value; 6631 } 6632 if (isSymbol(value)) { 6633 return NAN; 6634 } 6635 return +value; 6636 } 6637 6638 /** 6639 * The base implementation of `_.toString` which doesn't convert nullish 6640 * values to empty strings. 6641 * 6642 * @private 6643 * @param {*} value The value to process. 6644 * @returns {string} Returns the string. 6645 */ 6646 function baseToString(value) { 6647 // Exit early for strings to avoid a performance hit in some environments. 6648 if (typeof value == 'string') { 6649 return value; 6650 } 6651 if (isArray(value)) { 6652 // Recursively convert values (susceptible to call stack limits). 6653 return arrayMap(value, baseToString) + ''; 6654 } 6655 if (isSymbol(value)) { 6656 return symbolToString ? symbolToString.call(value) : ''; 6657 } 6658 var result = (value + ''); 6659 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 6660 } 6661 6662 /** 6663 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 6664 * 6665 * @private 6666 * @param {Array} array The array to inspect. 6667 * @param {Function} [iteratee] The iteratee invoked per element. 6668 * @param {Function} [comparator] The comparator invoked per element. 6669 * @returns {Array} Returns the new duplicate free array. 6670 */ 6671 function baseUniq(array, iteratee, comparator) { 6672 var index = -1, 6673 includes = arrayIncludes, 6674 length = array.length, 6675 isCommon = true, 6676 result = [], 6677 seen = result; 6678 6679 if (comparator) { 6680 isCommon = false; 6681 includes = arrayIncludesWith; 6682 } 6683 else if (length >= LARGE_ARRAY_SIZE) { 6684 var set = iteratee ? null : createSet(array); 6685 if (set) { 6686 return setToArray(set); 6687 } 6688 isCommon = false; 6689 includes = cacheHas; 6690 seen = new SetCache; 6691 } 6692 else { 6693 seen = iteratee ? [] : result; 6694 } 6695 outer: 6696 while (++index < length) { 6697 var value = array[index], 6698 computed = iteratee ? iteratee(value) : value; 6699 6700 value = (comparator || value !== 0) ? value : 0; 6701 if (isCommon && computed === computed) { 6702 var seenIndex = seen.length; 6703 while (seenIndex--) { 6704 if (seen[seenIndex] === computed) { 6705 continue outer; 6706 } 6707 } 6708 if (iteratee) { 6709 seen.push(computed); 6710 } 6711 result.push(value); 6712 } 6713 else if (!includes(seen, computed, comparator)) { 6714 if (seen !== result) { 6715 seen.push(computed); 6716 } 6717 result.push(value); 6718 } 6719 } 6720 return result; 6721 } 6722 6723 /** 6724 * The base implementation of `_.unset`. 6725 * 6726 * @private 6727 * @param {Object} object The object to modify. 6728 * @param {Array|string} path The property path to unset. 6729 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 6730 */ 6731 function baseUnset(object, path) { 6732 path = castPath(path, object); 6733 object = parent(object, path); 6734 return object == null || delete object[toKey(last(path))]; 6735 } 6736 6737 /** 6738 * The base implementation of `_.update`. 6739 * 6740 * @private 6741 * @param {Object} object The object to modify. 6742 * @param {Array|string} path The path of the property to update. 6743 * @param {Function} updater The function to produce the updated value. 6744 * @param {Function} [customizer] The function to customize path creation. 6745 * @returns {Object} Returns `object`. 6746 */ 6747 function baseUpdate(object, path, updater, customizer) { 6748 return baseSet(object, path, updater(baseGet(object, path)), customizer); 6749 } 6750 6751 /** 6752 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 6753 * without support for iteratee shorthands. 6754 * 6755 * @private 6756 * @param {Array} array The array to query. 6757 * @param {Function} predicate The function invoked per iteration. 6758 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 6759 * @param {boolean} [fromRight] Specify iterating from right to left. 6760 * @returns {Array} Returns the slice of `array`. 6761 */ 6762 function baseWhile(array, predicate, isDrop, fromRight) { 6763 var length = array.length, 6764 index = fromRight ? length : -1; 6765 6766 while ((fromRight ? index-- : ++index < length) && 6767 predicate(array[index], index, array)) {} 6768 6769 return isDrop 6770 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 6771 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 6772 } 6773 6774 /** 6775 * The base implementation of `wrapperValue` which returns the result of 6776 * performing a sequence of actions on the unwrapped `value`, where each 6777 * successive action is supplied the return value of the previous. 6778 * 6779 * @private 6780 * @param {*} value The unwrapped value. 6781 * @param {Array} actions Actions to perform to resolve the unwrapped value. 6782 * @returns {*} Returns the resolved value. 6783 */ 6784 function baseWrapperValue(value, actions) { 6785 var result = value; 6786 if (result instanceof LazyWrapper) { 6787 result = result.value(); 6788 } 6789 return arrayReduce(actions, function(result, action) { 6790 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 6791 }, result); 6792 } 6793 6794 /** 6795 * The base implementation of methods like `_.xor`, without support for 6796 * iteratee shorthands, that accepts an array of arrays to inspect. 6797 * 6798 * @private 6799 * @param {Array} arrays The arrays to inspect. 6800 * @param {Function} [iteratee] The iteratee invoked per element. 6801 * @param {Function} [comparator] The comparator invoked per element. 6802 * @returns {Array} Returns the new array of values. 6803 */ 6804 function baseXor(arrays, iteratee, comparator) { 6805 var length = arrays.length; 6806 if (length < 2) { 6807 return length ? baseUniq(arrays[0]) : []; 6808 } 6809 var index = -1, 6810 result = Array(length); 6811 6812 while (++index < length) { 6813 var array = arrays[index], 6814 othIndex = -1; 6815 6816 while (++othIndex < length) { 6817 if (othIndex != index) { 6818 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 6819 } 6820 } 6821 } 6822 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 6823 } 6824 6825 /** 6826 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 6827 * 6828 * @private 6829 * @param {Array} props The property identifiers. 6830 * @param {Array} values The property values. 6831 * @param {Function} assignFunc The function to assign values. 6832 * @returns {Object} Returns the new object. 6833 */ 6834 function baseZipObject(props, values, assignFunc) { 6835 var index = -1, 6836 length = props.length, 6837 valsLength = values.length, 6838 result = {}; 6839 6840 while (++index < length) { 6841 var value = index < valsLength ? values[index] : undefined; 6842 assignFunc(result, props[index], value); 6843 } 6844 return result; 6845 } 6846 6847 /** 6848 * Casts `value` to an empty array if it's not an array like object. 6849 * 6850 * @private 6851 * @param {*} value The value to inspect. 6852 * @returns {Array|Object} Returns the cast array-like object. 6853 */ 6854 function castArrayLikeObject(value) { 6855 return isArrayLikeObject(value) ? value : []; 6856 } 6857 6858 /** 6859 * Casts `value` to `identity` if it's not a function. 6860 * 6861 * @private 6862 * @param {*} value The value to inspect. 6863 * @returns {Function} Returns cast function. 6864 */ 6865 function castFunction(value) { 6866 return typeof value == 'function' ? value : identity; 6867 } 6868 6869 /** 6870 * Casts `value` to a path array if it's not one. 6871 * 6872 * @private 6873 * @param {*} value The value to inspect. 6874 * @param {Object} [object] The object to query keys on. 6875 * @returns {Array} Returns the cast property path array. 6876 */ 6877 function castPath(value, object) { 6878 if (isArray(value)) { 6879 return value; 6880 } 6881 return isKey(value, object) ? [value] : stringToPath(toString(value)); 6882 } 6883 6884 /** 6885 * A `baseRest` alias which can be replaced with `identity` by module 6886 * replacement plugins. 6887 * 6888 * @private 6889 * @type {Function} 6890 * @param {Function} func The function to apply a rest parameter to. 6891 * @returns {Function} Returns the new function. 6892 */ 6893 var castRest = baseRest; 6894 6895 /** 6896 * Casts `array` to a slice if it's needed. 6897 * 6898 * @private 6899 * @param {Array} array The array to inspect. 6900 * @param {number} start The start position. 6901 * @param {number} [end=array.length] The end position. 6902 * @returns {Array} Returns the cast slice. 6903 */ 6904 function castSlice(array, start, end) { 6905 var length = array.length; 6906 end = end === undefined ? length : end; 6907 return (!start && end >= length) ? array : baseSlice(array, start, end); 6908 } 6909 6910 /** 6911 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 6912 * 6913 * @private 6914 * @param {number|Object} id The timer id or timeout object of the timer to clear. 6915 */ 6916 var clearTimeout = ctxClearTimeout || function(id) { 6917 return root.clearTimeout(id); 6918 }; 6919 6920 /** 6921 * Creates a clone of `buffer`. 6922 * 6923 * @private 6924 * @param {Buffer} buffer The buffer to clone. 6925 * @param {boolean} [isDeep] Specify a deep clone. 6926 * @returns {Buffer} Returns the cloned buffer. 6927 */ 6928 function cloneBuffer(buffer, isDeep) { 6929 if (isDeep) { 6930 return buffer.slice(); 6931 } 6932 var length = buffer.length, 6933 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 6934 6935 buffer.copy(result); 6936 return result; 6937 } 6938 6939 /** 6940 * Creates a clone of `arrayBuffer`. 6941 * 6942 * @private 6943 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 6944 * @returns {ArrayBuffer} Returns the cloned array buffer. 6945 */ 6946 function cloneArrayBuffer(arrayBuffer) { 6947 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 6948 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 6949 return result; 6950 } 6951 6952 /** 6953 * Creates a clone of `dataView`. 6954 * 6955 * @private 6956 * @param {Object} dataView The data view to clone. 6957 * @param {boolean} [isDeep] Specify a deep clone. 6958 * @returns {Object} Returns the cloned data view. 6959 */ 6960 function cloneDataView(dataView, isDeep) { 6961 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 6962 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 6963 } 6964 6965 /** 6966 * Creates a clone of `regexp`. 6967 * 6968 * @private 6969 * @param {Object} regexp The regexp to clone. 6970 * @returns {Object} Returns the cloned regexp. 6971 */ 6972 function cloneRegExp(regexp) { 6973 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 6974 result.lastIndex = regexp.lastIndex; 6975 return result; 6976 } 6977 6978 /** 6979 * Creates a clone of the `symbol` object. 6980 * 6981 * @private 6982 * @param {Object} symbol The symbol object to clone. 6983 * @returns {Object} Returns the cloned symbol object. 6984 */ 6985 function cloneSymbol(symbol) { 6986 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 6987 } 6988 6989 /** 6990 * Creates a clone of `typedArray`. 6991 * 6992 * @private 6993 * @param {Object} typedArray The typed array to clone. 6994 * @param {boolean} [isDeep] Specify a deep clone. 6995 * @returns {Object} Returns the cloned typed array. 6996 */ 6997 function cloneTypedArray(typedArray, isDeep) { 6998 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 6999 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 7000 } 7001 7002 /** 7003 * Compares values to sort them in ascending order. 7004 * 7005 * @private 7006 * @param {*} value The value to compare. 7007 * @param {*} other The other value to compare. 7008 * @returns {number} Returns the sort order indicator for `value`. 7009 */ 7010 function compareAscending(value, other) { 7011 if (value !== other) { 7012 var valIsDefined = value !== undefined, 7013 valIsNull = value === null, 7014 valIsReflexive = value === value, 7015 valIsSymbol = isSymbol(value); 7016 7017 var othIsDefined = other !== undefined, 7018 othIsNull = other === null, 7019 othIsReflexive = other === other, 7020 othIsSymbol = isSymbol(other); 7021 7022 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 7023 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 7024 (valIsNull && othIsDefined && othIsReflexive) || 7025 (!valIsDefined && othIsReflexive) || 7026 !valIsReflexive) { 7027 return 1; 7028 } 7029 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 7030 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 7031 (othIsNull && valIsDefined && valIsReflexive) || 7032 (!othIsDefined && valIsReflexive) || 7033 !othIsReflexive) { 7034 return -1; 7035 } 7036 } 7037 return 0; 7038 } 7039 7040 /** 7041 * Used by `_.orderBy` to compare multiple properties of a value to another 7042 * and stable sort them. 7043 * 7044 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 7045 * specify an order of "desc" for descending or "asc" for ascending sort order 7046 * of corresponding values. 7047 * 7048 * @private 7049 * @param {Object} object The object to compare. 7050 * @param {Object} other The other object to compare. 7051 * @param {boolean[]|string[]} orders The order to sort by for each property. 7052 * @returns {number} Returns the sort order indicator for `object`. 7053 */ 7054 function compareMultiple(object, other, orders) { 7055 var index = -1, 7056 objCriteria = object.criteria, 7057 othCriteria = other.criteria, 7058 length = objCriteria.length, 7059 ordersLength = orders.length; 7060 7061 while (++index < length) { 7062 var result = compareAscending(objCriteria[index], othCriteria[index]); 7063 if (result) { 7064 if (index >= ordersLength) { 7065 return result; 7066 } 7067 var order = orders[index]; 7068 return result * (order == 'desc' ? -1 : 1); 7069 } 7070 } 7071 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 7072 // that causes it, under certain circumstances, to provide the same value for 7073 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 7074 // for more details. 7075 // 7076 // This also ensures a stable sort in V8 and other engines. 7077 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 7078 return object.index - other.index; 7079 } 7080 7081 /** 7082 * Creates an array that is the composition of partially applied arguments, 7083 * placeholders, and provided arguments into a single array of arguments. 7084 * 7085 * @private 7086 * @param {Array} args The provided arguments. 7087 * @param {Array} partials The arguments to prepend to those provided. 7088 * @param {Array} holders The `partials` placeholder indexes. 7089 * @params {boolean} [isCurried] Specify composing for a curried function. 7090 * @returns {Array} Returns the new array of composed arguments. 7091 */ 7092 function composeArgs(args, partials, holders, isCurried) { 7093 var argsIndex = -1, 7094 argsLength = args.length, 7095 holdersLength = holders.length, 7096 leftIndex = -1, 7097 leftLength = partials.length, 7098 rangeLength = nativeMax(argsLength - holdersLength, 0), 7099 result = Array(leftLength + rangeLength), 7100 isUncurried = !isCurried; 7101 7102 while (++leftIndex < leftLength) { 7103 result[leftIndex] = partials[leftIndex]; 7104 } 7105 while (++argsIndex < holdersLength) { 7106 if (isUncurried || argsIndex < argsLength) { 7107 result[holders[argsIndex]] = args[argsIndex]; 7108 } 7109 } 7110 while (rangeLength--) { 7111 result[leftIndex++] = args[argsIndex++]; 7112 } 7113 return result; 7114 } 7115 7116 /** 7117 * This function is like `composeArgs` except that the arguments composition 7118 * is tailored for `_.partialRight`. 7119 * 7120 * @private 7121 * @param {Array} args The provided arguments. 7122 * @param {Array} partials The arguments to append to those provided. 7123 * @param {Array} holders The `partials` placeholder indexes. 7124 * @params {boolean} [isCurried] Specify composing for a curried function. 7125 * @returns {Array} Returns the new array of composed arguments. 7126 */ 7127 function composeArgsRight(args, partials, holders, isCurried) { 7128 var argsIndex = -1, 7129 argsLength = args.length, 7130 holdersIndex = -1, 7131 holdersLength = holders.length, 7132 rightIndex = -1, 7133 rightLength = partials.length, 7134 rangeLength = nativeMax(argsLength - holdersLength, 0), 7135 result = Array(rangeLength + rightLength), 7136 isUncurried = !isCurried; 7137 7138 while (++argsIndex < rangeLength) { 7139 result[argsIndex] = args[argsIndex]; 7140 } 7141 var offset = argsIndex; 7142 while (++rightIndex < rightLength) { 7143 result[offset + rightIndex] = partials[rightIndex]; 7144 } 7145 while (++holdersIndex < holdersLength) { 7146 if (isUncurried || argsIndex < argsLength) { 7147 result[offset + holders[holdersIndex]] = args[argsIndex++]; 7148 } 7149 } 7150 return result; 7151 } 7152 7153 /** 7154 * Copies the values of `source` to `array`. 7155 * 7156 * @private 7157 * @param {Array} source The array to copy values from. 7158 * @param {Array} [array=[]] The array to copy values to. 7159 * @returns {Array} Returns `array`. 7160 */ 7161 function copyArray(source, array) { 7162 var index = -1, 7163 length = source.length; 7164 7165 array || (array = Array(length)); 7166 while (++index < length) { 7167 array[index] = source[index]; 7168 } 7169 return array; 7170 } 7171 7172 /** 7173 * Copies properties of `source` to `object`. 7174 * 7175 * @private 7176 * @param {Object} source The object to copy properties from. 7177 * @param {Array} props The property identifiers to copy. 7178 * @param {Object} [object={}] The object to copy properties to. 7179 * @param {Function} [customizer] The function to customize copied values. 7180 * @returns {Object} Returns `object`. 7181 */ 7182 function copyObject(source, props, object, customizer) { 7183 var isNew = !object; 7184 object || (object = {}); 7185 7186 var index = -1, 7187 length = props.length; 7188 7189 while (++index < length) { 7190 var key = props[index]; 7191 7192 var newValue = customizer 7193 ? customizer(object[key], source[key], key, object, source) 7194 : undefined; 7195 7196 if (newValue === undefined) { 7197 newValue = source[key]; 7198 } 7199 if (isNew) { 7200 baseAssignValue(object, key, newValue); 7201 } else { 7202 assignValue(object, key, newValue); 7203 } 7204 } 7205 return object; 7206 } 7207 7208 /** 7209 * Copies own symbols of `source` to `object`. 7210 * 7211 * @private 7212 * @param {Object} source The object to copy symbols from. 7213 * @param {Object} [object={}] The object to copy symbols to. 7214 * @returns {Object} Returns `object`. 7215 */ 7216 function copySymbols(source, object) { 7217 return copyObject(source, getSymbols(source), object); 7218 } 7219 7220 /** 7221 * Copies own and inherited symbols of `source` to `object`. 7222 * 7223 * @private 7224 * @param {Object} source The object to copy symbols from. 7225 * @param {Object} [object={}] The object to copy symbols to. 7226 * @returns {Object} Returns `object`. 7227 */ 7228 function copySymbolsIn(source, object) { 7229 return copyObject(source, getSymbolsIn(source), object); 7230 } 7231 7232 /** 7233 * Creates a function like `_.groupBy`. 7234 * 7235 * @private 7236 * @param {Function} setter The function to set accumulator values. 7237 * @param {Function} [initializer] The accumulator object initializer. 7238 * @returns {Function} Returns the new aggregator function. 7239 */ 7240 function createAggregator(setter, initializer) { 7241 return function(collection, iteratee) { 7242 var func = isArray(collection) ? arrayAggregator : baseAggregator, 7243 accumulator = initializer ? initializer() : {}; 7244 7245 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 7246 }; 7247 } 7248 7249 /** 7250 * Creates a function like `_.assign`. 7251 * 7252 * @private 7253 * @param {Function} assigner The function to assign values. 7254 * @returns {Function} Returns the new assigner function. 7255 */ 7256 function createAssigner(assigner) { 7257 return baseRest(function(object, sources) { 7258 var index = -1, 7259 length = sources.length, 7260 customizer = length > 1 ? sources[length - 1] : undefined, 7261 guard = length > 2 ? sources[2] : undefined; 7262 7263 customizer = (assigner.length > 3 && typeof customizer == 'function') 7264 ? (length--, customizer) 7265 : undefined; 7266 7267 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 7268 customizer = length < 3 ? undefined : customizer; 7269 length = 1; 7270 } 7271 object = Object(object); 7272 while (++index < length) { 7273 var source = sources[index]; 7274 if (source) { 7275 assigner(object, source, index, customizer); 7276 } 7277 } 7278 return object; 7279 }); 7280 } 7281 7282 /** 7283 * Creates a `baseEach` or `baseEachRight` function. 7284 * 7285 * @private 7286 * @param {Function} eachFunc The function to iterate over a collection. 7287 * @param {boolean} [fromRight] Specify iterating from right to left. 7288 * @returns {Function} Returns the new base function. 7289 */ 7290 function createBaseEach(eachFunc, fromRight) { 7291 return function(collection, iteratee) { 7292 if (collection == null) { 7293 return collection; 7294 } 7295 if (!isArrayLike(collection)) { 7296 return eachFunc(collection, iteratee); 7297 } 7298 var length = collection.length, 7299 index = fromRight ? length : -1, 7300 iterable = Object(collection); 7301 7302 while ((fromRight ? index-- : ++index < length)) { 7303 if (iteratee(iterable[index], index, iterable) === false) { 7304 break; 7305 } 7306 } 7307 return collection; 7308 }; 7309 } 7310 7311 /** 7312 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 7313 * 7314 * @private 7315 * @param {boolean} [fromRight] Specify iterating from right to left. 7316 * @returns {Function} Returns the new base function. 7317 */ 7318 function createBaseFor(fromRight) { 7319 return function(object, iteratee, keysFunc) { 7320 var index = -1, 7321 iterable = Object(object), 7322 props = keysFunc(object), 7323 length = props.length; 7324 7325 while (length--) { 7326 var key = props[fromRight ? length : ++index]; 7327 if (iteratee(iterable[key], key, iterable) === false) { 7328 break; 7329 } 7330 } 7331 return object; 7332 }; 7333 } 7334 7335 /** 7336 * Creates a function that wraps `func` to invoke it with the optional `this` 7337 * binding of `thisArg`. 7338 * 7339 * @private 7340 * @param {Function} func The function to wrap. 7341 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7342 * @param {*} [thisArg] The `this` binding of `func`. 7343 * @returns {Function} Returns the new wrapped function. 7344 */ 7345 function createBind(func, bitmask, thisArg) { 7346 var isBind = bitmask & WRAP_BIND_FLAG, 7347 Ctor = createCtor(func); 7348 7349 function wrapper() { 7350 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 7351 return fn.apply(isBind ? thisArg : this, arguments); 7352 } 7353 return wrapper; 7354 } 7355 7356 /** 7357 * Creates a function like `_.lowerFirst`. 7358 * 7359 * @private 7360 * @param {string} methodName The name of the `String` case method to use. 7361 * @returns {Function} Returns the new case function. 7362 */ 7363 function createCaseFirst(methodName) { 7364 return function(string) { 7365 string = toString(string); 7366 7367 var strSymbols = hasUnicode(string) 7368 ? stringToArray(string) 7369 : undefined; 7370 7371 var chr = strSymbols 7372 ? strSymbols[0] 7373 : string.charAt(0); 7374 7375 var trailing = strSymbols 7376 ? castSlice(strSymbols, 1).join('') 7377 : string.slice(1); 7378 7379 return chr[methodName]() + trailing; 7380 }; 7381 } 7382 7383 /** 7384 * Creates a function like `_.camelCase`. 7385 * 7386 * @private 7387 * @param {Function} callback The function to combine each word. 7388 * @returns {Function} Returns the new compounder function. 7389 */ 7390 function createCompounder(callback) { 7391 return function(string) { 7392 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 7393 }; 7394 } 7395 7396 /** 7397 * Creates a function that produces an instance of `Ctor` regardless of 7398 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 7399 * 7400 * @private 7401 * @param {Function} Ctor The constructor to wrap. 7402 * @returns {Function} Returns the new wrapped function. 7403 */ 7404 function createCtor(Ctor) { 7405 return function() { 7406 // Use a `switch` statement to work with class constructors. See 7407 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 7408 // for more details. 7409 var args = arguments; 7410 switch (args.length) { 7411 case 0: return new Ctor; 7412 case 1: return new Ctor(args[0]); 7413 case 2: return new Ctor(args[0], args[1]); 7414 case 3: return new Ctor(args[0], args[1], args[2]); 7415 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 7416 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 7417 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 7418 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 7419 } 7420 var thisBinding = baseCreate(Ctor.prototype), 7421 result = Ctor.apply(thisBinding, args); 7422 7423 // Mimic the constructor's `return` behavior. 7424 // See https://es5.github.io/#x13.2.2 for more details. 7425 return isObject(result) ? result : thisBinding; 7426 }; 7427 } 7428 7429 /** 7430 * Creates a function that wraps `func` to enable currying. 7431 * 7432 * @private 7433 * @param {Function} func The function to wrap. 7434 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7435 * @param {number} arity The arity of `func`. 7436 * @returns {Function} Returns the new wrapped function. 7437 */ 7438 function createCurry(func, bitmask, arity) { 7439 var Ctor = createCtor(func); 7440 7441 function wrapper() { 7442 var length = arguments.length, 7443 args = Array(length), 7444 index = length, 7445 placeholder = getHolder(wrapper); 7446 7447 while (index--) { 7448 args[index] = arguments[index]; 7449 } 7450 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 7451 ? [] 7452 : replaceHolders(args, placeholder); 7453 7454 length -= holders.length; 7455 if (length < arity) { 7456 return createRecurry( 7457 func, bitmask, createHybrid, wrapper.placeholder, undefined, 7458 args, holders, undefined, undefined, arity - length); 7459 } 7460 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 7461 return apply(fn, this, args); 7462 } 7463 return wrapper; 7464 } 7465 7466 /** 7467 * Creates a `_.find` or `_.findLast` function. 7468 * 7469 * @private 7470 * @param {Function} findIndexFunc The function to find the collection index. 7471 * @returns {Function} Returns the new find function. 7472 */ 7473 function createFind(findIndexFunc) { 7474 return function(collection, predicate, fromIndex) { 7475 var iterable = Object(collection); 7476 if (!isArrayLike(collection)) { 7477 var iteratee = getIteratee(predicate, 3); 7478 collection = keys(collection); 7479 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 7480 } 7481 var index = findIndexFunc(collection, predicate, fromIndex); 7482 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 7483 }; 7484 } 7485 7486 /** 7487 * Creates a `_.flow` or `_.flowRight` function. 7488 * 7489 * @private 7490 * @param {boolean} [fromRight] Specify iterating from right to left. 7491 * @returns {Function} Returns the new flow function. 7492 */ 7493 function createFlow(fromRight) { 7494 return flatRest(function(funcs) { 7495 var length = funcs.length, 7496 index = length, 7497 prereq = LodashWrapper.prototype.thru; 7498 7499 if (fromRight) { 7500 funcs.reverse(); 7501 } 7502 while (index--) { 7503 var func = funcs[index]; 7504 if (typeof func != 'function') { 7505 throw new TypeError(FUNC_ERROR_TEXT); 7506 } 7507 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 7508 var wrapper = new LodashWrapper([], true); 7509 } 7510 } 7511 index = wrapper ? index : length; 7512 while (++index < length) { 7513 func = funcs[index]; 7514 7515 var funcName = getFuncName(func), 7516 data = funcName == 'wrapper' ? getData(func) : undefined; 7517 7518 if (data && isLaziable(data[0]) && 7519 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 7520 !data[4].length && data[9] == 1 7521 ) { 7522 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 7523 } else { 7524 wrapper = (func.length == 1 && isLaziable(func)) 7525 ? wrapper[funcName]() 7526 : wrapper.thru(func); 7527 } 7528 } 7529 return function() { 7530 var args = arguments, 7531 value = args[0]; 7532 7533 if (wrapper && args.length == 1 && isArray(value)) { 7534 return wrapper.plant(value).value(); 7535 } 7536 var index = 0, 7537 result = length ? funcs[index].apply(this, args) : value; 7538 7539 while (++index < length) { 7540 result = funcs[index].call(this, result); 7541 } 7542 return result; 7543 }; 7544 }); 7545 } 7546 7547 /** 7548 * Creates a function that wraps `func` to invoke it with optional `this` 7549 * binding of `thisArg`, partial application, and currying. 7550 * 7551 * @private 7552 * @param {Function|string} func The function or method name to wrap. 7553 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7554 * @param {*} [thisArg] The `this` binding of `func`. 7555 * @param {Array} [partials] The arguments to prepend to those provided to 7556 * the new function. 7557 * @param {Array} [holders] The `partials` placeholder indexes. 7558 * @param {Array} [partialsRight] The arguments to append to those provided 7559 * to the new function. 7560 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 7561 * @param {Array} [argPos] The argument positions of the new function. 7562 * @param {number} [ary] The arity cap of `func`. 7563 * @param {number} [arity] The arity of `func`. 7564 * @returns {Function} Returns the new wrapped function. 7565 */ 7566 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 7567 var isAry = bitmask & WRAP_ARY_FLAG, 7568 isBind = bitmask & WRAP_BIND_FLAG, 7569 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 7570 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 7571 isFlip = bitmask & WRAP_FLIP_FLAG, 7572 Ctor = isBindKey ? undefined : createCtor(func); 7573 7574 function wrapper() { 7575 var length = arguments.length, 7576 args = Array(length), 7577 index = length; 7578 7579 while (index--) { 7580 args[index] = arguments[index]; 7581 } 7582 if (isCurried) { 7583 var placeholder = getHolder(wrapper), 7584 holdersCount = countHolders(args, placeholder); 7585 } 7586 if (partials) { 7587 args = composeArgs(args, partials, holders, isCurried); 7588 } 7589 if (partialsRight) { 7590 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 7591 } 7592 length -= holdersCount; 7593 if (isCurried && length < arity) { 7594 var newHolders = replaceHolders(args, placeholder); 7595 return createRecurry( 7596 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 7597 args, newHolders, argPos, ary, arity - length 7598 ); 7599 } 7600 var thisBinding = isBind ? thisArg : this, 7601 fn = isBindKey ? thisBinding[func] : func; 7602 7603 length = args.length; 7604 if (argPos) { 7605 args = reorder(args, argPos); 7606 } else if (isFlip && length > 1) { 7607 args.reverse(); 7608 } 7609 if (isAry && ary < length) { 7610 args.length = ary; 7611 } 7612 if (this && this !== root && this instanceof wrapper) { 7613 fn = Ctor || createCtor(fn); 7614 } 7615 return fn.apply(thisBinding, args); 7616 } 7617 return wrapper; 7618 } 7619 7620 /** 7621 * Creates a function like `_.invertBy`. 7622 * 7623 * @private 7624 * @param {Function} setter The function to set accumulator values. 7625 * @param {Function} toIteratee The function to resolve iteratees. 7626 * @returns {Function} Returns the new inverter function. 7627 */ 7628 function createInverter(setter, toIteratee) { 7629 return function(object, iteratee) { 7630 return baseInverter(object, setter, toIteratee(iteratee), {}); 7631 }; 7632 } 7633 7634 /** 7635 * Creates a function that performs a mathematical operation on two values. 7636 * 7637 * @private 7638 * @param {Function} operator The function to perform the operation. 7639 * @param {number} [defaultValue] The value used for `undefined` arguments. 7640 * @returns {Function} Returns the new mathematical operation function. 7641 */ 7642 function createMathOperation(operator, defaultValue) { 7643 return function(value, other) { 7644 var result; 7645 if (value === undefined && other === undefined) { 7646 return defaultValue; 7647 } 7648 if (value !== undefined) { 7649 result = value; 7650 } 7651 if (other !== undefined) { 7652 if (result === undefined) { 7653 return other; 7654 } 7655 if (typeof value == 'string' || typeof other == 'string') { 7656 value = baseToString(value); 7657 other = baseToString(other); 7658 } else { 7659 value = baseToNumber(value); 7660 other = baseToNumber(other); 7661 } 7662 result = operator(value, other); 7663 } 7664 return result; 7665 }; 7666 } 7667 7668 /** 7669 * Creates a function like `_.over`. 7670 * 7671 * @private 7672 * @param {Function} arrayFunc The function to iterate over iteratees. 7673 * @returns {Function} Returns the new over function. 7674 */ 7675 function createOver(arrayFunc) { 7676 return flatRest(function(iteratees) { 7677 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 7678 return baseRest(function(args) { 7679 var thisArg = this; 7680 return arrayFunc(iteratees, function(iteratee) { 7681 return apply(iteratee, thisArg, args); 7682 }); 7683 }); 7684 }); 7685 } 7686 7687 /** 7688 * Creates the padding for `string` based on `length`. The `chars` string 7689 * is truncated if the number of characters exceeds `length`. 7690 * 7691 * @private 7692 * @param {number} length The padding length. 7693 * @param {string} [chars=' '] The string used as padding. 7694 * @returns {string} Returns the padding for `string`. 7695 */ 7696 function createPadding(length, chars) { 7697 chars = chars === undefined ? ' ' : baseToString(chars); 7698 7699 var charsLength = chars.length; 7700 if (charsLength < 2) { 7701 return charsLength ? baseRepeat(chars, length) : chars; 7702 } 7703 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 7704 return hasUnicode(chars) 7705 ? castSlice(stringToArray(result), 0, length).join('') 7706 : result.slice(0, length); 7707 } 7708 7709 /** 7710 * Creates a function that wraps `func` to invoke it with the `this` binding 7711 * of `thisArg` and `partials` prepended to the arguments it receives. 7712 * 7713 * @private 7714 * @param {Function} func The function to wrap. 7715 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7716 * @param {*} thisArg The `this` binding of `func`. 7717 * @param {Array} partials The arguments to prepend to those provided to 7718 * the new function. 7719 * @returns {Function} Returns the new wrapped function. 7720 */ 7721 function createPartial(func, bitmask, thisArg, partials) { 7722 var isBind = bitmask & WRAP_BIND_FLAG, 7723 Ctor = createCtor(func); 7724 7725 function wrapper() { 7726 var argsIndex = -1, 7727 argsLength = arguments.length, 7728 leftIndex = -1, 7729 leftLength = partials.length, 7730 args = Array(leftLength + argsLength), 7731 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 7732 7733 while (++leftIndex < leftLength) { 7734 args[leftIndex] = partials[leftIndex]; 7735 } 7736 while (argsLength--) { 7737 args[leftIndex++] = arguments[++argsIndex]; 7738 } 7739 return apply(fn, isBind ? thisArg : this, args); 7740 } 7741 return wrapper; 7742 } 7743 7744 /** 7745 * Creates a `_.range` or `_.rangeRight` function. 7746 * 7747 * @private 7748 * @param {boolean} [fromRight] Specify iterating from right to left. 7749 * @returns {Function} Returns the new range function. 7750 */ 7751 function createRange(fromRight) { 7752 return function(start, end, step) { 7753 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 7754 end = step = undefined; 7755 } 7756 // Ensure the sign of `-0` is preserved. 7757 start = toFinite(start); 7758 if (end === undefined) { 7759 end = start; 7760 start = 0; 7761 } else { 7762 end = toFinite(end); 7763 } 7764 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 7765 return baseRange(start, end, step, fromRight); 7766 }; 7767 } 7768 7769 /** 7770 * Creates a function that performs a relational operation on two values. 7771 * 7772 * @private 7773 * @param {Function} operator The function to perform the operation. 7774 * @returns {Function} Returns the new relational operation function. 7775 */ 7776 function createRelationalOperation(operator) { 7777 return function(value, other) { 7778 if (!(typeof value == 'string' && typeof other == 'string')) { 7779 value = toNumber(value); 7780 other = toNumber(other); 7781 } 7782 return operator(value, other); 7783 }; 7784 } 7785 7786 /** 7787 * Creates a function that wraps `func` to continue currying. 7788 * 7789 * @private 7790 * @param {Function} func The function to wrap. 7791 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7792 * @param {Function} wrapFunc The function to create the `func` wrapper. 7793 * @param {*} placeholder The placeholder value. 7794 * @param {*} [thisArg] The `this` binding of `func`. 7795 * @param {Array} [partials] The arguments to prepend to those provided to 7796 * the new function. 7797 * @param {Array} [holders] The `partials` placeholder indexes. 7798 * @param {Array} [argPos] The argument positions of the new function. 7799 * @param {number} [ary] The arity cap of `func`. 7800 * @param {number} [arity] The arity of `func`. 7801 * @returns {Function} Returns the new wrapped function. 7802 */ 7803 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 7804 var isCurry = bitmask & WRAP_CURRY_FLAG, 7805 newHolders = isCurry ? holders : undefined, 7806 newHoldersRight = isCurry ? undefined : holders, 7807 newPartials = isCurry ? partials : undefined, 7808 newPartialsRight = isCurry ? undefined : partials; 7809 7810 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 7811 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 7812 7813 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 7814 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 7815 } 7816 var newData = [ 7817 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 7818 newHoldersRight, argPos, ary, arity 7819 ]; 7820 7821 var result = wrapFunc.apply(undefined, newData); 7822 if (isLaziable(func)) { 7823 setData(result, newData); 7824 } 7825 result.placeholder = placeholder; 7826 return setWrapToString(result, func, bitmask); 7827 } 7828 7829 /** 7830 * Creates a function like `_.round`. 7831 * 7832 * @private 7833 * @param {string} methodName The name of the `Math` method to use when rounding. 7834 * @returns {Function} Returns the new round function. 7835 */ 7836 function createRound(methodName) { 7837 var func = Math[methodName]; 7838 return function(number, precision) { 7839 number = toNumber(number); 7840 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 7841 if (precision) { 7842 // Shift with exponential notation to avoid floating-point issues. 7843 // See [MDN](https://mdn.io/round#Examples) for more details. 7844 var pair = (toString(number) + 'e').split('e'), 7845 value = func(pair[0] + 'e' + (+pair[1] + precision)); 7846 7847 pair = (toString(value) + 'e').split('e'); 7848 return +(pair[0] + 'e' + (+pair[1] - precision)); 7849 } 7850 return func(number); 7851 }; 7852 } 7853 7854 /** 7855 * Creates a set object of `values`. 7856 * 7857 * @private 7858 * @param {Array} values The values to add to the set. 7859 * @returns {Object} Returns the new set. 7860 */ 7861 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 7862 return new Set(values); 7863 }; 7864 7865 /** 7866 * Creates a `_.toPairs` or `_.toPairsIn` function. 7867 * 7868 * @private 7869 * @param {Function} keysFunc The function to get the keys of a given object. 7870 * @returns {Function} Returns the new pairs function. 7871 */ 7872 function createToPairs(keysFunc) { 7873 return function(object) { 7874 var tag = getTag(object); 7875 if (tag == mapTag) { 7876 return mapToArray(object); 7877 } 7878 if (tag == setTag) { 7879 return setToPairs(object); 7880 } 7881 return baseToPairs(object, keysFunc(object)); 7882 }; 7883 } 7884 7885 /** 7886 * Creates a function that either curries or invokes `func` with optional 7887 * `this` binding and partially applied arguments. 7888 * 7889 * @private 7890 * @param {Function|string} func The function or method name to wrap. 7891 * @param {number} bitmask The bitmask flags. 7892 * 1 - `_.bind` 7893 * 2 - `_.bindKey` 7894 * 4 - `_.curry` or `_.curryRight` of a bound function 7895 * 8 - `_.curry` 7896 * 16 - `_.curryRight` 7897 * 32 - `_.partial` 7898 * 64 - `_.partialRight` 7899 * 128 - `_.rearg` 7900 * 256 - `_.ary` 7901 * 512 - `_.flip` 7902 * @param {*} [thisArg] The `this` binding of `func`. 7903 * @param {Array} [partials] The arguments to be partially applied. 7904 * @param {Array} [holders] The `partials` placeholder indexes. 7905 * @param {Array} [argPos] The argument positions of the new function. 7906 * @param {number} [ary] The arity cap of `func`. 7907 * @param {number} [arity] The arity of `func`. 7908 * @returns {Function} Returns the new wrapped function. 7909 */ 7910 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 7911 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 7912 if (!isBindKey && typeof func != 'function') { 7913 throw new TypeError(FUNC_ERROR_TEXT); 7914 } 7915 var length = partials ? partials.length : 0; 7916 if (!length) { 7917 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 7918 partials = holders = undefined; 7919 } 7920 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 7921 arity = arity === undefined ? arity : toInteger(arity); 7922 length -= holders ? holders.length : 0; 7923 7924 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 7925 var partialsRight = partials, 7926 holdersRight = holders; 7927 7928 partials = holders = undefined; 7929 } 7930 var data = isBindKey ? undefined : getData(func); 7931 7932 var newData = [ 7933 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 7934 argPos, ary, arity 7935 ]; 7936 7937 if (data) { 7938 mergeData(newData, data); 7939 } 7940 func = newData[0]; 7941 bitmask = newData[1]; 7942 thisArg = newData[2]; 7943 partials = newData[3]; 7944 holders = newData[4]; 7945 arity = newData[9] = newData[9] === undefined 7946 ? (isBindKey ? 0 : func.length) 7947 : nativeMax(newData[9] - length, 0); 7948 7949 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 7950 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 7951 } 7952 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 7953 var result = createBind(func, bitmask, thisArg); 7954 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 7955 result = createCurry(func, bitmask, arity); 7956 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 7957 result = createPartial(func, bitmask, thisArg, partials); 7958 } else { 7959 result = createHybrid.apply(undefined, newData); 7960 } 7961 var setter = data ? baseSetData : setData; 7962 return setWrapToString(setter(result, newData), func, bitmask); 7963 } 7964 7965 /** 7966 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 7967 * of source objects to the destination object for all destination properties 7968 * that resolve to `undefined`. 7969 * 7970 * @private 7971 * @param {*} objValue The destination value. 7972 * @param {*} srcValue The source value. 7973 * @param {string} key The key of the property to assign. 7974 * @param {Object} object The parent object of `objValue`. 7975 * @returns {*} Returns the value to assign. 7976 */ 7977 function customDefaultsAssignIn(objValue, srcValue, key, object) { 7978 if (objValue === undefined || 7979 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 7980 return srcValue; 7981 } 7982 return objValue; 7983 } 7984 7985 /** 7986 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 7987 * objects into destination objects that are passed thru. 7988 * 7989 * @private 7990 * @param {*} objValue The destination value. 7991 * @param {*} srcValue The source value. 7992 * @param {string} key The key of the property to merge. 7993 * @param {Object} object The parent object of `objValue`. 7994 * @param {Object} source The parent object of `srcValue`. 7995 * @param {Object} [stack] Tracks traversed source values and their merged 7996 * counterparts. 7997 * @returns {*} Returns the value to assign. 7998 */ 7999 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 8000 if (isObject(objValue) && isObject(srcValue)) { 8001 // Recursively merge objects and arrays (susceptible to call stack limits). 8002 stack.set(srcValue, objValue); 8003 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 8004 stack['delete'](srcValue); 8005 } 8006 return objValue; 8007 } 8008 8009 /** 8010 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 8011 * objects. 8012 * 8013 * @private 8014 * @param {*} value The value to inspect. 8015 * @param {string} key The key of the property to inspect. 8016 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 8017 */ 8018 function customOmitClone(value) { 8019 return isPlainObject(value) ? undefined : value; 8020 } 8021 8022 /** 8023 * A specialized version of `baseIsEqualDeep` for arrays with support for 8024 * partial deep comparisons. 8025 * 8026 * @private 8027 * @param {Array} array The array to compare. 8028 * @param {Array} other The other array to compare. 8029 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 8030 * @param {Function} customizer The function to customize comparisons. 8031 * @param {Function} equalFunc The function to determine equivalents of values. 8032 * @param {Object} stack Tracks traversed `array` and `other` objects. 8033 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 8034 */ 8035 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 8036 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 8037 arrLength = array.length, 8038 othLength = other.length; 8039 8040 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 8041 return false; 8042 } 8043 // Assume cyclic values are equal. 8044 var stacked = stack.get(array); 8045 if (stacked && stack.get(other)) { 8046 return stacked == other; 8047 } 8048 var index = -1, 8049 result = true, 8050 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 8051 8052 stack.set(array, other); 8053 stack.set(other, array); 8054 8055 // Ignore non-index properties. 8056 while (++index < arrLength) { 8057 var arrValue = array[index], 8058 othValue = other[index]; 8059 8060 if (customizer) { 8061 var compared = isPartial 8062 ? customizer(othValue, arrValue, index, other, array, stack) 8063 : customizer(arrValue, othValue, index, array, other, stack); 8064 } 8065 if (compared !== undefined) { 8066 if (compared) { 8067 continue; 8068 } 8069 result = false; 8070 break; 8071 } 8072 // Recursively compare arrays (susceptible to call stack limits). 8073 if (seen) { 8074 if (!arraySome(other, function(othValue, othIndex) { 8075 if (!cacheHas(seen, othIndex) && 8076 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 8077 return seen.push(othIndex); 8078 } 8079 })) { 8080 result = false; 8081 break; 8082 } 8083 } else if (!( 8084 arrValue === othValue || 8085 equalFunc(arrValue, othValue, bitmask, customizer, stack) 8086 )) { 8087 result = false; 8088 break; 8089 } 8090 } 8091 stack['delete'](array); 8092 stack['delete'](other); 8093 return result; 8094 } 8095 8096 /** 8097 * A specialized version of `baseIsEqualDeep` for comparing objects of 8098 * the same `toStringTag`. 8099 * 8100 * **Note:** This function only supports comparing values with tags of 8101 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 8102 * 8103 * @private 8104 * @param {Object} object The object to compare. 8105 * @param {Object} other The other object to compare. 8106 * @param {string} tag The `toStringTag` of the objects to compare. 8107 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 8108 * @param {Function} customizer The function to customize comparisons. 8109 * @param {Function} equalFunc The function to determine equivalents of values. 8110 * @param {Object} stack Tracks traversed `object` and `other` objects. 8111 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 8112 */ 8113 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 8114 switch (tag) { 8115 case dataViewTag: 8116 if ((object.byteLength != other.byteLength) || 8117 (object.byteOffset != other.byteOffset)) { 8118 return false; 8119 } 8120 object = object.buffer; 8121 other = other.buffer; 8122 8123 case arrayBufferTag: 8124 if ((object.byteLength != other.byteLength) || 8125 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 8126 return false; 8127 } 8128 return true; 8129 8130 case boolTag: 8131 case dateTag: 8132 case numberTag: 8133 // Coerce booleans to `1` or `0` and dates to milliseconds. 8134 // Invalid dates are coerced to `NaN`. 8135 return eq(+object, +other); 8136 8137 case errorTag: 8138 return object.name == other.name && object.message == other.message; 8139 8140 case regexpTag: 8141 case stringTag: 8142 // Coerce regexes to strings and treat strings, primitives and objects, 8143 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 8144 // for more details. 8145 return object == (other + ''); 8146 8147 case mapTag: 8148 var convert = mapToArray; 8149 8150 case setTag: 8151 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 8152 convert || (convert = setToArray); 8153 8154 if (object.size != other.size && !isPartial) { 8155 return false; 8156 } 8157 // Assume cyclic values are equal. 8158 var stacked = stack.get(object); 8159 if (stacked) { 8160 return stacked == other; 8161 } 8162 bitmask |= COMPARE_UNORDERED_FLAG; 8163 8164 // Recursively compare objects (susceptible to call stack limits). 8165 stack.set(object, other); 8166 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 8167 stack['delete'](object); 8168 return result; 8169 8170 case symbolTag: 8171 if (symbolValueOf) { 8172 return symbolValueOf.call(object) == symbolValueOf.call(other); 8173 } 8174 } 8175 return false; 8176 } 8177 8178 /** 8179 * A specialized version of `baseIsEqualDeep` for objects with support for 8180 * partial deep comparisons. 8181 * 8182 * @private 8183 * @param {Object} object The object to compare. 8184 * @param {Object} other The other object to compare. 8185 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 8186 * @param {Function} customizer The function to customize comparisons. 8187 * @param {Function} equalFunc The function to determine equivalents of values. 8188 * @param {Object} stack Tracks traversed `object` and `other` objects. 8189 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 8190 */ 8191 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 8192 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 8193 objProps = getAllKeys(object), 8194 objLength = objProps.length, 8195 othProps = getAllKeys(other), 8196 othLength = othProps.length; 8197 8198 if (objLength != othLength && !isPartial) { 8199 return false; 8200 } 8201 var index = objLength; 8202 while (index--) { 8203 var key = objProps[index]; 8204 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 8205 return false; 8206 } 8207 } 8208 // Assume cyclic values are equal. 8209 var stacked = stack.get(object); 8210 if (stacked && stack.get(other)) { 8211 return stacked == other; 8212 } 8213 var result = true; 8214 stack.set(object, other); 8215 stack.set(other, object); 8216 8217 var skipCtor = isPartial; 8218 while (++index < objLength) { 8219 key = objProps[index]; 8220 var objValue = object[key], 8221 othValue = other[key]; 8222 8223 if (customizer) { 8224 var compared = isPartial 8225 ? customizer(othValue, objValue, key, other, object, stack) 8226 : customizer(objValue, othValue, key, object, other, stack); 8227 } 8228 // Recursively compare objects (susceptible to call stack limits). 8229 if (!(compared === undefined 8230 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 8231 : compared 8232 )) { 8233 result = false; 8234 break; 8235 } 8236 skipCtor || (skipCtor = key == 'constructor'); 8237 } 8238 if (result && !skipCtor) { 8239 var objCtor = object.constructor, 8240 othCtor = other.constructor; 8241 8242 // Non `Object` object instances with different constructors are not equal. 8243 if (objCtor != othCtor && 8244 ('constructor' in object && 'constructor' in other) && 8245 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 8246 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 8247 result = false; 8248 } 8249 } 8250 stack['delete'](object); 8251 stack['delete'](other); 8252 return result; 8253 } 8254 8255 /** 8256 * A specialized version of `baseRest` which flattens the rest array. 8257 * 8258 * @private 8259 * @param {Function} func The function to apply a rest parameter to. 8260 * @returns {Function} Returns the new function. 8261 */ 8262 function flatRest(func) { 8263 return setToString(overRest(func, undefined, flatten), func + ''); 8264 } 8265 8266 /** 8267 * Creates an array of own enumerable property names and symbols of `object`. 8268 * 8269 * @private 8270 * @param {Object} object The object to query. 8271 * @returns {Array} Returns the array of property names and symbols. 8272 */ 8273 function getAllKeys(object) { 8274 return baseGetAllKeys(object, keys, getSymbols); 8275 } 8276 8277 /** 8278 * Creates an array of own and inherited enumerable property names and 8279 * symbols of `object`. 8280 * 8281 * @private 8282 * @param {Object} object The object to query. 8283 * @returns {Array} Returns the array of property names and symbols. 8284 */ 8285 function getAllKeysIn(object) { 8286 return baseGetAllKeys(object, keysIn, getSymbolsIn); 8287 } 8288 8289 /** 8290 * Gets metadata for `func`. 8291 * 8292 * @private 8293 * @param {Function} func The function to query. 8294 * @returns {*} Returns the metadata for `func`. 8295 */ 8296 var getData = !metaMap ? noop : function(func) { 8297 return metaMap.get(func); 8298 }; 8299 8300 /** 8301 * Gets the name of `func`. 8302 * 8303 * @private 8304 * @param {Function} func The function to query. 8305 * @returns {string} Returns the function name. 8306 */ 8307 function getFuncName(func) { 8308 var result = (func.name + ''), 8309 array = realNames[result], 8310 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 8311 8312 while (length--) { 8313 var data = array[length], 8314 otherFunc = data.func; 8315 if (otherFunc == null || otherFunc == func) { 8316 return data.name; 8317 } 8318 } 8319 return result; 8320 } 8321 8322 /** 8323 * Gets the argument placeholder value for `func`. 8324 * 8325 * @private 8326 * @param {Function} func The function to inspect. 8327 * @returns {*} Returns the placeholder value. 8328 */ 8329 function getHolder(func) { 8330 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 8331 return object.placeholder; 8332 } 8333 8334 /** 8335 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 8336 * this function returns the custom method, otherwise it returns `baseIteratee`. 8337 * If arguments are provided, the chosen function is invoked with them and 8338 * its result is returned. 8339 * 8340 * @private 8341 * @param {*} [value] The value to convert to an iteratee. 8342 * @param {number} [arity] The arity of the created iteratee. 8343 * @returns {Function} Returns the chosen function or its result. 8344 */ 8345 function getIteratee() { 8346 var result = lodash.iteratee || iteratee; 8347 result = result === iteratee ? baseIteratee : result; 8348 return arguments.length ? result(arguments[0], arguments[1]) : result; 8349 } 8350 8351 /** 8352 * Gets the data for `map`. 8353 * 8354 * @private 8355 * @param {Object} map The map to query. 8356 * @param {string} key The reference key. 8357 * @returns {*} Returns the map data. 8358 */ 8359 function getMapData(map, key) { 8360 var data = map.__data__; 8361 return isKeyable(key) 8362 ? data[typeof key == 'string' ? 'string' : 'hash'] 8363 : data.map; 8364 } 8365 8366 /** 8367 * Gets the property names, values, and compare flags of `object`. 8368 * 8369 * @private 8370 * @param {Object} object The object to query. 8371 * @returns {Array} Returns the match data of `object`. 8372 */ 8373 function getMatchData(object) { 8374 var result = keys(object), 8375 length = result.length; 8376 8377 while (length--) { 8378 var key = result[length], 8379 value = object[key]; 8380 8381 result[length] = [key, value, isStrictComparable(value)]; 8382 } 8383 return result; 8384 } 8385 8386 /** 8387 * Gets the native function at `key` of `object`. 8388 * 8389 * @private 8390 * @param {Object} object The object to query. 8391 * @param {string} key The key of the method to get. 8392 * @returns {*} Returns the function if it's native, else `undefined`. 8393 */ 8394 function getNative(object, key) { 8395 var value = getValue(object, key); 8396 return baseIsNative(value) ? value : undefined; 8397 } 8398 8399 /** 8400 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 8401 * 8402 * @private 8403 * @param {*} value The value to query. 8404 * @returns {string} Returns the raw `toStringTag`. 8405 */ 8406 function getRawTag(value) { 8407 var isOwn = hasOwnProperty.call(value, symToStringTag), 8408 tag = value[symToStringTag]; 8409 8410 try { 8411 value[symToStringTag] = undefined; 8412 var unmasked = true; 8413 } catch (e) {} 8414 8415 var result = nativeObjectToString.call(value); 8416 if (unmasked) { 8417 if (isOwn) { 8418 value[symToStringTag] = tag; 8419 } else { 8420 delete value[symToStringTag]; 8421 } 8422 } 8423 return result; 8424 } 8425 8426 /** 8427 * Creates an array of the own enumerable symbols of `object`. 8428 * 8429 * @private 8430 * @param {Object} object The object to query. 8431 * @returns {Array} Returns the array of symbols. 8432 */ 8433 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 8434 if (object == null) { 8435 return []; 8436 } 8437 object = Object(object); 8438 return arrayFilter(nativeGetSymbols(object), function(symbol) { 8439 return propertyIsEnumerable.call(object, symbol); 8440 }); 8441 }; 8442 8443 /** 8444 * Creates an array of the own and inherited enumerable symbols of `object`. 8445 * 8446 * @private 8447 * @param {Object} object The object to query. 8448 * @returns {Array} Returns the array of symbols. 8449 */ 8450 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 8451 var result = []; 8452 while (object) { 8453 arrayPush(result, getSymbols(object)); 8454 object = getPrototype(object); 8455 } 8456 return result; 8457 }; 8458 8459 /** 8460 * Gets the `toStringTag` of `value`. 8461 * 8462 * @private 8463 * @param {*} value The value to query. 8464 * @returns {string} Returns the `toStringTag`. 8465 */ 8466 var getTag = baseGetTag; 8467 8468 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 8469 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 8470 (Map && getTag(new Map) != mapTag) || 8471 (Promise && getTag(Promise.resolve()) != promiseTag) || 8472 (Set && getTag(new Set) != setTag) || 8473 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 8474 getTag = function(value) { 8475 var result = baseGetTag(value), 8476 Ctor = result == objectTag ? value.constructor : undefined, 8477 ctorString = Ctor ? toSource(Ctor) : ''; 8478 8479 if (ctorString) { 8480 switch (ctorString) { 8481 case dataViewCtorString: return dataViewTag; 8482 case mapCtorString: return mapTag; 8483 case promiseCtorString: return promiseTag; 8484 case setCtorString: return setTag; 8485 case weakMapCtorString: return weakMapTag; 8486 } 8487 } 8488 return result; 8489 }; 8490 } 8491 8492 /** 8493 * Gets the view, applying any `transforms` to the `start` and `end` positions. 8494 * 8495 * @private 8496 * @param {number} start The start of the view. 8497 * @param {number} end The end of the view. 8498 * @param {Array} transforms The transformations to apply to the view. 8499 * @returns {Object} Returns an object containing the `start` and `end` 8500 * positions of the view. 8501 */ 8502 function getView(start, end, transforms) { 8503 var index = -1, 8504 length = transforms.length; 8505 8506 while (++index < length) { 8507 var data = transforms[index], 8508 size = data.size; 8509 8510 switch (data.type) { 8511 case 'drop': start += size; break; 8512 case 'dropRight': end -= size; break; 8513 case 'take': end = nativeMin(end, start + size); break; 8514 case 'takeRight': start = nativeMax(start, end - size); break; 8515 } 8516 } 8517 return { 'start': start, 'end': end }; 8518 } 8519 8520 /** 8521 * Extracts wrapper details from the `source` body comment. 8522 * 8523 * @private 8524 * @param {string} source The source to inspect. 8525 * @returns {Array} Returns the wrapper details. 8526 */ 8527 function getWrapDetails(source) { 8528 var match = source.match(reWrapDetails); 8529 return match ? match[1].split(reSplitDetails) : []; 8530 } 8531 8532 /** 8533 * Checks if `path` exists on `object`. 8534 * 8535 * @private 8536 * @param {Object} object The object to query. 8537 * @param {Array|string} path The path to check. 8538 * @param {Function} hasFunc The function to check properties. 8539 * @returns {boolean} Returns `true` if `path` exists, else `false`. 8540 */ 8541 function hasPath(object, path, hasFunc) { 8542 path = castPath(path, object); 8543 8544 var index = -1, 8545 length = path.length, 8546 result = false; 8547 8548 while (++index < length) { 8549 var key = toKey(path[index]); 8550 if (!(result = object != null && hasFunc(object, key))) { 8551 break; 8552 } 8553 object = object[key]; 8554 } 8555 if (result || ++index != length) { 8556 return result; 8557 } 8558 length = object == null ? 0 : object.length; 8559 return !!length && isLength(length) && isIndex(key, length) && 8560 (isArray(object) || isArguments(object)); 8561 } 8562 8563 /** 8564 * Initializes an array clone. 8565 * 8566 * @private 8567 * @param {Array} array The array to clone. 8568 * @returns {Array} Returns the initialized clone. 8569 */ 8570 function initCloneArray(array) { 8571 var length = array.length, 8572 result = new array.constructor(length); 8573 8574 // Add properties assigned by `RegExp#exec`. 8575 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 8576 result.index = array.index; 8577 result.input = array.input; 8578 } 8579 return result; 8580 } 8581 8582 /** 8583 * Initializes an object clone. 8584 * 8585 * @private 8586 * @param {Object} object The object to clone. 8587 * @returns {Object} Returns the initialized clone. 8588 */ 8589 function initCloneObject(object) { 8590 return (typeof object.constructor == 'function' && !isPrototype(object)) 8591 ? baseCreate(getPrototype(object)) 8592 : {}; 8593 } 8594 8595 /** 8596 * Initializes an object clone based on its `toStringTag`. 8597 * 8598 * **Note:** This function only supports cloning values with tags of 8599 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 8600 * 8601 * @private 8602 * @param {Object} object The object to clone. 8603 * @param {string} tag The `toStringTag` of the object to clone. 8604 * @param {boolean} [isDeep] Specify a deep clone. 8605 * @returns {Object} Returns the initialized clone. 8606 */ 8607 function initCloneByTag(object, tag, isDeep) { 8608 var Ctor = object.constructor; 8609 switch (tag) { 8610 case arrayBufferTag: 8611 return cloneArrayBuffer(object); 8612 8613 case boolTag: 8614 case dateTag: 8615 return new Ctor(+object); 8616 8617 case dataViewTag: 8618 return cloneDataView(object, isDeep); 8619 8620 case float32Tag: case float64Tag: 8621 case int8Tag: case int16Tag: case int32Tag: 8622 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 8623 return cloneTypedArray(object, isDeep); 8624 8625 case mapTag: 8626 return new Ctor; 8627 8628 case numberTag: 8629 case stringTag: 8630 return new Ctor(object); 8631 8632 case regexpTag: 8633 return cloneRegExp(object); 8634 8635 case setTag: 8636 return new Ctor; 8637 8638 case symbolTag: 8639 return cloneSymbol(object); 8640 } 8641 } 8642 8643 /** 8644 * Inserts wrapper `details` in a comment at the top of the `source` body. 8645 * 8646 * @private 8647 * @param {string} source The source to modify. 8648 * @returns {Array} details The details to insert. 8649 * @returns {string} Returns the modified source. 8650 */ 8651 function insertWrapDetails(source, details) { 8652 var length = details.length; 8653 if (!length) { 8654 return source; 8655 } 8656 var lastIndex = length - 1; 8657 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 8658 details = details.join(length > 2 ? ', ' : ' '); 8659 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 8660 } 8661 8662 /** 8663 * Checks if `value` is a flattenable `arguments` object or array. 8664 * 8665 * @private 8666 * @param {*} value The value to check. 8667 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 8668 */ 8669 function isFlattenable(value) { 8670 return isArray(value) || isArguments(value) || 8671 !!(spreadableSymbol && value && value[spreadableSymbol]); 8672 } 8673 8674 /** 8675 * Checks if `value` is a valid array-like index. 8676 * 8677 * @private 8678 * @param {*} value The value to check. 8679 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 8680 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 8681 */ 8682 function isIndex(value, length) { 8683 var type = typeof value; 8684 length = length == null ? MAX_SAFE_INTEGER : length; 8685 8686 return !!length && 8687 (type == 'number' || 8688 (type != 'symbol' && reIsUint.test(value))) && 8689 (value > -1 && value % 1 == 0 && value < length); 8690 } 8691 8692 /** 8693 * Checks if the given arguments are from an iteratee call. 8694 * 8695 * @private 8696 * @param {*} value The potential iteratee value argument. 8697 * @param {*} index The potential iteratee index or key argument. 8698 * @param {*} object The potential iteratee object argument. 8699 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 8700 * else `false`. 8701 */ 8702 function isIterateeCall(value, index, object) { 8703 if (!isObject(object)) { 8704 return false; 8705 } 8706 var type = typeof index; 8707 if (type == 'number' 8708 ? (isArrayLike(object) && isIndex(index, object.length)) 8709 : (type == 'string' && index in object) 8710 ) { 8711 return eq(object[index], value); 8712 } 8713 return false; 8714 } 8715 8716 /** 8717 * Checks if `value` is a property name and not a property path. 8718 * 8719 * @private 8720 * @param {*} value The value to check. 8721 * @param {Object} [object] The object to query keys on. 8722 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 8723 */ 8724 function isKey(value, object) { 8725 if (isArray(value)) { 8726 return false; 8727 } 8728 var type = typeof value; 8729 if (type == 'number' || type == 'symbol' || type == 'boolean' || 8730 value == null || isSymbol(value)) { 8731 return true; 8732 } 8733 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 8734 (object != null && value in Object(object)); 8735 } 8736 8737 /** 8738 * Checks if `value` is suitable for use as unique object key. 8739 * 8740 * @private 8741 * @param {*} value The value to check. 8742 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 8743 */ 8744 function isKeyable(value) { 8745 var type = typeof value; 8746 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 8747 ? (value !== '__proto__') 8748 : (value === null); 8749 } 8750 8751 /** 8752 * Checks if `func` has a lazy counterpart. 8753 * 8754 * @private 8755 * @param {Function} func The function to check. 8756 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 8757 * else `false`. 8758 */ 8759 function isLaziable(func) { 8760 var funcName = getFuncName(func), 8761 other = lodash[funcName]; 8762 8763 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 8764 return false; 8765 } 8766 if (func === other) { 8767 return true; 8768 } 8769 var data = getData(other); 8770 return !!data && func === data[0]; 8771 } 8772 8773 /** 8774 * Checks if `func` has its source masked. 8775 * 8776 * @private 8777 * @param {Function} func The function to check. 8778 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 8779 */ 8780 function isMasked(func) { 8781 return !!maskSrcKey && (maskSrcKey in func); 8782 } 8783 8784 /** 8785 * Checks if `func` is capable of being masked. 8786 * 8787 * @private 8788 * @param {*} value The value to check. 8789 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 8790 */ 8791 var isMaskable = coreJsData ? isFunction : stubFalse; 8792 8793 /** 8794 * Checks if `value` is likely a prototype object. 8795 * 8796 * @private 8797 * @param {*} value The value to check. 8798 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 8799 */ 8800 function isPrototype(value) { 8801 var Ctor = value && value.constructor, 8802 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 8803 8804 return value === proto; 8805 } 8806 8807 /** 8808 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 8809 * 8810 * @private 8811 * @param {*} value The value to check. 8812 * @returns {boolean} Returns `true` if `value` if suitable for strict 8813 * equality comparisons, else `false`. 8814 */ 8815 function isStrictComparable(value) { 8816 return value === value && !isObject(value); 8817 } 8818 8819 /** 8820 * A specialized version of `matchesProperty` for source values suitable 8821 * for strict equality comparisons, i.e. `===`. 8822 * 8823 * @private 8824 * @param {string} key The key of the property to get. 8825 * @param {*} srcValue The value to match. 8826 * @returns {Function} Returns the new spec function. 8827 */ 8828 function matchesStrictComparable(key, srcValue) { 8829 return function(object) { 8830 if (object == null) { 8831 return false; 8832 } 8833 return object[key] === srcValue && 8834 (srcValue !== undefined || (key in Object(object))); 8835 }; 8836 } 8837 8838 /** 8839 * A specialized version of `_.memoize` which clears the memoized function's 8840 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 8841 * 8842 * @private 8843 * @param {Function} func The function to have its output memoized. 8844 * @returns {Function} Returns the new memoized function. 8845 */ 8846 function memoizeCapped(func) { 8847 var result = memoize(func, function(key) { 8848 if (cache.size === MAX_MEMOIZE_SIZE) { 8849 cache.clear(); 8850 } 8851 return key; 8852 }); 8853 8854 var cache = result.cache; 8855 return result; 8856 } 8857 8858 /** 8859 * Merges the function metadata of `source` into `data`. 8860 * 8861 * Merging metadata reduces the number of wrappers used to invoke a function. 8862 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 8863 * may be applied regardless of execution order. Methods like `_.ary` and 8864 * `_.rearg` modify function arguments, making the order in which they are 8865 * executed important, preventing the merging of metadata. However, we make 8866 * an exception for a safe combined case where curried functions have `_.ary` 8867 * and or `_.rearg` applied. 8868 * 8869 * @private 8870 * @param {Array} data The destination metadata. 8871 * @param {Array} source The source metadata. 8872 * @returns {Array} Returns `data`. 8873 */ 8874 function mergeData(data, source) { 8875 var bitmask = data[1], 8876 srcBitmask = source[1], 8877 newBitmask = bitmask | srcBitmask, 8878 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 8879 8880 var isCombo = 8881 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 8882 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 8883 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 8884 8885 // Exit early if metadata can't be merged. 8886 if (!(isCommon || isCombo)) { 8887 return data; 8888 } 8889 // Use source `thisArg` if available. 8890 if (srcBitmask & WRAP_BIND_FLAG) { 8891 data[2] = source[2]; 8892 // Set when currying a bound function. 8893 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 8894 } 8895 // Compose partial arguments. 8896 var value = source[3]; 8897 if (value) { 8898 var partials = data[3]; 8899 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 8900 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 8901 } 8902 // Compose partial right arguments. 8903 value = source[5]; 8904 if (value) { 8905 partials = data[5]; 8906 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 8907 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 8908 } 8909 // Use source `argPos` if available. 8910 value = source[7]; 8911 if (value) { 8912 data[7] = value; 8913 } 8914 // Use source `ary` if it's smaller. 8915 if (srcBitmask & WRAP_ARY_FLAG) { 8916 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 8917 } 8918 // Use source `arity` if one is not provided. 8919 if (data[9] == null) { 8920 data[9] = source[9]; 8921 } 8922 // Use source `func` and merge bitmasks. 8923 data[0] = source[0]; 8924 data[1] = newBitmask; 8925 8926 return data; 8927 } 8928 8929 /** 8930 * This function is like 8931 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 8932 * except that it includes inherited enumerable properties. 8933 * 8934 * @private 8935 * @param {Object} object The object to query. 8936 * @returns {Array} Returns the array of property names. 8937 */ 8938 function nativeKeysIn(object) { 8939 var result = []; 8940 if (object != null) { 8941 for (var key in Object(object)) { 8942 result.push(key); 8943 } 8944 } 8945 return result; 8946 } 8947 8948 /** 8949 * Converts `value` to a string using `Object.prototype.toString`. 8950 * 8951 * @private 8952 * @param {*} value The value to convert. 8953 * @returns {string} Returns the converted string. 8954 */ 8955 function objectToString(value) { 8956 return nativeObjectToString.call(value); 8957 } 8958 8959 /** 8960 * A specialized version of `baseRest` which transforms the rest array. 8961 * 8962 * @private 8963 * @param {Function} func The function to apply a rest parameter to. 8964 * @param {number} [start=func.length-1] The start position of the rest parameter. 8965 * @param {Function} transform The rest array transform. 8966 * @returns {Function} Returns the new function. 8967 */ 8968 function overRest(func, start, transform) { 8969 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 8970 return function() { 8971 var args = arguments, 8972 index = -1, 8973 length = nativeMax(args.length - start, 0), 8974 array = Array(length); 8975 8976 while (++index < length) { 8977 array[index] = args[start + index]; 8978 } 8979 index = -1; 8980 var otherArgs = Array(start + 1); 8981 while (++index < start) { 8982 otherArgs[index] = args[index]; 8983 } 8984 otherArgs[start] = transform(array); 8985 return apply(func, this, otherArgs); 8986 }; 8987 } 8988 8989 /** 8990 * Gets the parent value at `path` of `object`. 8991 * 8992 * @private 8993 * @param {Object} object The object to query. 8994 * @param {Array} path The path to get the parent value of. 8995 * @returns {*} Returns the parent value. 8996 */ 8997 function parent(object, path) { 8998 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 8999 } 9000 9001 /** 9002 * Reorder `array` according to the specified indexes where the element at 9003 * the first index is assigned as the first element, the element at 9004 * the second index is assigned as the second element, and so on. 9005 * 9006 * @private 9007 * @param {Array} array The array to reorder. 9008 * @param {Array} indexes The arranged array indexes. 9009 * @returns {Array} Returns `array`. 9010 */ 9011 function reorder(array, indexes) { 9012 var arrLength = array.length, 9013 length = nativeMin(indexes.length, arrLength), 9014 oldArray = copyArray(array); 9015 9016 while (length--) { 9017 var index = indexes[length]; 9018 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 9019 } 9020 return array; 9021 } 9022 9023 /** 9024 * Sets metadata for `func`. 9025 * 9026 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 9027 * period of time, it will trip its breaker and transition to an identity 9028 * function to avoid garbage collection pauses in V8. See 9029 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 9030 * for more details. 9031 * 9032 * @private 9033 * @param {Function} func The function to associate metadata with. 9034 * @param {*} data The metadata. 9035 * @returns {Function} Returns `func`. 9036 */ 9037 var setData = shortOut(baseSetData); 9038 9039 /** 9040 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 9041 * 9042 * @private 9043 * @param {Function} func The function to delay. 9044 * @param {number} wait The number of milliseconds to delay invocation. 9045 * @returns {number|Object} Returns the timer id or timeout object. 9046 */ 9047 var setTimeout = ctxSetTimeout || function(func, wait) { 9048 return root.setTimeout(func, wait); 9049 }; 9050 9051 /** 9052 * Sets the `toString` method of `func` to return `string`. 9053 * 9054 * @private 9055 * @param {Function} func The function to modify. 9056 * @param {Function} string The `toString` result. 9057 * @returns {Function} Returns `func`. 9058 */ 9059 var setToString = shortOut(baseSetToString); 9060 9061 /** 9062 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 9063 * with wrapper details in a comment at the top of the source body. 9064 * 9065 * @private 9066 * @param {Function} wrapper The function to modify. 9067 * @param {Function} reference The reference function. 9068 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 9069 * @returns {Function} Returns `wrapper`. 9070 */ 9071 function setWrapToString(wrapper, reference, bitmask) { 9072 var source = (reference + ''); 9073 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 9074 } 9075 9076 /** 9077 * Creates a function that'll short out and invoke `identity` instead 9078 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 9079 * milliseconds. 9080 * 9081 * @private 9082 * @param {Function} func The function to restrict. 9083 * @returns {Function} Returns the new shortable function. 9084 */ 9085 function shortOut(func) { 9086 var count = 0, 9087 lastCalled = 0; 9088 9089 return function() { 9090 var stamp = nativeNow(), 9091 remaining = HOT_SPAN - (stamp - lastCalled); 9092 9093 lastCalled = stamp; 9094 if (remaining > 0) { 9095 if (++count >= HOT_COUNT) { 9096 return arguments[0]; 9097 } 9098 } else { 9099 count = 0; 9100 } 9101 return func.apply(undefined, arguments); 9102 }; 9103 } 9104 9105 /** 9106 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 9107 * 9108 * @private 9109 * @param {Array} array The array to shuffle. 9110 * @param {number} [size=array.length] The size of `array`. 9111 * @returns {Array} Returns `array`. 9112 */ 9113 function shuffleSelf(array, size) { 9114 var index = -1, 9115 length = array.length, 9116 lastIndex = length - 1; 9117 9118 size = size === undefined ? length : size; 9119 while (++index < size) { 9120 var rand = baseRandom(index, lastIndex), 9121 value = array[rand]; 9122 9123 array[rand] = array[index]; 9124 array[index] = value; 9125 } 9126 array.length = size; 9127 return array; 9128 } 9129 9130 /** 9131 * Converts `string` to a property path array. 9132 * 9133 * @private 9134 * @param {string} string The string to convert. 9135 * @returns {Array} Returns the property path array. 9136 */ 9137 var stringToPath = memoizeCapped(function(string) { 9138 var result = []; 9139 if (string.charCodeAt(0) === 46 /* . */) { 9140 result.push(''); 9141 } 9142 string.replace(rePropName, function(match, number, quote, subString) { 9143 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 9144 }); 9145 return result; 9146 }); 9147 9148 /** 9149 * Converts `value` to a string key if it's not a string or symbol. 9150 * 9151 * @private 9152 * @param {*} value The value to inspect. 9153 * @returns {string|symbol} Returns the key. 9154 */ 9155 function toKey(value) { 9156 if (typeof value == 'string' || isSymbol(value)) { 9157 return value; 9158 } 9159 var result = (value + ''); 9160 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 9161 } 9162 9163 /** 9164 * Converts `func` to its source code. 9165 * 9166 * @private 9167 * @param {Function} func The function to convert. 9168 * @returns {string} Returns the source code. 9169 */ 9170 function toSource(func) { 9171 if (func != null) { 9172 try { 9173 return funcToString.call(func); 9174 } catch (e) {} 9175 try { 9176 return (func + ''); 9177 } catch (e) {} 9178 } 9179 return ''; 9180 } 9181 9182 /** 9183 * Updates wrapper `details` based on `bitmask` flags. 9184 * 9185 * @private 9186 * @returns {Array} details The details to modify. 9187 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 9188 * @returns {Array} Returns `details`. 9189 */ 9190 function updateWrapDetails(details, bitmask) { 9191 arrayEach(wrapFlags, function(pair) { 9192 var value = '_.' + pair[0]; 9193 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 9194 details.push(value); 9195 } 9196 }); 9197 return details.sort(); 9198 } 9199 9200 /** 9201 * Creates a clone of `wrapper`. 9202 * 9203 * @private 9204 * @param {Object} wrapper The wrapper to clone. 9205 * @returns {Object} Returns the cloned wrapper. 9206 */ 9207 function wrapperClone(wrapper) { 9208 if (wrapper instanceof LazyWrapper) { 9209 return wrapper.clone(); 9210 } 9211 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 9212 result.__actions__ = copyArray(wrapper.__actions__); 9213 result.__index__ = wrapper.__index__; 9214 result.__values__ = wrapper.__values__; 9215 return result; 9216 } 9217 9218 /*------------------------------------------------------------------------*/ 9219 9220 /** 9221 * Creates an array of elements split into groups the length of `size`. 9222 * If `array` can't be split evenly, the final chunk will be the remaining 9223 * elements. 9224 * 9225 * @static 9226 * @memberOf _ 9227 * @since 3.0.0 9228 * @category Array 9229 * @param {Array} array The array to process. 9230 * @param {number} [size=1] The length of each chunk 9231 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9232 * @returns {Array} Returns the new array of chunks. 9233 * @example 9234 * 9235 * _.chunk(['a', 'b', 'c', 'd'], 2); 9236 * // => [['a', 'b'], ['c', 'd']] 9237 * 9238 * _.chunk(['a', 'b', 'c', 'd'], 3); 9239 * // => [['a', 'b', 'c'], ['d']] 9240 */ 9241 function chunk(array, size, guard) { 9242 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 9243 size = 1; 9244 } else { 9245 size = nativeMax(toInteger(size), 0); 9246 } 9247 var length = array == null ? 0 : array.length; 9248 if (!length || size < 1) { 9249 return []; 9250 } 9251 var index = 0, 9252 resIndex = 0, 9253 result = Array(nativeCeil(length / size)); 9254 9255 while (index < length) { 9256 result[resIndex++] = baseSlice(array, index, (index += size)); 9257 } 9258 return result; 9259 } 9260 9261 /** 9262 * Creates an array with all falsey values removed. The values `false`, `null`, 9263 * `0`, `""`, `undefined`, and `NaN` are falsey. 9264 * 9265 * @static 9266 * @memberOf _ 9267 * @since 0.1.0 9268 * @category Array 9269 * @param {Array} array The array to compact. 9270 * @returns {Array} Returns the new array of filtered values. 9271 * @example 9272 * 9273 * _.compact([0, 1, false, 2, '', 3]); 9274 * // => [1, 2, 3] 9275 */ 9276 function compact(array) { 9277 var index = -1, 9278 length = array == null ? 0 : array.length, 9279 resIndex = 0, 9280 result = []; 9281 9282 while (++index < length) { 9283 var value = array[index]; 9284 if (value) { 9285 result[resIndex++] = value; 9286 } 9287 } 9288 return result; 9289 } 9290 9291 /** 9292 * Creates a new array concatenating `array` with any additional arrays 9293 * and/or values. 9294 * 9295 * @static 9296 * @memberOf _ 9297 * @since 4.0.0 9298 * @category Array 9299 * @param {Array} array The array to concatenate. 9300 * @param {...*} [values] The values to concatenate. 9301 * @returns {Array} Returns the new concatenated array. 9302 * @example 9303 * 9304 * var array = [1]; 9305 * var other = _.concat(array, 2, [3], [[4]]); 9306 * 9307 * console.log(other); 9308 * // => [1, 2, 3, [4]] 9309 * 9310 * console.log(array); 9311 * // => [1] 9312 */ 9313 function concat() { 9314 var length = arguments.length; 9315 if (!length) { 9316 return []; 9317 } 9318 var args = Array(length - 1), 9319 array = arguments[0], 9320 index = length; 9321 9322 while (index--) { 9323 args[index - 1] = arguments[index]; 9324 } 9325 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 9326 } 9327 9328 /** 9329 * Creates an array of `array` values not included in the other given arrays 9330 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9331 * for equality comparisons. The order and references of result values are 9332 * determined by the first array. 9333 * 9334 * **Note:** Unlike `_.pullAll`, this method returns a new array. 9335 * 9336 * @static 9337 * @memberOf _ 9338 * @since 0.1.0 9339 * @category Array 9340 * @param {Array} array The array to inspect. 9341 * @param {...Array} [values] The values to exclude. 9342 * @returns {Array} Returns the new array of filtered values. 9343 * @see _.without, _.xor 9344 * @example 9345 * 9346 * _.difference([2, 1], [2, 3]); 9347 * // => [1] 9348 */ 9349 var difference = baseRest(function(array, values) { 9350 return isArrayLikeObject(array) 9351 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 9352 : []; 9353 }); 9354 9355 /** 9356 * This method is like `_.difference` except that it accepts `iteratee` which 9357 * is invoked for each element of `array` and `values` to generate the criterion 9358 * by which they're compared. The order and references of result values are 9359 * determined by the first array. The iteratee is invoked with one argument: 9360 * (value). 9361 * 9362 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 9363 * 9364 * @static 9365 * @memberOf _ 9366 * @since 4.0.0 9367 * @category Array 9368 * @param {Array} array The array to inspect. 9369 * @param {...Array} [values] The values to exclude. 9370 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9371 * @returns {Array} Returns the new array of filtered values. 9372 * @example 9373 * 9374 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 9375 * // => [1.2] 9376 * 9377 * // The `_.property` iteratee shorthand. 9378 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 9379 * // => [{ 'x': 2 }] 9380 */ 9381 var differenceBy = baseRest(function(array, values) { 9382 var iteratee = last(values); 9383 if (isArrayLikeObject(iteratee)) { 9384 iteratee = undefined; 9385 } 9386 return isArrayLikeObject(array) 9387 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 9388 : []; 9389 }); 9390 9391 /** 9392 * This method is like `_.difference` except that it accepts `comparator` 9393 * which is invoked to compare elements of `array` to `values`. The order and 9394 * references of result values are determined by the first array. The comparator 9395 * is invoked with two arguments: (arrVal, othVal). 9396 * 9397 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 9398 * 9399 * @static 9400 * @memberOf _ 9401 * @since 4.0.0 9402 * @category Array 9403 * @param {Array} array The array to inspect. 9404 * @param {...Array} [values] The values to exclude. 9405 * @param {Function} [comparator] The comparator invoked per element. 9406 * @returns {Array} Returns the new array of filtered values. 9407 * @example 9408 * 9409 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 9410 * 9411 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 9412 * // => [{ 'x': 2, 'y': 1 }] 9413 */ 9414 var differenceWith = baseRest(function(array, values) { 9415 var comparator = last(values); 9416 if (isArrayLikeObject(comparator)) { 9417 comparator = undefined; 9418 } 9419 return isArrayLikeObject(array) 9420 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 9421 : []; 9422 }); 9423 9424 /** 9425 * Creates a slice of `array` with `n` elements dropped from the beginning. 9426 * 9427 * @static 9428 * @memberOf _ 9429 * @since 0.5.0 9430 * @category Array 9431 * @param {Array} array The array to query. 9432 * @param {number} [n=1] The number of elements to drop. 9433 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9434 * @returns {Array} Returns the slice of `array`. 9435 * @example 9436 * 9437 * _.drop([1, 2, 3]); 9438 * // => [2, 3] 9439 * 9440 * _.drop([1, 2, 3], 2); 9441 * // => [3] 9442 * 9443 * _.drop([1, 2, 3], 5); 9444 * // => [] 9445 * 9446 * _.drop([1, 2, 3], 0); 9447 * // => [1, 2, 3] 9448 */ 9449 function drop(array, n, guard) { 9450 var length = array == null ? 0 : array.length; 9451 if (!length) { 9452 return []; 9453 } 9454 n = (guard || n === undefined) ? 1 : toInteger(n); 9455 return baseSlice(array, n < 0 ? 0 : n, length); 9456 } 9457 9458 /** 9459 * Creates a slice of `array` with `n` elements dropped from the end. 9460 * 9461 * @static 9462 * @memberOf _ 9463 * @since 3.0.0 9464 * @category Array 9465 * @param {Array} array The array to query. 9466 * @param {number} [n=1] The number of elements to drop. 9467 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9468 * @returns {Array} Returns the slice of `array`. 9469 * @example 9470 * 9471 * _.dropRight([1, 2, 3]); 9472 * // => [1, 2] 9473 * 9474 * _.dropRight([1, 2, 3], 2); 9475 * // => [1] 9476 * 9477 * _.dropRight([1, 2, 3], 5); 9478 * // => [] 9479 * 9480 * _.dropRight([1, 2, 3], 0); 9481 * // => [1, 2, 3] 9482 */ 9483 function dropRight(array, n, guard) { 9484 var length = array == null ? 0 : array.length; 9485 if (!length) { 9486 return []; 9487 } 9488 n = (guard || n === undefined) ? 1 : toInteger(n); 9489 n = length - n; 9490 return baseSlice(array, 0, n < 0 ? 0 : n); 9491 } 9492 9493 /** 9494 * Creates a slice of `array` excluding elements dropped from the end. 9495 * Elements are dropped until `predicate` returns falsey. The predicate is 9496 * invoked with three arguments: (value, index, array). 9497 * 9498 * @static 9499 * @memberOf _ 9500 * @since 3.0.0 9501 * @category Array 9502 * @param {Array} array The array to query. 9503 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9504 * @returns {Array} Returns the slice of `array`. 9505 * @example 9506 * 9507 * var users = [ 9508 * { 'user': 'barney', 'active': true }, 9509 * { 'user': 'fred', 'active': false }, 9510 * { 'user': 'pebbles', 'active': false } 9511 * ]; 9512 * 9513 * _.dropRightWhile(users, function(o) { return !o.active; }); 9514 * // => objects for ['barney'] 9515 * 9516 * // The `_.matches` iteratee shorthand. 9517 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 9518 * // => objects for ['barney', 'fred'] 9519 * 9520 * // The `_.matchesProperty` iteratee shorthand. 9521 * _.dropRightWhile(users, ['active', false]); 9522 * // => objects for ['barney'] 9523 * 9524 * // The `_.property` iteratee shorthand. 9525 * _.dropRightWhile(users, 'active'); 9526 * // => objects for ['barney', 'fred', 'pebbles'] 9527 */ 9528 function dropRightWhile(array, predicate) { 9529 return (array && array.length) 9530 ? baseWhile(array, getIteratee(predicate, 3), true, true) 9531 : []; 9532 } 9533 9534 /** 9535 * Creates a slice of `array` excluding elements dropped from the beginning. 9536 * Elements are dropped until `predicate` returns falsey. The predicate is 9537 * invoked with three arguments: (value, index, array). 9538 * 9539 * @static 9540 * @memberOf _ 9541 * @since 3.0.0 9542 * @category Array 9543 * @param {Array} array The array to query. 9544 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9545 * @returns {Array} Returns the slice of `array`. 9546 * @example 9547 * 9548 * var users = [ 9549 * { 'user': 'barney', 'active': false }, 9550 * { 'user': 'fred', 'active': false }, 9551 * { 'user': 'pebbles', 'active': true } 9552 * ]; 9553 * 9554 * _.dropWhile(users, function(o) { return !o.active; }); 9555 * // => objects for ['pebbles'] 9556 * 9557 * // The `_.matches` iteratee shorthand. 9558 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 9559 * // => objects for ['fred', 'pebbles'] 9560 * 9561 * // The `_.matchesProperty` iteratee shorthand. 9562 * _.dropWhile(users, ['active', false]); 9563 * // => objects for ['pebbles'] 9564 * 9565 * // The `_.property` iteratee shorthand. 9566 * _.dropWhile(users, 'active'); 9567 * // => objects for ['barney', 'fred', 'pebbles'] 9568 */ 9569 function dropWhile(array, predicate) { 9570 return (array && array.length) 9571 ? baseWhile(array, getIteratee(predicate, 3), true) 9572 : []; 9573 } 9574 9575 /** 9576 * Fills elements of `array` with `value` from `start` up to, but not 9577 * including, `end`. 9578 * 9579 * **Note:** This method mutates `array`. 9580 * 9581 * @static 9582 * @memberOf _ 9583 * @since 3.2.0 9584 * @category Array 9585 * @param {Array} array The array to fill. 9586 * @param {*} value The value to fill `array` with. 9587 * @param {number} [start=0] The start position. 9588 * @param {number} [end=array.length] The end position. 9589 * @returns {Array} Returns `array`. 9590 * @example 9591 * 9592 * var array = [1, 2, 3]; 9593 * 9594 * _.fill(array, 'a'); 9595 * console.log(array); 9596 * // => ['a', 'a', 'a'] 9597 * 9598 * _.fill(Array(3), 2); 9599 * // => [2, 2, 2] 9600 * 9601 * _.fill([4, 6, 8, 10], '*', 1, 3); 9602 * // => [4, '*', '*', 10] 9603 */ 9604 function fill(array, value, start, end) { 9605 var length = array == null ? 0 : array.length; 9606 if (!length) { 9607 return []; 9608 } 9609 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 9610 start = 0; 9611 end = length; 9612 } 9613 return baseFill(array, value, start, end); 9614 } 9615 9616 /** 9617 * This method is like `_.find` except that it returns the index of the first 9618 * element `predicate` returns truthy for instead of the element itself. 9619 * 9620 * @static 9621 * @memberOf _ 9622 * @since 1.1.0 9623 * @category Array 9624 * @param {Array} array The array to inspect. 9625 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9626 * @param {number} [fromIndex=0] The index to search from. 9627 * @returns {number} Returns the index of the found element, else `-1`. 9628 * @example 9629 * 9630 * var users = [ 9631 * { 'user': 'barney', 'active': false }, 9632 * { 'user': 'fred', 'active': false }, 9633 * { 'user': 'pebbles', 'active': true } 9634 * ]; 9635 * 9636 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 9637 * // => 0 9638 * 9639 * // The `_.matches` iteratee shorthand. 9640 * _.findIndex(users, { 'user': 'fred', 'active': false }); 9641 * // => 1 9642 * 9643 * // The `_.matchesProperty` iteratee shorthand. 9644 * _.findIndex(users, ['active', false]); 9645 * // => 0 9646 * 9647 * // The `_.property` iteratee shorthand. 9648 * _.findIndex(users, 'active'); 9649 * // => 2 9650 */ 9651 function findIndex(array, predicate, fromIndex) { 9652 var length = array == null ? 0 : array.length; 9653 if (!length) { 9654 return -1; 9655 } 9656 var index = fromIndex == null ? 0 : toInteger(fromIndex); 9657 if (index < 0) { 9658 index = nativeMax(length + index, 0); 9659 } 9660 return baseFindIndex(array, getIteratee(predicate, 3), index); 9661 } 9662 9663 /** 9664 * This method is like `_.findIndex` except that it iterates over elements 9665 * of `collection` from right to left. 9666 * 9667 * @static 9668 * @memberOf _ 9669 * @since 2.0.0 9670 * @category Array 9671 * @param {Array} array The array to inspect. 9672 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9673 * @param {number} [fromIndex=array.length-1] The index to search from. 9674 * @returns {number} Returns the index of the found element, else `-1`. 9675 * @example 9676 * 9677 * var users = [ 9678 * { 'user': 'barney', 'active': true }, 9679 * { 'user': 'fred', 'active': false }, 9680 * { 'user': 'pebbles', 'active': false } 9681 * ]; 9682 * 9683 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 9684 * // => 2 9685 * 9686 * // The `_.matches` iteratee shorthand. 9687 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 9688 * // => 0 9689 * 9690 * // The `_.matchesProperty` iteratee shorthand. 9691 * _.findLastIndex(users, ['active', false]); 9692 * // => 2 9693 * 9694 * // The `_.property` iteratee shorthand. 9695 * _.findLastIndex(users, 'active'); 9696 * // => 0 9697 */ 9698 function findLastIndex(array, predicate, fromIndex) { 9699 var length = array == null ? 0 : array.length; 9700 if (!length) { 9701 return -1; 9702 } 9703 var index = length - 1; 9704 if (fromIndex !== undefined) { 9705 index = toInteger(fromIndex); 9706 index = fromIndex < 0 9707 ? nativeMax(length + index, 0) 9708 : nativeMin(index, length - 1); 9709 } 9710 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 9711 } 9712 9713 /** 9714 * Flattens `array` a single level deep. 9715 * 9716 * @static 9717 * @memberOf _ 9718 * @since 0.1.0 9719 * @category Array 9720 * @param {Array} array The array to flatten. 9721 * @returns {Array} Returns the new flattened array. 9722 * @example 9723 * 9724 * _.flatten([1, [2, [3, [4]], 5]]); 9725 * // => [1, 2, [3, [4]], 5] 9726 */ 9727 function flatten(array) { 9728 var length = array == null ? 0 : array.length; 9729 return length ? baseFlatten(array, 1) : []; 9730 } 9731 9732 /** 9733 * Recursively flattens `array`. 9734 * 9735 * @static 9736 * @memberOf _ 9737 * @since 3.0.0 9738 * @category Array 9739 * @param {Array} array The array to flatten. 9740 * @returns {Array} Returns the new flattened array. 9741 * @example 9742 * 9743 * _.flattenDeep([1, [2, [3, [4]], 5]]); 9744 * // => [1, 2, 3, 4, 5] 9745 */ 9746 function flattenDeep(array) { 9747 var length = array == null ? 0 : array.length; 9748 return length ? baseFlatten(array, INFINITY) : []; 9749 } 9750 9751 /** 9752 * Recursively flatten `array` up to `depth` times. 9753 * 9754 * @static 9755 * @memberOf _ 9756 * @since 4.4.0 9757 * @category Array 9758 * @param {Array} array The array to flatten. 9759 * @param {number} [depth=1] The maximum recursion depth. 9760 * @returns {Array} Returns the new flattened array. 9761 * @example 9762 * 9763 * var array = [1, [2, [3, [4]], 5]]; 9764 * 9765 * _.flattenDepth(array, 1); 9766 * // => [1, 2, [3, [4]], 5] 9767 * 9768 * _.flattenDepth(array, 2); 9769 * // => [1, 2, 3, [4], 5] 9770 */ 9771 function flattenDepth(array, depth) { 9772 var length = array == null ? 0 : array.length; 9773 if (!length) { 9774 return []; 9775 } 9776 depth = depth === undefined ? 1 : toInteger(depth); 9777 return baseFlatten(array, depth); 9778 } 9779 9780 /** 9781 * The inverse of `_.toPairs`; this method returns an object composed 9782 * from key-value `pairs`. 9783 * 9784 * @static 9785 * @memberOf _ 9786 * @since 4.0.0 9787 * @category Array 9788 * @param {Array} pairs The key-value pairs. 9789 * @returns {Object} Returns the new object. 9790 * @example 9791 * 9792 * _.fromPairs([['a', 1], ['b', 2]]); 9793 * // => { 'a': 1, 'b': 2 } 9794 */ 9795 function fromPairs(pairs) { 9796 var index = -1, 9797 length = pairs == null ? 0 : pairs.length, 9798 result = {}; 9799 9800 while (++index < length) { 9801 var pair = pairs[index]; 9802 result[pair[0]] = pair[1]; 9803 } 9804 return result; 9805 } 9806 9807 /** 9808 * Gets the first element of `array`. 9809 * 9810 * @static 9811 * @memberOf _ 9812 * @since 0.1.0 9813 * @alias first 9814 * @category Array 9815 * @param {Array} array The array to query. 9816 * @returns {*} Returns the first element of `array`. 9817 * @example 9818 * 9819 * _.head([1, 2, 3]); 9820 * // => 1 9821 * 9822 * _.head([]); 9823 * // => undefined 9824 */ 9825 function head(array) { 9826 return (array && array.length) ? array[0] : undefined; 9827 } 9828 9829 /** 9830 * Gets the index at which the first occurrence of `value` is found in `array` 9831 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9832 * for equality comparisons. If `fromIndex` is negative, it's used as the 9833 * offset from the end of `array`. 9834 * 9835 * @static 9836 * @memberOf _ 9837 * @since 0.1.0 9838 * @category Array 9839 * @param {Array} array The array to inspect. 9840 * @param {*} value The value to search for. 9841 * @param {number} [fromIndex=0] The index to search from. 9842 * @returns {number} Returns the index of the matched value, else `-1`. 9843 * @example 9844 * 9845 * _.indexOf([1, 2, 1, 2], 2); 9846 * // => 1 9847 * 9848 * // Search from the `fromIndex`. 9849 * _.indexOf([1, 2, 1, 2], 2, 2); 9850 * // => 3 9851 */ 9852 function indexOf(array, value, fromIndex) { 9853 var length = array == null ? 0 : array.length; 9854 if (!length) { 9855 return -1; 9856 } 9857 var index = fromIndex == null ? 0 : toInteger(fromIndex); 9858 if (index < 0) { 9859 index = nativeMax(length + index, 0); 9860 } 9861 return baseIndexOf(array, value, index); 9862 } 9863 9864 /** 9865 * Gets all but the last element of `array`. 9866 * 9867 * @static 9868 * @memberOf _ 9869 * @since 0.1.0 9870 * @category Array 9871 * @param {Array} array The array to query. 9872 * @returns {Array} Returns the slice of `array`. 9873 * @example 9874 * 9875 * _.initial([1, 2, 3]); 9876 * // => [1, 2] 9877 */ 9878 function initial(array) { 9879 var length = array == null ? 0 : array.length; 9880 return length ? baseSlice(array, 0, -1) : []; 9881 } 9882 9883 /** 9884 * Creates an array of unique values that are included in all given arrays 9885 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9886 * for equality comparisons. The order and references of result values are 9887 * determined by the first array. 9888 * 9889 * @static 9890 * @memberOf _ 9891 * @since 0.1.0 9892 * @category Array 9893 * @param {...Array} [arrays] The arrays to inspect. 9894 * @returns {Array} Returns the new array of intersecting values. 9895 * @example 9896 * 9897 * _.intersection([2, 1], [2, 3]); 9898 * // => [2] 9899 */ 9900 var intersection = baseRest(function(arrays) { 9901 var mapped = arrayMap(arrays, castArrayLikeObject); 9902 return (mapped.length && mapped[0] === arrays[0]) 9903 ? baseIntersection(mapped) 9904 : []; 9905 }); 9906 9907 /** 9908 * This method is like `_.intersection` except that it accepts `iteratee` 9909 * which is invoked for each element of each `arrays` to generate the criterion 9910 * by which they're compared. The order and references of result values are 9911 * determined by the first array. The iteratee is invoked with one argument: 9912 * (value). 9913 * 9914 * @static 9915 * @memberOf _ 9916 * @since 4.0.0 9917 * @category Array 9918 * @param {...Array} [arrays] The arrays to inspect. 9919 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9920 * @returns {Array} Returns the new array of intersecting values. 9921 * @example 9922 * 9923 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 9924 * // => [2.1] 9925 * 9926 * // The `_.property` iteratee shorthand. 9927 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 9928 * // => [{ 'x': 1 }] 9929 */ 9930 var intersectionBy = baseRest(function(arrays) { 9931 var iteratee = last(arrays), 9932 mapped = arrayMap(arrays, castArrayLikeObject); 9933 9934 if (iteratee === last(mapped)) { 9935 iteratee = undefined; 9936 } else { 9937 mapped.pop(); 9938 } 9939 return (mapped.length && mapped[0] === arrays[0]) 9940 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 9941 : []; 9942 }); 9943 9944 /** 9945 * This method is like `_.intersection` except that it accepts `comparator` 9946 * which is invoked to compare elements of `arrays`. The order and references 9947 * of result values are determined by the first array. The comparator is 9948 * invoked with two arguments: (arrVal, othVal). 9949 * 9950 * @static 9951 * @memberOf _ 9952 * @since 4.0.0 9953 * @category Array 9954 * @param {...Array} [arrays] The arrays to inspect. 9955 * @param {Function} [comparator] The comparator invoked per element. 9956 * @returns {Array} Returns the new array of intersecting values. 9957 * @example 9958 * 9959 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 9960 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 9961 * 9962 * _.intersectionWith(objects, others, _.isEqual); 9963 * // => [{ 'x': 1, 'y': 2 }] 9964 */ 9965 var intersectionWith = baseRest(function(arrays) { 9966 var comparator = last(arrays), 9967 mapped = arrayMap(arrays, castArrayLikeObject); 9968 9969 comparator = typeof comparator == 'function' ? comparator : undefined; 9970 if (comparator) { 9971 mapped.pop(); 9972 } 9973 return (mapped.length && mapped[0] === arrays[0]) 9974 ? baseIntersection(mapped, undefined, comparator) 9975 : []; 9976 }); 9977 9978 /** 9979 * Converts all elements in `array` into a string separated by `separator`. 9980 * 9981 * @static 9982 * @memberOf _ 9983 * @since 4.0.0 9984 * @category Array 9985 * @param {Array} array The array to convert. 9986 * @param {string} [separator=','] The element separator. 9987 * @returns {string} Returns the joined string. 9988 * @example 9989 * 9990 * _.join(['a', 'b', 'c'], '~'); 9991 * // => 'a~b~c' 9992 */ 9993 function join(array, separator) { 9994 return array == null ? '' : nativeJoin.call(array, separator); 9995 } 9996 9997 /** 9998 * Gets the last element of `array`. 9999 * 10000 * @static 10001 * @memberOf _ 10002 * @since 0.1.0 10003 * @category Array 10004 * @param {Array} array The array to query. 10005 * @returns {*} Returns the last element of `array`. 10006 * @example 10007 * 10008 * _.last([1, 2, 3]); 10009 * // => 3 10010 */ 10011 function last(array) { 10012 var length = array == null ? 0 : array.length; 10013 return length ? array[length - 1] : undefined; 10014 } 10015 10016 /** 10017 * This method is like `_.indexOf` except that it iterates over elements of 10018 * `array` from right to left. 10019 * 10020 * @static 10021 * @memberOf _ 10022 * @since 0.1.0 10023 * @category Array 10024 * @param {Array} array The array to inspect. 10025 * @param {*} value The value to search for. 10026 * @param {number} [fromIndex=array.length-1] The index to search from. 10027 * @returns {number} Returns the index of the matched value, else `-1`. 10028 * @example 10029 * 10030 * _.lastIndexOf([1, 2, 1, 2], 2); 10031 * // => 3 10032 * 10033 * // Search from the `fromIndex`. 10034 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 10035 * // => 1 10036 */ 10037 function lastIndexOf(array, value, fromIndex) { 10038 var length = array == null ? 0 : array.length; 10039 if (!length) { 10040 return -1; 10041 } 10042 var index = length; 10043 if (fromIndex !== undefined) { 10044 index = toInteger(fromIndex); 10045 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 10046 } 10047 return value === value 10048 ? strictLastIndexOf(array, value, index) 10049 : baseFindIndex(array, baseIsNaN, index, true); 10050 } 10051 10052 /** 10053 * Gets the element at index `n` of `array`. If `n` is negative, the nth 10054 * element from the end is returned. 10055 * 10056 * @static 10057 * @memberOf _ 10058 * @since 4.11.0 10059 * @category Array 10060 * @param {Array} array The array to query. 10061 * @param {number} [n=0] The index of the element to return. 10062 * @returns {*} Returns the nth element of `array`. 10063 * @example 10064 * 10065 * var array = ['a', 'b', 'c', 'd']; 10066 * 10067 * _.nth(array, 1); 10068 * // => 'b' 10069 * 10070 * _.nth(array, -2); 10071 * // => 'c'; 10072 */ 10073 function nth(array, n) { 10074 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 10075 } 10076 10077 /** 10078 * Removes all given values from `array` using 10079 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10080 * for equality comparisons. 10081 * 10082 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 10083 * to remove elements from an array by predicate. 10084 * 10085 * @static 10086 * @memberOf _ 10087 * @since 2.0.0 10088 * @category Array 10089 * @param {Array} array The array to modify. 10090 * @param {...*} [values] The values to remove. 10091 * @returns {Array} Returns `array`. 10092 * @example 10093 * 10094 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 10095 * 10096 * _.pull(array, 'a', 'c'); 10097 * console.log(array); 10098 * // => ['b', 'b'] 10099 */ 10100 var pull = baseRest(pullAll); 10101 10102 /** 10103 * This method is like `_.pull` except that it accepts an array of values to remove. 10104 * 10105 * **Note:** Unlike `_.difference`, this method mutates `array`. 10106 * 10107 * @static 10108 * @memberOf _ 10109 * @since 4.0.0 10110 * @category Array 10111 * @param {Array} array The array to modify. 10112 * @param {Array} values The values to remove. 10113 * @returns {Array} Returns `array`. 10114 * @example 10115 * 10116 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 10117 * 10118 * _.pullAll(array, ['a', 'c']); 10119 * console.log(array); 10120 * // => ['b', 'b'] 10121 */ 10122 function pullAll(array, values) { 10123 return (array && array.length && values && values.length) 10124 ? basePullAll(array, values) 10125 : array; 10126 } 10127 10128 /** 10129 * This method is like `_.pullAll` except that it accepts `iteratee` which is 10130 * invoked for each element of `array` and `values` to generate the criterion 10131 * by which they're compared. The iteratee is invoked with one argument: (value). 10132 * 10133 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 10134 * 10135 * @static 10136 * @memberOf _ 10137 * @since 4.0.0 10138 * @category Array 10139 * @param {Array} array The array to modify. 10140 * @param {Array} values The values to remove. 10141 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10142 * @returns {Array} Returns `array`. 10143 * @example 10144 * 10145 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 10146 * 10147 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 10148 * console.log(array); 10149 * // => [{ 'x': 2 }] 10150 */ 10151 function pullAllBy(array, values, iteratee) { 10152 return (array && array.length && values && values.length) 10153 ? basePullAll(array, values, getIteratee(iteratee, 2)) 10154 : array; 10155 } 10156 10157 /** 10158 * This method is like `_.pullAll` except that it accepts `comparator` which 10159 * is invoked to compare elements of `array` to `values`. The comparator is 10160 * invoked with two arguments: (arrVal, othVal). 10161 * 10162 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 10163 * 10164 * @static 10165 * @memberOf _ 10166 * @since 4.6.0 10167 * @category Array 10168 * @param {Array} array The array to modify. 10169 * @param {Array} values The values to remove. 10170 * @param {Function} [comparator] The comparator invoked per element. 10171 * @returns {Array} Returns `array`. 10172 * @example 10173 * 10174 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 10175 * 10176 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 10177 * console.log(array); 10178 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 10179 */ 10180 function pullAllWith(array, values, comparator) { 10181 return (array && array.length && values && values.length) 10182 ? basePullAll(array, values, undefined, comparator) 10183 : array; 10184 } 10185 10186 /** 10187 * Removes elements from `array` corresponding to `indexes` and returns an 10188 * array of removed elements. 10189 * 10190 * **Note:** Unlike `_.at`, this method mutates `array`. 10191 * 10192 * @static 10193 * @memberOf _ 10194 * @since 3.0.0 10195 * @category Array 10196 * @param {Array} array The array to modify. 10197 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 10198 * @returns {Array} Returns the new array of removed elements. 10199 * @example 10200 * 10201 * var array = ['a', 'b', 'c', 'd']; 10202 * var pulled = _.pullAt(array, [1, 3]); 10203 * 10204 * console.log(array); 10205 * // => ['a', 'c'] 10206 * 10207 * console.log(pulled); 10208 * // => ['b', 'd'] 10209 */ 10210 var pullAt = flatRest(function(array, indexes) { 10211 var length = array == null ? 0 : array.length, 10212 result = baseAt(array, indexes); 10213 10214 basePullAt(array, arrayMap(indexes, function(index) { 10215 return isIndex(index, length) ? +index : index; 10216 }).sort(compareAscending)); 10217 10218 return result; 10219 }); 10220 10221 /** 10222 * Removes all elements from `array` that `predicate` returns truthy for 10223 * and returns an array of the removed elements. The predicate is invoked 10224 * with three arguments: (value, index, array). 10225 * 10226 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 10227 * to pull elements from an array by value. 10228 * 10229 * @static 10230 * @memberOf _ 10231 * @since 2.0.0 10232 * @category Array 10233 * @param {Array} array The array to modify. 10234 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10235 * @returns {Array} Returns the new array of removed elements. 10236 * @example 10237 * 10238 * var array = [1, 2, 3, 4]; 10239 * var evens = _.remove(array, function(n) { 10240 * return n % 2 == 0; 10241 * }); 10242 * 10243 * console.log(array); 10244 * // => [1, 3] 10245 * 10246 * console.log(evens); 10247 * // => [2, 4] 10248 */ 10249 function remove(array, predicate) { 10250 var result = []; 10251 if (!(array && array.length)) { 10252 return result; 10253 } 10254 var index = -1, 10255 indexes = [], 10256 length = array.length; 10257 10258 predicate = getIteratee(predicate, 3); 10259 while (++index < length) { 10260 var value = array[index]; 10261 if (predicate(value, index, array)) { 10262 result.push(value); 10263 indexes.push(index); 10264 } 10265 } 10266 basePullAt(array, indexes); 10267 return result; 10268 } 10269 10270 /** 10271 * Reverses `array` so that the first element becomes the last, the second 10272 * element becomes the second to last, and so on. 10273 * 10274 * **Note:** This method mutates `array` and is based on 10275 * [`Array#reverse`](https://mdn.io/Array/reverse). 10276 * 10277 * @static 10278 * @memberOf _ 10279 * @since 4.0.0 10280 * @category Array 10281 * @param {Array} array The array to modify. 10282 * @returns {Array} Returns `array`. 10283 * @example 10284 * 10285 * var array = [1, 2, 3]; 10286 * 10287 * _.reverse(array); 10288 * // => [3, 2, 1] 10289 * 10290 * console.log(array); 10291 * // => [3, 2, 1] 10292 */ 10293 function reverse(array) { 10294 return array == null ? array : nativeReverse.call(array); 10295 } 10296 10297 /** 10298 * Creates a slice of `array` from `start` up to, but not including, `end`. 10299 * 10300 * **Note:** This method is used instead of 10301 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 10302 * returned. 10303 * 10304 * @static 10305 * @memberOf _ 10306 * @since 3.0.0 10307 * @category Array 10308 * @param {Array} array The array to slice. 10309 * @param {number} [start=0] The start position. 10310 * @param {number} [end=array.length] The end position. 10311 * @returns {Array} Returns the slice of `array`. 10312 */ 10313 function slice(array, start, end) { 10314 var length = array == null ? 0 : array.length; 10315 if (!length) { 10316 return []; 10317 } 10318 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 10319 start = 0; 10320 end = length; 10321 } 10322 else { 10323 start = start == null ? 0 : toInteger(start); 10324 end = end === undefined ? length : toInteger(end); 10325 } 10326 return baseSlice(array, start, end); 10327 } 10328 10329 /** 10330 * Uses a binary search to determine the lowest index at which `value` 10331 * should be inserted into `array` in order to maintain its sort order. 10332 * 10333 * @static 10334 * @memberOf _ 10335 * @since 0.1.0 10336 * @category Array 10337 * @param {Array} array The sorted array to inspect. 10338 * @param {*} value The value to evaluate. 10339 * @returns {number} Returns the index at which `value` should be inserted 10340 * into `array`. 10341 * @example 10342 * 10343 * _.sortedIndex([30, 50], 40); 10344 * // => 1 10345 */ 10346 function sortedIndex(array, value) { 10347 return baseSortedIndex(array, value); 10348 } 10349 10350 /** 10351 * This method is like `_.sortedIndex` except that it accepts `iteratee` 10352 * which is invoked for `value` and each element of `array` to compute their 10353 * sort ranking. The iteratee is invoked with one argument: (value). 10354 * 10355 * @static 10356 * @memberOf _ 10357 * @since 4.0.0 10358 * @category Array 10359 * @param {Array} array The sorted array to inspect. 10360 * @param {*} value The value to evaluate. 10361 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10362 * @returns {number} Returns the index at which `value` should be inserted 10363 * into `array`. 10364 * @example 10365 * 10366 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 10367 * 10368 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 10369 * // => 0 10370 * 10371 * // The `_.property` iteratee shorthand. 10372 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 10373 * // => 0 10374 */ 10375 function sortedIndexBy(array, value, iteratee) { 10376 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 10377 } 10378 10379 /** 10380 * This method is like `_.indexOf` except that it performs a binary 10381 * search on a sorted `array`. 10382 * 10383 * @static 10384 * @memberOf _ 10385 * @since 4.0.0 10386 * @category Array 10387 * @param {Array} array The array to inspect. 10388 * @param {*} value The value to search for. 10389 * @returns {number} Returns the index of the matched value, else `-1`. 10390 * @example 10391 * 10392 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 10393 * // => 1 10394 */ 10395 function sortedIndexOf(array, value) { 10396 var length = array == null ? 0 : array.length; 10397 if (length) { 10398 var index = baseSortedIndex(array, value); 10399 if (index < length && eq(array[index], value)) { 10400 return index; 10401 } 10402 } 10403 return -1; 10404 } 10405 10406 /** 10407 * This method is like `_.sortedIndex` except that it returns the highest 10408 * index at which `value` should be inserted into `array` in order to 10409 * maintain its sort order. 10410 * 10411 * @static 10412 * @memberOf _ 10413 * @since 3.0.0 10414 * @category Array 10415 * @param {Array} array The sorted array to inspect. 10416 * @param {*} value The value to evaluate. 10417 * @returns {number} Returns the index at which `value` should be inserted 10418 * into `array`. 10419 * @example 10420 * 10421 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 10422 * // => 4 10423 */ 10424 function sortedLastIndex(array, value) { 10425 return baseSortedIndex(array, value, true); 10426 } 10427 10428 /** 10429 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 10430 * which is invoked for `value` and each element of `array` to compute their 10431 * sort ranking. The iteratee is invoked with one argument: (value). 10432 * 10433 * @static 10434 * @memberOf _ 10435 * @since 4.0.0 10436 * @category Array 10437 * @param {Array} array The sorted array to inspect. 10438 * @param {*} value The value to evaluate. 10439 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10440 * @returns {number} Returns the index at which `value` should be inserted 10441 * into `array`. 10442 * @example 10443 * 10444 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 10445 * 10446 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 10447 * // => 1 10448 * 10449 * // The `_.property` iteratee shorthand. 10450 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 10451 * // => 1 10452 */ 10453 function sortedLastIndexBy(array, value, iteratee) { 10454 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 10455 } 10456 10457 /** 10458 * This method is like `_.lastIndexOf` except that it performs a binary 10459 * search on a sorted `array`. 10460 * 10461 * @static 10462 * @memberOf _ 10463 * @since 4.0.0 10464 * @category Array 10465 * @param {Array} array The array to inspect. 10466 * @param {*} value The value to search for. 10467 * @returns {number} Returns the index of the matched value, else `-1`. 10468 * @example 10469 * 10470 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 10471 * // => 3 10472 */ 10473 function sortedLastIndexOf(array, value) { 10474 var length = array == null ? 0 : array.length; 10475 if (length) { 10476 var index = baseSortedIndex(array, value, true) - 1; 10477 if (eq(array[index], value)) { 10478 return index; 10479 } 10480 } 10481 return -1; 10482 } 10483 10484 /** 10485 * This method is like `_.uniq` except that it's designed and optimized 10486 * for sorted arrays. 10487 * 10488 * @static 10489 * @memberOf _ 10490 * @since 4.0.0 10491 * @category Array 10492 * @param {Array} array The array to inspect. 10493 * @returns {Array} Returns the new duplicate free array. 10494 * @example 10495 * 10496 * _.sortedUniq([1, 1, 2]); 10497 * // => [1, 2] 10498 */ 10499 function sortedUniq(array) { 10500 return (array && array.length) 10501 ? baseSortedUniq(array) 10502 : []; 10503 } 10504 10505 /** 10506 * This method is like `_.uniqBy` except that it's designed and optimized 10507 * for sorted arrays. 10508 * 10509 * @static 10510 * @memberOf _ 10511 * @since 4.0.0 10512 * @category Array 10513 * @param {Array} array The array to inspect. 10514 * @param {Function} [iteratee] The iteratee invoked per element. 10515 * @returns {Array} Returns the new duplicate free array. 10516 * @example 10517 * 10518 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 10519 * // => [1.1, 2.3] 10520 */ 10521 function sortedUniqBy(array, iteratee) { 10522 return (array && array.length) 10523 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 10524 : []; 10525 } 10526 10527 /** 10528 * Gets all but the first element of `array`. 10529 * 10530 * @static 10531 * @memberOf _ 10532 * @since 4.0.0 10533 * @category Array 10534 * @param {Array} array The array to query. 10535 * @returns {Array} Returns the slice of `array`. 10536 * @example 10537 * 10538 * _.tail([1, 2, 3]); 10539 * // => [2, 3] 10540 */ 10541 function tail(array) { 10542 var length = array == null ? 0 : array.length; 10543 return length ? baseSlice(array, 1, length) : []; 10544 } 10545 10546 /** 10547 * Creates a slice of `array` with `n` elements taken from the beginning. 10548 * 10549 * @static 10550 * @memberOf _ 10551 * @since 0.1.0 10552 * @category Array 10553 * @param {Array} array The array to query. 10554 * @param {number} [n=1] The number of elements to take. 10555 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10556 * @returns {Array} Returns the slice of `array`. 10557 * @example 10558 * 10559 * _.take([1, 2, 3]); 10560 * // => [1] 10561 * 10562 * _.take([1, 2, 3], 2); 10563 * // => [1, 2] 10564 * 10565 * _.take([1, 2, 3], 5); 10566 * // => [1, 2, 3] 10567 * 10568 * _.take([1, 2, 3], 0); 10569 * // => [] 10570 */ 10571 function take(array, n, guard) { 10572 if (!(array && array.length)) { 10573 return []; 10574 } 10575 n = (guard || n === undefined) ? 1 : toInteger(n); 10576 return baseSlice(array, 0, n < 0 ? 0 : n); 10577 } 10578 10579 /** 10580 * Creates a slice of `array` with `n` elements taken from the end. 10581 * 10582 * @static 10583 * @memberOf _ 10584 * @since 3.0.0 10585 * @category Array 10586 * @param {Array} array The array to query. 10587 * @param {number} [n=1] The number of elements to take. 10588 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10589 * @returns {Array} Returns the slice of `array`. 10590 * @example 10591 * 10592 * _.takeRight([1, 2, 3]); 10593 * // => [3] 10594 * 10595 * _.takeRight([1, 2, 3], 2); 10596 * // => [2, 3] 10597 * 10598 * _.takeRight([1, 2, 3], 5); 10599 * // => [1, 2, 3] 10600 * 10601 * _.takeRight([1, 2, 3], 0); 10602 * // => [] 10603 */ 10604 function takeRight(array, n, guard) { 10605 var length = array == null ? 0 : array.length; 10606 if (!length) { 10607 return []; 10608 } 10609 n = (guard || n === undefined) ? 1 : toInteger(n); 10610 n = length - n; 10611 return baseSlice(array, n < 0 ? 0 : n, length); 10612 } 10613 10614 /** 10615 * Creates a slice of `array` with elements taken from the end. Elements are 10616 * taken until `predicate` returns falsey. The predicate is invoked with 10617 * three arguments: (value, index, array). 10618 * 10619 * @static 10620 * @memberOf _ 10621 * @since 3.0.0 10622 * @category Array 10623 * @param {Array} array The array to query. 10624 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10625 * @returns {Array} Returns the slice of `array`. 10626 * @example 10627 * 10628 * var users = [ 10629 * { 'user': 'barney', 'active': true }, 10630 * { 'user': 'fred', 'active': false }, 10631 * { 'user': 'pebbles', 'active': false } 10632 * ]; 10633 * 10634 * _.takeRightWhile(users, function(o) { return !o.active; }); 10635 * // => objects for ['fred', 'pebbles'] 10636 * 10637 * // The `_.matches` iteratee shorthand. 10638 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 10639 * // => objects for ['pebbles'] 10640 * 10641 * // The `_.matchesProperty` iteratee shorthand. 10642 * _.takeRightWhile(users, ['active', false]); 10643 * // => objects for ['fred', 'pebbles'] 10644 * 10645 * // The `_.property` iteratee shorthand. 10646 * _.takeRightWhile(users, 'active'); 10647 * // => [] 10648 */ 10649 function takeRightWhile(array, predicate) { 10650 return (array && array.length) 10651 ? baseWhile(array, getIteratee(predicate, 3), false, true) 10652 : []; 10653 } 10654 10655 /** 10656 * Creates a slice of `array` with elements taken from the beginning. Elements 10657 * are taken until `predicate` returns falsey. The predicate is invoked with 10658 * three arguments: (value, index, array). 10659 * 10660 * @static 10661 * @memberOf _ 10662 * @since 3.0.0 10663 * @category Array 10664 * @param {Array} array The array to query. 10665 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10666 * @returns {Array} Returns the slice of `array`. 10667 * @example 10668 * 10669 * var users = [ 10670 * { 'user': 'barney', 'active': false }, 10671 * { 'user': 'fred', 'active': false }, 10672 * { 'user': 'pebbles', 'active': true } 10673 * ]; 10674 * 10675 * _.takeWhile(users, function(o) { return !o.active; }); 10676 * // => objects for ['barney', 'fred'] 10677 * 10678 * // The `_.matches` iteratee shorthand. 10679 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 10680 * // => objects for ['barney'] 10681 * 10682 * // The `_.matchesProperty` iteratee shorthand. 10683 * _.takeWhile(users, ['active', false]); 10684 * // => objects for ['barney', 'fred'] 10685 * 10686 * // The `_.property` iteratee shorthand. 10687 * _.takeWhile(users, 'active'); 10688 * // => [] 10689 */ 10690 function takeWhile(array, predicate) { 10691 return (array && array.length) 10692 ? baseWhile(array, getIteratee(predicate, 3)) 10693 : []; 10694 } 10695 10696 /** 10697 * Creates an array of unique values, in order, from all given arrays using 10698 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10699 * for equality comparisons. 10700 * 10701 * @static 10702 * @memberOf _ 10703 * @since 0.1.0 10704 * @category Array 10705 * @param {...Array} [arrays] The arrays to inspect. 10706 * @returns {Array} Returns the new array of combined values. 10707 * @example 10708 * 10709 * _.union([2], [1, 2]); 10710 * // => [2, 1] 10711 */ 10712 var union = baseRest(function(arrays) { 10713 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 10714 }); 10715 10716 /** 10717 * This method is like `_.union` except that it accepts `iteratee` which is 10718 * invoked for each element of each `arrays` to generate the criterion by 10719 * which uniqueness is computed. Result values are chosen from the first 10720 * array in which the value occurs. The iteratee is invoked with one argument: 10721 * (value). 10722 * 10723 * @static 10724 * @memberOf _ 10725 * @since 4.0.0 10726 * @category Array 10727 * @param {...Array} [arrays] The arrays to inspect. 10728 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10729 * @returns {Array} Returns the new array of combined values. 10730 * @example 10731 * 10732 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 10733 * // => [2.1, 1.2] 10734 * 10735 * // The `_.property` iteratee shorthand. 10736 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 10737 * // => [{ 'x': 1 }, { 'x': 2 }] 10738 */ 10739 var unionBy = baseRest(function(arrays) { 10740 var iteratee = last(arrays); 10741 if (isArrayLikeObject(iteratee)) { 10742 iteratee = undefined; 10743 } 10744 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 10745 }); 10746 10747 /** 10748 * This method is like `_.union` except that it accepts `comparator` which 10749 * is invoked to compare elements of `arrays`. Result values are chosen from 10750 * the first array in which the value occurs. The comparator is invoked 10751 * with two arguments: (arrVal, othVal). 10752 * 10753 * @static 10754 * @memberOf _ 10755 * @since 4.0.0 10756 * @category Array 10757 * @param {...Array} [arrays] The arrays to inspect. 10758 * @param {Function} [comparator] The comparator invoked per element. 10759 * @returns {Array} Returns the new array of combined values. 10760 * @example 10761 * 10762 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 10763 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10764 * 10765 * _.unionWith(objects, others, _.isEqual); 10766 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 10767 */ 10768 var unionWith = baseRest(function(arrays) { 10769 var comparator = last(arrays); 10770 comparator = typeof comparator == 'function' ? comparator : undefined; 10771 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 10772 }); 10773 10774 /** 10775 * Creates a duplicate-free version of an array, using 10776 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10777 * for equality comparisons, in which only the first occurrence of each element 10778 * is kept. The order of result values is determined by the order they occur 10779 * in the array. 10780 * 10781 * @static 10782 * @memberOf _ 10783 * @since 0.1.0 10784 * @category Array 10785 * @param {Array} array The array to inspect. 10786 * @returns {Array} Returns the new duplicate free array. 10787 * @example 10788 * 10789 * _.uniq([2, 1, 2]); 10790 * // => [2, 1] 10791 */ 10792 function uniq(array) { 10793 return (array && array.length) ? baseUniq(array) : []; 10794 } 10795 10796 /** 10797 * This method is like `_.uniq` except that it accepts `iteratee` which is 10798 * invoked for each element in `array` to generate the criterion by which 10799 * uniqueness is computed. The order of result values is determined by the 10800 * order they occur in the array. The iteratee is invoked with one argument: 10801 * (value). 10802 * 10803 * @static 10804 * @memberOf _ 10805 * @since 4.0.0 10806 * @category Array 10807 * @param {Array} array The array to inspect. 10808 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10809 * @returns {Array} Returns the new duplicate free array. 10810 * @example 10811 * 10812 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 10813 * // => [2.1, 1.2] 10814 * 10815 * // The `_.property` iteratee shorthand. 10816 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 10817 * // => [{ 'x': 1 }, { 'x': 2 }] 10818 */ 10819 function uniqBy(array, iteratee) { 10820 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 10821 } 10822 10823 /** 10824 * This method is like `_.uniq` except that it accepts `comparator` which 10825 * is invoked to compare elements of `array`. The order of result values is 10826 * determined by the order they occur in the array.The comparator is invoked 10827 * with two arguments: (arrVal, othVal). 10828 * 10829 * @static 10830 * @memberOf _ 10831 * @since 4.0.0 10832 * @category Array 10833 * @param {Array} array The array to inspect. 10834 * @param {Function} [comparator] The comparator invoked per element. 10835 * @returns {Array} Returns the new duplicate free array. 10836 * @example 10837 * 10838 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10839 * 10840 * _.uniqWith(objects, _.isEqual); 10841 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 10842 */ 10843 function uniqWith(array, comparator) { 10844 comparator = typeof comparator == 'function' ? comparator : undefined; 10845 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 10846 } 10847 10848 /** 10849 * This method is like `_.zip` except that it accepts an array of grouped 10850 * elements and creates an array regrouping the elements to their pre-zip 10851 * configuration. 10852 * 10853 * @static 10854 * @memberOf _ 10855 * @since 1.2.0 10856 * @category Array 10857 * @param {Array} array The array of grouped elements to process. 10858 * @returns {Array} Returns the new array of regrouped elements. 10859 * @example 10860 * 10861 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 10862 * // => [['a', 1, true], ['b', 2, false]] 10863 * 10864 * _.unzip(zipped); 10865 * // => [['a', 'b'], [1, 2], [true, false]] 10866 */ 10867 function unzip(array) { 10868 if (!(array && array.length)) { 10869 return []; 10870 } 10871 var length = 0; 10872 array = arrayFilter(array, function(group) { 10873 if (isArrayLikeObject(group)) { 10874 length = nativeMax(group.length, length); 10875 return true; 10876 } 10877 }); 10878 return baseTimes(length, function(index) { 10879 return arrayMap(array, baseProperty(index)); 10880 }); 10881 } 10882 10883 /** 10884 * This method is like `_.unzip` except that it accepts `iteratee` to specify 10885 * how regrouped values should be combined. The iteratee is invoked with the 10886 * elements of each group: (...group). 10887 * 10888 * @static 10889 * @memberOf _ 10890 * @since 3.8.0 10891 * @category Array 10892 * @param {Array} array The array of grouped elements to process. 10893 * @param {Function} [iteratee=_.identity] The function to combine 10894 * regrouped values. 10895 * @returns {Array} Returns the new array of regrouped elements. 10896 * @example 10897 * 10898 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 10899 * // => [[1, 10, 100], [2, 20, 200]] 10900 * 10901 * _.unzipWith(zipped, _.add); 10902 * // => [3, 30, 300] 10903 */ 10904 function unzipWith(array, iteratee) { 10905 if (!(array && array.length)) { 10906 return []; 10907 } 10908 var result = unzip(array); 10909 if (iteratee == null) { 10910 return result; 10911 } 10912 return arrayMap(result, function(group) { 10913 return apply(iteratee, undefined, group); 10914 }); 10915 } 10916 10917 /** 10918 * Creates an array excluding all given values using 10919 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10920 * for equality comparisons. 10921 * 10922 * **Note:** Unlike `_.pull`, this method returns a new array. 10923 * 10924 * @static 10925 * @memberOf _ 10926 * @since 0.1.0 10927 * @category Array 10928 * @param {Array} array The array to inspect. 10929 * @param {...*} [values] The values to exclude. 10930 * @returns {Array} Returns the new array of filtered values. 10931 * @see _.difference, _.xor 10932 * @example 10933 * 10934 * _.without([2, 1, 2, 3], 1, 2); 10935 * // => [3] 10936 */ 10937 var without = baseRest(function(array, values) { 10938 return isArrayLikeObject(array) 10939 ? baseDifference(array, values) 10940 : []; 10941 }); 10942 10943 /** 10944 * Creates an array of unique values that is the 10945 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 10946 * of the given arrays. The order of result values is determined by the order 10947 * they occur in the arrays. 10948 * 10949 * @static 10950 * @memberOf _ 10951 * @since 2.4.0 10952 * @category Array 10953 * @param {...Array} [arrays] The arrays to inspect. 10954 * @returns {Array} Returns the new array of filtered values. 10955 * @see _.difference, _.without 10956 * @example 10957 * 10958 * _.xor([2, 1], [2, 3]); 10959 * // => [1, 3] 10960 */ 10961 var xor = baseRest(function(arrays) { 10962 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 10963 }); 10964 10965 /** 10966 * This method is like `_.xor` except that it accepts `iteratee` which is 10967 * invoked for each element of each `arrays` to generate the criterion by 10968 * which by which they're compared. The order of result values is determined 10969 * by the order they occur in the arrays. The iteratee is invoked with one 10970 * argument: (value). 10971 * 10972 * @static 10973 * @memberOf _ 10974 * @since 4.0.0 10975 * @category Array 10976 * @param {...Array} [arrays] The arrays to inspect. 10977 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10978 * @returns {Array} Returns the new array of filtered values. 10979 * @example 10980 * 10981 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 10982 * // => [1.2, 3.4] 10983 * 10984 * // The `_.property` iteratee shorthand. 10985 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 10986 * // => [{ 'x': 2 }] 10987 */ 10988 var xorBy = baseRest(function(arrays) { 10989 var iteratee = last(arrays); 10990 if (isArrayLikeObject(iteratee)) { 10991 iteratee = undefined; 10992 } 10993 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 10994 }); 10995 10996 /** 10997 * This method is like `_.xor` except that it accepts `comparator` which is 10998 * invoked to compare elements of `arrays`. The order of result values is 10999 * determined by the order they occur in the arrays. The comparator is invoked 11000 * with two arguments: (arrVal, othVal). 11001 * 11002 * @static 11003 * @memberOf _ 11004 * @since 4.0.0 11005 * @category Array 11006 * @param {...Array} [arrays] The arrays to inspect. 11007 * @param {Function} [comparator] The comparator invoked per element. 11008 * @returns {Array} Returns the new array of filtered values. 11009 * @example 11010 * 11011 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 11012 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 11013 * 11014 * _.xorWith(objects, others, _.isEqual); 11015 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 11016 */ 11017 var xorWith = baseRest(function(arrays) { 11018 var comparator = last(arrays); 11019 comparator = typeof comparator == 'function' ? comparator : undefined; 11020 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 11021 }); 11022 11023 /** 11024 * Creates an array of grouped elements, the first of which contains the 11025 * first elements of the given arrays, the second of which contains the 11026 * second elements of the given arrays, and so on. 11027 * 11028 * @static 11029 * @memberOf _ 11030 * @since 0.1.0 11031 * @category Array 11032 * @param {...Array} [arrays] The arrays to process. 11033 * @returns {Array} Returns the new array of grouped elements. 11034 * @example 11035 * 11036 * _.zip(['a', 'b'], [1, 2], [true, false]); 11037 * // => [['a', 1, true], ['b', 2, false]] 11038 */ 11039 var zip = baseRest(unzip); 11040 11041 /** 11042 * This method is like `_.fromPairs` except that it accepts two arrays, 11043 * one of property identifiers and one of corresponding values. 11044 * 11045 * @static 11046 * @memberOf _ 11047 * @since 0.4.0 11048 * @category Array 11049 * @param {Array} [props=[]] The property identifiers. 11050 * @param {Array} [values=[]] The property values. 11051 * @returns {Object} Returns the new object. 11052 * @example 11053 * 11054 * _.zipObject(['a', 'b'], [1, 2]); 11055 * // => { 'a': 1, 'b': 2 } 11056 */ 11057 function zipObject(props, values) { 11058 return baseZipObject(props || [], values || [], assignValue); 11059 } 11060 11061 /** 11062 * This method is like `_.zipObject` except that it supports property paths. 11063 * 11064 * @static 11065 * @memberOf _ 11066 * @since 4.1.0 11067 * @category Array 11068 * @param {Array} [props=[]] The property identifiers. 11069 * @param {Array} [values=[]] The property values. 11070 * @returns {Object} Returns the new object. 11071 * @example 11072 * 11073 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 11074 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 11075 */ 11076 function zipObjectDeep(props, values) { 11077 return baseZipObject(props || [], values || [], baseSet); 11078 } 11079 11080 /** 11081 * This method is like `_.zip` except that it accepts `iteratee` to specify 11082 * how grouped values should be combined. The iteratee is invoked with the 11083 * elements of each group: (...group). 11084 * 11085 * @static 11086 * @memberOf _ 11087 * @since 3.8.0 11088 * @category Array 11089 * @param {...Array} [arrays] The arrays to process. 11090 * @param {Function} [iteratee=_.identity] The function to combine 11091 * grouped values. 11092 * @returns {Array} Returns the new array of grouped elements. 11093 * @example 11094 * 11095 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 11096 * return a + b + c; 11097 * }); 11098 * // => [111, 222] 11099 */ 11100 var zipWith = baseRest(function(arrays) { 11101 var length = arrays.length, 11102 iteratee = length > 1 ? arrays[length - 1] : undefined; 11103 11104 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 11105 return unzipWith(arrays, iteratee); 11106 }); 11107 11108 /*------------------------------------------------------------------------*/ 11109 11110 /** 11111 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 11112 * chain sequences enabled. The result of such sequences must be unwrapped 11113 * with `_#value`. 11114 * 11115 * @static 11116 * @memberOf _ 11117 * @since 1.3.0 11118 * @category Seq 11119 * @param {*} value The value to wrap. 11120 * @returns {Object} Returns the new `lodash` wrapper instance. 11121 * @example 11122 * 11123 * var users = [ 11124 * { 'user': 'barney', 'age': 36 }, 11125 * { 'user': 'fred', 'age': 40 }, 11126 * { 'user': 'pebbles', 'age': 1 } 11127 * ]; 11128 * 11129 * var youngest = _ 11130 * .chain(users) 11131 * .sortBy('age') 11132 * .map(function(o) { 11133 * return o.user + ' is ' + o.age; 11134 * }) 11135 * .head() 11136 * .value(); 11137 * // => 'pebbles is 1' 11138 */ 11139 function chain(value) { 11140 var result = lodash(value); 11141 result.__chain__ = true; 11142 return result; 11143 } 11144 11145 /** 11146 * This method invokes `interceptor` and returns `value`. The interceptor 11147 * is invoked with one argument; (value). The purpose of this method is to 11148 * "tap into" a method chain sequence in order to modify intermediate results. 11149 * 11150 * @static 11151 * @memberOf _ 11152 * @since 0.1.0 11153 * @category Seq 11154 * @param {*} value The value to provide to `interceptor`. 11155 * @param {Function} interceptor The function to invoke. 11156 * @returns {*} Returns `value`. 11157 * @example 11158 * 11159 * _([1, 2, 3]) 11160 * .tap(function(array) { 11161 * // Mutate input array. 11162 * array.pop(); 11163 * }) 11164 * .reverse() 11165 * .value(); 11166 * // => [2, 1] 11167 */ 11168 function tap(value, interceptor) { 11169 interceptor(value); 11170 return value; 11171 } 11172 11173 /** 11174 * This method is like `_.tap` except that it returns the result of `interceptor`. 11175 * The purpose of this method is to "pass thru" values replacing intermediate 11176 * results in a method chain sequence. 11177 * 11178 * @static 11179 * @memberOf _ 11180 * @since 3.0.0 11181 * @category Seq 11182 * @param {*} value The value to provide to `interceptor`. 11183 * @param {Function} interceptor The function to invoke. 11184 * @returns {*} Returns the result of `interceptor`. 11185 * @example 11186 * 11187 * _(' abc ') 11188 * .chain() 11189 * .trim() 11190 * .thru(function(value) { 11191 * return [value]; 11192 * }) 11193 * .value(); 11194 * // => ['abc'] 11195 */ 11196 function thru(value, interceptor) { 11197 return interceptor(value); 11198 } 11199 11200 /** 11201 * This method is the wrapper version of `_.at`. 11202 * 11203 * @name at 11204 * @memberOf _ 11205 * @since 1.0.0 11206 * @category Seq 11207 * @param {...(string|string[])} [paths] The property paths to pick. 11208 * @returns {Object} Returns the new `lodash` wrapper instance. 11209 * @example 11210 * 11211 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 11212 * 11213 * _(object).at(['a[0].b.c', 'a[1]']).value(); 11214 * // => [3, 4] 11215 */ 11216 var wrapperAt = flatRest(function(paths) { 11217 var length = paths.length, 11218 start = length ? paths[0] : 0, 11219 value = this.__wrapped__, 11220 interceptor = function(object) { return baseAt(object, paths); }; 11221 11222 if (length > 1 || this.__actions__.length || 11223 !(value instanceof LazyWrapper) || !isIndex(start)) { 11224 return this.thru(interceptor); 11225 } 11226 value = value.slice(start, +start + (length ? 1 : 0)); 11227 value.__actions__.push({ 11228 'func': thru, 11229 'args': [interceptor], 11230 'thisArg': undefined 11231 }); 11232 return new LodashWrapper(value, this.__chain__).thru(function(array) { 11233 if (length && !array.length) { 11234 array.push(undefined); 11235 } 11236 return array; 11237 }); 11238 }); 11239 11240 /** 11241 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 11242 * 11243 * @name chain 11244 * @memberOf _ 11245 * @since 0.1.0 11246 * @category Seq 11247 * @returns {Object} Returns the new `lodash` wrapper instance. 11248 * @example 11249 * 11250 * var users = [ 11251 * { 'user': 'barney', 'age': 36 }, 11252 * { 'user': 'fred', 'age': 40 } 11253 * ]; 11254 * 11255 * // A sequence without explicit chaining. 11256 * _(users).head(); 11257 * // => { 'user': 'barney', 'age': 36 } 11258 * 11259 * // A sequence with explicit chaining. 11260 * _(users) 11261 * .chain() 11262 * .head() 11263 * .pick('user') 11264 * .value(); 11265 * // => { 'user': 'barney' } 11266 */ 11267 function wrapperChain() { 11268 return chain(this); 11269 } 11270 11271 /** 11272 * Executes the chain sequence and returns the wrapped result. 11273 * 11274 * @name commit 11275 * @memberOf _ 11276 * @since 3.2.0 11277 * @category Seq 11278 * @returns {Object} Returns the new `lodash` wrapper instance. 11279 * @example 11280 * 11281 * var array = [1, 2]; 11282 * var wrapped = _(array).push(3); 11283 * 11284 * console.log(array); 11285 * // => [1, 2] 11286 * 11287 * wrapped = wrapped.commit(); 11288 * console.log(array); 11289 * // => [1, 2, 3] 11290 * 11291 * wrapped.last(); 11292 * // => 3 11293 * 11294 * console.log(array); 11295 * // => [1, 2, 3] 11296 */ 11297 function wrapperCommit() { 11298 return new LodashWrapper(this.value(), this.__chain__); 11299 } 11300 11301 /** 11302 * Gets the next value on a wrapped object following the 11303 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 11304 * 11305 * @name next 11306 * @memberOf _ 11307 * @since 4.0.0 11308 * @category Seq 11309 * @returns {Object} Returns the next iterator value. 11310 * @example 11311 * 11312 * var wrapped = _([1, 2]); 11313 * 11314 * wrapped.next(); 11315 * // => { 'done': false, 'value': 1 } 11316 * 11317 * wrapped.next(); 11318 * // => { 'done': false, 'value': 2 } 11319 * 11320 * wrapped.next(); 11321 * // => { 'done': true, 'value': undefined } 11322 */ 11323 function wrapperNext() { 11324 if (this.__values__ === undefined) { 11325 this.__values__ = toArray(this.value()); 11326 } 11327 var done = this.__index__ >= this.__values__.length, 11328 value = done ? undefined : this.__values__[this.__index__++]; 11329 11330 return { 'done': done, 'value': value }; 11331 } 11332 11333 /** 11334 * Enables the wrapper to be iterable. 11335 * 11336 * @name Symbol.iterator 11337 * @memberOf _ 11338 * @since 4.0.0 11339 * @category Seq 11340 * @returns {Object} Returns the wrapper object. 11341 * @example 11342 * 11343 * var wrapped = _([1, 2]); 11344 * 11345 * wrapped[Symbol.iterator]() === wrapped; 11346 * // => true 11347 * 11348 * Array.from(wrapped); 11349 * // => [1, 2] 11350 */ 11351 function wrapperToIterator() { 11352 return this; 11353 } 11354 11355 /** 11356 * Creates a clone of the chain sequence planting `value` as the wrapped value. 11357 * 11358 * @name plant 11359 * @memberOf _ 11360 * @since 3.2.0 11361 * @category Seq 11362 * @param {*} value The value to plant. 11363 * @returns {Object} Returns the new `lodash` wrapper instance. 11364 * @example 11365 * 11366 * function square(n) { 11367 * return n * n; 11368 * } 11369 * 11370 * var wrapped = _([1, 2]).map(square); 11371 * var other = wrapped.plant([3, 4]); 11372 * 11373 * other.value(); 11374 * // => [9, 16] 11375 * 11376 * wrapped.value(); 11377 * // => [1, 4] 11378 */ 11379 function wrapperPlant(value) { 11380 var result, 11381 parent = this; 11382 11383 while (parent instanceof baseLodash) { 11384 var clone = wrapperClone(parent); 11385 clone.__index__ = 0; 11386 clone.__values__ = undefined; 11387 if (result) { 11388 previous.__wrapped__ = clone; 11389 } else { 11390 result = clone; 11391 } 11392 var previous = clone; 11393 parent = parent.__wrapped__; 11394 } 11395 previous.__wrapped__ = value; 11396 return result; 11397 } 11398 11399 /** 11400 * This method is the wrapper version of `_.reverse`. 11401 * 11402 * **Note:** This method mutates the wrapped array. 11403 * 11404 * @name reverse 11405 * @memberOf _ 11406 * @since 0.1.0 11407 * @category Seq 11408 * @returns {Object} Returns the new `lodash` wrapper instance. 11409 * @example 11410 * 11411 * var array = [1, 2, 3]; 11412 * 11413 * _(array).reverse().value() 11414 * // => [3, 2, 1] 11415 * 11416 * console.log(array); 11417 * // => [3, 2, 1] 11418 */ 11419 function wrapperReverse() { 11420 var value = this.__wrapped__; 11421 if (value instanceof LazyWrapper) { 11422 var wrapped = value; 11423 if (this.__actions__.length) { 11424 wrapped = new LazyWrapper(this); 11425 } 11426 wrapped = wrapped.reverse(); 11427 wrapped.__actions__.push({ 11428 'func': thru, 11429 'args': [reverse], 11430 'thisArg': undefined 11431 }); 11432 return new LodashWrapper(wrapped, this.__chain__); 11433 } 11434 return this.thru(reverse); 11435 } 11436 11437 /** 11438 * Executes the chain sequence to resolve the unwrapped value. 11439 * 11440 * @name value 11441 * @memberOf _ 11442 * @since 0.1.0 11443 * @alias toJSON, valueOf 11444 * @category Seq 11445 * @returns {*} Returns the resolved unwrapped value. 11446 * @example 11447 * 11448 * _([1, 2, 3]).value(); 11449 * // => [1, 2, 3] 11450 */ 11451 function wrapperValue() { 11452 return baseWrapperValue(this.__wrapped__, this.__actions__); 11453 } 11454 11455 /*------------------------------------------------------------------------*/ 11456 11457 /** 11458 * Creates an object composed of keys generated from the results of running 11459 * each element of `collection` thru `iteratee`. The corresponding value of 11460 * each key is the number of times the key was returned by `iteratee`. The 11461 * iteratee is invoked with one argument: (value). 11462 * 11463 * @static 11464 * @memberOf _ 11465 * @since 0.5.0 11466 * @category Collection 11467 * @param {Array|Object} collection The collection to iterate over. 11468 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11469 * @returns {Object} Returns the composed aggregate object. 11470 * @example 11471 * 11472 * _.countBy([6.1, 4.2, 6.3], Math.floor); 11473 * // => { '4': 1, '6': 2 } 11474 * 11475 * // The `_.property` iteratee shorthand. 11476 * _.countBy(['one', 'two', 'three'], 'length'); 11477 * // => { '3': 2, '5': 1 } 11478 */ 11479 var countBy = createAggregator(function(result, value, key) { 11480 if (hasOwnProperty.call(result, key)) { 11481 ++result[key]; 11482 } else { 11483 baseAssignValue(result, key, 1); 11484 } 11485 }); 11486 11487 /** 11488 * Checks if `predicate` returns truthy for **all** elements of `collection`. 11489 * Iteration is stopped once `predicate` returns falsey. The predicate is 11490 * invoked with three arguments: (value, index|key, collection). 11491 * 11492 * **Note:** This method returns `true` for 11493 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 11494 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 11495 * elements of empty collections. 11496 * 11497 * @static 11498 * @memberOf _ 11499 * @since 0.1.0 11500 * @category Collection 11501 * @param {Array|Object} collection The collection to iterate over. 11502 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11503 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11504 * @returns {boolean} Returns `true` if all elements pass the predicate check, 11505 * else `false`. 11506 * @example 11507 * 11508 * _.every([true, 1, null, 'yes'], Boolean); 11509 * // => false 11510 * 11511 * var users = [ 11512 * { 'user': 'barney', 'age': 36, 'active': false }, 11513 * { 'user': 'fred', 'age': 40, 'active': false } 11514 * ]; 11515 * 11516 * // The `_.matches` iteratee shorthand. 11517 * _.every(users, { 'user': 'barney', 'active': false }); 11518 * // => false 11519 * 11520 * // The `_.matchesProperty` iteratee shorthand. 11521 * _.every(users, ['active', false]); 11522 * // => true 11523 * 11524 * // The `_.property` iteratee shorthand. 11525 * _.every(users, 'active'); 11526 * // => false 11527 */ 11528 function every(collection, predicate, guard) { 11529 var func = isArray(collection) ? arrayEvery : baseEvery; 11530 if (guard && isIterateeCall(collection, predicate, guard)) { 11531 predicate = undefined; 11532 } 11533 return func(collection, getIteratee(predicate, 3)); 11534 } 11535 11536 /** 11537 * Iterates over elements of `collection`, returning an array of all elements 11538 * `predicate` returns truthy for. The predicate is invoked with three 11539 * arguments: (value, index|key, collection). 11540 * 11541 * **Note:** Unlike `_.remove`, this method returns a new array. 11542 * 11543 * @static 11544 * @memberOf _ 11545 * @since 0.1.0 11546 * @category Collection 11547 * @param {Array|Object} collection The collection to iterate over. 11548 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11549 * @returns {Array} Returns the new filtered array. 11550 * @see _.reject 11551 * @example 11552 * 11553 * var users = [ 11554 * { 'user': 'barney', 'age': 36, 'active': true }, 11555 * { 'user': 'fred', 'age': 40, 'active': false } 11556 * ]; 11557 * 11558 * _.filter(users, function(o) { return !o.active; }); 11559 * // => objects for ['fred'] 11560 * 11561 * // The `_.matches` iteratee shorthand. 11562 * _.filter(users, { 'age': 36, 'active': true }); 11563 * // => objects for ['barney'] 11564 * 11565 * // The `_.matchesProperty` iteratee shorthand. 11566 * _.filter(users, ['active', false]); 11567 * // => objects for ['fred'] 11568 * 11569 * // The `_.property` iteratee shorthand. 11570 * _.filter(users, 'active'); 11571 * // => objects for ['barney'] 11572 */ 11573 function filter(collection, predicate) { 11574 var func = isArray(collection) ? arrayFilter : baseFilter; 11575 return func(collection, getIteratee(predicate, 3)); 11576 } 11577 11578 /** 11579 * Iterates over elements of `collection`, returning the first element 11580 * `predicate` returns truthy for. The predicate is invoked with three 11581 * arguments: (value, index|key, collection). 11582 * 11583 * @static 11584 * @memberOf _ 11585 * @since 0.1.0 11586 * @category Collection 11587 * @param {Array|Object} collection The collection to inspect. 11588 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11589 * @param {number} [fromIndex=0] The index to search from. 11590 * @returns {*} Returns the matched element, else `undefined`. 11591 * @example 11592 * 11593 * var users = [ 11594 * { 'user': 'barney', 'age': 36, 'active': true }, 11595 * { 'user': 'fred', 'age': 40, 'active': false }, 11596 * { 'user': 'pebbles', 'age': 1, 'active': true } 11597 * ]; 11598 * 11599 * _.find(users, function(o) { return o.age < 40; }); 11600 * // => object for 'barney' 11601 * 11602 * // The `_.matches` iteratee shorthand. 11603 * _.find(users, { 'age': 1, 'active': true }); 11604 * // => object for 'pebbles' 11605 * 11606 * // The `_.matchesProperty` iteratee shorthand. 11607 * _.find(users, ['active', false]); 11608 * // => object for 'fred' 11609 * 11610 * // The `_.property` iteratee shorthand. 11611 * _.find(users, 'active'); 11612 * // => object for 'barney' 11613 */ 11614 var find = createFind(findIndex); 11615 11616 /** 11617 * This method is like `_.find` except that it iterates over elements of 11618 * `collection` from right to left. 11619 * 11620 * @static 11621 * @memberOf _ 11622 * @since 2.0.0 11623 * @category Collection 11624 * @param {Array|Object} collection The collection to inspect. 11625 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11626 * @param {number} [fromIndex=collection.length-1] The index to search from. 11627 * @returns {*} Returns the matched element, else `undefined`. 11628 * @example 11629 * 11630 * _.findLast([1, 2, 3, 4], function(n) { 11631 * return n % 2 == 1; 11632 * }); 11633 * // => 3 11634 */ 11635 var findLast = createFind(findLastIndex); 11636 11637 /** 11638 * Creates a flattened array of values by running each element in `collection` 11639 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 11640 * with three arguments: (value, index|key, collection). 11641 * 11642 * @static 11643 * @memberOf _ 11644 * @since 4.0.0 11645 * @category Collection 11646 * @param {Array|Object} collection The collection to iterate over. 11647 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11648 * @returns {Array} Returns the new flattened array. 11649 * @example 11650 * 11651 * function duplicate(n) { 11652 * return [n, n]; 11653 * } 11654 * 11655 * _.flatMap([1, 2], duplicate); 11656 * // => [1, 1, 2, 2] 11657 */ 11658 function flatMap(collection, iteratee) { 11659 return baseFlatten(map(collection, iteratee), 1); 11660 } 11661 11662 /** 11663 * This method is like `_.flatMap` except that it recursively flattens the 11664 * mapped results. 11665 * 11666 * @static 11667 * @memberOf _ 11668 * @since 4.7.0 11669 * @category Collection 11670 * @param {Array|Object} collection The collection to iterate over. 11671 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11672 * @returns {Array} Returns the new flattened array. 11673 * @example 11674 * 11675 * function duplicate(n) { 11676 * return [[[n, n]]]; 11677 * } 11678 * 11679 * _.flatMapDeep([1, 2], duplicate); 11680 * // => [1, 1, 2, 2] 11681 */ 11682 function flatMapDeep(collection, iteratee) { 11683 return baseFlatten(map(collection, iteratee), INFINITY); 11684 } 11685 11686 /** 11687 * This method is like `_.flatMap` except that it recursively flattens the 11688 * mapped results up to `depth` times. 11689 * 11690 * @static 11691 * @memberOf _ 11692 * @since 4.7.0 11693 * @category Collection 11694 * @param {Array|Object} collection The collection to iterate over. 11695 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11696 * @param {number} [depth=1] The maximum recursion depth. 11697 * @returns {Array} Returns the new flattened array. 11698 * @example 11699 * 11700 * function duplicate(n) { 11701 * return [[[n, n]]]; 11702 * } 11703 * 11704 * _.flatMapDepth([1, 2], duplicate, 2); 11705 * // => [[1, 1], [2, 2]] 11706 */ 11707 function flatMapDepth(collection, iteratee, depth) { 11708 depth = depth === undefined ? 1 : toInteger(depth); 11709 return baseFlatten(map(collection, iteratee), depth); 11710 } 11711 11712 /** 11713 * Iterates over elements of `collection` and invokes `iteratee` for each element. 11714 * The iteratee is invoked with three arguments: (value, index|key, collection). 11715 * Iteratee functions may exit iteration early by explicitly returning `false`. 11716 * 11717 * **Note:** As with other "Collections" methods, objects with a "length" 11718 * property are iterated like arrays. To avoid this behavior use `_.forIn` 11719 * or `_.forOwn` for object iteration. 11720 * 11721 * @static 11722 * @memberOf _ 11723 * @since 0.1.0 11724 * @alias each 11725 * @category Collection 11726 * @param {Array|Object} collection The collection to iterate over. 11727 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11728 * @returns {Array|Object} Returns `collection`. 11729 * @see _.forEachRight 11730 * @example 11731 * 11732 * _.forEach([1, 2], function(value) { 11733 * console.log(value); 11734 * }); 11735 * // => Logs `1` then `2`. 11736 * 11737 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 11738 * console.log(key); 11739 * }); 11740 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 11741 */ 11742 function forEach(collection, iteratee) { 11743 var func = isArray(collection) ? arrayEach : baseEach; 11744 return func(collection, getIteratee(iteratee, 3)); 11745 } 11746 11747 /** 11748 * This method is like `_.forEach` except that it iterates over elements of 11749 * `collection` from right to left. 11750 * 11751 * @static 11752 * @memberOf _ 11753 * @since 2.0.0 11754 * @alias eachRight 11755 * @category Collection 11756 * @param {Array|Object} collection The collection to iterate over. 11757 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11758 * @returns {Array|Object} Returns `collection`. 11759 * @see _.forEach 11760 * @example 11761 * 11762 * _.forEachRight([1, 2], function(value) { 11763 * console.log(value); 11764 * }); 11765 * // => Logs `2` then `1`. 11766 */ 11767 function forEachRight(collection, iteratee) { 11768 var func = isArray(collection) ? arrayEachRight : baseEachRight; 11769 return func(collection, getIteratee(iteratee, 3)); 11770 } 11771 11772 /** 11773 * Creates an object composed of keys generated from the results of running 11774 * each element of `collection` thru `iteratee`. The order of grouped values 11775 * is determined by the order they occur in `collection`. The corresponding 11776 * value of each key is an array of elements responsible for generating the 11777 * key. The iteratee is invoked with one argument: (value). 11778 * 11779 * @static 11780 * @memberOf _ 11781 * @since 0.1.0 11782 * @category Collection 11783 * @param {Array|Object} collection The collection to iterate over. 11784 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11785 * @returns {Object} Returns the composed aggregate object. 11786 * @example 11787 * 11788 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 11789 * // => { '4': [4.2], '6': [6.1, 6.3] } 11790 * 11791 * // The `_.property` iteratee shorthand. 11792 * _.groupBy(['one', 'two', 'three'], 'length'); 11793 * // => { '3': ['one', 'two'], '5': ['three'] } 11794 */ 11795 var groupBy = createAggregator(function(result, value, key) { 11796 if (hasOwnProperty.call(result, key)) { 11797 result[key].push(value); 11798 } else { 11799 baseAssignValue(result, key, [value]); 11800 } 11801 }); 11802 11803 /** 11804 * Checks if `value` is in `collection`. If `collection` is a string, it's 11805 * checked for a substring of `value`, otherwise 11806 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 11807 * is used for equality comparisons. If `fromIndex` is negative, it's used as 11808 * the offset from the end of `collection`. 11809 * 11810 * @static 11811 * @memberOf _ 11812 * @since 0.1.0 11813 * @category Collection 11814 * @param {Array|Object|string} collection The collection to inspect. 11815 * @param {*} value The value to search for. 11816 * @param {number} [fromIndex=0] The index to search from. 11817 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 11818 * @returns {boolean} Returns `true` if `value` is found, else `false`. 11819 * @example 11820 * 11821 * _.includes([1, 2, 3], 1); 11822 * // => true 11823 * 11824 * _.includes([1, 2, 3], 1, 2); 11825 * // => false 11826 * 11827 * _.includes({ 'a': 1, 'b': 2 }, 1); 11828 * // => true 11829 * 11830 * _.includes('abcd', 'bc'); 11831 * // => true 11832 */ 11833 function includes(collection, value, fromIndex, guard) { 11834 collection = isArrayLike(collection) ? collection : values(collection); 11835 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 11836 11837 var length = collection.length; 11838 if (fromIndex < 0) { 11839 fromIndex = nativeMax(length + fromIndex, 0); 11840 } 11841 return isString(collection) 11842 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 11843 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 11844 } 11845 11846 /** 11847 * Invokes the method at `path` of each element in `collection`, returning 11848 * an array of the results of each invoked method. Any additional arguments 11849 * are provided to each invoked method. If `path` is a function, it's invoked 11850 * for, and `this` bound to, each element in `collection`. 11851 * 11852 * @static 11853 * @memberOf _ 11854 * @since 4.0.0 11855 * @category Collection 11856 * @param {Array|Object} collection The collection to iterate over. 11857 * @param {Array|Function|string} path The path of the method to invoke or 11858 * the function invoked per iteration. 11859 * @param {...*} [args] The arguments to invoke each method with. 11860 * @returns {Array} Returns the array of results. 11861 * @example 11862 * 11863 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 11864 * // => [[1, 5, 7], [1, 2, 3]] 11865 * 11866 * _.invokeMap([123, 456], String.prototype.split, ''); 11867 * // => [['1', '2', '3'], ['4', '5', '6']] 11868 */ 11869 var invokeMap = baseRest(function(collection, path, args) { 11870 var index = -1, 11871 isFunc = typeof path == 'function', 11872 result = isArrayLike(collection) ? Array(collection.length) : []; 11873 11874 baseEach(collection, function(value) { 11875 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 11876 }); 11877 return result; 11878 }); 11879 11880 /** 11881 * Creates an object composed of keys generated from the results of running 11882 * each element of `collection` thru `iteratee`. The corresponding value of 11883 * each key is the last element responsible for generating the key. The 11884 * iteratee is invoked with one argument: (value). 11885 * 11886 * @static 11887 * @memberOf _ 11888 * @since 4.0.0 11889 * @category Collection 11890 * @param {Array|Object} collection The collection to iterate over. 11891 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11892 * @returns {Object} Returns the composed aggregate object. 11893 * @example 11894 * 11895 * var array = [ 11896 * { 'dir': 'left', 'code': 97 }, 11897 * { 'dir': 'right', 'code': 100 } 11898 * ]; 11899 * 11900 * _.keyBy(array, function(o) { 11901 * return String.fromCharCode(o.code); 11902 * }); 11903 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 11904 * 11905 * _.keyBy(array, 'dir'); 11906 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 11907 */ 11908 var keyBy = createAggregator(function(result, value, key) { 11909 baseAssignValue(result, key, value); 11910 }); 11911 11912 /** 11913 * Creates an array of values by running each element in `collection` thru 11914 * `iteratee`. The iteratee is invoked with three arguments: 11915 * (value, index|key, collection). 11916 * 11917 * Many lodash methods are guarded to work as iteratees for methods like 11918 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 11919 * 11920 * The guarded methods are: 11921 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 11922 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 11923 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 11924 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 11925 * 11926 * @static 11927 * @memberOf _ 11928 * @since 0.1.0 11929 * @category Collection 11930 * @param {Array|Object} collection The collection to iterate over. 11931 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11932 * @returns {Array} Returns the new mapped array. 11933 * @example 11934 * 11935 * function square(n) { 11936 * return n * n; 11937 * } 11938 * 11939 * _.map([4, 8], square); 11940 * // => [16, 64] 11941 * 11942 * _.map({ 'a': 4, 'b': 8 }, square); 11943 * // => [16, 64] (iteration order is not guaranteed) 11944 * 11945 * var users = [ 11946 * { 'user': 'barney' }, 11947 * { 'user': 'fred' } 11948 * ]; 11949 * 11950 * // The `_.property` iteratee shorthand. 11951 * _.map(users, 'user'); 11952 * // => ['barney', 'fred'] 11953 */ 11954 function map(collection, iteratee) { 11955 var func = isArray(collection) ? arrayMap : baseMap; 11956 return func(collection, getIteratee(iteratee, 3)); 11957 } 11958 11959 /** 11960 * This method is like `_.sortBy` except that it allows specifying the sort 11961 * orders of the iteratees to sort by. If `orders` is unspecified, all values 11962 * are sorted in ascending order. Otherwise, specify an order of "desc" for 11963 * descending or "asc" for ascending sort order of corresponding values. 11964 * 11965 * @static 11966 * @memberOf _ 11967 * @since 4.0.0 11968 * @category Collection 11969 * @param {Array|Object} collection The collection to iterate over. 11970 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 11971 * The iteratees to sort by. 11972 * @param {string[]} [orders] The sort orders of `iteratees`. 11973 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 11974 * @returns {Array} Returns the new sorted array. 11975 * @example 11976 * 11977 * var users = [ 11978 * { 'user': 'fred', 'age': 48 }, 11979 * { 'user': 'barney', 'age': 34 }, 11980 * { 'user': 'fred', 'age': 40 }, 11981 * { 'user': 'barney', 'age': 36 } 11982 * ]; 11983 * 11984 * // Sort by `user` in ascending order and by `age` in descending order. 11985 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 11986 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 11987 */ 11988 function orderBy(collection, iteratees, orders, guard) { 11989 if (collection == null) { 11990 return []; 11991 } 11992 if (!isArray(iteratees)) { 11993 iteratees = iteratees == null ? [] : [iteratees]; 11994 } 11995 orders = guard ? undefined : orders; 11996 if (!isArray(orders)) { 11997 orders = orders == null ? [] : [orders]; 11998 } 11999 return baseOrderBy(collection, iteratees, orders); 12000 } 12001 12002 /** 12003 * Creates an array of elements split into two groups, the first of which 12004 * contains elements `predicate` returns truthy for, the second of which 12005 * contains elements `predicate` returns falsey for. The predicate is 12006 * invoked with one argument: (value). 12007 * 12008 * @static 12009 * @memberOf _ 12010 * @since 3.0.0 12011 * @category Collection 12012 * @param {Array|Object} collection The collection to iterate over. 12013 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12014 * @returns {Array} Returns the array of grouped elements. 12015 * @example 12016 * 12017 * var users = [ 12018 * { 'user': 'barney', 'age': 36, 'active': false }, 12019 * { 'user': 'fred', 'age': 40, 'active': true }, 12020 * { 'user': 'pebbles', 'age': 1, 'active': false } 12021 * ]; 12022 * 12023 * _.partition(users, function(o) { return o.active; }); 12024 * // => objects for [['fred'], ['barney', 'pebbles']] 12025 * 12026 * // The `_.matches` iteratee shorthand. 12027 * _.partition(users, { 'age': 1, 'active': false }); 12028 * // => objects for [['pebbles'], ['barney', 'fred']] 12029 * 12030 * // The `_.matchesProperty` iteratee shorthand. 12031 * _.partition(users, ['active', false]); 12032 * // => objects for [['barney', 'pebbles'], ['fred']] 12033 * 12034 * // The `_.property` iteratee shorthand. 12035 * _.partition(users, 'active'); 12036 * // => objects for [['fred'], ['barney', 'pebbles']] 12037 */ 12038 var partition = createAggregator(function(result, value, key) { 12039 result[key ? 0 : 1].push(value); 12040 }, function() { return [[], []]; }); 12041 12042 /** 12043 * Reduces `collection` to a value which is the accumulated result of running 12044 * each element in `collection` thru `iteratee`, where each successive 12045 * invocation is supplied the return value of the previous. If `accumulator` 12046 * is not given, the first element of `collection` is used as the initial 12047 * value. The iteratee is invoked with four arguments: 12048 * (accumulator, value, index|key, collection). 12049 * 12050 * Many lodash methods are guarded to work as iteratees for methods like 12051 * `_.reduce`, `_.reduceRight`, and `_.transform`. 12052 * 12053 * The guarded methods are: 12054 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 12055 * and `sortBy` 12056 * 12057 * @static 12058 * @memberOf _ 12059 * @since 0.1.0 12060 * @category Collection 12061 * @param {Array|Object} collection The collection to iterate over. 12062 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 12063 * @param {*} [accumulator] The initial value. 12064 * @returns {*} Returns the accumulated value. 12065 * @see _.reduceRight 12066 * @example 12067 * 12068 * _.reduce([1, 2], function(sum, n) { 12069 * return sum + n; 12070 * }, 0); 12071 * // => 3 12072 * 12073 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 12074 * (result[value] || (result[value] = [])).push(key); 12075 * return result; 12076 * }, {}); 12077 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 12078 */ 12079 function reduce(collection, iteratee, accumulator) { 12080 var func = isArray(collection) ? arrayReduce : baseReduce, 12081 initAccum = arguments.length < 3; 12082 12083 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 12084 } 12085 12086 /** 12087 * This method is like `_.reduce` except that it iterates over elements of 12088 * `collection` from right to left. 12089 * 12090 * @static 12091 * @memberOf _ 12092 * @since 0.1.0 12093 * @category Collection 12094 * @param {Array|Object} collection The collection to iterate over. 12095 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 12096 * @param {*} [accumulator] The initial value. 12097 * @returns {*} Returns the accumulated value. 12098 * @see _.reduce 12099 * @example 12100 * 12101 * var array = [[0, 1], [2, 3], [4, 5]]; 12102 * 12103 * _.reduceRight(array, function(flattened, other) { 12104 * return flattened.concat(other); 12105 * }, []); 12106 * // => [4, 5, 2, 3, 0, 1] 12107 */ 12108 function reduceRight(collection, iteratee, accumulator) { 12109 var func = isArray(collection) ? arrayReduceRight : baseReduce, 12110 initAccum = arguments.length < 3; 12111 12112 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 12113 } 12114 12115 /** 12116 * The opposite of `_.filter`; this method returns the elements of `collection` 12117 * that `predicate` does **not** return truthy for. 12118 * 12119 * @static 12120 * @memberOf _ 12121 * @since 0.1.0 12122 * @category Collection 12123 * @param {Array|Object} collection The collection to iterate over. 12124 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12125 * @returns {Array} Returns the new filtered array. 12126 * @see _.filter 12127 * @example 12128 * 12129 * var users = [ 12130 * { 'user': 'barney', 'age': 36, 'active': false }, 12131 * { 'user': 'fred', 'age': 40, 'active': true } 12132 * ]; 12133 * 12134 * _.reject(users, function(o) { return !o.active; }); 12135 * // => objects for ['fred'] 12136 * 12137 * // The `_.matches` iteratee shorthand. 12138 * _.reject(users, { 'age': 40, 'active': true }); 12139 * // => objects for ['barney'] 12140 * 12141 * // The `_.matchesProperty` iteratee shorthand. 12142 * _.reject(users, ['active', false]); 12143 * // => objects for ['fred'] 12144 * 12145 * // The `_.property` iteratee shorthand. 12146 * _.reject(users, 'active'); 12147 * // => objects for ['barney'] 12148 */ 12149 function reject(collection, predicate) { 12150 var func = isArray(collection) ? arrayFilter : baseFilter; 12151 return func(collection, negate(getIteratee(predicate, 3))); 12152 } 12153 12154 /** 12155 * Gets a random element from `collection`. 12156 * 12157 * @static 12158 * @memberOf _ 12159 * @since 2.0.0 12160 * @category Collection 12161 * @param {Array|Object} collection The collection to sample. 12162 * @returns {*} Returns the random element. 12163 * @example 12164 * 12165 * _.sample([1, 2, 3, 4]); 12166 * // => 2 12167 */ 12168 function sample(collection) { 12169 var func = isArray(collection) ? arraySample : baseSample; 12170 return func(collection); 12171 } 12172 12173 /** 12174 * Gets `n` random elements at unique keys from `collection` up to the 12175 * size of `collection`. 12176 * 12177 * @static 12178 * @memberOf _ 12179 * @since 4.0.0 12180 * @category Collection 12181 * @param {Array|Object} collection The collection to sample. 12182 * @param {number} [n=1] The number of elements to sample. 12183 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12184 * @returns {Array} Returns the random elements. 12185 * @example 12186 * 12187 * _.sampleSize([1, 2, 3], 2); 12188 * // => [3, 1] 12189 * 12190 * _.sampleSize([1, 2, 3], 4); 12191 * // => [2, 3, 1] 12192 */ 12193 function sampleSize(collection, n, guard) { 12194 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 12195 n = 1; 12196 } else { 12197 n = toInteger(n); 12198 } 12199 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 12200 return func(collection, n); 12201 } 12202 12203 /** 12204 * Creates an array of shuffled values, using a version of the 12205 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 12206 * 12207 * @static 12208 * @memberOf _ 12209 * @since 0.1.0 12210 * @category Collection 12211 * @param {Array|Object} collection The collection to shuffle. 12212 * @returns {Array} Returns the new shuffled array. 12213 * @example 12214 * 12215 * _.shuffle([1, 2, 3, 4]); 12216 * // => [4, 1, 3, 2] 12217 */ 12218 function shuffle(collection) { 12219 var func = isArray(collection) ? arrayShuffle : baseShuffle; 12220 return func(collection); 12221 } 12222 12223 /** 12224 * Gets the size of `collection` by returning its length for array-like 12225 * values or the number of own enumerable string keyed properties for objects. 12226 * 12227 * @static 12228 * @memberOf _ 12229 * @since 0.1.0 12230 * @category Collection 12231 * @param {Array|Object|string} collection The collection to inspect. 12232 * @returns {number} Returns the collection size. 12233 * @example 12234 * 12235 * _.size([1, 2, 3]); 12236 * // => 3 12237 * 12238 * _.size({ 'a': 1, 'b': 2 }); 12239 * // => 2 12240 * 12241 * _.size('pebbles'); 12242 * // => 7 12243 */ 12244 function size(collection) { 12245 if (collection == null) { 12246 return 0; 12247 } 12248 if (isArrayLike(collection)) { 12249 return isString(collection) ? stringSize(collection) : collection.length; 12250 } 12251 var tag = getTag(collection); 12252 if (tag == mapTag || tag == setTag) { 12253 return collection.size; 12254 } 12255 return baseKeys(collection).length; 12256 } 12257 12258 /** 12259 * Checks if `predicate` returns truthy for **any** element of `collection`. 12260 * Iteration is stopped once `predicate` returns truthy. The predicate is 12261 * invoked with three arguments: (value, index|key, collection). 12262 * 12263 * @static 12264 * @memberOf _ 12265 * @since 0.1.0 12266 * @category Collection 12267 * @param {Array|Object} collection The collection to iterate over. 12268 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12269 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12270 * @returns {boolean} Returns `true` if any element passes the predicate check, 12271 * else `false`. 12272 * @example 12273 * 12274 * _.some([null, 0, 'yes', false], Boolean); 12275 * // => true 12276 * 12277 * var users = [ 12278 * { 'user': 'barney', 'active': true }, 12279 * { 'user': 'fred', 'active': false } 12280 * ]; 12281 * 12282 * // The `_.matches` iteratee shorthand. 12283 * _.some(users, { 'user': 'barney', 'active': false }); 12284 * // => false 12285 * 12286 * // The `_.matchesProperty` iteratee shorthand. 12287 * _.some(users, ['active', false]); 12288 * // => true 12289 * 12290 * // The `_.property` iteratee shorthand. 12291 * _.some(users, 'active'); 12292 * // => true 12293 */ 12294 function some(collection, predicate, guard) { 12295 var func = isArray(collection) ? arraySome : baseSome; 12296 if (guard && isIterateeCall(collection, predicate, guard)) { 12297 predicate = undefined; 12298 } 12299 return func(collection, getIteratee(predicate, 3)); 12300 } 12301 12302 /** 12303 * Creates an array of elements, sorted in ascending order by the results of 12304 * running each element in a collection thru each iteratee. This method 12305 * performs a stable sort, that is, it preserves the original sort order of 12306 * equal elements. The iteratees are invoked with one argument: (value). 12307 * 12308 * @static 12309 * @memberOf _ 12310 * @since 0.1.0 12311 * @category Collection 12312 * @param {Array|Object} collection The collection to iterate over. 12313 * @param {...(Function|Function[])} [iteratees=[_.identity]] 12314 * The iteratees to sort by. 12315 * @returns {Array} Returns the new sorted array. 12316 * @example 12317 * 12318 * var users = [ 12319 * { 'user': 'fred', 'age': 48 }, 12320 * { 'user': 'barney', 'age': 36 }, 12321 * { 'user': 'fred', 'age': 40 }, 12322 * { 'user': 'barney', 'age': 34 } 12323 * ]; 12324 * 12325 * _.sortBy(users, [function(o) { return o.user; }]); 12326 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 12327 * 12328 * _.sortBy(users, ['user', 'age']); 12329 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] 12330 */ 12331 var sortBy = baseRest(function(collection, iteratees) { 12332 if (collection == null) { 12333 return []; 12334 } 12335 var length = iteratees.length; 12336 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 12337 iteratees = []; 12338 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 12339 iteratees = [iteratees[0]]; 12340 } 12341 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 12342 }); 12343 12344 /*------------------------------------------------------------------------*/ 12345 12346 /** 12347 * Gets the timestamp of the number of milliseconds that have elapsed since 12348 * the Unix epoch (1 January 1970 00:00:00 UTC). 12349 * 12350 * @static 12351 * @memberOf _ 12352 * @since 2.4.0 12353 * @category Date 12354 * @returns {number} Returns the timestamp. 12355 * @example 12356 * 12357 * _.defer(function(stamp) { 12358 * console.log(_.now() - stamp); 12359 * }, _.now()); 12360 * // => Logs the number of milliseconds it took for the deferred invocation. 12361 */ 12362 var now = ctxNow || function() { 12363 return root.Date.now(); 12364 }; 12365 12366 /*------------------------------------------------------------------------*/ 12367 12368 /** 12369 * The opposite of `_.before`; this method creates a function that invokes 12370 * `func` once it's called `n` or more times. 12371 * 12372 * @static 12373 * @memberOf _ 12374 * @since 0.1.0 12375 * @category Function 12376 * @param {number} n The number of calls before `func` is invoked. 12377 * @param {Function} func The function to restrict. 12378 * @returns {Function} Returns the new restricted function. 12379 * @example 12380 * 12381 * var saves = ['profile', 'settings']; 12382 * 12383 * var done = _.after(saves.length, function() { 12384 * console.log('done saving!'); 12385 * }); 12386 * 12387 * _.forEach(saves, function(type) { 12388 * asyncSave({ 'type': type, 'complete': done }); 12389 * }); 12390 * // => Logs 'done saving!' after the two async saves have completed. 12391 */ 12392 function after(n, func) { 12393 if (typeof func != 'function') { 12394 throw new TypeError(FUNC_ERROR_TEXT); 12395 } 12396 n = toInteger(n); 12397 return function() { 12398 if (--n < 1) { 12399 return func.apply(this, arguments); 12400 } 12401 }; 12402 } 12403 12404 /** 12405 * Creates a function that invokes `func`, with up to `n` arguments, 12406 * ignoring any additional arguments. 12407 * 12408 * @static 12409 * @memberOf _ 12410 * @since 3.0.0 12411 * @category Function 12412 * @param {Function} func The function to cap arguments for. 12413 * @param {number} [n=func.length] The arity cap. 12414 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12415 * @returns {Function} Returns the new capped function. 12416 * @example 12417 * 12418 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 12419 * // => [6, 8, 10] 12420 */ 12421 function ary(func, n, guard) { 12422 n = guard ? undefined : n; 12423 n = (func && n == null) ? func.length : n; 12424 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 12425 } 12426 12427 /** 12428 * Creates a function that invokes `func`, with the `this` binding and arguments 12429 * of the created function, while it's called less than `n` times. Subsequent 12430 * calls to the created function return the result of the last `func` invocation. 12431 * 12432 * @static 12433 * @memberOf _ 12434 * @since 3.0.0 12435 * @category Function 12436 * @param {number} n The number of calls at which `func` is no longer invoked. 12437 * @param {Function} func The function to restrict. 12438 * @returns {Function} Returns the new restricted function. 12439 * @example 12440 * 12441 * jQuery(element).on('click', _.before(5, addContactToList)); 12442 * // => Allows adding up to 4 contacts to the list. 12443 */ 12444 function before(n, func) { 12445 var result; 12446 if (typeof func != 'function') { 12447 throw new TypeError(FUNC_ERROR_TEXT); 12448 } 12449 n = toInteger(n); 12450 return function() { 12451 if (--n > 0) { 12452 result = func.apply(this, arguments); 12453 } 12454 if (n <= 1) { 12455 func = undefined; 12456 } 12457 return result; 12458 }; 12459 } 12460 12461 /** 12462 * Creates a function that invokes `func` with the `this` binding of `thisArg` 12463 * and `partials` prepended to the arguments it receives. 12464 * 12465 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 12466 * may be used as a placeholder for partially applied arguments. 12467 * 12468 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 12469 * property of bound functions. 12470 * 12471 * @static 12472 * @memberOf _ 12473 * @since 0.1.0 12474 * @category Function 12475 * @param {Function} func The function to bind. 12476 * @param {*} thisArg The `this` binding of `func`. 12477 * @param {...*} [partials] The arguments to be partially applied. 12478 * @returns {Function} Returns the new bound function. 12479 * @example 12480 * 12481 * function greet(greeting, punctuation) { 12482 * return greeting + ' ' + this.user + punctuation; 12483 * } 12484 * 12485 * var object = { 'user': 'fred' }; 12486 * 12487 * var bound = _.bind(greet, object, 'hi'); 12488 * bound('!'); 12489 * // => 'hi fred!' 12490 * 12491 * // Bound with placeholders. 12492 * var bound = _.bind(greet, object, _, '!'); 12493 * bound('hi'); 12494 * // => 'hi fred!' 12495 */ 12496 var bind = baseRest(function(func, thisArg, partials) { 12497 var bitmask = WRAP_BIND_FLAG; 12498 if (partials.length) { 12499 var holders = replaceHolders(partials, getHolder(bind)); 12500 bitmask |= WRAP_PARTIAL_FLAG; 12501 } 12502 return createWrap(func, bitmask, thisArg, partials, holders); 12503 }); 12504 12505 /** 12506 * Creates a function that invokes the method at `object[key]` with `partials` 12507 * prepended to the arguments it receives. 12508 * 12509 * This method differs from `_.bind` by allowing bound functions to reference 12510 * methods that may be redefined or don't yet exist. See 12511 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 12512 * for more details. 12513 * 12514 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 12515 * builds, may be used as a placeholder for partially applied arguments. 12516 * 12517 * @static 12518 * @memberOf _ 12519 * @since 0.10.0 12520 * @category Function 12521 * @param {Object} object The object to invoke the method on. 12522 * @param {string} key The key of the method. 12523 * @param {...*} [partials] The arguments to be partially applied. 12524 * @returns {Function} Returns the new bound function. 12525 * @example 12526 * 12527 * var object = { 12528 * 'user': 'fred', 12529 * 'greet': function(greeting, punctuation) { 12530 * return greeting + ' ' + this.user + punctuation; 12531 * } 12532 * }; 12533 * 12534 * var bound = _.bindKey(object, 'greet', 'hi'); 12535 * bound('!'); 12536 * // => 'hi fred!' 12537 * 12538 * object.greet = function(greeting, punctuation) { 12539 * return greeting + 'ya ' + this.user + punctuation; 12540 * }; 12541 * 12542 * bound('!'); 12543 * // => 'hiya fred!' 12544 * 12545 * // Bound with placeholders. 12546 * var bound = _.bindKey(object, 'greet', _, '!'); 12547 * bound('hi'); 12548 * // => 'hiya fred!' 12549 */ 12550 var bindKey = baseRest(function(object, key, partials) { 12551 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 12552 if (partials.length) { 12553 var holders = replaceHolders(partials, getHolder(bindKey)); 12554 bitmask |= WRAP_PARTIAL_FLAG; 12555 } 12556 return createWrap(key, bitmask, object, partials, holders); 12557 }); 12558 12559 /** 12560 * Creates a function that accepts arguments of `func` and either invokes 12561 * `func` returning its result, if at least `arity` number of arguments have 12562 * been provided, or returns a function that accepts the remaining `func` 12563 * arguments, and so on. The arity of `func` may be specified if `func.length` 12564 * is not sufficient. 12565 * 12566 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 12567 * may be used as a placeholder for provided arguments. 12568 * 12569 * **Note:** This method doesn't set the "length" property of curried functions. 12570 * 12571 * @static 12572 * @memberOf _ 12573 * @since 2.0.0 12574 * @category Function 12575 * @param {Function} func The function to curry. 12576 * @param {number} [arity=func.length] The arity of `func`. 12577 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12578 * @returns {Function} Returns the new curried function. 12579 * @example 12580 * 12581 * var abc = function(a, b, c) { 12582 * return [a, b, c]; 12583 * }; 12584 * 12585 * var curried = _.curry(abc); 12586 * 12587 * curried(1)(2)(3); 12588 * // => [1, 2, 3] 12589 * 12590 * curried(1, 2)(3); 12591 * // => [1, 2, 3] 12592 * 12593 * curried(1, 2, 3); 12594 * // => [1, 2, 3] 12595 * 12596 * // Curried with placeholders. 12597 * curried(1)(_, 3)(2); 12598 * // => [1, 2, 3] 12599 */ 12600 function curry(func, arity, guard) { 12601 arity = guard ? undefined : arity; 12602 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 12603 result.placeholder = curry.placeholder; 12604 return result; 12605 } 12606 12607 /** 12608 * This method is like `_.curry` except that arguments are applied to `func` 12609 * in the manner of `_.partialRight` instead of `_.partial`. 12610 * 12611 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 12612 * builds, may be used as a placeholder for provided arguments. 12613 * 12614 * **Note:** This method doesn't set the "length" property of curried functions. 12615 * 12616 * @static 12617 * @memberOf _ 12618 * @since 3.0.0 12619 * @category Function 12620 * @param {Function} func The function to curry. 12621 * @param {number} [arity=func.length] The arity of `func`. 12622 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12623 * @returns {Function} Returns the new curried function. 12624 * @example 12625 * 12626 * var abc = function(a, b, c) { 12627 * return [a, b, c]; 12628 * }; 12629 * 12630 * var curried = _.curryRight(abc); 12631 * 12632 * curried(3)(2)(1); 12633 * // => [1, 2, 3] 12634 * 12635 * curried(2, 3)(1); 12636 * // => [1, 2, 3] 12637 * 12638 * curried(1, 2, 3); 12639 * // => [1, 2, 3] 12640 * 12641 * // Curried with placeholders. 12642 * curried(3)(1, _)(2); 12643 * // => [1, 2, 3] 12644 */ 12645 function curryRight(func, arity, guard) { 12646 arity = guard ? undefined : arity; 12647 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 12648 result.placeholder = curryRight.placeholder; 12649 return result; 12650 } 12651 12652 /** 12653 * Creates a debounced function that delays invoking `func` until after `wait` 12654 * milliseconds have elapsed since the last time the debounced function was 12655 * invoked. The debounced function comes with a `cancel` method to cancel 12656 * delayed `func` invocations and a `flush` method to immediately invoke them. 12657 * Provide `options` to indicate whether `func` should be invoked on the 12658 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 12659 * with the last arguments provided to the debounced function. Subsequent 12660 * calls to the debounced function return the result of the last `func` 12661 * invocation. 12662 * 12663 * **Note:** If `leading` and `trailing` options are `true`, `func` is 12664 * invoked on the trailing edge of the timeout only if the debounced function 12665 * is invoked more than once during the `wait` timeout. 12666 * 12667 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 12668 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 12669 * 12670 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 12671 * for details over the differences between `_.debounce` and `_.throttle`. 12672 * 12673 * @static 12674 * @memberOf _ 12675 * @since 0.1.0 12676 * @category Function 12677 * @param {Function} func The function to debounce. 12678 * @param {number} [wait=0] The number of milliseconds to delay. 12679 * @param {Object} [options={}] The options object. 12680 * @param {boolean} [options.leading=false] 12681 * Specify invoking on the leading edge of the timeout. 12682 * @param {number} [options.maxWait] 12683 * The maximum time `func` is allowed to be delayed before it's invoked. 12684 * @param {boolean} [options.trailing=true] 12685 * Specify invoking on the trailing edge of the timeout. 12686 * @returns {Function} Returns the new debounced function. 12687 * @example 12688 * 12689 * // Avoid costly calculations while the window size is in flux. 12690 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 12691 * 12692 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 12693 * jQuery(element).on('click', _.debounce(sendMail, 300, { 12694 * 'leading': true, 12695 * 'trailing': false 12696 * })); 12697 * 12698 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 12699 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 12700 * var source = new EventSource('/stream'); 12701 * jQuery(source).on('message', debounced); 12702 * 12703 * // Cancel the trailing debounced invocation. 12704 * jQuery(window).on('popstate', debounced.cancel); 12705 */ 12706 function debounce(func, wait, options) { 12707 var lastArgs, 12708 lastThis, 12709 maxWait, 12710 result, 12711 timerId, 12712 lastCallTime, 12713 lastInvokeTime = 0, 12714 leading = false, 12715 maxing = false, 12716 trailing = true; 12717 12718 if (typeof func != 'function') { 12719 throw new TypeError(FUNC_ERROR_TEXT); 12720 } 12721 wait = toNumber(wait) || 0; 12722 if (isObject(options)) { 12723 leading = !!options.leading; 12724 maxing = 'maxWait' in options; 12725 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 12726 trailing = 'trailing' in options ? !!options.trailing : trailing; 12727 } 12728 12729 function invokeFunc(time) { 12730 var args = lastArgs, 12731 thisArg = lastThis; 12732 12733 lastArgs = lastThis = undefined; 12734 lastInvokeTime = time; 12735 result = func.apply(thisArg, args); 12736 return result; 12737 } 12738 12739 function leadingEdge(time) { 12740 // Reset any `maxWait` timer. 12741 lastInvokeTime = time; 12742 // Start the timer for the trailing edge. 12743 timerId = setTimeout(timerExpired, wait); 12744 // Invoke the leading edge. 12745 return leading ? invokeFunc(time) : result; 12746 } 12747 12748 function remainingWait(time) { 12749 var timeSinceLastCall = time - lastCallTime, 12750 timeSinceLastInvoke = time - lastInvokeTime, 12751 timeWaiting = wait - timeSinceLastCall; 12752 12753 return maxing 12754 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 12755 : timeWaiting; 12756 } 12757 12758 function shouldInvoke(time) { 12759 var timeSinceLastCall = time - lastCallTime, 12760 timeSinceLastInvoke = time - lastInvokeTime; 12761 12762 // Either this is the first call, activity has stopped and we're at the 12763 // trailing edge, the system time has gone backwards and we're treating 12764 // it as the trailing edge, or we've hit the `maxWait` limit. 12765 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 12766 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 12767 } 12768 12769 function timerExpired() { 12770 var time = now(); 12771 if (shouldInvoke(time)) { 12772 return trailingEdge(time); 12773 } 12774 // Restart the timer. 12775 timerId = setTimeout(timerExpired, remainingWait(time)); 12776 } 12777 12778 function trailingEdge(time) { 12779 timerId = undefined; 12780 12781 // Only invoke if we have `lastArgs` which means `func` has been 12782 // debounced at least once. 12783 if (trailing && lastArgs) { 12784 return invokeFunc(time); 12785 } 12786 lastArgs = lastThis = undefined; 12787 return result; 12788 } 12789 12790 function cancel() { 12791 if (timerId !== undefined) { 12792 clearTimeout(timerId); 12793 } 12794 lastInvokeTime = 0; 12795 lastArgs = lastCallTime = lastThis = timerId = undefined; 12796 } 12797 12798 function flush() { 12799 return timerId === undefined ? result : trailingEdge(now()); 12800 } 12801 12802 function debounced() { 12803 var time = now(), 12804 isInvoking = shouldInvoke(time); 12805 12806 lastArgs = arguments; 12807 lastThis = this; 12808 lastCallTime = time; 12809 12810 if (isInvoking) { 12811 if (timerId === undefined) { 12812 return leadingEdge(lastCallTime); 12813 } 12814 if (maxing) { 12815 // Handle invocations in a tight loop. 12816 timerId = setTimeout(timerExpired, wait); 12817 return invokeFunc(lastCallTime); 12818 } 12819 } 12820 if (timerId === undefined) { 12821 timerId = setTimeout(timerExpired, wait); 12822 } 12823 return result; 12824 } 12825 debounced.cancel = cancel; 12826 debounced.flush = flush; 12827 return debounced; 12828 } 12829 12830 /** 12831 * Defers invoking the `func` until the current call stack has cleared. Any 12832 * additional arguments are provided to `func` when it's invoked. 12833 * 12834 * @static 12835 * @memberOf _ 12836 * @since 0.1.0 12837 * @category Function 12838 * @param {Function} func The function to defer. 12839 * @param {...*} [args] The arguments to invoke `func` with. 12840 * @returns {number} Returns the timer id. 12841 * @example 12842 * 12843 * _.defer(function(text) { 12844 * console.log(text); 12845 * }, 'deferred'); 12846 * // => Logs 'deferred' after one millisecond. 12847 */ 12848 var defer = baseRest(function(func, args) { 12849 return baseDelay(func, 1, args); 12850 }); 12851 12852 /** 12853 * Invokes `func` after `wait` milliseconds. Any additional arguments are 12854 * provided to `func` when it's invoked. 12855 * 12856 * @static 12857 * @memberOf _ 12858 * @since 0.1.0 12859 * @category Function 12860 * @param {Function} func The function to delay. 12861 * @param {number} wait The number of milliseconds to delay invocation. 12862 * @param {...*} [args] The arguments to invoke `func` with. 12863 * @returns {number} Returns the timer id. 12864 * @example 12865 * 12866 * _.delay(function(text) { 12867 * console.log(text); 12868 * }, 1000, 'later'); 12869 * // => Logs 'later' after one second. 12870 */ 12871 var delay = baseRest(function(func, wait, args) { 12872 return baseDelay(func, toNumber(wait) || 0, args); 12873 }); 12874 12875 /** 12876 * Creates a function that invokes `func` with arguments reversed. 12877 * 12878 * @static 12879 * @memberOf _ 12880 * @since 4.0.0 12881 * @category Function 12882 * @param {Function} func The function to flip arguments for. 12883 * @returns {Function} Returns the new flipped function. 12884 * @example 12885 * 12886 * var flipped = _.flip(function() { 12887 * return _.toArray(arguments); 12888 * }); 12889 * 12890 * flipped('a', 'b', 'c', 'd'); 12891 * // => ['d', 'c', 'b', 'a'] 12892 */ 12893 function flip(func) { 12894 return createWrap(func, WRAP_FLIP_FLAG); 12895 } 12896 12897 /** 12898 * Creates a function that memoizes the result of `func`. If `resolver` is 12899 * provided, it determines the cache key for storing the result based on the 12900 * arguments provided to the memoized function. By default, the first argument 12901 * provided to the memoized function is used as the map cache key. The `func` 12902 * is invoked with the `this` binding of the memoized function. 12903 * 12904 * **Note:** The cache is exposed as the `cache` property on the memoized 12905 * function. Its creation may be customized by replacing the `_.memoize.Cache` 12906 * constructor with one whose instances implement the 12907 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 12908 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 12909 * 12910 * @static 12911 * @memberOf _ 12912 * @since 0.1.0 12913 * @category Function 12914 * @param {Function} func The function to have its output memoized. 12915 * @param {Function} [resolver] The function to resolve the cache key. 12916 * @returns {Function} Returns the new memoized function. 12917 * @example 12918 * 12919 * var object = { 'a': 1, 'b': 2 }; 12920 * var other = { 'c': 3, 'd': 4 }; 12921 * 12922 * var values = _.memoize(_.values); 12923 * values(object); 12924 * // => [1, 2] 12925 * 12926 * values(other); 12927 * // => [3, 4] 12928 * 12929 * object.a = 2; 12930 * values(object); 12931 * // => [1, 2] 12932 * 12933 * // Modify the result cache. 12934 * values.cache.set(object, ['a', 'b']); 12935 * values(object); 12936 * // => ['a', 'b'] 12937 * 12938 * // Replace `_.memoize.Cache`. 12939 * _.memoize.Cache = WeakMap; 12940 */ 12941 function memoize(func, resolver) { 12942 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 12943 throw new TypeError(FUNC_ERROR_TEXT); 12944 } 12945 var memoized = function() { 12946 var args = arguments, 12947 key = resolver ? resolver.apply(this, args) : args[0], 12948 cache = memoized.cache; 12949 12950 if (cache.has(key)) { 12951 return cache.get(key); 12952 } 12953 var result = func.apply(this, args); 12954 memoized.cache = cache.set(key, result) || cache; 12955 return result; 12956 }; 12957 memoized.cache = new (memoize.Cache || MapCache); 12958 return memoized; 12959 } 12960 12961 // Expose `MapCache`. 12962 memoize.Cache = MapCache; 12963 12964 /** 12965 * Creates a function that negates the result of the predicate `func`. The 12966 * `func` predicate is invoked with the `this` binding and arguments of the 12967 * created function. 12968 * 12969 * @static 12970 * @memberOf _ 12971 * @since 3.0.0 12972 * @category Function 12973 * @param {Function} predicate The predicate to negate. 12974 * @returns {Function} Returns the new negated function. 12975 * @example 12976 * 12977 * function isEven(n) { 12978 * return n % 2 == 0; 12979 * } 12980 * 12981 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 12982 * // => [1, 3, 5] 12983 */ 12984 function negate(predicate) { 12985 if (typeof predicate != 'function') { 12986 throw new TypeError(FUNC_ERROR_TEXT); 12987 } 12988 return function() { 12989 var args = arguments; 12990 switch (args.length) { 12991 case 0: return !predicate.call(this); 12992 case 1: return !predicate.call(this, args[0]); 12993 case 2: return !predicate.call(this, args[0], args[1]); 12994 case 3: return !predicate.call(this, args[0], args[1], args[2]); 12995 } 12996 return !predicate.apply(this, args); 12997 }; 12998 } 12999 13000 /** 13001 * Creates a function that is restricted to invoking `func` once. Repeat calls 13002 * to the function return the value of the first invocation. The `func` is 13003 * invoked with the `this` binding and arguments of the created function. 13004 * 13005 * @static 13006 * @memberOf _ 13007 * @since 0.1.0 13008 * @category Function 13009 * @param {Function} func The function to restrict. 13010 * @returns {Function} Returns the new restricted function. 13011 * @example 13012 * 13013 * var initialize = _.once(createApplication); 13014 * initialize(); 13015 * initialize(); 13016 * // => `createApplication` is invoked once 13017 */ 13018 function once(func) { 13019 return before(2, func); 13020 } 13021 13022 /** 13023 * Creates a function that invokes `func` with its arguments transformed. 13024 * 13025 * @static 13026 * @since 4.0.0 13027 * @memberOf _ 13028 * @category Function 13029 * @param {Function} func The function to wrap. 13030 * @param {...(Function|Function[])} [transforms=[_.identity]] 13031 * The argument transforms. 13032 * @returns {Function} Returns the new function. 13033 * @example 13034 * 13035 * function doubled(n) { 13036 * return n * 2; 13037 * } 13038 * 13039 * function square(n) { 13040 * return n * n; 13041 * } 13042 * 13043 * var func = _.overArgs(function(x, y) { 13044 * return [x, y]; 13045 * }, [square, doubled]); 13046 * 13047 * func(9, 3); 13048 * // => [81, 6] 13049 * 13050 * func(10, 5); 13051 * // => [100, 10] 13052 */ 13053 var overArgs = castRest(function(func, transforms) { 13054 transforms = (transforms.length == 1 && isArray(transforms[0])) 13055 ? arrayMap(transforms[0], baseUnary(getIteratee())) 13056 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 13057 13058 var funcsLength = transforms.length; 13059 return baseRest(function(args) { 13060 var index = -1, 13061 length = nativeMin(args.length, funcsLength); 13062 13063 while (++index < length) { 13064 args[index] = transforms[index].call(this, args[index]); 13065 } 13066 return apply(func, this, args); 13067 }); 13068 }); 13069 13070 /** 13071 * Creates a function that invokes `func` with `partials` prepended to the 13072 * arguments it receives. This method is like `_.bind` except it does **not** 13073 * alter the `this` binding. 13074 * 13075 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 13076 * builds, may be used as a placeholder for partially applied arguments. 13077 * 13078 * **Note:** This method doesn't set the "length" property of partially 13079 * applied functions. 13080 * 13081 * @static 13082 * @memberOf _ 13083 * @since 0.2.0 13084 * @category Function 13085 * @param {Function} func The function to partially apply arguments to. 13086 * @param {...*} [partials] The arguments to be partially applied. 13087 * @returns {Function} Returns the new partially applied function. 13088 * @example 13089 * 13090 * function greet(greeting, name) { 13091 * return greeting + ' ' + name; 13092 * } 13093 * 13094 * var sayHelloTo = _.partial(greet, 'hello'); 13095 * sayHelloTo('fred'); 13096 * // => 'hello fred' 13097 * 13098 * // Partially applied with placeholders. 13099 * var greetFred = _.partial(greet, _, 'fred'); 13100 * greetFred('hi'); 13101 * // => 'hi fred' 13102 */ 13103 var partial = baseRest(function(func, partials) { 13104 var holders = replaceHolders(partials, getHolder(partial)); 13105 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 13106 }); 13107 13108 /** 13109 * This method is like `_.partial` except that partially applied arguments 13110 * are appended to the arguments it receives. 13111 * 13112 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 13113 * builds, may be used as a placeholder for partially applied arguments. 13114 * 13115 * **Note:** This method doesn't set the "length" property of partially 13116 * applied functions. 13117 * 13118 * @static 13119 * @memberOf _ 13120 * @since 1.0.0 13121 * @category Function 13122 * @param {Function} func The function to partially apply arguments to. 13123 * @param {...*} [partials] The arguments to be partially applied. 13124 * @returns {Function} Returns the new partially applied function. 13125 * @example 13126 * 13127 * function greet(greeting, name) { 13128 * return greeting + ' ' + name; 13129 * } 13130 * 13131 * var greetFred = _.partialRight(greet, 'fred'); 13132 * greetFred('hi'); 13133 * // => 'hi fred' 13134 * 13135 * // Partially applied with placeholders. 13136 * var sayHelloTo = _.partialRight(greet, 'hello', _); 13137 * sayHelloTo('fred'); 13138 * // => 'hello fred' 13139 */ 13140 var partialRight = baseRest(function(func, partials) { 13141 var holders = replaceHolders(partials, getHolder(partialRight)); 13142 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 13143 }); 13144 13145 /** 13146 * Creates a function that invokes `func` with arguments arranged according 13147 * to the specified `indexes` where the argument value at the first index is 13148 * provided as the first argument, the argument value at the second index is 13149 * provided as the second argument, and so on. 13150 * 13151 * @static 13152 * @memberOf _ 13153 * @since 3.0.0 13154 * @category Function 13155 * @param {Function} func The function to rearrange arguments for. 13156 * @param {...(number|number[])} indexes The arranged argument indexes. 13157 * @returns {Function} Returns the new function. 13158 * @example 13159 * 13160 * var rearged = _.rearg(function(a, b, c) { 13161 * return [a, b, c]; 13162 * }, [2, 0, 1]); 13163 * 13164 * rearged('b', 'c', 'a') 13165 * // => ['a', 'b', 'c'] 13166 */ 13167 var rearg = flatRest(function(func, indexes) { 13168 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 13169 }); 13170 13171 /** 13172 * Creates a function that invokes `func` with the `this` binding of the 13173 * created function and arguments from `start` and beyond provided as 13174 * an array. 13175 * 13176 * **Note:** This method is based on the 13177 * [rest parameter](https://mdn.io/rest_parameters). 13178 * 13179 * @static 13180 * @memberOf _ 13181 * @since 4.0.0 13182 * @category Function 13183 * @param {Function} func The function to apply a rest parameter to. 13184 * @param {number} [start=func.length-1] The start position of the rest parameter. 13185 * @returns {Function} Returns the new function. 13186 * @example 13187 * 13188 * var say = _.rest(function(what, names) { 13189 * return what + ' ' + _.initial(names).join(', ') + 13190 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 13191 * }); 13192 * 13193 * say('hello', 'fred', 'barney', 'pebbles'); 13194 * // => 'hello fred, barney, & pebbles' 13195 */ 13196 function rest(func, start) { 13197 if (typeof func != 'function') { 13198 throw new TypeError(FUNC_ERROR_TEXT); 13199 } 13200 start = start === undefined ? start : toInteger(start); 13201 return baseRest(func, start); 13202 } 13203 13204 /** 13205 * Creates a function that invokes `func` with the `this` binding of the 13206 * create function and an array of arguments much like 13207 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 13208 * 13209 * **Note:** This method is based on the 13210 * [spread operator](https://mdn.io/spread_operator). 13211 * 13212 * @static 13213 * @memberOf _ 13214 * @since 3.2.0 13215 * @category Function 13216 * @param {Function} func The function to spread arguments over. 13217 * @param {number} [start=0] The start position of the spread. 13218 * @returns {Function} Returns the new function. 13219 * @example 13220 * 13221 * var say = _.spread(function(who, what) { 13222 * return who + ' says ' + what; 13223 * }); 13224 * 13225 * say(['fred', 'hello']); 13226 * // => 'fred says hello' 13227 * 13228 * var numbers = Promise.all([ 13229 * Promise.resolve(40), 13230 * Promise.resolve(36) 13231 * ]); 13232 * 13233 * numbers.then(_.spread(function(x, y) { 13234 * return x + y; 13235 * })); 13236 * // => a Promise of 76 13237 */ 13238 function spread(func, start) { 13239 if (typeof func != 'function') { 13240 throw new TypeError(FUNC_ERROR_TEXT); 13241 } 13242 start = start == null ? 0 : nativeMax(toInteger(start), 0); 13243 return baseRest(function(args) { 13244 var array = args[start], 13245 otherArgs = castSlice(args, 0, start); 13246 13247 if (array) { 13248 arrayPush(otherArgs, array); 13249 } 13250 return apply(func, this, otherArgs); 13251 }); 13252 } 13253 13254 /** 13255 * Creates a throttled function that only invokes `func` at most once per 13256 * every `wait` milliseconds. The throttled function comes with a `cancel` 13257 * method to cancel delayed `func` invocations and a `flush` method to 13258 * immediately invoke them. Provide `options` to indicate whether `func` 13259 * should be invoked on the leading and/or trailing edge of the `wait` 13260 * timeout. The `func` is invoked with the last arguments provided to the 13261 * throttled function. Subsequent calls to the throttled function return the 13262 * result of the last `func` invocation. 13263 * 13264 * **Note:** If `leading` and `trailing` options are `true`, `func` is 13265 * invoked on the trailing edge of the timeout only if the throttled function 13266 * is invoked more than once during the `wait` timeout. 13267 * 13268 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 13269 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 13270 * 13271 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 13272 * for details over the differences between `_.throttle` and `_.debounce`. 13273 * 13274 * @static 13275 * @memberOf _ 13276 * @since 0.1.0 13277 * @category Function 13278 * @param {Function} func The function to throttle. 13279 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 13280 * @param {Object} [options={}] The options object. 13281 * @param {boolean} [options.leading=true] 13282 * Specify invoking on the leading edge of the timeout. 13283 * @param {boolean} [options.trailing=true] 13284 * Specify invoking on the trailing edge of the timeout. 13285 * @returns {Function} Returns the new throttled function. 13286 * @example 13287 * 13288 * // Avoid excessively updating the position while scrolling. 13289 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 13290 * 13291 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 13292 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 13293 * jQuery(element).on('click', throttled); 13294 * 13295 * // Cancel the trailing throttled invocation. 13296 * jQuery(window).on('popstate', throttled.cancel); 13297 */ 13298 function throttle(func, wait, options) { 13299 var leading = true, 13300 trailing = true; 13301 13302 if (typeof func != 'function') { 13303 throw new TypeError(FUNC_ERROR_TEXT); 13304 } 13305 if (isObject(options)) { 13306 leading = 'leading' in options ? !!options.leading : leading; 13307 trailing = 'trailing' in options ? !!options.trailing : trailing; 13308 } 13309 return debounce(func, wait, { 13310 'leading': leading, 13311 'maxWait': wait, 13312 'trailing': trailing 13313 }); 13314 } 13315 13316 /** 13317 * Creates a function that accepts up to one argument, ignoring any 13318 * additional arguments. 13319 * 13320 * @static 13321 * @memberOf _ 13322 * @since 4.0.0 13323 * @category Function 13324 * @param {Function} func The function to cap arguments for. 13325 * @returns {Function} Returns the new capped function. 13326 * @example 13327 * 13328 * _.map(['6', '8', '10'], _.unary(parseInt)); 13329 * // => [6, 8, 10] 13330 */ 13331 function unary(func) { 13332 return ary(func, 1); 13333 } 13334 13335 /** 13336 * Creates a function that provides `value` to `wrapper` as its first 13337 * argument. Any additional arguments provided to the function are appended 13338 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 13339 * binding of the created function. 13340 * 13341 * @static 13342 * @memberOf _ 13343 * @since 0.1.0 13344 * @category Function 13345 * @param {*} value The value to wrap. 13346 * @param {Function} [wrapper=identity] The wrapper function. 13347 * @returns {Function} Returns the new function. 13348 * @example 13349 * 13350 * var p = _.wrap(_.escape, function(func, text) { 13351 * return '<p>' + func(text) + '</p>'; 13352 * }); 13353 * 13354 * p('fred, barney, & pebbles'); 13355 * // => '<p>fred, barney, & pebbles</p>' 13356 */ 13357 function wrap(value, wrapper) { 13358 return partial(castFunction(wrapper), value); 13359 } 13360 13361 /*------------------------------------------------------------------------*/ 13362 13363 /** 13364 * Casts `value` as an array if it's not one. 13365 * 13366 * @static 13367 * @memberOf _ 13368 * @since 4.4.0 13369 * @category Lang 13370 * @param {*} value The value to inspect. 13371 * @returns {Array} Returns the cast array. 13372 * @example 13373 * 13374 * _.castArray(1); 13375 * // => [1] 13376 * 13377 * _.castArray({ 'a': 1 }); 13378 * // => [{ 'a': 1 }] 13379 * 13380 * _.castArray('abc'); 13381 * // => ['abc'] 13382 * 13383 * _.castArray(null); 13384 * // => [null] 13385 * 13386 * _.castArray(undefined); 13387 * // => [undefined] 13388 * 13389 * _.castArray(); 13390 * // => [] 13391 * 13392 * var array = [1, 2, 3]; 13393 * console.log(_.castArray(array) === array); 13394 * // => true 13395 */ 13396 function castArray() { 13397 if (!arguments.length) { 13398 return []; 13399 } 13400 var value = arguments[0]; 13401 return isArray(value) ? value : [value]; 13402 } 13403 13404 /** 13405 * Creates a shallow clone of `value`. 13406 * 13407 * **Note:** This method is loosely based on the 13408 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 13409 * and supports cloning arrays, array buffers, booleans, date objects, maps, 13410 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 13411 * arrays. The own enumerable properties of `arguments` objects are cloned 13412 * as plain objects. An empty object is returned for uncloneable values such 13413 * as error objects, functions, DOM nodes, and WeakMaps. 13414 * 13415 * @static 13416 * @memberOf _ 13417 * @since 0.1.0 13418 * @category Lang 13419 * @param {*} value The value to clone. 13420 * @returns {*} Returns the cloned value. 13421 * @see _.cloneDeep 13422 * @example 13423 * 13424 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 13425 * 13426 * var shallow = _.clone(objects); 13427 * console.log(shallow[0] === objects[0]); 13428 * // => true 13429 */ 13430 function clone(value) { 13431 return baseClone(value, CLONE_SYMBOLS_FLAG); 13432 } 13433 13434 /** 13435 * This method is like `_.clone` except that it accepts `customizer` which 13436 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 13437 * cloning is handled by the method instead. The `customizer` is invoked with 13438 * up to four arguments; (value [, index|key, object, stack]). 13439 * 13440 * @static 13441 * @memberOf _ 13442 * @since 4.0.0 13443 * @category Lang 13444 * @param {*} value The value to clone. 13445 * @param {Function} [customizer] The function to customize cloning. 13446 * @returns {*} Returns the cloned value. 13447 * @see _.cloneDeepWith 13448 * @example 13449 * 13450 * function customizer(value) { 13451 * if (_.isElement(value)) { 13452 * return value.cloneNode(false); 13453 * } 13454 * } 13455 * 13456 * var el = _.cloneWith(document.body, customizer); 13457 * 13458 * console.log(el === document.body); 13459 * // => false 13460 * console.log(el.nodeName); 13461 * // => 'BODY' 13462 * console.log(el.childNodes.length); 13463 * // => 0 13464 */ 13465 function cloneWith(value, customizer) { 13466 customizer = typeof customizer == 'function' ? customizer : undefined; 13467 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 13468 } 13469 13470 /** 13471 * This method is like `_.clone` except that it recursively clones `value`. 13472 * 13473 * @static 13474 * @memberOf _ 13475 * @since 1.0.0 13476 * @category Lang 13477 * @param {*} value The value to recursively clone. 13478 * @returns {*} Returns the deep cloned value. 13479 * @see _.clone 13480 * @example 13481 * 13482 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 13483 * 13484 * var deep = _.cloneDeep(objects); 13485 * console.log(deep[0] === objects[0]); 13486 * // => false 13487 */ 13488 function cloneDeep(value) { 13489 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 13490 } 13491 13492 /** 13493 * This method is like `_.cloneWith` except that it recursively clones `value`. 13494 * 13495 * @static 13496 * @memberOf _ 13497 * @since 4.0.0 13498 * @category Lang 13499 * @param {*} value The value to recursively clone. 13500 * @param {Function} [customizer] The function to customize cloning. 13501 * @returns {*} Returns the deep cloned value. 13502 * @see _.cloneWith 13503 * @example 13504 * 13505 * function customizer(value) { 13506 * if (_.isElement(value)) { 13507 * return value.cloneNode(true); 13508 * } 13509 * } 13510 * 13511 * var el = _.cloneDeepWith(document.body, customizer); 13512 * 13513 * console.log(el === document.body); 13514 * // => false 13515 * console.log(el.nodeName); 13516 * // => 'BODY' 13517 * console.log(el.childNodes.length); 13518 * // => 20 13519 */ 13520 function cloneDeepWith(value, customizer) { 13521 customizer = typeof customizer == 'function' ? customizer : undefined; 13522 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 13523 } 13524 13525 /** 13526 * Checks if `object` conforms to `source` by invoking the predicate 13527 * properties of `source` with the corresponding property values of `object`. 13528 * 13529 * **Note:** This method is equivalent to `_.conforms` when `source` is 13530 * partially applied. 13531 * 13532 * @static 13533 * @memberOf _ 13534 * @since 4.14.0 13535 * @category Lang 13536 * @param {Object} object The object to inspect. 13537 * @param {Object} source The object of property predicates to conform to. 13538 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 13539 * @example 13540 * 13541 * var object = { 'a': 1, 'b': 2 }; 13542 * 13543 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 13544 * // => true 13545 * 13546 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 13547 * // => false 13548 */ 13549 function conformsTo(object, source) { 13550 return source == null || baseConformsTo(object, source, keys(source)); 13551 } 13552 13553 /** 13554 * Performs a 13555 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13556 * comparison between two values to determine if they are equivalent. 13557 * 13558 * @static 13559 * @memberOf _ 13560 * @since 4.0.0 13561 * @category Lang 13562 * @param {*} value The value to compare. 13563 * @param {*} other The other value to compare. 13564 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13565 * @example 13566 * 13567 * var object = { 'a': 1 }; 13568 * var other = { 'a': 1 }; 13569 * 13570 * _.eq(object, object); 13571 * // => true 13572 * 13573 * _.eq(object, other); 13574 * // => false 13575 * 13576 * _.eq('a', 'a'); 13577 * // => true 13578 * 13579 * _.eq('a', Object('a')); 13580 * // => false 13581 * 13582 * _.eq(NaN, NaN); 13583 * // => true 13584 */ 13585 function eq(value, other) { 13586 return value === other || (value !== value && other !== other); 13587 } 13588 13589 /** 13590 * Checks if `value` is greater than `other`. 13591 * 13592 * @static 13593 * @memberOf _ 13594 * @since 3.9.0 13595 * @category Lang 13596 * @param {*} value The value to compare. 13597 * @param {*} other The other value to compare. 13598 * @returns {boolean} Returns `true` if `value` is greater than `other`, 13599 * else `false`. 13600 * @see _.lt 13601 * @example 13602 * 13603 * _.gt(3, 1); 13604 * // => true 13605 * 13606 * _.gt(3, 3); 13607 * // => false 13608 * 13609 * _.gt(1, 3); 13610 * // => false 13611 */ 13612 var gt = createRelationalOperation(baseGt); 13613 13614 /** 13615 * Checks if `value` is greater than or equal to `other`. 13616 * 13617 * @static 13618 * @memberOf _ 13619 * @since 3.9.0 13620 * @category Lang 13621 * @param {*} value The value to compare. 13622 * @param {*} other The other value to compare. 13623 * @returns {boolean} Returns `true` if `value` is greater than or equal to 13624 * `other`, else `false`. 13625 * @see _.lte 13626 * @example 13627 * 13628 * _.gte(3, 1); 13629 * // => true 13630 * 13631 * _.gte(3, 3); 13632 * // => true 13633 * 13634 * _.gte(1, 3); 13635 * // => false 13636 */ 13637 var gte = createRelationalOperation(function(value, other) { 13638 return value >= other; 13639 }); 13640 13641 /** 13642 * Checks if `value` is likely an `arguments` object. 13643 * 13644 * @static 13645 * @memberOf _ 13646 * @since 0.1.0 13647 * @category Lang 13648 * @param {*} value The value to check. 13649 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 13650 * else `false`. 13651 * @example 13652 * 13653 * _.isArguments(function() { return arguments; }()); 13654 * // => true 13655 * 13656 * _.isArguments([1, 2, 3]); 13657 * // => false 13658 */ 13659 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 13660 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 13661 !propertyIsEnumerable.call(value, 'callee'); 13662 }; 13663 13664 /** 13665 * Checks if `value` is classified as an `Array` object. 13666 * 13667 * @static 13668 * @memberOf _ 13669 * @since 0.1.0 13670 * @category Lang 13671 * @param {*} value The value to check. 13672 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 13673 * @example 13674 * 13675 * _.isArray([1, 2, 3]); 13676 * // => true 13677 * 13678 * _.isArray(document.body.children); 13679 * // => false 13680 * 13681 * _.isArray('abc'); 13682 * // => false 13683 * 13684 * _.isArray(_.noop); 13685 * // => false 13686 */ 13687 var isArray = Array.isArray; 13688 13689 /** 13690 * Checks if `value` is classified as an `ArrayBuffer` object. 13691 * 13692 * @static 13693 * @memberOf _ 13694 * @since 4.3.0 13695 * @category Lang 13696 * @param {*} value The value to check. 13697 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 13698 * @example 13699 * 13700 * _.isArrayBuffer(new ArrayBuffer(2)); 13701 * // => true 13702 * 13703 * _.isArrayBuffer(new Array(2)); 13704 * // => false 13705 */ 13706 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 13707 13708 /** 13709 * Checks if `value` is array-like. A value is considered array-like if it's 13710 * not a function and has a `value.length` that's an integer greater than or 13711 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 13712 * 13713 * @static 13714 * @memberOf _ 13715 * @since 4.0.0 13716 * @category Lang 13717 * @param {*} value The value to check. 13718 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 13719 * @example 13720 * 13721 * _.isArrayLike([1, 2, 3]); 13722 * // => true 13723 * 13724 * _.isArrayLike(document.body.children); 13725 * // => true 13726 * 13727 * _.isArrayLike('abc'); 13728 * // => true 13729 * 13730 * _.isArrayLike(_.noop); 13731 * // => false 13732 */ 13733 function isArrayLike(value) { 13734 return value != null && isLength(value.length) && !isFunction(value); 13735 } 13736 13737 /** 13738 * This method is like `_.isArrayLike` except that it also checks if `value` 13739 * is an object. 13740 * 13741 * @static 13742 * @memberOf _ 13743 * @since 4.0.0 13744 * @category Lang 13745 * @param {*} value The value to check. 13746 * @returns {boolean} Returns `true` if `value` is an array-like object, 13747 * else `false`. 13748 * @example 13749 * 13750 * _.isArrayLikeObject([1, 2, 3]); 13751 * // => true 13752 * 13753 * _.isArrayLikeObject(document.body.children); 13754 * // => true 13755 * 13756 * _.isArrayLikeObject('abc'); 13757 * // => false 13758 * 13759 * _.isArrayLikeObject(_.noop); 13760 * // => false 13761 */ 13762 function isArrayLikeObject(value) { 13763 return isObjectLike(value) && isArrayLike(value); 13764 } 13765 13766 /** 13767 * Checks if `value` is classified as a boolean primitive or object. 13768 * 13769 * @static 13770 * @memberOf _ 13771 * @since 0.1.0 13772 * @category Lang 13773 * @param {*} value The value to check. 13774 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 13775 * @example 13776 * 13777 * _.isBoolean(false); 13778 * // => true 13779 * 13780 * _.isBoolean(null); 13781 * // => false 13782 */ 13783 function isBoolean(value) { 13784 return value === true || value === false || 13785 (isObjectLike(value) && baseGetTag(value) == boolTag); 13786 } 13787 13788 /** 13789 * Checks if `value` is a buffer. 13790 * 13791 * @static 13792 * @memberOf _ 13793 * @since 4.3.0 13794 * @category Lang 13795 * @param {*} value The value to check. 13796 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 13797 * @example 13798 * 13799 * _.isBuffer(new Buffer(2)); 13800 * // => true 13801 * 13802 * _.isBuffer(new Uint8Array(2)); 13803 * // => false 13804 */ 13805 var isBuffer = nativeIsBuffer || stubFalse; 13806 13807 /** 13808 * Checks if `value` is classified as a `Date` object. 13809 * 13810 * @static 13811 * @memberOf _ 13812 * @since 0.1.0 13813 * @category Lang 13814 * @param {*} value The value to check. 13815 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 13816 * @example 13817 * 13818 * _.isDate(new Date); 13819 * // => true 13820 * 13821 * _.isDate('Mon April 23 2012'); 13822 * // => false 13823 */ 13824 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 13825 13826 /** 13827 * Checks if `value` is likely a DOM element. 13828 * 13829 * @static 13830 * @memberOf _ 13831 * @since 0.1.0 13832 * @category Lang 13833 * @param {*} value The value to check. 13834 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 13835 * @example 13836 * 13837 * _.isElement(document.body); 13838 * // => true 13839 * 13840 * _.isElement('<body>'); 13841 * // => false 13842 */ 13843 function isElement(value) { 13844 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 13845 } 13846 13847 /** 13848 * Checks if `value` is an empty object, collection, map, or set. 13849 * 13850 * Objects are considered empty if they have no own enumerable string keyed 13851 * properties. 13852 * 13853 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 13854 * jQuery-like collections are considered empty if they have a `length` of `0`. 13855 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 13856 * 13857 * @static 13858 * @memberOf _ 13859 * @since 0.1.0 13860 * @category Lang 13861 * @param {*} value The value to check. 13862 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 13863 * @example 13864 * 13865 * _.isEmpty(null); 13866 * // => true 13867 * 13868 * _.isEmpty(true); 13869 * // => true 13870 * 13871 * _.isEmpty(1); 13872 * // => true 13873 * 13874 * _.isEmpty([1, 2, 3]); 13875 * // => false 13876 * 13877 * _.isEmpty({ 'a': 1 }); 13878 * // => false 13879 */ 13880 function isEmpty(value) { 13881 if (value == null) { 13882 return true; 13883 } 13884 if (isArrayLike(value) && 13885 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 13886 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 13887 return !value.length; 13888 } 13889 var tag = getTag(value); 13890 if (tag == mapTag || tag == setTag) { 13891 return !value.size; 13892 } 13893 if (isPrototype(value)) { 13894 return !baseKeys(value).length; 13895 } 13896 for (var key in value) { 13897 if (hasOwnProperty.call(value, key)) { 13898 return false; 13899 } 13900 } 13901 return true; 13902 } 13903 13904 /** 13905 * Performs a deep comparison between two values to determine if they are 13906 * equivalent. 13907 * 13908 * **Note:** This method supports comparing arrays, array buffers, booleans, 13909 * date objects, error objects, maps, numbers, `Object` objects, regexes, 13910 * sets, strings, symbols, and typed arrays. `Object` objects are compared 13911 * by their own, not inherited, enumerable properties. Functions and DOM 13912 * nodes are compared by strict equality, i.e. `===`. 13913 * 13914 * @static 13915 * @memberOf _ 13916 * @since 0.1.0 13917 * @category Lang 13918 * @param {*} value The value to compare. 13919 * @param {*} other The other value to compare. 13920 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13921 * @example 13922 * 13923 * var object = { 'a': 1 }; 13924 * var other = { 'a': 1 }; 13925 * 13926 * _.isEqual(object, other); 13927 * // => true 13928 * 13929 * object === other; 13930 * // => false 13931 */ 13932 function isEqual(value, other) { 13933 return baseIsEqual(value, other); 13934 } 13935 13936 /** 13937 * This method is like `_.isEqual` except that it accepts `customizer` which 13938 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 13939 * are handled by the method instead. The `customizer` is invoked with up to 13940 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 13941 * 13942 * @static 13943 * @memberOf _ 13944 * @since 4.0.0 13945 * @category Lang 13946 * @param {*} value The value to compare. 13947 * @param {*} other The other value to compare. 13948 * @param {Function} [customizer] The function to customize comparisons. 13949 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13950 * @example 13951 * 13952 * function isGreeting(value) { 13953 * return /^h(?:i|ello)$/.test(value); 13954 * } 13955 * 13956 * function customizer(objValue, othValue) { 13957 * if (isGreeting(objValue) && isGreeting(othValue)) { 13958 * return true; 13959 * } 13960 * } 13961 * 13962 * var array = ['hello', 'goodbye']; 13963 * var other = ['hi', 'goodbye']; 13964 * 13965 * _.isEqualWith(array, other, customizer); 13966 * // => true 13967 */ 13968 function isEqualWith(value, other, customizer) { 13969 customizer = typeof customizer == 'function' ? customizer : undefined; 13970 var result = customizer ? customizer(value, other) : undefined; 13971 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 13972 } 13973 13974 /** 13975 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 13976 * `SyntaxError`, `TypeError`, or `URIError` object. 13977 * 13978 * @static 13979 * @memberOf _ 13980 * @since 3.0.0 13981 * @category Lang 13982 * @param {*} value The value to check. 13983 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 13984 * @example 13985 * 13986 * _.isError(new Error); 13987 * // => true 13988 * 13989 * _.isError(Error); 13990 * // => false 13991 */ 13992 function isError(value) { 13993 if (!isObjectLike(value)) { 13994 return false; 13995 } 13996 var tag = baseGetTag(value); 13997 return tag == errorTag || tag == domExcTag || 13998 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 13999 } 14000 14001 /** 14002 * Checks if `value` is a finite primitive number. 14003 * 14004 * **Note:** This method is based on 14005 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 14006 * 14007 * @static 14008 * @memberOf _ 14009 * @since 0.1.0 14010 * @category Lang 14011 * @param {*} value The value to check. 14012 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 14013 * @example 14014 * 14015 * _.isFinite(3); 14016 * // => true 14017 * 14018 * _.isFinite(Number.MIN_VALUE); 14019 * // => true 14020 * 14021 * _.isFinite(Infinity); 14022 * // => false 14023 * 14024 * _.isFinite('3'); 14025 * // => false 14026 */ 14027 function isFinite(value) { 14028 return typeof value == 'number' && nativeIsFinite(value); 14029 } 14030 14031 /** 14032 * Checks if `value` is classified as a `Function` object. 14033 * 14034 * @static 14035 * @memberOf _ 14036 * @since 0.1.0 14037 * @category Lang 14038 * @param {*} value The value to check. 14039 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 14040 * @example 14041 * 14042 * _.isFunction(_); 14043 * // => true 14044 * 14045 * _.isFunction(/abc/); 14046 * // => false 14047 */ 14048 function isFunction(value) { 14049 if (!isObject(value)) { 14050 return false; 14051 } 14052 // The use of `Object#toString` avoids issues with the `typeof` operator 14053 // in Safari 9 which returns 'object' for typed arrays and other constructors. 14054 var tag = baseGetTag(value); 14055 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 14056 } 14057 14058 /** 14059 * Checks if `value` is an integer. 14060 * 14061 * **Note:** This method is based on 14062 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 14063 * 14064 * @static 14065 * @memberOf _ 14066 * @since 4.0.0 14067 * @category Lang 14068 * @param {*} value The value to check. 14069 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 14070 * @example 14071 * 14072 * _.isInteger(3); 14073 * // => true 14074 * 14075 * _.isInteger(Number.MIN_VALUE); 14076 * // => false 14077 * 14078 * _.isInteger(Infinity); 14079 * // => false 14080 * 14081 * _.isInteger('3'); 14082 * // => false 14083 */ 14084 function isInteger(value) { 14085 return typeof value == 'number' && value == toInteger(value); 14086 } 14087 14088 /** 14089 * Checks if `value` is a valid array-like length. 14090 * 14091 * **Note:** This method is loosely based on 14092 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 14093 * 14094 * @static 14095 * @memberOf _ 14096 * @since 4.0.0 14097 * @category Lang 14098 * @param {*} value The value to check. 14099 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 14100 * @example 14101 * 14102 * _.isLength(3); 14103 * // => true 14104 * 14105 * _.isLength(Number.MIN_VALUE); 14106 * // => false 14107 * 14108 * _.isLength(Infinity); 14109 * // => false 14110 * 14111 * _.isLength('3'); 14112 * // => false 14113 */ 14114 function isLength(value) { 14115 return typeof value == 'number' && 14116 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 14117 } 14118 14119 /** 14120 * Checks if `value` is the 14121 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 14122 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 14123 * 14124 * @static 14125 * @memberOf _ 14126 * @since 0.1.0 14127 * @category Lang 14128 * @param {*} value The value to check. 14129 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 14130 * @example 14131 * 14132 * _.isObject({}); 14133 * // => true 14134 * 14135 * _.isObject([1, 2, 3]); 14136 * // => true 14137 * 14138 * _.isObject(_.noop); 14139 * // => true 14140 * 14141 * _.isObject(null); 14142 * // => false 14143 */ 14144 function isObject(value) { 14145 var type = typeof value; 14146 return value != null && (type == 'object' || type == 'function'); 14147 } 14148 14149 /** 14150 * Checks if `value` is object-like. A value is object-like if it's not `null` 14151 * and has a `typeof` result of "object". 14152 * 14153 * @static 14154 * @memberOf _ 14155 * @since 4.0.0 14156 * @category Lang 14157 * @param {*} value The value to check. 14158 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 14159 * @example 14160 * 14161 * _.isObjectLike({}); 14162 * // => true 14163 * 14164 * _.isObjectLike([1, 2, 3]); 14165 * // => true 14166 * 14167 * _.isObjectLike(_.noop); 14168 * // => false 14169 * 14170 * _.isObjectLike(null); 14171 * // => false 14172 */ 14173 function isObjectLike(value) { 14174 return value != null && typeof value == 'object'; 14175 } 14176 14177 /** 14178 * Checks if `value` is classified as a `Map` object. 14179 * 14180 * @static 14181 * @memberOf _ 14182 * @since 4.3.0 14183 * @category Lang 14184 * @param {*} value The value to check. 14185 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 14186 * @example 14187 * 14188 * _.isMap(new Map); 14189 * // => true 14190 * 14191 * _.isMap(new WeakMap); 14192 * // => false 14193 */ 14194 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 14195 14196 /** 14197 * Performs a partial deep comparison between `object` and `source` to 14198 * determine if `object` contains equivalent property values. 14199 * 14200 * **Note:** This method is equivalent to `_.matches` when `source` is 14201 * partially applied. 14202 * 14203 * Partial comparisons will match empty array and empty object `source` 14204 * values against any array or object value, respectively. See `_.isEqual` 14205 * for a list of supported value comparisons. 14206 * 14207 * @static 14208 * @memberOf _ 14209 * @since 3.0.0 14210 * @category Lang 14211 * @param {Object} object The object to inspect. 14212 * @param {Object} source The object of property values to match. 14213 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 14214 * @example 14215 * 14216 * var object = { 'a': 1, 'b': 2 }; 14217 * 14218 * _.isMatch(object, { 'b': 2 }); 14219 * // => true 14220 * 14221 * _.isMatch(object, { 'b': 1 }); 14222 * // => false 14223 */ 14224 function isMatch(object, source) { 14225 return object === source || baseIsMatch(object, source, getMatchData(source)); 14226 } 14227 14228 /** 14229 * This method is like `_.isMatch` except that it accepts `customizer` which 14230 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 14231 * are handled by the method instead. The `customizer` is invoked with five 14232 * arguments: (objValue, srcValue, index|key, object, source). 14233 * 14234 * @static 14235 * @memberOf _ 14236 * @since 4.0.0 14237 * @category Lang 14238 * @param {Object} object The object to inspect. 14239 * @param {Object} source The object of property values to match. 14240 * @param {Function} [customizer] The function to customize comparisons. 14241 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 14242 * @example 14243 * 14244 * function isGreeting(value) { 14245 * return /^h(?:i|ello)$/.test(value); 14246 * } 14247 * 14248 * function customizer(objValue, srcValue) { 14249 * if (isGreeting(objValue) && isGreeting(srcValue)) { 14250 * return true; 14251 * } 14252 * } 14253 * 14254 * var object = { 'greeting': 'hello' }; 14255 * var source = { 'greeting': 'hi' }; 14256 * 14257 * _.isMatchWith(object, source, customizer); 14258 * // => true 14259 */ 14260 function isMatchWith(object, source, customizer) { 14261 customizer = typeof customizer == 'function' ? customizer : undefined; 14262 return baseIsMatch(object, source, getMatchData(source), customizer); 14263 } 14264 14265 /** 14266 * Checks if `value` is `NaN`. 14267 * 14268 * **Note:** This method is based on 14269 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 14270 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 14271 * `undefined` and other non-number values. 14272 * 14273 * @static 14274 * @memberOf _ 14275 * @since 0.1.0 14276 * @category Lang 14277 * @param {*} value The value to check. 14278 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 14279 * @example 14280 * 14281 * _.isNaN(NaN); 14282 * // => true 14283 * 14284 * _.isNaN(new Number(NaN)); 14285 * // => true 14286 * 14287 * isNaN(undefined); 14288 * // => true 14289 * 14290 * _.isNaN(undefined); 14291 * // => false 14292 */ 14293 function isNaN(value) { 14294 // An `NaN` primitive is the only value that is not equal to itself. 14295 // Perform the `toStringTag` check first to avoid errors with some 14296 // ActiveX objects in IE. 14297 return isNumber(value) && value != +value; 14298 } 14299 14300 /** 14301 * Checks if `value` is a pristine native function. 14302 * 14303 * **Note:** This method can't reliably detect native functions in the presence 14304 * of the core-js package because core-js circumvents this kind of detection. 14305 * Despite multiple requests, the core-js maintainer has made it clear: any 14306 * attempt to fix the detection will be obstructed. As a result, we're left 14307 * with little choice but to throw an error. Unfortunately, this also affects 14308 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 14309 * which rely on core-js. 14310 * 14311 * @static 14312 * @memberOf _ 14313 * @since 3.0.0 14314 * @category Lang 14315 * @param {*} value The value to check. 14316 * @returns {boolean} Returns `true` if `value` is a native function, 14317 * else `false`. 14318 * @example 14319 * 14320 * _.isNative(Array.prototype.push); 14321 * // => true 14322 * 14323 * _.isNative(_); 14324 * // => false 14325 */ 14326 function isNative(value) { 14327 if (isMaskable(value)) { 14328 throw new Error(CORE_ERROR_TEXT); 14329 } 14330 return baseIsNative(value); 14331 } 14332 14333 /** 14334 * Checks if `value` is `null`. 14335 * 14336 * @static 14337 * @memberOf _ 14338 * @since 0.1.0 14339 * @category Lang 14340 * @param {*} value The value to check. 14341 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 14342 * @example 14343 * 14344 * _.isNull(null); 14345 * // => true 14346 * 14347 * _.isNull(void 0); 14348 * // => false 14349 */ 14350 function isNull(value) { 14351 return value === null; 14352 } 14353 14354 /** 14355 * Checks if `value` is `null` or `undefined`. 14356 * 14357 * @static 14358 * @memberOf _ 14359 * @since 4.0.0 14360 * @category Lang 14361 * @param {*} value The value to check. 14362 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 14363 * @example 14364 * 14365 * _.isNil(null); 14366 * // => true 14367 * 14368 * _.isNil(void 0); 14369 * // => true 14370 * 14371 * _.isNil(NaN); 14372 * // => false 14373 */ 14374 function isNil(value) { 14375 return value == null; 14376 } 14377 14378 /** 14379 * Checks if `value` is classified as a `Number` primitive or object. 14380 * 14381 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 14382 * classified as numbers, use the `_.isFinite` method. 14383 * 14384 * @static 14385 * @memberOf _ 14386 * @since 0.1.0 14387 * @category Lang 14388 * @param {*} value The value to check. 14389 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 14390 * @example 14391 * 14392 * _.isNumber(3); 14393 * // => true 14394 * 14395 * _.isNumber(Number.MIN_VALUE); 14396 * // => true 14397 * 14398 * _.isNumber(Infinity); 14399 * // => true 14400 * 14401 * _.isNumber('3'); 14402 * // => false 14403 */ 14404 function isNumber(value) { 14405 return typeof value == 'number' || 14406 (isObjectLike(value) && baseGetTag(value) == numberTag); 14407 } 14408 14409 /** 14410 * Checks if `value` is a plain object, that is, an object created by the 14411 * `Object` constructor or one with a `[[Prototype]]` of `null`. 14412 * 14413 * @static 14414 * @memberOf _ 14415 * @since 0.8.0 14416 * @category Lang 14417 * @param {*} value The value to check. 14418 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 14419 * @example 14420 * 14421 * function Foo() { 14422 * this.a = 1; 14423 * } 14424 * 14425 * _.isPlainObject(new Foo); 14426 * // => false 14427 * 14428 * _.isPlainObject([1, 2, 3]); 14429 * // => false 14430 * 14431 * _.isPlainObject({ 'x': 0, 'y': 0 }); 14432 * // => true 14433 * 14434 * _.isPlainObject(Object.create(null)); 14435 * // => true 14436 */ 14437 function isPlainObject(value) { 14438 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 14439 return false; 14440 } 14441 var proto = getPrototype(value); 14442 if (proto === null) { 14443 return true; 14444 } 14445 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 14446 return typeof Ctor == 'function' && Ctor instanceof Ctor && 14447 funcToString.call(Ctor) == objectCtorString; 14448 } 14449 14450 /** 14451 * Checks if `value` is classified as a `RegExp` object. 14452 * 14453 * @static 14454 * @memberOf _ 14455 * @since 0.1.0 14456 * @category Lang 14457 * @param {*} value The value to check. 14458 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 14459 * @example 14460 * 14461 * _.isRegExp(/abc/); 14462 * // => true 14463 * 14464 * _.isRegExp('/abc/'); 14465 * // => false 14466 */ 14467 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 14468 14469 /** 14470 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 14471 * double precision number which isn't the result of a rounded unsafe integer. 14472 * 14473 * **Note:** This method is based on 14474 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 14475 * 14476 * @static 14477 * @memberOf _ 14478 * @since 4.0.0 14479 * @category Lang 14480 * @param {*} value The value to check. 14481 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 14482 * @example 14483 * 14484 * _.isSafeInteger(3); 14485 * // => true 14486 * 14487 * _.isSafeInteger(Number.MIN_VALUE); 14488 * // => false 14489 * 14490 * _.isSafeInteger(Infinity); 14491 * // => false 14492 * 14493 * _.isSafeInteger('3'); 14494 * // => false 14495 */ 14496 function isSafeInteger(value) { 14497 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 14498 } 14499 14500 /** 14501 * Checks if `value` is classified as a `Set` object. 14502 * 14503 * @static 14504 * @memberOf _ 14505 * @since 4.3.0 14506 * @category Lang 14507 * @param {*} value The value to check. 14508 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 14509 * @example 14510 * 14511 * _.isSet(new Set); 14512 * // => true 14513 * 14514 * _.isSet(new WeakSet); 14515 * // => false 14516 */ 14517 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 14518 14519 /** 14520 * Checks if `value` is classified as a `String` primitive or object. 14521 * 14522 * @static 14523 * @since 0.1.0 14524 * @memberOf _ 14525 * @category Lang 14526 * @param {*} value The value to check. 14527 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 14528 * @example 14529 * 14530 * _.isString('abc'); 14531 * // => true 14532 * 14533 * _.isString(1); 14534 * // => false 14535 */ 14536 function isString(value) { 14537 return typeof value == 'string' || 14538 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 14539 } 14540 14541 /** 14542 * Checks if `value` is classified as a `Symbol` primitive or object. 14543 * 14544 * @static 14545 * @memberOf _ 14546 * @since 4.0.0 14547 * @category Lang 14548 * @param {*} value The value to check. 14549 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 14550 * @example 14551 * 14552 * _.isSymbol(Symbol.iterator); 14553 * // => true 14554 * 14555 * _.isSymbol('abc'); 14556 * // => false 14557 */ 14558 function isSymbol(value) { 14559 return typeof value == 'symbol' || 14560 (isObjectLike(value) && baseGetTag(value) == symbolTag); 14561 } 14562 14563 /** 14564 * Checks if `value` is classified as a typed array. 14565 * 14566 * @static 14567 * @memberOf _ 14568 * @since 3.0.0 14569 * @category Lang 14570 * @param {*} value The value to check. 14571 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 14572 * @example 14573 * 14574 * _.isTypedArray(new Uint8Array); 14575 * // => true 14576 * 14577 * _.isTypedArray([]); 14578 * // => false 14579 */ 14580 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 14581 14582 /** 14583 * Checks if `value` is `undefined`. 14584 * 14585 * @static 14586 * @since 0.1.0 14587 * @memberOf _ 14588 * @category Lang 14589 * @param {*} value The value to check. 14590 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 14591 * @example 14592 * 14593 * _.isUndefined(void 0); 14594 * // => true 14595 * 14596 * _.isUndefined(null); 14597 * // => false 14598 */ 14599 function isUndefined(value) { 14600 return value === undefined; 14601 } 14602 14603 /** 14604 * Checks if `value` is classified as a `WeakMap` object. 14605 * 14606 * @static 14607 * @memberOf _ 14608 * @since 4.3.0 14609 * @category Lang 14610 * @param {*} value The value to check. 14611 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 14612 * @example 14613 * 14614 * _.isWeakMap(new WeakMap); 14615 * // => true 14616 * 14617 * _.isWeakMap(new Map); 14618 * // => false 14619 */ 14620 function isWeakMap(value) { 14621 return isObjectLike(value) && getTag(value) == weakMapTag; 14622 } 14623 14624 /** 14625 * Checks if `value` is classified as a `WeakSet` object. 14626 * 14627 * @static 14628 * @memberOf _ 14629 * @since 4.3.0 14630 * @category Lang 14631 * @param {*} value The value to check. 14632 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 14633 * @example 14634 * 14635 * _.isWeakSet(new WeakSet); 14636 * // => true 14637 * 14638 * _.isWeakSet(new Set); 14639 * // => false 14640 */ 14641 function isWeakSet(value) { 14642 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 14643 } 14644 14645 /** 14646 * Checks if `value` is less than `other`. 14647 * 14648 * @static 14649 * @memberOf _ 14650 * @since 3.9.0 14651 * @category Lang 14652 * @param {*} value The value to compare. 14653 * @param {*} other The other value to compare. 14654 * @returns {boolean} Returns `true` if `value` is less than `other`, 14655 * else `false`. 14656 * @see _.gt 14657 * @example 14658 * 14659 * _.lt(1, 3); 14660 * // => true 14661 * 14662 * _.lt(3, 3); 14663 * // => false 14664 * 14665 * _.lt(3, 1); 14666 * // => false 14667 */ 14668 var lt = createRelationalOperation(baseLt); 14669 14670 /** 14671 * Checks if `value` is less than or equal to `other`. 14672 * 14673 * @static 14674 * @memberOf _ 14675 * @since 3.9.0 14676 * @category Lang 14677 * @param {*} value The value to compare. 14678 * @param {*} other The other value to compare. 14679 * @returns {boolean} Returns `true` if `value` is less than or equal to 14680 * `other`, else `false`. 14681 * @see _.gte 14682 * @example 14683 * 14684 * _.lte(1, 3); 14685 * // => true 14686 * 14687 * _.lte(3, 3); 14688 * // => true 14689 * 14690 * _.lte(3, 1); 14691 * // => false 14692 */ 14693 var lte = createRelationalOperation(function(value, other) { 14694 return value <= other; 14695 }); 14696 14697 /** 14698 * Converts `value` to an array. 14699 * 14700 * @static 14701 * @since 0.1.0 14702 * @memberOf _ 14703 * @category Lang 14704 * @param {*} value The value to convert. 14705 * @returns {Array} Returns the converted array. 14706 * @example 14707 * 14708 * _.toArray({ 'a': 1, 'b': 2 }); 14709 * // => [1, 2] 14710 * 14711 * _.toArray('abc'); 14712 * // => ['a', 'b', 'c'] 14713 * 14714 * _.toArray(1); 14715 * // => [] 14716 * 14717 * _.toArray(null); 14718 * // => [] 14719 */ 14720 function toArray(value) { 14721 if (!value) { 14722 return []; 14723 } 14724 if (isArrayLike(value)) { 14725 return isString(value) ? stringToArray(value) : copyArray(value); 14726 } 14727 if (symIterator && value[symIterator]) { 14728 return iteratorToArray(value[symIterator]()); 14729 } 14730 var tag = getTag(value), 14731 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 14732 14733 return func(value); 14734 } 14735 14736 /** 14737 * Converts `value` to a finite number. 14738 * 14739 * @static 14740 * @memberOf _ 14741 * @since 4.12.0 14742 * @category Lang 14743 * @param {*} value The value to convert. 14744 * @returns {number} Returns the converted number. 14745 * @example 14746 * 14747 * _.toFinite(3.2); 14748 * // => 3.2 14749 * 14750 * _.toFinite(Number.MIN_VALUE); 14751 * // => 5e-324 14752 * 14753 * _.toFinite(Infinity); 14754 * // => 1.7976931348623157e+308 14755 * 14756 * _.toFinite('3.2'); 14757 * // => 3.2 14758 */ 14759 function toFinite(value) { 14760 if (!value) { 14761 return value === 0 ? value : 0; 14762 } 14763 value = toNumber(value); 14764 if (value === INFINITY || value === -INFINITY) { 14765 var sign = (value < 0 ? -1 : 1); 14766 return sign * MAX_INTEGER; 14767 } 14768 return value === value ? value : 0; 14769 } 14770 14771 /** 14772 * Converts `value` to an integer. 14773 * 14774 * **Note:** This method is loosely based on 14775 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 14776 * 14777 * @static 14778 * @memberOf _ 14779 * @since 4.0.0 14780 * @category Lang 14781 * @param {*} value The value to convert. 14782 * @returns {number} Returns the converted integer. 14783 * @example 14784 * 14785 * _.toInteger(3.2); 14786 * // => 3 14787 * 14788 * _.toInteger(Number.MIN_VALUE); 14789 * // => 0 14790 * 14791 * _.toInteger(Infinity); 14792 * // => 1.7976931348623157e+308 14793 * 14794 * _.toInteger('3.2'); 14795 * // => 3 14796 */ 14797 function toInteger(value) { 14798 var result = toFinite(value), 14799 remainder = result % 1; 14800 14801 return result === result ? (remainder ? result - remainder : result) : 0; 14802 } 14803 14804 /** 14805 * Converts `value` to an integer suitable for use as the length of an 14806 * array-like object. 14807 * 14808 * **Note:** This method is based on 14809 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 14810 * 14811 * @static 14812 * @memberOf _ 14813 * @since 4.0.0 14814 * @category Lang 14815 * @param {*} value The value to convert. 14816 * @returns {number} Returns the converted integer. 14817 * @example 14818 * 14819 * _.toLength(3.2); 14820 * // => 3 14821 * 14822 * _.toLength(Number.MIN_VALUE); 14823 * // => 0 14824 * 14825 * _.toLength(Infinity); 14826 * // => 4294967295 14827 * 14828 * _.toLength('3.2'); 14829 * // => 3 14830 */ 14831 function toLength(value) { 14832 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 14833 } 14834 14835 /** 14836 * Converts `value` to a number. 14837 * 14838 * @static 14839 * @memberOf _ 14840 * @since 4.0.0 14841 * @category Lang 14842 * @param {*} value The value to process. 14843 * @returns {number} Returns the number. 14844 * @example 14845 * 14846 * _.toNumber(3.2); 14847 * // => 3.2 14848 * 14849 * _.toNumber(Number.MIN_VALUE); 14850 * // => 5e-324 14851 * 14852 * _.toNumber(Infinity); 14853 * // => Infinity 14854 * 14855 * _.toNumber('3.2'); 14856 * // => 3.2 14857 */ 14858 function toNumber(value) { 14859 if (typeof value == 'number') { 14860 return value; 14861 } 14862 if (isSymbol(value)) { 14863 return NAN; 14864 } 14865 if (isObject(value)) { 14866 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 14867 value = isObject(other) ? (other + '') : other; 14868 } 14869 if (typeof value != 'string') { 14870 return value === 0 ? value : +value; 14871 } 14872 value = value.replace(reTrim, ''); 14873 var isBinary = reIsBinary.test(value); 14874 return (isBinary || reIsOctal.test(value)) 14875 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 14876 : (reIsBadHex.test(value) ? NAN : +value); 14877 } 14878 14879 /** 14880 * Converts `value` to a plain object flattening inherited enumerable string 14881 * keyed properties of `value` to own properties of the plain object. 14882 * 14883 * @static 14884 * @memberOf _ 14885 * @since 3.0.0 14886 * @category Lang 14887 * @param {*} value The value to convert. 14888 * @returns {Object} Returns the converted plain object. 14889 * @example 14890 * 14891 * function Foo() { 14892 * this.b = 2; 14893 * } 14894 * 14895 * Foo.prototype.c = 3; 14896 * 14897 * _.assign({ 'a': 1 }, new Foo); 14898 * // => { 'a': 1, 'b': 2 } 14899 * 14900 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 14901 * // => { 'a': 1, 'b': 2, 'c': 3 } 14902 */ 14903 function toPlainObject(value) { 14904 return copyObject(value, keysIn(value)); 14905 } 14906 14907 /** 14908 * Converts `value` to a safe integer. A safe integer can be compared and 14909 * represented correctly. 14910 * 14911 * @static 14912 * @memberOf _ 14913 * @since 4.0.0 14914 * @category Lang 14915 * @param {*} value The value to convert. 14916 * @returns {number} Returns the converted integer. 14917 * @example 14918 * 14919 * _.toSafeInteger(3.2); 14920 * // => 3 14921 * 14922 * _.toSafeInteger(Number.MIN_VALUE); 14923 * // => 0 14924 * 14925 * _.toSafeInteger(Infinity); 14926 * // => 9007199254740991 14927 * 14928 * _.toSafeInteger('3.2'); 14929 * // => 3 14930 */ 14931 function toSafeInteger(value) { 14932 return value 14933 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 14934 : (value === 0 ? value : 0); 14935 } 14936 14937 /** 14938 * Converts `value` to a string. An empty string is returned for `null` 14939 * and `undefined` values. The sign of `-0` is preserved. 14940 * 14941 * @static 14942 * @memberOf _ 14943 * @since 4.0.0 14944 * @category Lang 14945 * @param {*} value The value to convert. 14946 * @returns {string} Returns the converted string. 14947 * @example 14948 * 14949 * _.toString(null); 14950 * // => '' 14951 * 14952 * _.toString(-0); 14953 * // => '-0' 14954 * 14955 * _.toString([1, 2, 3]); 14956 * // => '1,2,3' 14957 */ 14958 function toString(value) { 14959 return value == null ? '' : baseToString(value); 14960 } 14961 14962 /*------------------------------------------------------------------------*/ 14963 14964 /** 14965 * Assigns own enumerable string keyed properties of source objects to the 14966 * destination object. Source objects are applied from left to right. 14967 * Subsequent sources overwrite property assignments of previous sources. 14968 * 14969 * **Note:** This method mutates `object` and is loosely based on 14970 * [`Object.assign`](https://mdn.io/Object/assign). 14971 * 14972 * @static 14973 * @memberOf _ 14974 * @since 0.10.0 14975 * @category Object 14976 * @param {Object} object The destination object. 14977 * @param {...Object} [sources] The source objects. 14978 * @returns {Object} Returns `object`. 14979 * @see _.assignIn 14980 * @example 14981 * 14982 * function Foo() { 14983 * this.a = 1; 14984 * } 14985 * 14986 * function Bar() { 14987 * this.c = 3; 14988 * } 14989 * 14990 * Foo.prototype.b = 2; 14991 * Bar.prototype.d = 4; 14992 * 14993 * _.assign({ 'a': 0 }, new Foo, new Bar); 14994 * // => { 'a': 1, 'c': 3 } 14995 */ 14996 var assign = createAssigner(function(object, source) { 14997 if (isPrototype(source) || isArrayLike(source)) { 14998 copyObject(source, keys(source), object); 14999 return; 15000 } 15001 for (var key in source) { 15002 if (hasOwnProperty.call(source, key)) { 15003 assignValue(object, key, source[key]); 15004 } 15005 } 15006 }); 15007 15008 /** 15009 * This method is like `_.assign` except that it iterates over own and 15010 * inherited source properties. 15011 * 15012 * **Note:** This method mutates `object`. 15013 * 15014 * @static 15015 * @memberOf _ 15016 * @since 4.0.0 15017 * @alias extend 15018 * @category Object 15019 * @param {Object} object The destination object. 15020 * @param {...Object} [sources] The source objects. 15021 * @returns {Object} Returns `object`. 15022 * @see _.assign 15023 * @example 15024 * 15025 * function Foo() { 15026 * this.a = 1; 15027 * } 15028 * 15029 * function Bar() { 15030 * this.c = 3; 15031 * } 15032 * 15033 * Foo.prototype.b = 2; 15034 * Bar.prototype.d = 4; 15035 * 15036 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 15037 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 15038 */ 15039 var assignIn = createAssigner(function(object, source) { 15040 copyObject(source, keysIn(source), object); 15041 }); 15042 15043 /** 15044 * This method is like `_.assignIn` except that it accepts `customizer` 15045 * which is invoked to produce the assigned values. If `customizer` returns 15046 * `undefined`, assignment is handled by the method instead. The `customizer` 15047 * is invoked with five arguments: (objValue, srcValue, key, object, source). 15048 * 15049 * **Note:** This method mutates `object`. 15050 * 15051 * @static 15052 * @memberOf _ 15053 * @since 4.0.0 15054 * @alias extendWith 15055 * @category Object 15056 * @param {Object} object The destination object. 15057 * @param {...Object} sources The source objects. 15058 * @param {Function} [customizer] The function to customize assigned values. 15059 * @returns {Object} Returns `object`. 15060 * @see _.assignWith 15061 * @example 15062 * 15063 * function customizer(objValue, srcValue) { 15064 * return _.isUndefined(objValue) ? srcValue : objValue; 15065 * } 15066 * 15067 * var defaults = _.partialRight(_.assignInWith, customizer); 15068 * 15069 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 15070 * // => { 'a': 1, 'b': 2 } 15071 */ 15072 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 15073 copyObject(source, keysIn(source), object, customizer); 15074 }); 15075 15076 /** 15077 * This method is like `_.assign` except that it accepts `customizer` 15078 * which is invoked to produce the assigned values. If `customizer` returns 15079 * `undefined`, assignment is handled by the method instead. The `customizer` 15080 * is invoked with five arguments: (objValue, srcValue, key, object, source). 15081 * 15082 * **Note:** This method mutates `object`. 15083 * 15084 * @static 15085 * @memberOf _ 15086 * @since 4.0.0 15087 * @category Object 15088 * @param {Object} object The destination object. 15089 * @param {...Object} sources The source objects. 15090 * @param {Function} [customizer] The function to customize assigned values. 15091 * @returns {Object} Returns `object`. 15092 * @see _.assignInWith 15093 * @example 15094 * 15095 * function customizer(objValue, srcValue) { 15096 * return _.isUndefined(objValue) ? srcValue : objValue; 15097 * } 15098 * 15099 * var defaults = _.partialRight(_.assignWith, customizer); 15100 * 15101 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 15102 * // => { 'a': 1, 'b': 2 } 15103 */ 15104 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 15105 copyObject(source, keys(source), object, customizer); 15106 }); 15107 15108 /** 15109 * Creates an array of values corresponding to `paths` of `object`. 15110 * 15111 * @static 15112 * @memberOf _ 15113 * @since 1.0.0 15114 * @category Object 15115 * @param {Object} object The object to iterate over. 15116 * @param {...(string|string[])} [paths] The property paths to pick. 15117 * @returns {Array} Returns the picked values. 15118 * @example 15119 * 15120 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 15121 * 15122 * _.at(object, ['a[0].b.c', 'a[1]']); 15123 * // => [3, 4] 15124 */ 15125 var at = flatRest(baseAt); 15126 15127 /** 15128 * Creates an object that inherits from the `prototype` object. If a 15129 * `properties` object is given, its own enumerable string keyed properties 15130 * are assigned to the created object. 15131 * 15132 * @static 15133 * @memberOf _ 15134 * @since 2.3.0 15135 * @category Object 15136 * @param {Object} prototype The object to inherit from. 15137 * @param {Object} [properties] The properties to assign to the object. 15138 * @returns {Object} Returns the new object. 15139 * @example 15140 * 15141 * function Shape() { 15142 * this.x = 0; 15143 * this.y = 0; 15144 * } 15145 * 15146 * function Circle() { 15147 * Shape.call(this); 15148 * } 15149 * 15150 * Circle.prototype = _.create(Shape.prototype, { 15151 * 'constructor': Circle 15152 * }); 15153 * 15154 * var circle = new Circle; 15155 * circle instanceof Circle; 15156 * // => true 15157 * 15158 * circle instanceof Shape; 15159 * // => true 15160 */ 15161 function create(prototype, properties) { 15162 var result = baseCreate(prototype); 15163 return properties == null ? result : baseAssign(result, properties); 15164 } 15165 15166 /** 15167 * Assigns own and inherited enumerable string keyed properties of source 15168 * objects to the destination object for all destination properties that 15169 * resolve to `undefined`. Source objects are applied from left to right. 15170 * Once a property is set, additional values of the same property are ignored. 15171 * 15172 * **Note:** This method mutates `object`. 15173 * 15174 * @static 15175 * @since 0.1.0 15176 * @memberOf _ 15177 * @category Object 15178 * @param {Object} object The destination object. 15179 * @param {...Object} [sources] The source objects. 15180 * @returns {Object} Returns `object`. 15181 * @see _.defaultsDeep 15182 * @example 15183 * 15184 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 15185 * // => { 'a': 1, 'b': 2 } 15186 */ 15187 var defaults = baseRest(function(object, sources) { 15188 object = Object(object); 15189 15190 var index = -1; 15191 var length = sources.length; 15192 var guard = length > 2 ? sources[2] : undefined; 15193 15194 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 15195 length = 1; 15196 } 15197 15198 while (++index < length) { 15199 var source = sources[index]; 15200 var props = keysIn(source); 15201 var propsIndex = -1; 15202 var propsLength = props.length; 15203 15204 while (++propsIndex < propsLength) { 15205 var key = props[propsIndex]; 15206 var value = object[key]; 15207 15208 if (value === undefined || 15209 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 15210 object[key] = source[key]; 15211 } 15212 } 15213 } 15214 15215 return object; 15216 }); 15217 15218 /** 15219 * This method is like `_.defaults` except that it recursively assigns 15220 * default properties. 15221 * 15222 * **Note:** This method mutates `object`. 15223 * 15224 * @static 15225 * @memberOf _ 15226 * @since 3.10.0 15227 * @category Object 15228 * @param {Object} object The destination object. 15229 * @param {...Object} [sources] The source objects. 15230 * @returns {Object} Returns `object`. 15231 * @see _.defaults 15232 * @example 15233 * 15234 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 15235 * // => { 'a': { 'b': 2, 'c': 3 } } 15236 */ 15237 var defaultsDeep = baseRest(function(args) { 15238 args.push(undefined, customDefaultsMerge); 15239 return apply(mergeWith, undefined, args); 15240 }); 15241 15242 /** 15243 * This method is like `_.find` except that it returns the key of the first 15244 * element `predicate` returns truthy for instead of the element itself. 15245 * 15246 * @static 15247 * @memberOf _ 15248 * @since 1.1.0 15249 * @category Object 15250 * @param {Object} object The object to inspect. 15251 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15252 * @returns {string|undefined} Returns the key of the matched element, 15253 * else `undefined`. 15254 * @example 15255 * 15256 * var users = { 15257 * 'barney': { 'age': 36, 'active': true }, 15258 * 'fred': { 'age': 40, 'active': false }, 15259 * 'pebbles': { 'age': 1, 'active': true } 15260 * }; 15261 * 15262 * _.findKey(users, function(o) { return o.age < 40; }); 15263 * // => 'barney' (iteration order is not guaranteed) 15264 * 15265 * // The `_.matches` iteratee shorthand. 15266 * _.findKey(users, { 'age': 1, 'active': true }); 15267 * // => 'pebbles' 15268 * 15269 * // The `_.matchesProperty` iteratee shorthand. 15270 * _.findKey(users, ['active', false]); 15271 * // => 'fred' 15272 * 15273 * // The `_.property` iteratee shorthand. 15274 * _.findKey(users, 'active'); 15275 * // => 'barney' 15276 */ 15277 function findKey(object, predicate) { 15278 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 15279 } 15280 15281 /** 15282 * This method is like `_.findKey` except that it iterates over elements of 15283 * a collection in the opposite order. 15284 * 15285 * @static 15286 * @memberOf _ 15287 * @since 2.0.0 15288 * @category Object 15289 * @param {Object} object The object to inspect. 15290 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15291 * @returns {string|undefined} Returns the key of the matched element, 15292 * else `undefined`. 15293 * @example 15294 * 15295 * var users = { 15296 * 'barney': { 'age': 36, 'active': true }, 15297 * 'fred': { 'age': 40, 'active': false }, 15298 * 'pebbles': { 'age': 1, 'active': true } 15299 * }; 15300 * 15301 * _.findLastKey(users, function(o) { return o.age < 40; }); 15302 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 15303 * 15304 * // The `_.matches` iteratee shorthand. 15305 * _.findLastKey(users, { 'age': 36, 'active': true }); 15306 * // => 'barney' 15307 * 15308 * // The `_.matchesProperty` iteratee shorthand. 15309 * _.findLastKey(users, ['active', false]); 15310 * // => 'fred' 15311 * 15312 * // The `_.property` iteratee shorthand. 15313 * _.findLastKey(users, 'active'); 15314 * // => 'pebbles' 15315 */ 15316 function findLastKey(object, predicate) { 15317 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 15318 } 15319 15320 /** 15321 * Iterates over own and inherited enumerable string keyed properties of an 15322 * object and invokes `iteratee` for each property. The iteratee is invoked 15323 * with three arguments: (value, key, object). Iteratee functions may exit 15324 * iteration early by explicitly returning `false`. 15325 * 15326 * @static 15327 * @memberOf _ 15328 * @since 0.3.0 15329 * @category Object 15330 * @param {Object} object The object to iterate over. 15331 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15332 * @returns {Object} Returns `object`. 15333 * @see _.forInRight 15334 * @example 15335 * 15336 * function Foo() { 15337 * this.a = 1; 15338 * this.b = 2; 15339 * } 15340 * 15341 * Foo.prototype.c = 3; 15342 * 15343 * _.forIn(new Foo, function(value, key) { 15344 * console.log(key); 15345 * }); 15346 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 15347 */ 15348 function forIn(object, iteratee) { 15349 return object == null 15350 ? object 15351 : baseFor(object, getIteratee(iteratee, 3), keysIn); 15352 } 15353 15354 /** 15355 * This method is like `_.forIn` except that it iterates over properties of 15356 * `object` in the opposite order. 15357 * 15358 * @static 15359 * @memberOf _ 15360 * @since 2.0.0 15361 * @category Object 15362 * @param {Object} object The object to iterate over. 15363 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15364 * @returns {Object} Returns `object`. 15365 * @see _.forIn 15366 * @example 15367 * 15368 * function Foo() { 15369 * this.a = 1; 15370 * this.b = 2; 15371 * } 15372 * 15373 * Foo.prototype.c = 3; 15374 * 15375 * _.forInRight(new Foo, function(value, key) { 15376 * console.log(key); 15377 * }); 15378 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 15379 */ 15380 function forInRight(object, iteratee) { 15381 return object == null 15382 ? object 15383 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 15384 } 15385 15386 /** 15387 * Iterates over own enumerable string keyed properties of an object and 15388 * invokes `iteratee` for each property. The iteratee is invoked with three 15389 * arguments: (value, key, object). Iteratee functions may exit iteration 15390 * early by explicitly returning `false`. 15391 * 15392 * @static 15393 * @memberOf _ 15394 * @since 0.3.0 15395 * @category Object 15396 * @param {Object} object The object to iterate over. 15397 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15398 * @returns {Object} Returns `object`. 15399 * @see _.forOwnRight 15400 * @example 15401 * 15402 * function Foo() { 15403 * this.a = 1; 15404 * this.b = 2; 15405 * } 15406 * 15407 * Foo.prototype.c = 3; 15408 * 15409 * _.forOwn(new Foo, function(value, key) { 15410 * console.log(key); 15411 * }); 15412 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 15413 */ 15414 function forOwn(object, iteratee) { 15415 return object && baseForOwn(object, getIteratee(iteratee, 3)); 15416 } 15417 15418 /** 15419 * This method is like `_.forOwn` except that it iterates over properties of 15420 * `object` in the opposite order. 15421 * 15422 * @static 15423 * @memberOf _ 15424 * @since 2.0.0 15425 * @category Object 15426 * @param {Object} object The object to iterate over. 15427 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15428 * @returns {Object} Returns `object`. 15429 * @see _.forOwn 15430 * @example 15431 * 15432 * function Foo() { 15433 * this.a = 1; 15434 * this.b = 2; 15435 * } 15436 * 15437 * Foo.prototype.c = 3; 15438 * 15439 * _.forOwnRight(new Foo, function(value, key) { 15440 * console.log(key); 15441 * }); 15442 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 15443 */ 15444 function forOwnRight(object, iteratee) { 15445 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 15446 } 15447 15448 /** 15449 * Creates an array of function property names from own enumerable properties 15450 * of `object`. 15451 * 15452 * @static 15453 * @since 0.1.0 15454 * @memberOf _ 15455 * @category Object 15456 * @param {Object} object The object to inspect. 15457 * @returns {Array} Returns the function names. 15458 * @see _.functionsIn 15459 * @example 15460 * 15461 * function Foo() { 15462 * this.a = _.constant('a'); 15463 * this.b = _.constant('b'); 15464 * } 15465 * 15466 * Foo.prototype.c = _.constant('c'); 15467 * 15468 * _.functions(new Foo); 15469 * // => ['a', 'b'] 15470 */ 15471 function functions(object) { 15472 return object == null ? [] : baseFunctions(object, keys(object)); 15473 } 15474 15475 /** 15476 * Creates an array of function property names from own and inherited 15477 * enumerable properties of `object`. 15478 * 15479 * @static 15480 * @memberOf _ 15481 * @since 4.0.0 15482 * @category Object 15483 * @param {Object} object The object to inspect. 15484 * @returns {Array} Returns the function names. 15485 * @see _.functions 15486 * @example 15487 * 15488 * function Foo() { 15489 * this.a = _.constant('a'); 15490 * this.b = _.constant('b'); 15491 * } 15492 * 15493 * Foo.prototype.c = _.constant('c'); 15494 * 15495 * _.functionsIn(new Foo); 15496 * // => ['a', 'b', 'c'] 15497 */ 15498 function functionsIn(object) { 15499 return object == null ? [] : baseFunctions(object, keysIn(object)); 15500 } 15501 15502 /** 15503 * Gets the value at `path` of `object`. If the resolved value is 15504 * `undefined`, the `defaultValue` is returned in its place. 15505 * 15506 * @static 15507 * @memberOf _ 15508 * @since 3.7.0 15509 * @category Object 15510 * @param {Object} object The object to query. 15511 * @param {Array|string} path The path of the property to get. 15512 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 15513 * @returns {*} Returns the resolved value. 15514 * @example 15515 * 15516 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 15517 * 15518 * _.get(object, 'a[0].b.c'); 15519 * // => 3 15520 * 15521 * _.get(object, ['a', '0', 'b', 'c']); 15522 * // => 3 15523 * 15524 * _.get(object, 'a.b.c', 'default'); 15525 * // => 'default' 15526 */ 15527 function get(object, path, defaultValue) { 15528 var result = object == null ? undefined : baseGet(object, path); 15529 return result === undefined ? defaultValue : result; 15530 } 15531 15532 /** 15533 * Checks if `path` is a direct property of `object`. 15534 * 15535 * @static 15536 * @since 0.1.0 15537 * @memberOf _ 15538 * @category Object 15539 * @param {Object} object The object to query. 15540 * @param {Array|string} path The path to check. 15541 * @returns {boolean} Returns `true` if `path` exists, else `false`. 15542 * @example 15543 * 15544 * var object = { 'a': { 'b': 2 } }; 15545 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 15546 * 15547 * _.has(object, 'a'); 15548 * // => true 15549 * 15550 * _.has(object, 'a.b'); 15551 * // => true 15552 * 15553 * _.has(object, ['a', 'b']); 15554 * // => true 15555 * 15556 * _.has(other, 'a'); 15557 * // => false 15558 */ 15559 function has(object, path) { 15560 return object != null && hasPath(object, path, baseHas); 15561 } 15562 15563 /** 15564 * Checks if `path` is a direct or inherited property of `object`. 15565 * 15566 * @static 15567 * @memberOf _ 15568 * @since 4.0.0 15569 * @category Object 15570 * @param {Object} object The object to query. 15571 * @param {Array|string} path The path to check. 15572 * @returns {boolean} Returns `true` if `path` exists, else `false`. 15573 * @example 15574 * 15575 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 15576 * 15577 * _.hasIn(object, 'a'); 15578 * // => true 15579 * 15580 * _.hasIn(object, 'a.b'); 15581 * // => true 15582 * 15583 * _.hasIn(object, ['a', 'b']); 15584 * // => true 15585 * 15586 * _.hasIn(object, 'b'); 15587 * // => false 15588 */ 15589 function hasIn(object, path) { 15590 return object != null && hasPath(object, path, baseHasIn); 15591 } 15592 15593 /** 15594 * Creates an object composed of the inverted keys and values of `object`. 15595 * If `object` contains duplicate values, subsequent values overwrite 15596 * property assignments of previous values. 15597 * 15598 * @static 15599 * @memberOf _ 15600 * @since 0.7.0 15601 * @category Object 15602 * @param {Object} object The object to invert. 15603 * @returns {Object} Returns the new inverted object. 15604 * @example 15605 * 15606 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 15607 * 15608 * _.invert(object); 15609 * // => { '1': 'c', '2': 'b' } 15610 */ 15611 var invert = createInverter(function(result, value, key) { 15612 if (value != null && 15613 typeof value.toString != 'function') { 15614 value = nativeObjectToString.call(value); 15615 } 15616 15617 result[value] = key; 15618 }, constant(identity)); 15619 15620 /** 15621 * This method is like `_.invert` except that the inverted object is generated 15622 * from the results of running each element of `object` thru `iteratee`. The 15623 * corresponding inverted value of each inverted key is an array of keys 15624 * responsible for generating the inverted value. The iteratee is invoked 15625 * with one argument: (value). 15626 * 15627 * @static 15628 * @memberOf _ 15629 * @since 4.1.0 15630 * @category Object 15631 * @param {Object} object The object to invert. 15632 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 15633 * @returns {Object} Returns the new inverted object. 15634 * @example 15635 * 15636 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 15637 * 15638 * _.invertBy(object); 15639 * // => { '1': ['a', 'c'], '2': ['b'] } 15640 * 15641 * _.invertBy(object, function(value) { 15642 * return 'group' + value; 15643 * }); 15644 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 15645 */ 15646 var invertBy = createInverter(function(result, value, key) { 15647 if (value != null && 15648 typeof value.toString != 'function') { 15649 value = nativeObjectToString.call(value); 15650 } 15651 15652 if (hasOwnProperty.call(result, value)) { 15653 result[value].push(key); 15654 } else { 15655 result[value] = [key]; 15656 } 15657 }, getIteratee); 15658 15659 /** 15660 * Invokes the method at `path` of `object`. 15661 * 15662 * @static 15663 * @memberOf _ 15664 * @since 4.0.0 15665 * @category Object 15666 * @param {Object} object The object to query. 15667 * @param {Array|string} path The path of the method to invoke. 15668 * @param {...*} [args] The arguments to invoke the method with. 15669 * @returns {*} Returns the result of the invoked method. 15670 * @example 15671 * 15672 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 15673 * 15674 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 15675 * // => [2, 3] 15676 */ 15677 var invoke = baseRest(baseInvoke); 15678 15679 /** 15680 * Creates an array of the own enumerable property names of `object`. 15681 * 15682 * **Note:** Non-object values are coerced to objects. See the 15683 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 15684 * for more details. 15685 * 15686 * @static 15687 * @since 0.1.0 15688 * @memberOf _ 15689 * @category Object 15690 * @param {Object} object The object to query. 15691 * @returns {Array} Returns the array of property names. 15692 * @example 15693 * 15694 * function Foo() { 15695 * this.a = 1; 15696 * this.b = 2; 15697 * } 15698 * 15699 * Foo.prototype.c = 3; 15700 * 15701 * _.keys(new Foo); 15702 * // => ['a', 'b'] (iteration order is not guaranteed) 15703 * 15704 * _.keys('hi'); 15705 * // => ['0', '1'] 15706 */ 15707 function keys(object) { 15708 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 15709 } 15710 15711 /** 15712 * Creates an array of the own and inherited enumerable property names of `object`. 15713 * 15714 * **Note:** Non-object values are coerced to objects. 15715 * 15716 * @static 15717 * @memberOf _ 15718 * @since 3.0.0 15719 * @category Object 15720 * @param {Object} object The object to query. 15721 * @returns {Array} Returns the array of property names. 15722 * @example 15723 * 15724 * function Foo() { 15725 * this.a = 1; 15726 * this.b = 2; 15727 * } 15728 * 15729 * Foo.prototype.c = 3; 15730 * 15731 * _.keysIn(new Foo); 15732 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 15733 */ 15734 function keysIn(object) { 15735 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 15736 } 15737 15738 /** 15739 * The opposite of `_.mapValues`; this method creates an object with the 15740 * same values as `object` and keys generated by running each own enumerable 15741 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 15742 * with three arguments: (value, key, object). 15743 * 15744 * @static 15745 * @memberOf _ 15746 * @since 3.8.0 15747 * @category Object 15748 * @param {Object} object The object to iterate over. 15749 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15750 * @returns {Object} Returns the new mapped object. 15751 * @see _.mapValues 15752 * @example 15753 * 15754 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 15755 * return key + value; 15756 * }); 15757 * // => { 'a1': 1, 'b2': 2 } 15758 */ 15759 function mapKeys(object, iteratee) { 15760 var result = {}; 15761 iteratee = getIteratee(iteratee, 3); 15762 15763 baseForOwn(object, function(value, key, object) { 15764 baseAssignValue(result, iteratee(value, key, object), value); 15765 }); 15766 return result; 15767 } 15768 15769 /** 15770 * Creates an object with the same keys as `object` and values generated 15771 * by running each own enumerable string keyed property of `object` thru 15772 * `iteratee`. The iteratee is invoked with three arguments: 15773 * (value, key, object). 15774 * 15775 * @static 15776 * @memberOf _ 15777 * @since 2.4.0 15778 * @category Object 15779 * @param {Object} object The object to iterate over. 15780 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15781 * @returns {Object} Returns the new mapped object. 15782 * @see _.mapKeys 15783 * @example 15784 * 15785 * var users = { 15786 * 'fred': { 'user': 'fred', 'age': 40 }, 15787 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 15788 * }; 15789 * 15790 * _.mapValues(users, function(o) { return o.age; }); 15791 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15792 * 15793 * // The `_.property` iteratee shorthand. 15794 * _.mapValues(users, 'age'); 15795 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15796 */ 15797 function mapValues(object, iteratee) { 15798 var result = {}; 15799 iteratee = getIteratee(iteratee, 3); 15800 15801 baseForOwn(object, function(value, key, object) { 15802 baseAssignValue(result, key, iteratee(value, key, object)); 15803 }); 15804 return result; 15805 } 15806 15807 /** 15808 * This method is like `_.assign` except that it recursively merges own and 15809 * inherited enumerable string keyed properties of source objects into the 15810 * destination object. Source properties that resolve to `undefined` are 15811 * skipped if a destination value exists. Array and plain object properties 15812 * are merged recursively. Other objects and value types are overridden by 15813 * assignment. Source objects are applied from left to right. Subsequent 15814 * sources overwrite property assignments of previous sources. 15815 * 15816 * **Note:** This method mutates `object`. 15817 * 15818 * @static 15819 * @memberOf _ 15820 * @since 0.5.0 15821 * @category Object 15822 * @param {Object} object The destination object. 15823 * @param {...Object} [sources] The source objects. 15824 * @returns {Object} Returns `object`. 15825 * @example 15826 * 15827 * var object = { 15828 * 'a': [{ 'b': 2 }, { 'd': 4 }] 15829 * }; 15830 * 15831 * var other = { 15832 * 'a': [{ 'c': 3 }, { 'e': 5 }] 15833 * }; 15834 * 15835 * _.merge(object, other); 15836 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 15837 */ 15838 var merge = createAssigner(function(object, source, srcIndex) { 15839 baseMerge(object, source, srcIndex); 15840 }); 15841 15842 /** 15843 * This method is like `_.merge` except that it accepts `customizer` which 15844 * is invoked to produce the merged values of the destination and source 15845 * properties. If `customizer` returns `undefined`, merging is handled by the 15846 * method instead. The `customizer` is invoked with six arguments: 15847 * (objValue, srcValue, key, object, source, stack). 15848 * 15849 * **Note:** This method mutates `object`. 15850 * 15851 * @static 15852 * @memberOf _ 15853 * @since 4.0.0 15854 * @category Object 15855 * @param {Object} object The destination object. 15856 * @param {...Object} sources The source objects. 15857 * @param {Function} customizer The function to customize assigned values. 15858 * @returns {Object} Returns `object`. 15859 * @example 15860 * 15861 * function customizer(objValue, srcValue) { 15862 * if (_.isArray(objValue)) { 15863 * return objValue.concat(srcValue); 15864 * } 15865 * } 15866 * 15867 * var object = { 'a': [1], 'b': [2] }; 15868 * var other = { 'a': [3], 'b': [4] }; 15869 * 15870 * _.mergeWith(object, other, customizer); 15871 * // => { 'a': [1, 3], 'b': [2, 4] } 15872 */ 15873 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 15874 baseMerge(object, source, srcIndex, customizer); 15875 }); 15876 15877 /** 15878 * The opposite of `_.pick`; this method creates an object composed of the 15879 * own and inherited enumerable property paths of `object` that are not omitted. 15880 * 15881 * **Note:** This method is considerably slower than `_.pick`. 15882 * 15883 * @static 15884 * @since 0.1.0 15885 * @memberOf _ 15886 * @category Object 15887 * @param {Object} object The source object. 15888 * @param {...(string|string[])} [paths] The property paths to omit. 15889 * @returns {Object} Returns the new object. 15890 * @example 15891 * 15892 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15893 * 15894 * _.omit(object, ['a', 'c']); 15895 * // => { 'b': '2' } 15896 */ 15897 var omit = flatRest(function(object, paths) { 15898 var result = {}; 15899 if (object == null) { 15900 return result; 15901 } 15902 var isDeep = false; 15903 paths = arrayMap(paths, function(path) { 15904 path = castPath(path, object); 15905 isDeep || (isDeep = path.length > 1); 15906 return path; 15907 }); 15908 copyObject(object, getAllKeysIn(object), result); 15909 if (isDeep) { 15910 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 15911 } 15912 var length = paths.length; 15913 while (length--) { 15914 baseUnset(result, paths[length]); 15915 } 15916 return result; 15917 }); 15918 15919 /** 15920 * The opposite of `_.pickBy`; this method creates an object composed of 15921 * the own and inherited enumerable string keyed properties of `object` that 15922 * `predicate` doesn't return truthy for. The predicate is invoked with two 15923 * arguments: (value, key). 15924 * 15925 * @static 15926 * @memberOf _ 15927 * @since 4.0.0 15928 * @category Object 15929 * @param {Object} object The source object. 15930 * @param {Function} [predicate=_.identity] The function invoked per property. 15931 * @returns {Object} Returns the new object. 15932 * @example 15933 * 15934 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15935 * 15936 * _.omitBy(object, _.isNumber); 15937 * // => { 'b': '2' } 15938 */ 15939 function omitBy(object, predicate) { 15940 return pickBy(object, negate(getIteratee(predicate))); 15941 } 15942 15943 /** 15944 * Creates an object composed of the picked `object` properties. 15945 * 15946 * @static 15947 * @since 0.1.0 15948 * @memberOf _ 15949 * @category Object 15950 * @param {Object} object The source object. 15951 * @param {...(string|string[])} [paths] The property paths to pick. 15952 * @returns {Object} Returns the new object. 15953 * @example 15954 * 15955 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15956 * 15957 * _.pick(object, ['a', 'c']); 15958 * // => { 'a': 1, 'c': 3 } 15959 */ 15960 var pick = flatRest(function(object, paths) { 15961 return object == null ? {} : basePick(object, paths); 15962 }); 15963 15964 /** 15965 * Creates an object composed of the `object` properties `predicate` returns 15966 * truthy for. The predicate is invoked with two arguments: (value, key). 15967 * 15968 * @static 15969 * @memberOf _ 15970 * @since 4.0.0 15971 * @category Object 15972 * @param {Object} object The source object. 15973 * @param {Function} [predicate=_.identity] The function invoked per property. 15974 * @returns {Object} Returns the new object. 15975 * @example 15976 * 15977 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15978 * 15979 * _.pickBy(object, _.isNumber); 15980 * // => { 'a': 1, 'c': 3 } 15981 */ 15982 function pickBy(object, predicate) { 15983 if (object == null) { 15984 return {}; 15985 } 15986 var props = arrayMap(getAllKeysIn(object), function(prop) { 15987 return [prop]; 15988 }); 15989 predicate = getIteratee(predicate); 15990 return basePickBy(object, props, function(value, path) { 15991 return predicate(value, path[0]); 15992 }); 15993 } 15994 15995 /** 15996 * This method is like `_.get` except that if the resolved value is a 15997 * function it's invoked with the `this` binding of its parent object and 15998 * its result is returned. 15999 * 16000 * @static 16001 * @since 0.1.0 16002 * @memberOf _ 16003 * @category Object 16004 * @param {Object} object The object to query. 16005 * @param {Array|string} path The path of the property to resolve. 16006 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 16007 * @returns {*} Returns the resolved value. 16008 * @example 16009 * 16010 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 16011 * 16012 * _.result(object, 'a[0].b.c1'); 16013 * // => 3 16014 * 16015 * _.result(object, 'a[0].b.c2'); 16016 * // => 4 16017 * 16018 * _.result(object, 'a[0].b.c3', 'default'); 16019 * // => 'default' 16020 * 16021 * _.result(object, 'a[0].b.c3', _.constant('default')); 16022 * // => 'default' 16023 */ 16024 function result(object, path, defaultValue) { 16025 path = castPath(path, object); 16026 16027 var index = -1, 16028 length = path.length; 16029 16030 // Ensure the loop is entered when path is empty. 16031 if (!length) { 16032 length = 1; 16033 object = undefined; 16034 } 16035 while (++index < length) { 16036 var value = object == null ? undefined : object[toKey(path[index])]; 16037 if (value === undefined) { 16038 index = length; 16039 value = defaultValue; 16040 } 16041 object = isFunction(value) ? value.call(object) : value; 16042 } 16043 return object; 16044 } 16045 16046 /** 16047 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 16048 * it's created. Arrays are created for missing index properties while objects 16049 * are created for all other missing properties. Use `_.setWith` to customize 16050 * `path` creation. 16051 * 16052 * **Note:** This method mutates `object`. 16053 * 16054 * @static 16055 * @memberOf _ 16056 * @since 3.7.0 16057 * @category Object 16058 * @param {Object} object The object to modify. 16059 * @param {Array|string} path The path of the property to set. 16060 * @param {*} value The value to set. 16061 * @returns {Object} Returns `object`. 16062 * @example 16063 * 16064 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 16065 * 16066 * _.set(object, 'a[0].b.c', 4); 16067 * console.log(object.a[0].b.c); 16068 * // => 4 16069 * 16070 * _.set(object, ['x', '0', 'y', 'z'], 5); 16071 * console.log(object.x[0].y.z); 16072 * // => 5 16073 */ 16074 function set(object, path, value) { 16075 return object == null ? object : baseSet(object, path, value); 16076 } 16077 16078 /** 16079 * This method is like `_.set` except that it accepts `customizer` which is 16080 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 16081 * path creation is handled by the method instead. The `customizer` is invoked 16082 * with three arguments: (nsValue, key, nsObject). 16083 * 16084 * **Note:** This method mutates `object`. 16085 * 16086 * @static 16087 * @memberOf _ 16088 * @since 4.0.0 16089 * @category Object 16090 * @param {Object} object The object to modify. 16091 * @param {Array|string} path The path of the property to set. 16092 * @param {*} value The value to set. 16093 * @param {Function} [customizer] The function to customize assigned values. 16094 * @returns {Object} Returns `object`. 16095 * @example 16096 * 16097 * var object = {}; 16098 * 16099 * _.setWith(object, '[0][1]', 'a', Object); 16100 * // => { '0': { '1': 'a' } } 16101 */ 16102 function setWith(object, path, value, customizer) { 16103 customizer = typeof customizer == 'function' ? customizer : undefined; 16104 return object == null ? object : baseSet(object, path, value, customizer); 16105 } 16106 16107 /** 16108 * Creates an array of own enumerable string keyed-value pairs for `object` 16109 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 16110 * entries are returned. 16111 * 16112 * @static 16113 * @memberOf _ 16114 * @since 4.0.0 16115 * @alias entries 16116 * @category Object 16117 * @param {Object} object The object to query. 16118 * @returns {Array} Returns the key-value pairs. 16119 * @example 16120 * 16121 * function Foo() { 16122 * this.a = 1; 16123 * this.b = 2; 16124 * } 16125 * 16126 * Foo.prototype.c = 3; 16127 * 16128 * _.toPairs(new Foo); 16129 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 16130 */ 16131 var toPairs = createToPairs(keys); 16132 16133 /** 16134 * Creates an array of own and inherited enumerable string keyed-value pairs 16135 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 16136 * or set, its entries are returned. 16137 * 16138 * @static 16139 * @memberOf _ 16140 * @since 4.0.0 16141 * @alias entriesIn 16142 * @category Object 16143 * @param {Object} object The object to query. 16144 * @returns {Array} Returns the key-value pairs. 16145 * @example 16146 * 16147 * function Foo() { 16148 * this.a = 1; 16149 * this.b = 2; 16150 * } 16151 * 16152 * Foo.prototype.c = 3; 16153 * 16154 * _.toPairsIn(new Foo); 16155 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 16156 */ 16157 var toPairsIn = createToPairs(keysIn); 16158 16159 /** 16160 * An alternative to `_.reduce`; this method transforms `object` to a new 16161 * `accumulator` object which is the result of running each of its own 16162 * enumerable string keyed properties thru `iteratee`, with each invocation 16163 * potentially mutating the `accumulator` object. If `accumulator` is not 16164 * provided, a new object with the same `[[Prototype]]` will be used. The 16165 * iteratee is invoked with four arguments: (accumulator, value, key, object). 16166 * Iteratee functions may exit iteration early by explicitly returning `false`. 16167 * 16168 * @static 16169 * @memberOf _ 16170 * @since 1.3.0 16171 * @category Object 16172 * @param {Object} object The object to iterate over. 16173 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 16174 * @param {*} [accumulator] The custom accumulator value. 16175 * @returns {*} Returns the accumulated value. 16176 * @example 16177 * 16178 * _.transform([2, 3, 4], function(result, n) { 16179 * result.push(n *= n); 16180 * return n % 2 == 0; 16181 * }, []); 16182 * // => [4, 9] 16183 * 16184 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 16185 * (result[value] || (result[value] = [])).push(key); 16186 * }, {}); 16187 * // => { '1': ['a', 'c'], '2': ['b'] } 16188 */ 16189 function transform(object, iteratee, accumulator) { 16190 var isArr = isArray(object), 16191 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 16192 16193 iteratee = getIteratee(iteratee, 4); 16194 if (accumulator == null) { 16195 var Ctor = object && object.constructor; 16196 if (isArrLike) { 16197 accumulator = isArr ? new Ctor : []; 16198 } 16199 else if (isObject(object)) { 16200 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 16201 } 16202 else { 16203 accumulator = {}; 16204 } 16205 } 16206 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 16207 return iteratee(accumulator, value, index, object); 16208 }); 16209 return accumulator; 16210 } 16211 16212 /** 16213 * Removes the property at `path` of `object`. 16214 * 16215 * **Note:** This method mutates `object`. 16216 * 16217 * @static 16218 * @memberOf _ 16219 * @since 4.0.0 16220 * @category Object 16221 * @param {Object} object The object to modify. 16222 * @param {Array|string} path The path of the property to unset. 16223 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 16224 * @example 16225 * 16226 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 16227 * _.unset(object, 'a[0].b.c'); 16228 * // => true 16229 * 16230 * console.log(object); 16231 * // => { 'a': [{ 'b': {} }] }; 16232 * 16233 * _.unset(object, ['a', '0', 'b', 'c']); 16234 * // => true 16235 * 16236 * console.log(object); 16237 * // => { 'a': [{ 'b': {} }] }; 16238 */ 16239 function unset(object, path) { 16240 return object == null ? true : baseUnset(object, path); 16241 } 16242 16243 /** 16244 * This method is like `_.set` except that accepts `updater` to produce the 16245 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 16246 * is invoked with one argument: (value). 16247 * 16248 * **Note:** This method mutates `object`. 16249 * 16250 * @static 16251 * @memberOf _ 16252 * @since 4.6.0 16253 * @category Object 16254 * @param {Object} object The object to modify. 16255 * @param {Array|string} path The path of the property to set. 16256 * @param {Function} updater The function to produce the updated value. 16257 * @returns {Object} Returns `object`. 16258 * @example 16259 * 16260 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 16261 * 16262 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 16263 * console.log(object.a[0].b.c); 16264 * // => 9 16265 * 16266 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 16267 * console.log(object.x[0].y.z); 16268 * // => 0 16269 */ 16270 function update(object, path, updater) { 16271 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 16272 } 16273 16274 /** 16275 * This method is like `_.update` except that it accepts `customizer` which is 16276 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 16277 * path creation is handled by the method instead. The `customizer` is invoked 16278 * with three arguments: (nsValue, key, nsObject). 16279 * 16280 * **Note:** This method mutates `object`. 16281 * 16282 * @static 16283 * @memberOf _ 16284 * @since 4.6.0 16285 * @category Object 16286 * @param {Object} object The object to modify. 16287 * @param {Array|string} path The path of the property to set. 16288 * @param {Function} updater The function to produce the updated value. 16289 * @param {Function} [customizer] The function to customize assigned values. 16290 * @returns {Object} Returns `object`. 16291 * @example 16292 * 16293 * var object = {}; 16294 * 16295 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 16296 * // => { '0': { '1': 'a' } } 16297 */ 16298 function updateWith(object, path, updater, customizer) { 16299 customizer = typeof customizer == 'function' ? customizer : undefined; 16300 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 16301 } 16302 16303 /** 16304 * Creates an array of the own enumerable string keyed property values of `object`. 16305 * 16306 * **Note:** Non-object values are coerced to objects. 16307 * 16308 * @static 16309 * @since 0.1.0 16310 * @memberOf _ 16311 * @category Object 16312 * @param {Object} object The object to query. 16313 * @returns {Array} Returns the array of property values. 16314 * @example 16315 * 16316 * function Foo() { 16317 * this.a = 1; 16318 * this.b = 2; 16319 * } 16320 * 16321 * Foo.prototype.c = 3; 16322 * 16323 * _.values(new Foo); 16324 * // => [1, 2] (iteration order is not guaranteed) 16325 * 16326 * _.values('hi'); 16327 * // => ['h', 'i'] 16328 */ 16329 function values(object) { 16330 return object == null ? [] : baseValues(object, keys(object)); 16331 } 16332 16333 /** 16334 * Creates an array of the own and inherited enumerable string keyed property 16335 * values of `object`. 16336 * 16337 * **Note:** Non-object values are coerced to objects. 16338 * 16339 * @static 16340 * @memberOf _ 16341 * @since 3.0.0 16342 * @category Object 16343 * @param {Object} object The object to query. 16344 * @returns {Array} Returns the array of property values. 16345 * @example 16346 * 16347 * function Foo() { 16348 * this.a = 1; 16349 * this.b = 2; 16350 * } 16351 * 16352 * Foo.prototype.c = 3; 16353 * 16354 * _.valuesIn(new Foo); 16355 * // => [1, 2, 3] (iteration order is not guaranteed) 16356 */ 16357 function valuesIn(object) { 16358 return object == null ? [] : baseValues(object, keysIn(object)); 16359 } 16360 16361 /*------------------------------------------------------------------------*/ 16362 16363 /** 16364 * Clamps `number` within the inclusive `lower` and `upper` bounds. 16365 * 16366 * @static 16367 * @memberOf _ 16368 * @since 4.0.0 16369 * @category Number 16370 * @param {number} number The number to clamp. 16371 * @param {number} [lower] The lower bound. 16372 * @param {number} upper The upper bound. 16373 * @returns {number} Returns the clamped number. 16374 * @example 16375 * 16376 * _.clamp(-10, -5, 5); 16377 * // => -5 16378 * 16379 * _.clamp(10, -5, 5); 16380 * // => 5 16381 */ 16382 function clamp(number, lower, upper) { 16383 if (upper === undefined) { 16384 upper = lower; 16385 lower = undefined; 16386 } 16387 if (upper !== undefined) { 16388 upper = toNumber(upper); 16389 upper = upper === upper ? upper : 0; 16390 } 16391 if (lower !== undefined) { 16392 lower = toNumber(lower); 16393 lower = lower === lower ? lower : 0; 16394 } 16395 return baseClamp(toNumber(number), lower, upper); 16396 } 16397 16398 /** 16399 * Checks if `n` is between `start` and up to, but not including, `end`. If 16400 * `end` is not specified, it's set to `start` with `start` then set to `0`. 16401 * If `start` is greater than `end` the params are swapped to support 16402 * negative ranges. 16403 * 16404 * @static 16405 * @memberOf _ 16406 * @since 3.3.0 16407 * @category Number 16408 * @param {number} number The number to check. 16409 * @param {number} [start=0] The start of the range. 16410 * @param {number} end The end of the range. 16411 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 16412 * @see _.range, _.rangeRight 16413 * @example 16414 * 16415 * _.inRange(3, 2, 4); 16416 * // => true 16417 * 16418 * _.inRange(4, 8); 16419 * // => true 16420 * 16421 * _.inRange(4, 2); 16422 * // => false 16423 * 16424 * _.inRange(2, 2); 16425 * // => false 16426 * 16427 * _.inRange(1.2, 2); 16428 * // => true 16429 * 16430 * _.inRange(5.2, 4); 16431 * // => false 16432 * 16433 * _.inRange(-3, -2, -6); 16434 * // => true 16435 */ 16436 function inRange(number, start, end) { 16437 start = toFinite(start); 16438 if (end === undefined) { 16439 end = start; 16440 start = 0; 16441 } else { 16442 end = toFinite(end); 16443 } 16444 number = toNumber(number); 16445 return baseInRange(number, start, end); 16446 } 16447 16448 /** 16449 * Produces a random number between the inclusive `lower` and `upper` bounds. 16450 * If only one argument is provided a number between `0` and the given number 16451 * is returned. If `floating` is `true`, or either `lower` or `upper` are 16452 * floats, a floating-point number is returned instead of an integer. 16453 * 16454 * **Note:** JavaScript follows the IEEE-754 standard for resolving 16455 * floating-point values which can produce unexpected results. 16456 * 16457 * @static 16458 * @memberOf _ 16459 * @since 0.7.0 16460 * @category Number 16461 * @param {number} [lower=0] The lower bound. 16462 * @param {number} [upper=1] The upper bound. 16463 * @param {boolean} [floating] Specify returning a floating-point number. 16464 * @returns {number} Returns the random number. 16465 * @example 16466 * 16467 * _.random(0, 5); 16468 * // => an integer between 0 and 5 16469 * 16470 * _.random(5); 16471 * // => also an integer between 0 and 5 16472 * 16473 * _.random(5, true); 16474 * // => a floating-point number between 0 and 5 16475 * 16476 * _.random(1.2, 5.2); 16477 * // => a floating-point number between 1.2 and 5.2 16478 */ 16479 function random(lower, upper, floating) { 16480 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 16481 upper = floating = undefined; 16482 } 16483 if (floating === undefined) { 16484 if (typeof upper == 'boolean') { 16485 floating = upper; 16486 upper = undefined; 16487 } 16488 else if (typeof lower == 'boolean') { 16489 floating = lower; 16490 lower = undefined; 16491 } 16492 } 16493 if (lower === undefined && upper === undefined) { 16494 lower = 0; 16495 upper = 1; 16496 } 16497 else { 16498 lower = toFinite(lower); 16499 if (upper === undefined) { 16500 upper = lower; 16501 lower = 0; 16502 } else { 16503 upper = toFinite(upper); 16504 } 16505 } 16506 if (lower > upper) { 16507 var temp = lower; 16508 lower = upper; 16509 upper = temp; 16510 } 16511 if (floating || lower % 1 || upper % 1) { 16512 var rand = nativeRandom(); 16513 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 16514 } 16515 return baseRandom(lower, upper); 16516 } 16517 16518 /*------------------------------------------------------------------------*/ 16519 16520 /** 16521 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 16522 * 16523 * @static 16524 * @memberOf _ 16525 * @since 3.0.0 16526 * @category String 16527 * @param {string} [string=''] The string to convert. 16528 * @returns {string} Returns the camel cased string. 16529 * @example 16530 * 16531 * _.camelCase('Foo Bar'); 16532 * // => 'fooBar' 16533 * 16534 * _.camelCase('--foo-bar--'); 16535 * // => 'fooBar' 16536 * 16537 * _.camelCase('__FOO_BAR__'); 16538 * // => 'fooBar' 16539 */ 16540 var camelCase = createCompounder(function(result, word, index) { 16541 word = word.toLowerCase(); 16542 return result + (index ? capitalize(word) : word); 16543 }); 16544 16545 /** 16546 * Converts the first character of `string` to upper case and the remaining 16547 * to lower case. 16548 * 16549 * @static 16550 * @memberOf _ 16551 * @since 3.0.0 16552 * @category String 16553 * @param {string} [string=''] The string to capitalize. 16554 * @returns {string} Returns the capitalized string. 16555 * @example 16556 * 16557 * _.capitalize('FRED'); 16558 * // => 'Fred' 16559 */ 16560 function capitalize(string) { 16561 return upperFirst(toString(string).toLowerCase()); 16562 } 16563 16564 /** 16565 * Deburrs `string` by converting 16566 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 16567 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 16568 * letters to basic Latin letters and removing 16569 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 16570 * 16571 * @static 16572 * @memberOf _ 16573 * @since 3.0.0 16574 * @category String 16575 * @param {string} [string=''] The string to deburr. 16576 * @returns {string} Returns the deburred string. 16577 * @example 16578 * 16579 * _.deburr('déjà vu'); 16580 * // => 'deja vu' 16581 */ 16582 function deburr(string) { 16583 string = toString(string); 16584 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 16585 } 16586 16587 /** 16588 * Checks if `string` ends with the given target string. 16589 * 16590 * @static 16591 * @memberOf _ 16592 * @since 3.0.0 16593 * @category String 16594 * @param {string} [string=''] The string to inspect. 16595 * @param {string} [target] The string to search for. 16596 * @param {number} [position=string.length] The position to search up to. 16597 * @returns {boolean} Returns `true` if `string` ends with `target`, 16598 * else `false`. 16599 * @example 16600 * 16601 * _.endsWith('abc', 'c'); 16602 * // => true 16603 * 16604 * _.endsWith('abc', 'b'); 16605 * // => false 16606 * 16607 * _.endsWith('abc', 'b', 2); 16608 * // => true 16609 */ 16610 function endsWith(string, target, position) { 16611 string = toString(string); 16612 target = baseToString(target); 16613 16614 var length = string.length; 16615 position = position === undefined 16616 ? length 16617 : baseClamp(toInteger(position), 0, length); 16618 16619 var end = position; 16620 position -= target.length; 16621 return position >= 0 && string.slice(position, end) == target; 16622 } 16623 16624 /** 16625 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 16626 * corresponding HTML entities. 16627 * 16628 * **Note:** No other characters are escaped. To escape additional 16629 * characters use a third-party library like [_he_](https://mths.be/he). 16630 * 16631 * Though the ">" character is escaped for symmetry, characters like 16632 * ">" and "/" don't need escaping in HTML and have no special meaning 16633 * unless they're part of a tag or unquoted attribute value. See 16634 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 16635 * (under "semi-related fun fact") for more details. 16636 * 16637 * When working with HTML you should always 16638 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 16639 * XSS vectors. 16640 * 16641 * @static 16642 * @since 0.1.0 16643 * @memberOf _ 16644 * @category String 16645 * @param {string} [string=''] The string to escape. 16646 * @returns {string} Returns the escaped string. 16647 * @example 16648 * 16649 * _.escape('fred, barney, & pebbles'); 16650 * // => 'fred, barney, & pebbles' 16651 */ 16652 function escape(string) { 16653 string = toString(string); 16654 return (string && reHasUnescapedHtml.test(string)) 16655 ? string.replace(reUnescapedHtml, escapeHtmlChar) 16656 : string; 16657 } 16658 16659 /** 16660 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 16661 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 16662 * 16663 * @static 16664 * @memberOf _ 16665 * @since 3.0.0 16666 * @category String 16667 * @param {string} [string=''] The string to escape. 16668 * @returns {string} Returns the escaped string. 16669 * @example 16670 * 16671 * _.escapeRegExp('[lodash](https://lodash.com/)'); 16672 * // => '\[lodash\]\(https://lodash\.com/\)' 16673 */ 16674 function escapeRegExp(string) { 16675 string = toString(string); 16676 return (string && reHasRegExpChar.test(string)) 16677 ? string.replace(reRegExpChar, '\\$&') 16678 : string; 16679 } 16680 16681 /** 16682 * Converts `string` to 16683 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 16684 * 16685 * @static 16686 * @memberOf _ 16687 * @since 3.0.0 16688 * @category String 16689 * @param {string} [string=''] The string to convert. 16690 * @returns {string} Returns the kebab cased string. 16691 * @example 16692 * 16693 * _.kebabCase('Foo Bar'); 16694 * // => 'foo-bar' 16695 * 16696 * _.kebabCase('fooBar'); 16697 * // => 'foo-bar' 16698 * 16699 * _.kebabCase('__FOO_BAR__'); 16700 * // => 'foo-bar' 16701 */ 16702 var kebabCase = createCompounder(function(result, word, index) { 16703 return result + (index ? '-' : '') + word.toLowerCase(); 16704 }); 16705 16706 /** 16707 * Converts `string`, as space separated words, to lower case. 16708 * 16709 * @static 16710 * @memberOf _ 16711 * @since 4.0.0 16712 * @category String 16713 * @param {string} [string=''] The string to convert. 16714 * @returns {string} Returns the lower cased string. 16715 * @example 16716 * 16717 * _.lowerCase('--Foo-Bar--'); 16718 * // => 'foo bar' 16719 * 16720 * _.lowerCase('fooBar'); 16721 * // => 'foo bar' 16722 * 16723 * _.lowerCase('__FOO_BAR__'); 16724 * // => 'foo bar' 16725 */ 16726 var lowerCase = createCompounder(function(result, word, index) { 16727 return result + (index ? ' ' : '') + word.toLowerCase(); 16728 }); 16729 16730 /** 16731 * Converts the first character of `string` to lower case. 16732 * 16733 * @static 16734 * @memberOf _ 16735 * @since 4.0.0 16736 * @category String 16737 * @param {string} [string=''] The string to convert. 16738 * @returns {string} Returns the converted string. 16739 * @example 16740 * 16741 * _.lowerFirst('Fred'); 16742 * // => 'fred' 16743 * 16744 * _.lowerFirst('FRED'); 16745 * // => 'fRED' 16746 */ 16747 var lowerFirst = createCaseFirst('toLowerCase'); 16748 16749 /** 16750 * Pads `string` on the left and right sides if it's shorter than `length`. 16751 * Padding characters are truncated if they can't be evenly divided by `length`. 16752 * 16753 * @static 16754 * @memberOf _ 16755 * @since 3.0.0 16756 * @category String 16757 * @param {string} [string=''] The string to pad. 16758 * @param {number} [length=0] The padding length. 16759 * @param {string} [chars=' '] The string used as padding. 16760 * @returns {string} Returns the padded string. 16761 * @example 16762 * 16763 * _.pad('abc', 8); 16764 * // => ' abc ' 16765 * 16766 * _.pad('abc', 8, '_-'); 16767 * // => '_-abc_-_' 16768 * 16769 * _.pad('abc', 3); 16770 * // => 'abc' 16771 */ 16772 function pad(string, length, chars) { 16773 string = toString(string); 16774 length = toInteger(length); 16775 16776 var strLength = length ? stringSize(string) : 0; 16777 if (!length || strLength >= length) { 16778 return string; 16779 } 16780 var mid = (length - strLength) / 2; 16781 return ( 16782 createPadding(nativeFloor(mid), chars) + 16783 string + 16784 createPadding(nativeCeil(mid), chars) 16785 ); 16786 } 16787 16788 /** 16789 * Pads `string` on the right side if it's shorter than `length`. Padding 16790 * characters are truncated if they exceed `length`. 16791 * 16792 * @static 16793 * @memberOf _ 16794 * @since 4.0.0 16795 * @category String 16796 * @param {string} [string=''] The string to pad. 16797 * @param {number} [length=0] The padding length. 16798 * @param {string} [chars=' '] The string used as padding. 16799 * @returns {string} Returns the padded string. 16800 * @example 16801 * 16802 * _.padEnd('abc', 6); 16803 * // => 'abc ' 16804 * 16805 * _.padEnd('abc', 6, '_-'); 16806 * // => 'abc_-_' 16807 * 16808 * _.padEnd('abc', 3); 16809 * // => 'abc' 16810 */ 16811 function padEnd(string, length, chars) { 16812 string = toString(string); 16813 length = toInteger(length); 16814 16815 var strLength = length ? stringSize(string) : 0; 16816 return (length && strLength < length) 16817 ? (string + createPadding(length - strLength, chars)) 16818 : string; 16819 } 16820 16821 /** 16822 * Pads `string` on the left side if it's shorter than `length`. Padding 16823 * characters are truncated if they exceed `length`. 16824 * 16825 * @static 16826 * @memberOf _ 16827 * @since 4.0.0 16828 * @category String 16829 * @param {string} [string=''] The string to pad. 16830 * @param {number} [length=0] The padding length. 16831 * @param {string} [chars=' '] The string used as padding. 16832 * @returns {string} Returns the padded string. 16833 * @example 16834 * 16835 * _.padStart('abc', 6); 16836 * // => ' abc' 16837 * 16838 * _.padStart('abc', 6, '_-'); 16839 * // => '_-_abc' 16840 * 16841 * _.padStart('abc', 3); 16842 * // => 'abc' 16843 */ 16844 function padStart(string, length, chars) { 16845 string = toString(string); 16846 length = toInteger(length); 16847 16848 var strLength = length ? stringSize(string) : 0; 16849 return (length && strLength < length) 16850 ? (createPadding(length - strLength, chars) + string) 16851 : string; 16852 } 16853 16854 /** 16855 * Converts `string` to an integer of the specified radix. If `radix` is 16856 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 16857 * hexadecimal, in which case a `radix` of `16` is used. 16858 * 16859 * **Note:** This method aligns with the 16860 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 16861 * 16862 * @static 16863 * @memberOf _ 16864 * @since 1.1.0 16865 * @category String 16866 * @param {string} string The string to convert. 16867 * @param {number} [radix=10] The radix to interpret `value` by. 16868 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16869 * @returns {number} Returns the converted integer. 16870 * @example 16871 * 16872 * _.parseInt('08'); 16873 * // => 8 16874 * 16875 * _.map(['6', '08', '10'], _.parseInt); 16876 * // => [6, 8, 10] 16877 */ 16878 function parseInt(string, radix, guard) { 16879 if (guard || radix == null) { 16880 radix = 0; 16881 } else if (radix) { 16882 radix = +radix; 16883 } 16884 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 16885 } 16886 16887 /** 16888 * Repeats the given string `n` times. 16889 * 16890 * @static 16891 * @memberOf _ 16892 * @since 3.0.0 16893 * @category String 16894 * @param {string} [string=''] The string to repeat. 16895 * @param {number} [n=1] The number of times to repeat the string. 16896 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16897 * @returns {string} Returns the repeated string. 16898 * @example 16899 * 16900 * _.repeat('*', 3); 16901 * // => '***' 16902 * 16903 * _.repeat('abc', 2); 16904 * // => 'abcabc' 16905 * 16906 * _.repeat('abc', 0); 16907 * // => '' 16908 */ 16909 function repeat(string, n, guard) { 16910 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 16911 n = 1; 16912 } else { 16913 n = toInteger(n); 16914 } 16915 return baseRepeat(toString(string), n); 16916 } 16917 16918 /** 16919 * Replaces matches for `pattern` in `string` with `replacement`. 16920 * 16921 * **Note:** This method is based on 16922 * [`String#replace`](https://mdn.io/String/replace). 16923 * 16924 * @static 16925 * @memberOf _ 16926 * @since 4.0.0 16927 * @category String 16928 * @param {string} [string=''] The string to modify. 16929 * @param {RegExp|string} pattern The pattern to replace. 16930 * @param {Function|string} replacement The match replacement. 16931 * @returns {string} Returns the modified string. 16932 * @example 16933 * 16934 * _.replace('Hi Fred', 'Fred', 'Barney'); 16935 * // => 'Hi Barney' 16936 */ 16937 function replace() { 16938 var args = arguments, 16939 string = toString(args[0]); 16940 16941 return args.length < 3 ? string : string.replace(args[1], args[2]); 16942 } 16943 16944 /** 16945 * Converts `string` to 16946 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 16947 * 16948 * @static 16949 * @memberOf _ 16950 * @since 3.0.0 16951 * @category String 16952 * @param {string} [string=''] The string to convert. 16953 * @returns {string} Returns the snake cased string. 16954 * @example 16955 * 16956 * _.snakeCase('Foo Bar'); 16957 * // => 'foo_bar' 16958 * 16959 * _.snakeCase('fooBar'); 16960 * // => 'foo_bar' 16961 * 16962 * _.snakeCase('--FOO-BAR--'); 16963 * // => 'foo_bar' 16964 */ 16965 var snakeCase = createCompounder(function(result, word, index) { 16966 return result + (index ? '_' : '') + word.toLowerCase(); 16967 }); 16968 16969 /** 16970 * Splits `string` by `separator`. 16971 * 16972 * **Note:** This method is based on 16973 * [`String#split`](https://mdn.io/String/split). 16974 * 16975 * @static 16976 * @memberOf _ 16977 * @since 4.0.0 16978 * @category String 16979 * @param {string} [string=''] The string to split. 16980 * @param {RegExp|string} separator The separator pattern to split by. 16981 * @param {number} [limit] The length to truncate results to. 16982 * @returns {Array} Returns the string segments. 16983 * @example 16984 * 16985 * _.split('a-b-c', '-', 2); 16986 * // => ['a', 'b'] 16987 */ 16988 function split(string, separator, limit) { 16989 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 16990 separator = limit = undefined; 16991 } 16992 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 16993 if (!limit) { 16994 return []; 16995 } 16996 string = toString(string); 16997 if (string && ( 16998 typeof separator == 'string' || 16999 (separator != null && !isRegExp(separator)) 17000 )) { 17001 separator = baseToString(separator); 17002 if (!separator && hasUnicode(string)) { 17003 return castSlice(stringToArray(string), 0, limit); 17004 } 17005 } 17006 return string.split(separator, limit); 17007 } 17008 17009 /** 17010 * Converts `string` to 17011 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 17012 * 17013 * @static 17014 * @memberOf _ 17015 * @since 3.1.0 17016 * @category String 17017 * @param {string} [string=''] The string to convert. 17018 * @returns {string} Returns the start cased string. 17019 * @example 17020 * 17021 * _.startCase('--foo-bar--'); 17022 * // => 'Foo Bar' 17023 * 17024 * _.startCase('fooBar'); 17025 * // => 'Foo Bar' 17026 * 17027 * _.startCase('__FOO_BAR__'); 17028 * // => 'FOO BAR' 17029 */ 17030 var startCase = createCompounder(function(result, word, index) { 17031 return result + (index ? ' ' : '') + upperFirst(word); 17032 }); 17033 17034 /** 17035 * Checks if `string` starts with the given target string. 17036 * 17037 * @static 17038 * @memberOf _ 17039 * @since 3.0.0 17040 * @category String 17041 * @param {string} [string=''] The string to inspect. 17042 * @param {string} [target] The string to search for. 17043 * @param {number} [position=0] The position to search from. 17044 * @returns {boolean} Returns `true` if `string` starts with `target`, 17045 * else `false`. 17046 * @example 17047 * 17048 * _.startsWith('abc', 'a'); 17049 * // => true 17050 * 17051 * _.startsWith('abc', 'b'); 17052 * // => false 17053 * 17054 * _.startsWith('abc', 'b', 1); 17055 * // => true 17056 */ 17057 function startsWith(string, target, position) { 17058 string = toString(string); 17059 position = position == null 17060 ? 0 17061 : baseClamp(toInteger(position), 0, string.length); 17062 17063 target = baseToString(target); 17064 return string.slice(position, position + target.length) == target; 17065 } 17066 17067 /** 17068 * Creates a compiled template function that can interpolate data properties 17069 * in "interpolate" delimiters, HTML-escape interpolated data properties in 17070 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 17071 * properties may be accessed as free variables in the template. If a setting 17072 * object is given, it takes precedence over `_.templateSettings` values. 17073 * 17074 * **Note:** In the development build `_.template` utilizes 17075 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 17076 * for easier debugging. 17077 * 17078 * For more information on precompiling templates see 17079 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 17080 * 17081 * For more information on Chrome extension sandboxes see 17082 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 17083 * 17084 * @static 17085 * @since 0.1.0 17086 * @memberOf _ 17087 * @category String 17088 * @param {string} [string=''] The template string. 17089 * @param {Object} [options={}] The options object. 17090 * @param {RegExp} [options.escape=_.templateSettings.escape] 17091 * The HTML "escape" delimiter. 17092 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 17093 * The "evaluate" delimiter. 17094 * @param {Object} [options.imports=_.templateSettings.imports] 17095 * An object to import into the template as free variables. 17096 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 17097 * The "interpolate" delimiter. 17098 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 17099 * The sourceURL of the compiled template. 17100 * @param {string} [options.variable='obj'] 17101 * The data object variable name. 17102 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17103 * @returns {Function} Returns the compiled template function. 17104 * @example 17105 * 17106 * // Use the "interpolate" delimiter to create a compiled template. 17107 * var compiled = _.template('hello <%= user %>!'); 17108 * compiled({ 'user': 'fred' }); 17109 * // => 'hello fred!' 17110 * 17111 * // Use the HTML "escape" delimiter to escape data property values. 17112 * var compiled = _.template('<b><%- value %></b>'); 17113 * compiled({ 'value': '<script>' }); 17114 * // => '<b><script></b>' 17115 * 17116 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 17117 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 17118 * compiled({ 'users': ['fred', 'barney'] }); 17119 * // => '<li>fred</li><li>barney</li>' 17120 * 17121 * // Use the internal `print` function in "evaluate" delimiters. 17122 * var compiled = _.template('<% print("hello " + user); %>!'); 17123 * compiled({ 'user': 'barney' }); 17124 * // => 'hello barney!' 17125 * 17126 * // Use the ES template literal delimiter as an "interpolate" delimiter. 17127 * // Disable support by replacing the "interpolate" delimiter. 17128 * var compiled = _.template('hello ${ user }!'); 17129 * compiled({ 'user': 'pebbles' }); 17130 * // => 'hello pebbles!' 17131 * 17132 * // Use backslashes to treat delimiters as plain text. 17133 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 17134 * compiled({ 'value': 'ignored' }); 17135 * // => '<%- value %>' 17136 * 17137 * // Use the `imports` option to import `jQuery` as `jq`. 17138 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 17139 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 17140 * compiled({ 'users': ['fred', 'barney'] }); 17141 * // => '<li>fred</li><li>barney</li>' 17142 * 17143 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 17144 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 17145 * compiled(data); 17146 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 17147 * 17148 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 17149 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 17150 * compiled.source; 17151 * // => function(data) { 17152 * // var __t, __p = ''; 17153 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 17154 * // return __p; 17155 * // } 17156 * 17157 * // Use custom template delimiters. 17158 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 17159 * var compiled = _.template('hello {{ user }}!'); 17160 * compiled({ 'user': 'mustache' }); 17161 * // => 'hello mustache!' 17162 * 17163 * // Use the `source` property to inline compiled templates for meaningful 17164 * // line numbers in error messages and stack traces. 17165 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 17166 * var JST = {\ 17167 * "main": ' + _.template(mainText).source + '\ 17168 * };\ 17169 * '); 17170 */ 17171 function template(string, options, guard) { 17172 // Based on John Resig's `tmpl` implementation 17173 // (http://ejohn.org/blog/javascript-micro-templating/) 17174 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 17175 var settings = lodash.templateSettings; 17176 17177 if (guard && isIterateeCall(string, options, guard)) { 17178 options = undefined; 17179 } 17180 string = toString(string); 17181 options = assignInWith({}, options, settings, customDefaultsAssignIn); 17182 17183 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 17184 importsKeys = keys(imports), 17185 importsValues = baseValues(imports, importsKeys); 17186 17187 var isEscaping, 17188 isEvaluating, 17189 index = 0, 17190 interpolate = options.interpolate || reNoMatch, 17191 source = "__p += '"; 17192 17193 // Compile the regexp to match each delimiter. 17194 var reDelimiters = RegExp( 17195 (options.escape || reNoMatch).source + '|' + 17196 interpolate.source + '|' + 17197 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 17198 (options.evaluate || reNoMatch).source + '|$' 17199 , 'g'); 17200 17201 // Use a sourceURL for easier debugging. 17202 var sourceURL = '//# sourceURL=' + 17203 ('sourceURL' in options 17204 ? options.sourceURL 17205 : ('lodash.templateSources[' + (++templateCounter) + ']') 17206 ) + '\n'; 17207 17208 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 17209 interpolateValue || (interpolateValue = esTemplateValue); 17210 17211 // Escape characters that can't be included in string literals. 17212 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 17213 17214 // Replace delimiters with snippets. 17215 if (escapeValue) { 17216 isEscaping = true; 17217 source += "' +\n__e(" + escapeValue + ") +\n'"; 17218 } 17219 if (evaluateValue) { 17220 isEvaluating = true; 17221 source += "';\n" + evaluateValue + ";\n__p += '"; 17222 } 17223 if (interpolateValue) { 17224 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 17225 } 17226 index = offset + match.length; 17227 17228 // The JS engine embedded in Adobe products needs `match` returned in 17229 // order to produce the correct `offset` value. 17230 return match; 17231 }); 17232 17233 source += "';\n"; 17234 17235 // If `variable` is not specified wrap a with-statement around the generated 17236 // code to add the data object to the top of the scope chain. 17237 var variable = options.variable; 17238 if (!variable) { 17239 source = 'with (obj) {\n' + source + '\n}\n'; 17240 } 17241 // Cleanup code by stripping empty strings. 17242 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 17243 .replace(reEmptyStringMiddle, '$1') 17244 .replace(reEmptyStringTrailing, '$1;'); 17245 17246 // Frame code as the function body. 17247 source = 'function(' + (variable || 'obj') + ') {\n' + 17248 (variable 17249 ? '' 17250 : 'obj || (obj = {});\n' 17251 ) + 17252 "var __t, __p = ''" + 17253 (isEscaping 17254 ? ', __e = _.escape' 17255 : '' 17256 ) + 17257 (isEvaluating 17258 ? ', __j = Array.prototype.join;\n' + 17259 "function print() { __p += __j.call(arguments, '') }\n" 17260 : ';\n' 17261 ) + 17262 source + 17263 'return __p\n}'; 17264 17265 var result = attempt(function() { 17266 return Function(importsKeys, sourceURL + 'return ' + source) 17267 .apply(undefined, importsValues); 17268 }); 17269 17270 // Provide the compiled function's source by its `toString` method or 17271 // the `source` property as a convenience for inlining compiled templates. 17272 result.source = source; 17273 if (isError(result)) { 17274 throw result; 17275 } 17276 return result; 17277 } 17278 17279 /** 17280 * Converts `string`, as a whole, to lower case just like 17281 * [String#toLowerCase](https://mdn.io/toLowerCase). 17282 * 17283 * @static 17284 * @memberOf _ 17285 * @since 4.0.0 17286 * @category String 17287 * @param {string} [string=''] The string to convert. 17288 * @returns {string} Returns the lower cased string. 17289 * @example 17290 * 17291 * _.toLower('--Foo-Bar--'); 17292 * // => '--foo-bar--' 17293 * 17294 * _.toLower('fooBar'); 17295 * // => 'foobar' 17296 * 17297 * _.toLower('__FOO_BAR__'); 17298 * // => '__foo_bar__' 17299 */ 17300 function toLower(value) { 17301 return toString(value).toLowerCase(); 17302 } 17303 17304 /** 17305 * Converts `string`, as a whole, to upper case just like 17306 * [String#toUpperCase](https://mdn.io/toUpperCase). 17307 * 17308 * @static 17309 * @memberOf _ 17310 * @since 4.0.0 17311 * @category String 17312 * @param {string} [string=''] The string to convert. 17313 * @returns {string} Returns the upper cased string. 17314 * @example 17315 * 17316 * _.toUpper('--foo-bar--'); 17317 * // => '--FOO-BAR--' 17318 * 17319 * _.toUpper('fooBar'); 17320 * // => 'FOOBAR' 17321 * 17322 * _.toUpper('__foo_bar__'); 17323 * // => '__FOO_BAR__' 17324 */ 17325 function toUpper(value) { 17326 return toString(value).toUpperCase(); 17327 } 17328 17329 /** 17330 * Removes leading and trailing whitespace or specified characters from `string`. 17331 * 17332 * @static 17333 * @memberOf _ 17334 * @since 3.0.0 17335 * @category String 17336 * @param {string} [string=''] The string to trim. 17337 * @param {string} [chars=whitespace] The characters to trim. 17338 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17339 * @returns {string} Returns the trimmed string. 17340 * @example 17341 * 17342 * _.trim(' abc '); 17343 * // => 'abc' 17344 * 17345 * _.trim('-_-abc-_-', '_-'); 17346 * // => 'abc' 17347 * 17348 * _.map([' foo ', ' bar '], _.trim); 17349 * // => ['foo', 'bar'] 17350 */ 17351 function trim(string, chars, guard) { 17352 string = toString(string); 17353 if (string && (guard || chars === undefined)) { 17354 return string.replace(reTrim, ''); 17355 } 17356 if (!string || !(chars = baseToString(chars))) { 17357 return string; 17358 } 17359 var strSymbols = stringToArray(string), 17360 chrSymbols = stringToArray(chars), 17361 start = charsStartIndex(strSymbols, chrSymbols), 17362 end = charsEndIndex(strSymbols, chrSymbols) + 1; 17363 17364 return castSlice(strSymbols, start, end).join(''); 17365 } 17366 17367 /** 17368 * Removes trailing whitespace or specified characters from `string`. 17369 * 17370 * @static 17371 * @memberOf _ 17372 * @since 4.0.0 17373 * @category String 17374 * @param {string} [string=''] The string to trim. 17375 * @param {string} [chars=whitespace] The characters to trim. 17376 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17377 * @returns {string} Returns the trimmed string. 17378 * @example 17379 * 17380 * _.trimEnd(' abc '); 17381 * // => ' abc' 17382 * 17383 * _.trimEnd('-_-abc-_-', '_-'); 17384 * // => '-_-abc' 17385 */ 17386 function trimEnd(string, chars, guard) { 17387 string = toString(string); 17388 if (string && (guard || chars === undefined)) { 17389 return string.replace(reTrimEnd, ''); 17390 } 17391 if (!string || !(chars = baseToString(chars))) { 17392 return string; 17393 } 17394 var strSymbols = stringToArray(string), 17395 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 17396 17397 return castSlice(strSymbols, 0, end).join(''); 17398 } 17399 17400 /** 17401 * Removes leading whitespace or specified characters from `string`. 17402 * 17403 * @static 17404 * @memberOf _ 17405 * @since 4.0.0 17406 * @category String 17407 * @param {string} [string=''] The string to trim. 17408 * @param {string} [chars=whitespace] The characters to trim. 17409 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17410 * @returns {string} Returns the trimmed string. 17411 * @example 17412 * 17413 * _.trimStart(' abc '); 17414 * // => 'abc ' 17415 * 17416 * _.trimStart('-_-abc-_-', '_-'); 17417 * // => 'abc-_-' 17418 */ 17419 function trimStart(string, chars, guard) { 17420 string = toString(string); 17421 if (string && (guard || chars === undefined)) { 17422 return string.replace(reTrimStart, ''); 17423 } 17424 if (!string || !(chars = baseToString(chars))) { 17425 return string; 17426 } 17427 var strSymbols = stringToArray(string), 17428 start = charsStartIndex(strSymbols, stringToArray(chars)); 17429 17430 return castSlice(strSymbols, start).join(''); 17431 } 17432 17433 /** 17434 * Truncates `string` if it's longer than the given maximum string length. 17435 * The last characters of the truncated string are replaced with the omission 17436 * string which defaults to "...". 17437 * 17438 * @static 17439 * @memberOf _ 17440 * @since 4.0.0 17441 * @category String 17442 * @param {string} [string=''] The string to truncate. 17443 * @param {Object} [options={}] The options object. 17444 * @param {number} [options.length=30] The maximum string length. 17445 * @param {string} [options.omission='...'] The string to indicate text is omitted. 17446 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 17447 * @returns {string} Returns the truncated string. 17448 * @example 17449 * 17450 * _.truncate('hi-diddly-ho there, neighborino'); 17451 * // => 'hi-diddly-ho there, neighbo...' 17452 * 17453 * _.truncate('hi-diddly-ho there, neighborino', { 17454 * 'length': 24, 17455 * 'separator': ' ' 17456 * }); 17457 * // => 'hi-diddly-ho there,...' 17458 * 17459 * _.truncate('hi-diddly-ho there, neighborino', { 17460 * 'length': 24, 17461 * 'separator': /,? +/ 17462 * }); 17463 * // => 'hi-diddly-ho there...' 17464 * 17465 * _.truncate('hi-diddly-ho there, neighborino', { 17466 * 'omission': ' [...]' 17467 * }); 17468 * // => 'hi-diddly-ho there, neig [...]' 17469 */ 17470 function truncate(string, options) { 17471 var length = DEFAULT_TRUNC_LENGTH, 17472 omission = DEFAULT_TRUNC_OMISSION; 17473 17474 if (isObject(options)) { 17475 var separator = 'separator' in options ? options.separator : separator; 17476 length = 'length' in options ? toInteger(options.length) : length; 17477 omission = 'omission' in options ? baseToString(options.omission) : omission; 17478 } 17479 string = toString(string); 17480 17481 var strLength = string.length; 17482 if (hasUnicode(string)) { 17483 var strSymbols = stringToArray(string); 17484 strLength = strSymbols.length; 17485 } 17486 if (length >= strLength) { 17487 return string; 17488 } 17489 var end = length - stringSize(omission); 17490 if (end < 1) { 17491 return omission; 17492 } 17493 var result = strSymbols 17494 ? castSlice(strSymbols, 0, end).join('') 17495 : string.slice(0, end); 17496 17497 if (separator === undefined) { 17498 return result + omission; 17499 } 17500 if (strSymbols) { 17501 end += (result.length - end); 17502 } 17503 if (isRegExp(separator)) { 17504 if (string.slice(end).search(separator)) { 17505 var match, 17506 substring = result; 17507 17508 if (!separator.global) { 17509 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 17510 } 17511 separator.lastIndex = 0; 17512 while ((match = separator.exec(substring))) { 17513 var newEnd = match.index; 17514 } 17515 result = result.slice(0, newEnd === undefined ? end : newEnd); 17516 } 17517 } else if (string.indexOf(baseToString(separator), end) != end) { 17518 var index = result.lastIndexOf(separator); 17519 if (index > -1) { 17520 result = result.slice(0, index); 17521 } 17522 } 17523 return result + omission; 17524 } 17525 17526 /** 17527 * The inverse of `_.escape`; this method converts the HTML entities 17528 * `&`, `<`, `>`, `"`, and `'` in `string` to 17529 * their corresponding characters. 17530 * 17531 * **Note:** No other HTML entities are unescaped. To unescape additional 17532 * HTML entities use a third-party library like [_he_](https://mths.be/he). 17533 * 17534 * @static 17535 * @memberOf _ 17536 * @since 0.6.0 17537 * @category String 17538 * @param {string} [string=''] The string to unescape. 17539 * @returns {string} Returns the unescaped string. 17540 * @example 17541 * 17542 * _.unescape('fred, barney, & pebbles'); 17543 * // => 'fred, barney, & pebbles' 17544 */ 17545 function unescape(string) { 17546 string = toString(string); 17547 return (string && reHasEscapedHtml.test(string)) 17548 ? string.replace(reEscapedHtml, unescapeHtmlChar) 17549 : string; 17550 } 17551 17552 /** 17553 * Converts `string`, as space separated words, to upper case. 17554 * 17555 * @static 17556 * @memberOf _ 17557 * @since 4.0.0 17558 * @category String 17559 * @param {string} [string=''] The string to convert. 17560 * @returns {string} Returns the upper cased string. 17561 * @example 17562 * 17563 * _.upperCase('--foo-bar'); 17564 * // => 'FOO BAR' 17565 * 17566 * _.upperCase('fooBar'); 17567 * // => 'FOO BAR' 17568 * 17569 * _.upperCase('__foo_bar__'); 17570 * // => 'FOO BAR' 17571 */ 17572 var upperCase = createCompounder(function(result, word, index) { 17573 return result + (index ? ' ' : '') + word.toUpperCase(); 17574 }); 17575 17576 /** 17577 * Converts the first character of `string` to upper case. 17578 * 17579 * @static 17580 * @memberOf _ 17581 * @since 4.0.0 17582 * @category String 17583 * @param {string} [string=''] The string to convert. 17584 * @returns {string} Returns the converted string. 17585 * @example 17586 * 17587 * _.upperFirst('fred'); 17588 * // => 'Fred' 17589 * 17590 * _.upperFirst('FRED'); 17591 * // => 'FRED' 17592 */ 17593 var upperFirst = createCaseFirst('toUpperCase'); 17594 17595 /** 17596 * Splits `string` into an array of its words. 17597 * 17598 * @static 17599 * @memberOf _ 17600 * @since 3.0.0 17601 * @category String 17602 * @param {string} [string=''] The string to inspect. 17603 * @param {RegExp|string} [pattern] The pattern to match words. 17604 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17605 * @returns {Array} Returns the words of `string`. 17606 * @example 17607 * 17608 * _.words('fred, barney, & pebbles'); 17609 * // => ['fred', 'barney', 'pebbles'] 17610 * 17611 * _.words('fred, barney, & pebbles', /[^, ]+/g); 17612 * // => ['fred', 'barney', '&', 'pebbles'] 17613 */ 17614 function words(string, pattern, guard) { 17615 string = toString(string); 17616 pattern = guard ? undefined : pattern; 17617 17618 if (pattern === undefined) { 17619 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 17620 } 17621 return string.match(pattern) || []; 17622 } 17623 17624 /*------------------------------------------------------------------------*/ 17625 17626 /** 17627 * Attempts to invoke `func`, returning either the result or the caught error 17628 * object. Any additional arguments are provided to `func` when it's invoked. 17629 * 17630 * @static 17631 * @memberOf _ 17632 * @since 3.0.0 17633 * @category Util 17634 * @param {Function} func The function to attempt. 17635 * @param {...*} [args] The arguments to invoke `func` with. 17636 * @returns {*} Returns the `func` result or error object. 17637 * @example 17638 * 17639 * // Avoid throwing errors for invalid selectors. 17640 * var elements = _.attempt(function(selector) { 17641 * return document.querySelectorAll(selector); 17642 * }, '>_>'); 17643 * 17644 * if (_.isError(elements)) { 17645 * elements = []; 17646 * } 17647 */ 17648 var attempt = baseRest(function(func, args) { 17649 try { 17650 return apply(func, undefined, args); 17651 } catch (e) { 17652 return isError(e) ? e : new Error(e); 17653 } 17654 }); 17655 17656 /** 17657 * Binds methods of an object to the object itself, overwriting the existing 17658 * method. 17659 * 17660 * **Note:** This method doesn't set the "length" property of bound functions. 17661 * 17662 * @static 17663 * @since 0.1.0 17664 * @memberOf _ 17665 * @category Util 17666 * @param {Object} object The object to bind and assign the bound methods to. 17667 * @param {...(string|string[])} methodNames The object method names to bind. 17668 * @returns {Object} Returns `object`. 17669 * @example 17670 * 17671 * var view = { 17672 * 'label': 'docs', 17673 * 'click': function() { 17674 * console.log('clicked ' + this.label); 17675 * } 17676 * }; 17677 * 17678 * _.bindAll(view, ['click']); 17679 * jQuery(element).on('click', view.click); 17680 * // => Logs 'clicked docs' when clicked. 17681 */ 17682 var bindAll = flatRest(function(object, methodNames) { 17683 arrayEach(methodNames, function(key) { 17684 key = toKey(key); 17685 baseAssignValue(object, key, bind(object[key], object)); 17686 }); 17687 return object; 17688 }); 17689 17690 /** 17691 * Creates a function that iterates over `pairs` and invokes the corresponding 17692 * function of the first predicate to return truthy. The predicate-function 17693 * pairs are invoked with the `this` binding and arguments of the created 17694 * function. 17695 * 17696 * @static 17697 * @memberOf _ 17698 * @since 4.0.0 17699 * @category Util 17700 * @param {Array} pairs The predicate-function pairs. 17701 * @returns {Function} Returns the new composite function. 17702 * @example 17703 * 17704 * var func = _.cond([ 17705 * [_.matches({ 'a': 1 }), _.constant('matches A')], 17706 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 17707 * [_.stubTrue, _.constant('no match')] 17708 * ]); 17709 * 17710 * func({ 'a': 1, 'b': 2 }); 17711 * // => 'matches A' 17712 * 17713 * func({ 'a': 0, 'b': 1 }); 17714 * // => 'matches B' 17715 * 17716 * func({ 'a': '1', 'b': '2' }); 17717 * // => 'no match' 17718 */ 17719 function cond(pairs) { 17720 var length = pairs == null ? 0 : pairs.length, 17721 toIteratee = getIteratee(); 17722 17723 pairs = !length ? [] : arrayMap(pairs, function(pair) { 17724 if (typeof pair[1] != 'function') { 17725 throw new TypeError(FUNC_ERROR_TEXT); 17726 } 17727 return [toIteratee(pair[0]), pair[1]]; 17728 }); 17729 17730 return baseRest(function(args) { 17731 var index = -1; 17732 while (++index < length) { 17733 var pair = pairs[index]; 17734 if (apply(pair[0], this, args)) { 17735 return apply(pair[1], this, args); 17736 } 17737 } 17738 }); 17739 } 17740 17741 /** 17742 * Creates a function that invokes the predicate properties of `source` with 17743 * the corresponding property values of a given object, returning `true` if 17744 * all predicates return truthy, else `false`. 17745 * 17746 * **Note:** The created function is equivalent to `_.conformsTo` with 17747 * `source` partially applied. 17748 * 17749 * @static 17750 * @memberOf _ 17751 * @since 4.0.0 17752 * @category Util 17753 * @param {Object} source The object of property predicates to conform to. 17754 * @returns {Function} Returns the new spec function. 17755 * @example 17756 * 17757 * var objects = [ 17758 * { 'a': 2, 'b': 1 }, 17759 * { 'a': 1, 'b': 2 } 17760 * ]; 17761 * 17762 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 17763 * // => [{ 'a': 1, 'b': 2 }] 17764 */ 17765 function conforms(source) { 17766 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 17767 } 17768 17769 /** 17770 * Creates a function that returns `value`. 17771 * 17772 * @static 17773 * @memberOf _ 17774 * @since 2.4.0 17775 * @category Util 17776 * @param {*} value The value to return from the new function. 17777 * @returns {Function} Returns the new constant function. 17778 * @example 17779 * 17780 * var objects = _.times(2, _.constant({ 'a': 1 })); 17781 * 17782 * console.log(objects); 17783 * // => [{ 'a': 1 }, { 'a': 1 }] 17784 * 17785 * console.log(objects[0] === objects[1]); 17786 * // => true 17787 */ 17788 function constant(value) { 17789 return function() { 17790 return value; 17791 }; 17792 } 17793 17794 /** 17795 * Checks `value` to determine whether a default value should be returned in 17796 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 17797 * or `undefined`. 17798 * 17799 * @static 17800 * @memberOf _ 17801 * @since 4.14.0 17802 * @category Util 17803 * @param {*} value The value to check. 17804 * @param {*} defaultValue The default value. 17805 * @returns {*} Returns the resolved value. 17806 * @example 17807 * 17808 * _.defaultTo(1, 10); 17809 * // => 1 17810 * 17811 * _.defaultTo(undefined, 10); 17812 * // => 10 17813 */ 17814 function defaultTo(value, defaultValue) { 17815 return (value == null || value !== value) ? defaultValue : value; 17816 } 17817 17818 /** 17819 * Creates a function that returns the result of invoking the given functions 17820 * with the `this` binding of the created function, where each successive 17821 * invocation is supplied the return value of the previous. 17822 * 17823 * @static 17824 * @memberOf _ 17825 * @since 3.0.0 17826 * @category Util 17827 * @param {...(Function|Function[])} [funcs] The functions to invoke. 17828 * @returns {Function} Returns the new composite function. 17829 * @see _.flowRight 17830 * @example 17831 * 17832 * function square(n) { 17833 * return n * n; 17834 * } 17835 * 17836 * var addSquare = _.flow([_.add, square]); 17837 * addSquare(1, 2); 17838 * // => 9 17839 */ 17840 var flow = createFlow(); 17841 17842 /** 17843 * This method is like `_.flow` except that it creates a function that 17844 * invokes the given functions from right to left. 17845 * 17846 * @static 17847 * @since 3.0.0 17848 * @memberOf _ 17849 * @category Util 17850 * @param {...(Function|Function[])} [funcs] The functions to invoke. 17851 * @returns {Function} Returns the new composite function. 17852 * @see _.flow 17853 * @example 17854 * 17855 * function square(n) { 17856 * return n * n; 17857 * } 17858 * 17859 * var addSquare = _.flowRight([square, _.add]); 17860 * addSquare(1, 2); 17861 * // => 9 17862 */ 17863 var flowRight = createFlow(true); 17864 17865 /** 17866 * This method returns the first argument it receives. 17867 * 17868 * @static 17869 * @since 0.1.0 17870 * @memberOf _ 17871 * @category Util 17872 * @param {*} value Any value. 17873 * @returns {*} Returns `value`. 17874 * @example 17875 * 17876 * var object = { 'a': 1 }; 17877 * 17878 * console.log(_.identity(object) === object); 17879 * // => true 17880 */ 17881 function identity(value) { 17882 return value; 17883 } 17884 17885 /** 17886 * Creates a function that invokes `func` with the arguments of the created 17887 * function. If `func` is a property name, the created function returns the 17888 * property value for a given element. If `func` is an array or object, the 17889 * created function returns `true` for elements that contain the equivalent 17890 * source properties, otherwise it returns `false`. 17891 * 17892 * @static 17893 * @since 4.0.0 17894 * @memberOf _ 17895 * @category Util 17896 * @param {*} [func=_.identity] The value to convert to a callback. 17897 * @returns {Function} Returns the callback. 17898 * @example 17899 * 17900 * var users = [ 17901 * { 'user': 'barney', 'age': 36, 'active': true }, 17902 * { 'user': 'fred', 'age': 40, 'active': false } 17903 * ]; 17904 * 17905 * // The `_.matches` iteratee shorthand. 17906 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 17907 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 17908 * 17909 * // The `_.matchesProperty` iteratee shorthand. 17910 * _.filter(users, _.iteratee(['user', 'fred'])); 17911 * // => [{ 'user': 'fred', 'age': 40 }] 17912 * 17913 * // The `_.property` iteratee shorthand. 17914 * _.map(users, _.iteratee('user')); 17915 * // => ['barney', 'fred'] 17916 * 17917 * // Create custom iteratee shorthands. 17918 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 17919 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 17920 * return func.test(string); 17921 * }; 17922 * }); 17923 * 17924 * _.filter(['abc', 'def'], /ef/); 17925 * // => ['def'] 17926 */ 17927 function iteratee(func) { 17928 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 17929 } 17930 17931 /** 17932 * Creates a function that performs a partial deep comparison between a given 17933 * object and `source`, returning `true` if the given object has equivalent 17934 * property values, else `false`. 17935 * 17936 * **Note:** The created function is equivalent to `_.isMatch` with `source` 17937 * partially applied. 17938 * 17939 * Partial comparisons will match empty array and empty object `source` 17940 * values against any array or object value, respectively. See `_.isEqual` 17941 * for a list of supported value comparisons. 17942 * 17943 * @static 17944 * @memberOf _ 17945 * @since 3.0.0 17946 * @category Util 17947 * @param {Object} source The object of property values to match. 17948 * @returns {Function} Returns the new spec function. 17949 * @example 17950 * 17951 * var objects = [ 17952 * { 'a': 1, 'b': 2, 'c': 3 }, 17953 * { 'a': 4, 'b': 5, 'c': 6 } 17954 * ]; 17955 * 17956 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 17957 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 17958 */ 17959 function matches(source) { 17960 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 17961 } 17962 17963 /** 17964 * Creates a function that performs a partial deep comparison between the 17965 * value at `path` of a given object to `srcValue`, returning `true` if the 17966 * object value is equivalent, else `false`. 17967 * 17968 * **Note:** Partial comparisons will match empty array and empty object 17969 * `srcValue` values against any array or object value, respectively. See 17970 * `_.isEqual` for a list of supported value comparisons. 17971 * 17972 * @static 17973 * @memberOf _ 17974 * @since 3.2.0 17975 * @category Util 17976 * @param {Array|string} path The path of the property to get. 17977 * @param {*} srcValue The value to match. 17978 * @returns {Function} Returns the new spec function. 17979 * @example 17980 * 17981 * var objects = [ 17982 * { 'a': 1, 'b': 2, 'c': 3 }, 17983 * { 'a': 4, 'b': 5, 'c': 6 } 17984 * ]; 17985 * 17986 * _.find(objects, _.matchesProperty('a', 4)); 17987 * // => { 'a': 4, 'b': 5, 'c': 6 } 17988 */ 17989 function matchesProperty(path, srcValue) { 17990 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 17991 } 17992 17993 /** 17994 * Creates a function that invokes the method at `path` of a given object. 17995 * Any additional arguments are provided to the invoked method. 17996 * 17997 * @static 17998 * @memberOf _ 17999 * @since 3.7.0 18000 * @category Util 18001 * @param {Array|string} path The path of the method to invoke. 18002 * @param {...*} [args] The arguments to invoke the method with. 18003 * @returns {Function} Returns the new invoker function. 18004 * @example 18005 * 18006 * var objects = [ 18007 * { 'a': { 'b': _.constant(2) } }, 18008 * { 'a': { 'b': _.constant(1) } } 18009 * ]; 18010 * 18011 * _.map(objects, _.method('a.b')); 18012 * // => [2, 1] 18013 * 18014 * _.map(objects, _.method(['a', 'b'])); 18015 * // => [2, 1] 18016 */ 18017 var method = baseRest(function(path, args) { 18018 return function(object) { 18019 return baseInvoke(object, path, args); 18020 }; 18021 }); 18022 18023 /** 18024 * The opposite of `_.method`; this method creates a function that invokes 18025 * the method at a given path of `object`. Any additional arguments are 18026 * provided to the invoked method. 18027 * 18028 * @static 18029 * @memberOf _ 18030 * @since 3.7.0 18031 * @category Util 18032 * @param {Object} object The object to query. 18033 * @param {...*} [args] The arguments to invoke the method with. 18034 * @returns {Function} Returns the new invoker function. 18035 * @example 18036 * 18037 * var array = _.times(3, _.constant), 18038 * object = { 'a': array, 'b': array, 'c': array }; 18039 * 18040 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 18041 * // => [2, 0] 18042 * 18043 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 18044 * // => [2, 0] 18045 */ 18046 var methodOf = baseRest(function(object, args) { 18047 return function(path) { 18048 return baseInvoke(object, path, args); 18049 }; 18050 }); 18051 18052 /** 18053 * Adds all own enumerable string keyed function properties of a source 18054 * object to the destination object. If `object` is a function, then methods 18055 * are added to its prototype as well. 18056 * 18057 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 18058 * avoid conflicts caused by modifying the original. 18059 * 18060 * @static 18061 * @since 0.1.0 18062 * @memberOf _ 18063 * @category Util 18064 * @param {Function|Object} [object=lodash] The destination object. 18065 * @param {Object} source The object of functions to add. 18066 * @param {Object} [options={}] The options object. 18067 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 18068 * @returns {Function|Object} Returns `object`. 18069 * @example 18070 * 18071 * function vowels(string) { 18072 * return _.filter(string, function(v) { 18073 * return /[aeiou]/i.test(v); 18074 * }); 18075 * } 18076 * 18077 * _.mixin({ 'vowels': vowels }); 18078 * _.vowels('fred'); 18079 * // => ['e'] 18080 * 18081 * _('fred').vowels().value(); 18082 * // => ['e'] 18083 * 18084 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 18085 * _('fred').vowels(); 18086 * // => ['e'] 18087 */ 18088 function mixin(object, source, options) { 18089 var props = keys(source), 18090 methodNames = baseFunctions(source, props); 18091 18092 if (options == null && 18093 !(isObject(source) && (methodNames.length || !props.length))) { 18094 options = source; 18095 source = object; 18096 object = this; 18097 methodNames = baseFunctions(source, keys(source)); 18098 } 18099 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 18100 isFunc = isFunction(object); 18101 18102 arrayEach(methodNames, function(methodName) { 18103 var func = source[methodName]; 18104 object[methodName] = func; 18105 if (isFunc) { 18106 object.prototype[methodName] = function() { 18107 var chainAll = this.__chain__; 18108 if (chain || chainAll) { 18109 var result = object(this.__wrapped__), 18110 actions = result.__actions__ = copyArray(this.__actions__); 18111 18112 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 18113 result.__chain__ = chainAll; 18114 return result; 18115 } 18116 return func.apply(object, arrayPush([this.value()], arguments)); 18117 }; 18118 } 18119 }); 18120 18121 return object; 18122 } 18123 18124 /** 18125 * Reverts the `_` variable to its previous value and returns a reference to 18126 * the `lodash` function. 18127 * 18128 * @static 18129 * @since 0.1.0 18130 * @memberOf _ 18131 * @category Util 18132 * @returns {Function} Returns the `lodash` function. 18133 * @example 18134 * 18135 * var lodash = _.noConflict(); 18136 */ 18137 function noConflict() { 18138 if (root._ === this) { 18139 root._ = oldDash; 18140 } 18141 return this; 18142 } 18143 18144 /** 18145 * This method returns `undefined`. 18146 * 18147 * @static 18148 * @memberOf _ 18149 * @since 2.3.0 18150 * @category Util 18151 * @example 18152 * 18153 * _.times(2, _.noop); 18154 * // => [undefined, undefined] 18155 */ 18156 function noop() { 18157 // No operation performed. 18158 } 18159 18160 /** 18161 * Creates a function that gets the argument at index `n`. If `n` is negative, 18162 * the nth argument from the end is returned. 18163 * 18164 * @static 18165 * @memberOf _ 18166 * @since 4.0.0 18167 * @category Util 18168 * @param {number} [n=0] The index of the argument to return. 18169 * @returns {Function} Returns the new pass-thru function. 18170 * @example 18171 * 18172 * var func = _.nthArg(1); 18173 * func('a', 'b', 'c', 'd'); 18174 * // => 'b' 18175 * 18176 * var func = _.nthArg(-2); 18177 * func('a', 'b', 'c', 'd'); 18178 * // => 'c' 18179 */ 18180 function nthArg(n) { 18181 n = toInteger(n); 18182 return baseRest(function(args) { 18183 return baseNth(args, n); 18184 }); 18185 } 18186 18187 /** 18188 * Creates a function that invokes `iteratees` with the arguments it receives 18189 * and returns their results. 18190 * 18191 * @static 18192 * @memberOf _ 18193 * @since 4.0.0 18194 * @category Util 18195 * @param {...(Function|Function[])} [iteratees=[_.identity]] 18196 * The iteratees to invoke. 18197 * @returns {Function} Returns the new function. 18198 * @example 18199 * 18200 * var func = _.over([Math.max, Math.min]); 18201 * 18202 * func(1, 2, 3, 4); 18203 * // => [4, 1] 18204 */ 18205 var over = createOver(arrayMap); 18206 18207 /** 18208 * Creates a function that checks if **all** of the `predicates` return 18209 * truthy when invoked with the arguments it receives. 18210 * 18211 * @static 18212 * @memberOf _ 18213 * @since 4.0.0 18214 * @category Util 18215 * @param {...(Function|Function[])} [predicates=[_.identity]] 18216 * The predicates to check. 18217 * @returns {Function} Returns the new function. 18218 * @example 18219 * 18220 * var func = _.overEvery([Boolean, isFinite]); 18221 * 18222 * func('1'); 18223 * // => true 18224 * 18225 * func(null); 18226 * // => false 18227 * 18228 * func(NaN); 18229 * // => false 18230 */ 18231 var overEvery = createOver(arrayEvery); 18232 18233 /** 18234 * Creates a function that checks if **any** of the `predicates` return 18235 * truthy when invoked with the arguments it receives. 18236 * 18237 * @static 18238 * @memberOf _ 18239 * @since 4.0.0 18240 * @category Util 18241 * @param {...(Function|Function[])} [predicates=[_.identity]] 18242 * The predicates to check. 18243 * @returns {Function} Returns the new function. 18244 * @example 18245 * 18246 * var func = _.overSome([Boolean, isFinite]); 18247 * 18248 * func('1'); 18249 * // => true 18250 * 18251 * func(null); 18252 * // => true 18253 * 18254 * func(NaN); 18255 * // => false 18256 */ 18257 var overSome = createOver(arraySome); 18258 18259 /** 18260 * Creates a function that returns the value at `path` of a given object. 18261 * 18262 * @static 18263 * @memberOf _ 18264 * @since 2.4.0 18265 * @category Util 18266 * @param {Array|string} path The path of the property to get. 18267 * @returns {Function} Returns the new accessor function. 18268 * @example 18269 * 18270 * var objects = [ 18271 * { 'a': { 'b': 2 } }, 18272 * { 'a': { 'b': 1 } } 18273 * ]; 18274 * 18275 * _.map(objects, _.property('a.b')); 18276 * // => [2, 1] 18277 * 18278 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 18279 * // => [1, 2] 18280 */ 18281 function property(path) { 18282 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 18283 } 18284 18285 /** 18286 * The opposite of `_.property`; this method creates a function that returns 18287 * the value at a given path of `object`. 18288 * 18289 * @static 18290 * @memberOf _ 18291 * @since 3.0.0 18292 * @category Util 18293 * @param {Object} object The object to query. 18294 * @returns {Function} Returns the new accessor function. 18295 * @example 18296 * 18297 * var array = [0, 1, 2], 18298 * object = { 'a': array, 'b': array, 'c': array }; 18299 * 18300 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 18301 * // => [2, 0] 18302 * 18303 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 18304 * // => [2, 0] 18305 */ 18306 function propertyOf(object) { 18307 return function(path) { 18308 return object == null ? undefined : baseGet(object, path); 18309 }; 18310 } 18311 18312 /** 18313 * Creates an array of numbers (positive and/or negative) progressing from 18314 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 18315 * `start` is specified without an `end` or `step`. If `end` is not specified, 18316 * it's set to `start` with `start` then set to `0`. 18317 * 18318 * **Note:** JavaScript follows the IEEE-754 standard for resolving 18319 * floating-point values which can produce unexpected results. 18320 * 18321 * @static 18322 * @since 0.1.0 18323 * @memberOf _ 18324 * @category Util 18325 * @param {number} [start=0] The start of the range. 18326 * @param {number} end The end of the range. 18327 * @param {number} [step=1] The value to increment or decrement by. 18328 * @returns {Array} Returns the range of numbers. 18329 * @see _.inRange, _.rangeRight 18330 * @example 18331 * 18332 * _.range(4); 18333 * // => [0, 1, 2, 3] 18334 * 18335 * _.range(-4); 18336 * // => [0, -1, -2, -3] 18337 * 18338 * _.range(1, 5); 18339 * // => [1, 2, 3, 4] 18340 * 18341 * _.range(0, 20, 5); 18342 * // => [0, 5, 10, 15] 18343 * 18344 * _.range(0, -4, -1); 18345 * // => [0, -1, -2, -3] 18346 * 18347 * _.range(1, 4, 0); 18348 * // => [1, 1, 1] 18349 * 18350 * _.range(0); 18351 * // => [] 18352 */ 18353 var range = createRange(); 18354 18355 /** 18356 * This method is like `_.range` except that it populates values in 18357 * descending order. 18358 * 18359 * @static 18360 * @memberOf _ 18361 * @since 4.0.0 18362 * @category Util 18363 * @param {number} [start=0] The start of the range. 18364 * @param {number} end The end of the range. 18365 * @param {number} [step=1] The value to increment or decrement by. 18366 * @returns {Array} Returns the range of numbers. 18367 * @see _.inRange, _.range 18368 * @example 18369 * 18370 * _.rangeRight(4); 18371 * // => [3, 2, 1, 0] 18372 * 18373 * _.rangeRight(-4); 18374 * // => [-3, -2, -1, 0] 18375 * 18376 * _.rangeRight(1, 5); 18377 * // => [4, 3, 2, 1] 18378 * 18379 * _.rangeRight(0, 20, 5); 18380 * // => [15, 10, 5, 0] 18381 * 18382 * _.rangeRight(0, -4, -1); 18383 * // => [-3, -2, -1, 0] 18384 * 18385 * _.rangeRight(1, 4, 0); 18386 * // => [1, 1, 1] 18387 * 18388 * _.rangeRight(0); 18389 * // => [] 18390 */ 18391 var rangeRight = createRange(true); 18392 18393 /** 18394 * This method returns a new empty array. 18395 * 18396 * @static 18397 * @memberOf _ 18398 * @since 4.13.0 18399 * @category Util 18400 * @returns {Array} Returns the new empty array. 18401 * @example 18402 * 18403 * var arrays = _.times(2, _.stubArray); 18404 * 18405 * console.log(arrays); 18406 * // => [[], []] 18407 * 18408 * console.log(arrays[0] === arrays[1]); 18409 * // => false 18410 */ 18411 function stubArray() { 18412 return []; 18413 } 18414 18415 /** 18416 * This method returns `false`. 18417 * 18418 * @static 18419 * @memberOf _ 18420 * @since 4.13.0 18421 * @category Util 18422 * @returns {boolean} Returns `false`. 18423 * @example 18424 * 18425 * _.times(2, _.stubFalse); 18426 * // => [false, false] 18427 */ 18428 function stubFalse() { 18429 return false; 18430 } 18431 18432 /** 18433 * This method returns a new empty object. 18434 * 18435 * @static 18436 * @memberOf _ 18437 * @since 4.13.0 18438 * @category Util 18439 * @returns {Object} Returns the new empty object. 18440 * @example 18441 * 18442 * var objects = _.times(2, _.stubObject); 18443 * 18444 * console.log(objects); 18445 * // => [{}, {}] 18446 * 18447 * console.log(objects[0] === objects[1]); 18448 * // => false 18449 */ 18450 function stubObject() { 18451 return {}; 18452 } 18453 18454 /** 18455 * This method returns an empty string. 18456 * 18457 * @static 18458 * @memberOf _ 18459 * @since 4.13.0 18460 * @category Util 18461 * @returns {string} Returns the empty string. 18462 * @example 18463 * 18464 * _.times(2, _.stubString); 18465 * // => ['', ''] 18466 */ 18467 function stubString() { 18468 return ''; 18469 } 18470 18471 /** 18472 * This method returns `true`. 18473 * 18474 * @static 18475 * @memberOf _ 18476 * @since 4.13.0 18477 * @category Util 18478 * @returns {boolean} Returns `true`. 18479 * @example 18480 * 18481 * _.times(2, _.stubTrue); 18482 * // => [true, true] 18483 */ 18484 function stubTrue() { 18485 return true; 18486 } 18487 18488 /** 18489 * Invokes the iteratee `n` times, returning an array of the results of 18490 * each invocation. The iteratee is invoked with one argument; (index). 18491 * 18492 * @static 18493 * @since 0.1.0 18494 * @memberOf _ 18495 * @category Util 18496 * @param {number} n The number of times to invoke `iteratee`. 18497 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18498 * @returns {Array} Returns the array of results. 18499 * @example 18500 * 18501 * _.times(3, String); 18502 * // => ['0', '1', '2'] 18503 * 18504 * _.times(4, _.constant(0)); 18505 * // => [0, 0, 0, 0] 18506 */ 18507 function times(n, iteratee) { 18508 n = toInteger(n); 18509 if (n < 1 || n > MAX_SAFE_INTEGER) { 18510 return []; 18511 } 18512 var index = MAX_ARRAY_LENGTH, 18513 length = nativeMin(n, MAX_ARRAY_LENGTH); 18514 18515 iteratee = getIteratee(iteratee); 18516 n -= MAX_ARRAY_LENGTH; 18517 18518 var result = baseTimes(length, iteratee); 18519 while (++index < n) { 18520 iteratee(index); 18521 } 18522 return result; 18523 } 18524 18525 /** 18526 * Converts `value` to a property path array. 18527 * 18528 * @static 18529 * @memberOf _ 18530 * @since 4.0.0 18531 * @category Util 18532 * @param {*} value The value to convert. 18533 * @returns {Array} Returns the new property path array. 18534 * @example 18535 * 18536 * _.toPath('a.b.c'); 18537 * // => ['a', 'b', 'c'] 18538 * 18539 * _.toPath('a[0].b.c'); 18540 * // => ['a', '0', 'b', 'c'] 18541 */ 18542 function toPath(value) { 18543 if (isArray(value)) { 18544 return arrayMap(value, toKey); 18545 } 18546 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 18547 } 18548 18549 /** 18550 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 18551 * 18552 * @static 18553 * @since 0.1.0 18554 * @memberOf _ 18555 * @category Util 18556 * @param {string} [prefix=''] The value to prefix the ID with. 18557 * @returns {string} Returns the unique ID. 18558 * @example 18559 * 18560 * _.uniqueId('contact_'); 18561 * // => 'contact_104' 18562 * 18563 * _.uniqueId(); 18564 * // => '105' 18565 */ 18566 function uniqueId(prefix) { 18567 var id = ++idCounter; 18568 return toString(prefix) + id; 18569 } 18570 18571 /*------------------------------------------------------------------------*/ 18572 18573 /** 18574 * Adds two numbers. 18575 * 18576 * @static 18577 * @memberOf _ 18578 * @since 3.4.0 18579 * @category Math 18580 * @param {number} augend The first number in an addition. 18581 * @param {number} addend The second number in an addition. 18582 * @returns {number} Returns the total. 18583 * @example 18584 * 18585 * _.add(6, 4); 18586 * // => 10 18587 */ 18588 var add = createMathOperation(function(augend, addend) { 18589 return augend + addend; 18590 }, 0); 18591 18592 /** 18593 * Computes `number` rounded up to `precision`. 18594 * 18595 * @static 18596 * @memberOf _ 18597 * @since 3.10.0 18598 * @category Math 18599 * @param {number} number The number to round up. 18600 * @param {number} [precision=0] The precision to round up to. 18601 * @returns {number} Returns the rounded up number. 18602 * @example 18603 * 18604 * _.ceil(4.006); 18605 * // => 5 18606 * 18607 * _.ceil(6.004, 2); 18608 * // => 6.01 18609 * 18610 * _.ceil(6040, -2); 18611 * // => 6100 18612 */ 18613 var ceil = createRound('ceil'); 18614 18615 /** 18616 * Divide two numbers. 18617 * 18618 * @static 18619 * @memberOf _ 18620 * @since 4.7.0 18621 * @category Math 18622 * @param {number} dividend The first number in a division. 18623 * @param {number} divisor The second number in a division. 18624 * @returns {number} Returns the quotient. 18625 * @example 18626 * 18627 * _.divide(6, 4); 18628 * // => 1.5 18629 */ 18630 var divide = createMathOperation(function(dividend, divisor) { 18631 return dividend / divisor; 18632 }, 1); 18633 18634 /** 18635 * Computes `number` rounded down to `precision`. 18636 * 18637 * @static 18638 * @memberOf _ 18639 * @since 3.10.0 18640 * @category Math 18641 * @param {number} number The number to round down. 18642 * @param {number} [precision=0] The precision to round down to. 18643 * @returns {number} Returns the rounded down number. 18644 * @example 18645 * 18646 * _.floor(4.006); 18647 * // => 4 18648 * 18649 * _.floor(0.046, 2); 18650 * // => 0.04 18651 * 18652 * _.floor(4060, -2); 18653 * // => 4000 18654 */ 18655 var floor = createRound('floor'); 18656 18657 /** 18658 * Computes the maximum value of `array`. If `array` is empty or falsey, 18659 * `undefined` is returned. 18660 * 18661 * @static 18662 * @since 0.1.0 18663 * @memberOf _ 18664 * @category Math 18665 * @param {Array} array The array to iterate over. 18666 * @returns {*} Returns the maximum value. 18667 * @example 18668 * 18669 * _.max([4, 2, 8, 6]); 18670 * // => 8 18671 * 18672 * _.max([]); 18673 * // => undefined 18674 */ 18675 function max(array) { 18676 return (array && array.length) 18677 ? baseExtremum(array, identity, baseGt) 18678 : undefined; 18679 } 18680 18681 /** 18682 * This method is like `_.max` except that it accepts `iteratee` which is 18683 * invoked for each element in `array` to generate the criterion by which 18684 * the value is ranked. The iteratee is invoked with one argument: (value). 18685 * 18686 * @static 18687 * @memberOf _ 18688 * @since 4.0.0 18689 * @category Math 18690 * @param {Array} array The array to iterate over. 18691 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18692 * @returns {*} Returns the maximum value. 18693 * @example 18694 * 18695 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 18696 * 18697 * _.maxBy(objects, function(o) { return o.n; }); 18698 * // => { 'n': 2 } 18699 * 18700 * // The `_.property` iteratee shorthand. 18701 * _.maxBy(objects, 'n'); 18702 * // => { 'n': 2 } 18703 */ 18704 function maxBy(array, iteratee) { 18705 return (array && array.length) 18706 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 18707 : undefined; 18708 } 18709 18710 /** 18711 * Computes the mean of the values in `array`. 18712 * 18713 * @static 18714 * @memberOf _ 18715 * @since 4.0.0 18716 * @category Math 18717 * @param {Array} array The array to iterate over. 18718 * @returns {number} Returns the mean. 18719 * @example 18720 * 18721 * _.mean([4, 2, 8, 6]); 18722 * // => 5 18723 */ 18724 function mean(array) { 18725 return baseMean(array, identity); 18726 } 18727 18728 /** 18729 * This method is like `_.mean` except that it accepts `iteratee` which is 18730 * invoked for each element in `array` to generate the value to be averaged. 18731 * The iteratee is invoked with one argument: (value). 18732 * 18733 * @static 18734 * @memberOf _ 18735 * @since 4.7.0 18736 * @category Math 18737 * @param {Array} array The array to iterate over. 18738 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18739 * @returns {number} Returns the mean. 18740 * @example 18741 * 18742 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 18743 * 18744 * _.meanBy(objects, function(o) { return o.n; }); 18745 * // => 5 18746 * 18747 * // The `_.property` iteratee shorthand. 18748 * _.meanBy(objects, 'n'); 18749 * // => 5 18750 */ 18751 function meanBy(array, iteratee) { 18752 return baseMean(array, getIteratee(iteratee, 2)); 18753 } 18754 18755 /** 18756 * Computes the minimum value of `array`. If `array` is empty or falsey, 18757 * `undefined` is returned. 18758 * 18759 * @static 18760 * @since 0.1.0 18761 * @memberOf _ 18762 * @category Math 18763 * @param {Array} array The array to iterate over. 18764 * @returns {*} Returns the minimum value. 18765 * @example 18766 * 18767 * _.min([4, 2, 8, 6]); 18768 * // => 2 18769 * 18770 * _.min([]); 18771 * // => undefined 18772 */ 18773 function min(array) { 18774 return (array && array.length) 18775 ? baseExtremum(array, identity, baseLt) 18776 : undefined; 18777 } 18778 18779 /** 18780 * This method is like `_.min` except that it accepts `iteratee` which is 18781 * invoked for each element in `array` to generate the criterion by which 18782 * the value is ranked. The iteratee is invoked with one argument: (value). 18783 * 18784 * @static 18785 * @memberOf _ 18786 * @since 4.0.0 18787 * @category Math 18788 * @param {Array} array The array to iterate over. 18789 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18790 * @returns {*} Returns the minimum value. 18791 * @example 18792 * 18793 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 18794 * 18795 * _.minBy(objects, function(o) { return o.n; }); 18796 * // => { 'n': 1 } 18797 * 18798 * // The `_.property` iteratee shorthand. 18799 * _.minBy(objects, 'n'); 18800 * // => { 'n': 1 } 18801 */ 18802 function minBy(array, iteratee) { 18803 return (array && array.length) 18804 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 18805 : undefined; 18806 } 18807 18808 /** 18809 * Multiply two numbers. 18810 * 18811 * @static 18812 * @memberOf _ 18813 * @since 4.7.0 18814 * @category Math 18815 * @param {number} multiplier The first number in a multiplication. 18816 * @param {number} multiplicand The second number in a multiplication. 18817 * @returns {number} Returns the product. 18818 * @example 18819 * 18820 * _.multiply(6, 4); 18821 * // => 24 18822 */ 18823 var multiply = createMathOperation(function(multiplier, multiplicand) { 18824 return multiplier * multiplicand; 18825 }, 1); 18826 18827 /** 18828 * Computes `number` rounded to `precision`. 18829 * 18830 * @static 18831 * @memberOf _ 18832 * @since 3.10.0 18833 * @category Math 18834 * @param {number} number The number to round. 18835 * @param {number} [precision=0] The precision to round to. 18836 * @returns {number} Returns the rounded number. 18837 * @example 18838 * 18839 * _.round(4.006); 18840 * // => 4 18841 * 18842 * _.round(4.006, 2); 18843 * // => 4.01 18844 * 18845 * _.round(4060, -2); 18846 * // => 4100 18847 */ 18848 var round = createRound('round'); 18849 18850 /** 18851 * Subtract two numbers. 18852 * 18853 * @static 18854 * @memberOf _ 18855 * @since 4.0.0 18856 * @category Math 18857 * @param {number} minuend The first number in a subtraction. 18858 * @param {number} subtrahend The second number in a subtraction. 18859 * @returns {number} Returns the difference. 18860 * @example 18861 * 18862 * _.subtract(6, 4); 18863 * // => 2 18864 */ 18865 var subtract = createMathOperation(function(minuend, subtrahend) { 18866 return minuend - subtrahend; 18867 }, 0); 18868 18869 /** 18870 * Computes the sum of the values in `array`. 18871 * 18872 * @static 18873 * @memberOf _ 18874 * @since 3.4.0 18875 * @category Math 18876 * @param {Array} array The array to iterate over. 18877 * @returns {number} Returns the sum. 18878 * @example 18879 * 18880 * _.sum([4, 2, 8, 6]); 18881 * // => 20 18882 */ 18883 function sum(array) { 18884 return (array && array.length) 18885 ? baseSum(array, identity) 18886 : 0; 18887 } 18888 18889 /** 18890 * This method is like `_.sum` except that it accepts `iteratee` which is 18891 * invoked for each element in `array` to generate the value to be summed. 18892 * The iteratee is invoked with one argument: (value). 18893 * 18894 * @static 18895 * @memberOf _ 18896 * @since 4.0.0 18897 * @category Math 18898 * @param {Array} array The array to iterate over. 18899 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18900 * @returns {number} Returns the sum. 18901 * @example 18902 * 18903 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 18904 * 18905 * _.sumBy(objects, function(o) { return o.n; }); 18906 * // => 20 18907 * 18908 * // The `_.property` iteratee shorthand. 18909 * _.sumBy(objects, 'n'); 18910 * // => 20 18911 */ 18912 function sumBy(array, iteratee) { 18913 return (array && array.length) 18914 ? baseSum(array, getIteratee(iteratee, 2)) 18915 : 0; 18916 } 18917 18918 /*------------------------------------------------------------------------*/ 18919 18920 // Add methods that return wrapped values in chain sequences. 18921 lodash.after = after; 18922 lodash.ary = ary; 18923 lodash.assign = assign; 18924 lodash.assignIn = assignIn; 18925 lodash.assignInWith = assignInWith; 18926 lodash.assignWith = assignWith; 18927 lodash.at = at; 18928 lodash.before = before; 18929 lodash.bind = bind; 18930 lodash.bindAll = bindAll; 18931 lodash.bindKey = bindKey; 18932 lodash.castArray = castArray; 18933 lodash.chain = chain; 18934 lodash.chunk = chunk; 18935 lodash.compact = compact; 18936 lodash.concat = concat; 18937 lodash.cond = cond; 18938 lodash.conforms = conforms; 18939 lodash.constant = constant; 18940 lodash.countBy = countBy; 18941 lodash.create = create; 18942 lodash.curry = curry; 18943 lodash.curryRight = curryRight; 18944 lodash.debounce = debounce; 18945 lodash.defaults = defaults; 18946 lodash.defaultsDeep = defaultsDeep; 18947 lodash.defer = defer; 18948 lodash.delay = delay; 18949 lodash.difference = difference; 18950 lodash.differenceBy = differenceBy; 18951 lodash.differenceWith = differenceWith; 18952 lodash.drop = drop; 18953 lodash.dropRight = dropRight; 18954 lodash.dropRightWhile = dropRightWhile; 18955 lodash.dropWhile = dropWhile; 18956 lodash.fill = fill; 18957 lodash.filter = filter; 18958 lodash.flatMap = flatMap; 18959 lodash.flatMapDeep = flatMapDeep; 18960 lodash.flatMapDepth = flatMapDepth; 18961 lodash.flatten = flatten; 18962 lodash.flattenDeep = flattenDeep; 18963 lodash.flattenDepth = flattenDepth; 18964 lodash.flip = flip; 18965 lodash.flow = flow; 18966 lodash.flowRight = flowRight; 18967 lodash.fromPairs = fromPairs; 18968 lodash.functions = functions; 18969 lodash.functionsIn = functionsIn; 18970 lodash.groupBy = groupBy; 18971 lodash.initial = initial; 18972 lodash.intersection = intersection; 18973 lodash.intersectionBy = intersectionBy; 18974 lodash.intersectionWith = intersectionWith; 18975 lodash.invert = invert; 18976 lodash.invertBy = invertBy; 18977 lodash.invokeMap = invokeMap; 18978 lodash.iteratee = iteratee; 18979 lodash.keyBy = keyBy; 18980 lodash.keys = keys; 18981 lodash.keysIn = keysIn; 18982 lodash.map = map; 18983 lodash.mapKeys = mapKeys; 18984 lodash.mapValues = mapValues; 18985 lodash.matches = matches; 18986 lodash.matchesProperty = matchesProperty; 18987 lodash.memoize = memoize; 18988 lodash.merge = merge; 18989 lodash.mergeWith = mergeWith; 18990 lodash.method = method; 18991 lodash.methodOf = methodOf; 18992 lodash.mixin = mixin; 18993 lodash.negate = negate; 18994 lodash.nthArg = nthArg; 18995 lodash.omit = omit; 18996 lodash.omitBy = omitBy; 18997 lodash.once = once; 18998 lodash.orderBy = orderBy; 18999 lodash.over = over; 19000 lodash.overArgs = overArgs; 19001 lodash.overEvery = overEvery; 19002 lodash.overSome = overSome; 19003 lodash.partial = partial; 19004 lodash.partialRight = partialRight; 19005 lodash.partition = partition; 19006 lodash.pick = pick; 19007 lodash.pickBy = pickBy; 19008 lodash.property = property; 19009 lodash.propertyOf = propertyOf; 19010 lodash.pull = pull; 19011 lodash.pullAll = pullAll; 19012 lodash.pullAllBy = pullAllBy; 19013 lodash.pullAllWith = pullAllWith; 19014 lodash.pullAt = pullAt; 19015 lodash.range = range; 19016 lodash.rangeRight = rangeRight; 19017 lodash.rearg = rearg; 19018 lodash.reject = reject; 19019 lodash.remove = remove; 19020 lodash.rest = rest; 19021 lodash.reverse = reverse; 19022 lodash.sampleSize = sampleSize; 19023 lodash.set = set; 19024 lodash.setWith = setWith; 19025 lodash.shuffle = shuffle; 19026 lodash.slice = slice; 19027 lodash.sortBy = sortBy; 19028 lodash.sortedUniq = sortedUniq; 19029 lodash.sortedUniqBy = sortedUniqBy; 19030 lodash.split = split; 19031 lodash.spread = spread; 19032 lodash.tail = tail; 19033 lodash.take = take; 19034 lodash.takeRight = takeRight; 19035 lodash.takeRightWhile = takeRightWhile; 19036 lodash.takeWhile = takeWhile; 19037 lodash.tap = tap; 19038 lodash.throttle = throttle; 19039 lodash.thru = thru; 19040 lodash.toArray = toArray; 19041 lodash.toPairs = toPairs; 19042 lodash.toPairsIn = toPairsIn; 19043 lodash.toPath = toPath; 19044 lodash.toPlainObject = toPlainObject; 19045 lodash.transform = transform; 19046 lodash.unary = unary; 19047 lodash.union = union; 19048 lodash.unionBy = unionBy; 19049 lodash.unionWith = unionWith; 19050 lodash.uniq = uniq; 19051 lodash.uniqBy = uniqBy; 19052 lodash.uniqWith = uniqWith; 19053 lodash.unset = unset; 19054 lodash.unzip = unzip; 19055 lodash.unzipWith = unzipWith; 19056 lodash.update = update; 19057 lodash.updateWith = updateWith; 19058 lodash.values = values; 19059 lodash.valuesIn = valuesIn; 19060 lodash.without = without; 19061 lodash.words = words; 19062 lodash.wrap = wrap; 19063 lodash.xor = xor; 19064 lodash.xorBy = xorBy; 19065 lodash.xorWith = xorWith; 19066 lodash.zip = zip; 19067 lodash.zipObject = zipObject; 19068 lodash.zipObjectDeep = zipObjectDeep; 19069 lodash.zipWith = zipWith; 19070 19071 // Add aliases. 19072 lodash.entries = toPairs; 19073 lodash.entriesIn = toPairsIn; 19074 lodash.extend = assignIn; 19075 lodash.extendWith = assignInWith; 19076 19077 // Add methods to `lodash.prototype`. 19078 mixin(lodash, lodash); 19079 19080 /*------------------------------------------------------------------------*/ 19081 19082 // Add methods that return unwrapped values in chain sequences. 19083 lodash.add = add; 19084 lodash.attempt = attempt; 19085 lodash.camelCase = camelCase; 19086 lodash.capitalize = capitalize; 19087 lodash.ceil = ceil; 19088 lodash.clamp = clamp; 19089 lodash.clone = clone; 19090 lodash.cloneDeep = cloneDeep; 19091 lodash.cloneDeepWith = cloneDeepWith; 19092 lodash.cloneWith = cloneWith; 19093 lodash.conformsTo = conformsTo; 19094 lodash.deburr = deburr; 19095 lodash.defaultTo = defaultTo; 19096 lodash.divide = divide; 19097 lodash.endsWith = endsWith; 19098 lodash.eq = eq; 19099 lodash.escape = escape; 19100 lodash.escapeRegExp = escapeRegExp; 19101 lodash.every = every; 19102 lodash.find = find; 19103 lodash.findIndex = findIndex; 19104 lodash.findKey = findKey; 19105 lodash.findLast = findLast; 19106 lodash.findLastIndex = findLastIndex; 19107 lodash.findLastKey = findLastKey; 19108 lodash.floor = floor; 19109 lodash.forEach = forEach; 19110 lodash.forEachRight = forEachRight; 19111 lodash.forIn = forIn; 19112 lodash.forInRight = forInRight; 19113 lodash.forOwn = forOwn; 19114 lodash.forOwnRight = forOwnRight; 19115 lodash.get = get; 19116 lodash.gt = gt; 19117 lodash.gte = gte; 19118 lodash.has = has; 19119 lodash.hasIn = hasIn; 19120 lodash.head = head; 19121 lodash.identity = identity; 19122 lodash.includes = includes; 19123 lodash.indexOf = indexOf; 19124 lodash.inRange = inRange; 19125 lodash.invoke = invoke; 19126 lodash.isArguments = isArguments; 19127 lodash.isArray = isArray; 19128 lodash.isArrayBuffer = isArrayBuffer; 19129 lodash.isArrayLike = isArrayLike; 19130 lodash.isArrayLikeObject = isArrayLikeObject; 19131 lodash.isBoolean = isBoolean; 19132 lodash.isBuffer = isBuffer; 19133 lodash.isDate = isDate; 19134 lodash.isElement = isElement; 19135 lodash.isEmpty = isEmpty; 19136 lodash.isEqual = isEqual; 19137 lodash.isEqualWith = isEqualWith; 19138 lodash.isError = isError; 19139 lodash.isFinite = isFinite; 19140 lodash.isFunction = isFunction; 19141 lodash.isInteger = isInteger; 19142 lodash.isLength = isLength; 19143 lodash.isMap = isMap; 19144 lodash.isMatch = isMatch; 19145 lodash.isMatchWith = isMatchWith; 19146 lodash.isNaN = isNaN; 19147 lodash.isNative = isNative; 19148 lodash.isNil = isNil; 19149 lodash.isNull = isNull; 19150 lodash.isNumber = isNumber; 19151 lodash.isObject = isObject; 19152 lodash.isObjectLike = isObjectLike; 19153 lodash.isPlainObject = isPlainObject; 19154 lodash.isRegExp = isRegExp; 19155 lodash.isSafeInteger = isSafeInteger; 19156 lodash.isSet = isSet; 19157 lodash.isString = isString; 19158 lodash.isSymbol = isSymbol; 19159 lodash.isTypedArray = isTypedArray; 19160 lodash.isUndefined = isUndefined; 19161 lodash.isWeakMap = isWeakMap; 19162 lodash.isWeakSet = isWeakSet; 19163 lodash.join = join; 19164 lodash.kebabCase = kebabCase; 19165 lodash.last = last; 19166 lodash.lastIndexOf = lastIndexOf; 19167 lodash.lowerCase = lowerCase; 19168 lodash.lowerFirst = lowerFirst; 19169 lodash.lt = lt; 19170 lodash.lte = lte; 19171 lodash.max = max; 19172 lodash.maxBy = maxBy; 19173 lodash.mean = mean; 19174 lodash.meanBy = meanBy; 19175 lodash.min = min; 19176 lodash.minBy = minBy; 19177 lodash.stubArray = stubArray; 19178 lodash.stubFalse = stubFalse; 19179 lodash.stubObject = stubObject; 19180 lodash.stubString = stubString; 19181 lodash.stubTrue = stubTrue; 19182 lodash.multiply = multiply; 19183 lodash.nth = nth; 19184 lodash.noConflict = noConflict; 19185 lodash.noop = noop; 19186 lodash.now = now; 19187 lodash.pad = pad; 19188 lodash.padEnd = padEnd; 19189 lodash.padStart = padStart; 19190 lodash.parseInt = parseInt; 19191 lodash.random = random; 19192 lodash.reduce = reduce; 19193 lodash.reduceRight = reduceRight; 19194 lodash.repeat = repeat; 19195 lodash.replace = replace; 19196 lodash.result = result; 19197 lodash.round = round; 19198 lodash.runInContext = runInContext; 19199 lodash.sample = sample; 19200 lodash.size = size; 19201 lodash.snakeCase = snakeCase; 19202 lodash.some = some; 19203 lodash.sortedIndex = sortedIndex; 19204 lodash.sortedIndexBy = sortedIndexBy; 19205 lodash.sortedIndexOf = sortedIndexOf; 19206 lodash.sortedLastIndex = sortedLastIndex; 19207 lodash.sortedLastIndexBy = sortedLastIndexBy; 19208 lodash.sortedLastIndexOf = sortedLastIndexOf; 19209 lodash.startCase = startCase; 19210 lodash.startsWith = startsWith; 19211 lodash.subtract = subtract; 19212 lodash.sum = sum; 19213 lodash.sumBy = sumBy; 19214 lodash.template = template; 19215 lodash.times = times; 19216 lodash.toFinite = toFinite; 19217 lodash.toInteger = toInteger; 19218 lodash.toLength = toLength; 19219 lodash.toLower = toLower; 19220 lodash.toNumber = toNumber; 19221 lodash.toSafeInteger = toSafeInteger; 19222 lodash.toString = toString; 19223 lodash.toUpper = toUpper; 19224 lodash.trim = trim; 19225 lodash.trimEnd = trimEnd; 19226 lodash.trimStart = trimStart; 19227 lodash.truncate = truncate; 19228 lodash.unescape = unescape; 19229 lodash.uniqueId = uniqueId; 19230 lodash.upperCase = upperCase; 19231 lodash.upperFirst = upperFirst; 19232 19233 // Add aliases. 19234 lodash.each = forEach; 19235 lodash.eachRight = forEachRight; 19236 lodash.first = head; 19237 19238 mixin(lodash, (function() { 19239 var source = {}; 19240 baseForOwn(lodash, function(func, methodName) { 19241 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 19242 source[methodName] = func; 19243 } 19244 }); 19245 return source; 19246 }()), { 'chain': false }); 19247 19248 /*------------------------------------------------------------------------*/ 19249 19250 /** 19251 * The semantic version number. 19252 * 19253 * @static 19254 * @memberOf _ 19255 * @type {string} 19256 */ 19257 lodash.VERSION = VERSION; 19258 19259 // Assign default placeholders. 19260 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 19261 lodash[methodName].placeholder = lodash; 19262 }); 19263 19264 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 19265 arrayEach(['drop', 'take'], function(methodName, index) { 19266 LazyWrapper.prototype[methodName] = function(n) { 19267 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 19268 19269 var result = (this.__filtered__ && !index) 19270 ? new LazyWrapper(this) 19271 : this.clone(); 19272 19273 if (result.__filtered__) { 19274 result.__takeCount__ = nativeMin(n, result.__takeCount__); 19275 } else { 19276 result.__views__.push({ 19277 'size': nativeMin(n, MAX_ARRAY_LENGTH), 19278 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 19279 }); 19280 } 19281 return result; 19282 }; 19283 19284 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 19285 return this.reverse()[methodName](n).reverse(); 19286 }; 19287 }); 19288 19289 // Add `LazyWrapper` methods that accept an `iteratee` value. 19290 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 19291 var type = index + 1, 19292 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 19293 19294 LazyWrapper.prototype[methodName] = function(iteratee) { 19295 var result = this.clone(); 19296 result.__iteratees__.push({ 19297 'iteratee': getIteratee(iteratee, 3), 19298 'type': type 19299 }); 19300 result.__filtered__ = result.__filtered__ || isFilter; 19301 return result; 19302 }; 19303 }); 19304 19305 // Add `LazyWrapper` methods for `_.head` and `_.last`. 19306 arrayEach(['head', 'last'], function(methodName, index) { 19307 var takeName = 'take' + (index ? 'Right' : ''); 19308 19309 LazyWrapper.prototype[methodName] = function() { 19310 return this[takeName](1).value()[0]; 19311 }; 19312 }); 19313 19314 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 19315 arrayEach(['initial', 'tail'], function(methodName, index) { 19316 var dropName = 'drop' + (index ? '' : 'Right'); 19317 19318 LazyWrapper.prototype[methodName] = function() { 19319 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 19320 }; 19321 }); 19322 19323 LazyWrapper.prototype.compact = function() { 19324 return this.filter(identity); 19325 }; 19326 19327 LazyWrapper.prototype.find = function(predicate) { 19328 return this.filter(predicate).head(); 19329 }; 19330 19331 LazyWrapper.prototype.findLast = function(predicate) { 19332 return this.reverse().find(predicate); 19333 }; 19334 19335 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 19336 if (typeof path == 'function') { 19337 return new LazyWrapper(this); 19338 } 19339 return this.map(function(value) { 19340 return baseInvoke(value, path, args); 19341 }); 19342 }); 19343 19344 LazyWrapper.prototype.reject = function(predicate) { 19345 return this.filter(negate(getIteratee(predicate))); 19346 }; 19347 19348 LazyWrapper.prototype.slice = function(start, end) { 19349 start = toInteger(start); 19350 19351 var result = this; 19352 if (result.__filtered__ && (start > 0 || end < 0)) { 19353 return new LazyWrapper(result); 19354 } 19355 if (start < 0) { 19356 result = result.takeRight(-start); 19357 } else if (start) { 19358 result = result.drop(start); 19359 } 19360 if (end !== undefined) { 19361 end = toInteger(end); 19362 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 19363 } 19364 return result; 19365 }; 19366 19367 LazyWrapper.prototype.takeRightWhile = function(predicate) { 19368 return this.reverse().takeWhile(predicate).reverse(); 19369 }; 19370 19371 LazyWrapper.prototype.toArray = function() { 19372 return this.take(MAX_ARRAY_LENGTH); 19373 }; 19374 19375 // Add `LazyWrapper` methods to `lodash.prototype`. 19376 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 19377 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 19378 isTaker = /^(?:head|last)$/.test(methodName), 19379 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 19380 retUnwrapped = isTaker || /^find/.test(methodName); 19381 19382 if (!lodashFunc) { 19383 return; 19384 } 19385 lodash.prototype[methodName] = function() { 19386 var value = this.__wrapped__, 19387 args = isTaker ? [1] : arguments, 19388 isLazy = value instanceof LazyWrapper, 19389 iteratee = args[0], 19390 useLazy = isLazy || isArray(value); 19391 19392 var interceptor = function(value) { 19393 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 19394 return (isTaker && chainAll) ? result[0] : result; 19395 }; 19396 19397 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 19398 // Avoid lazy use if the iteratee has a "length" value other than `1`. 19399 isLazy = useLazy = false; 19400 } 19401 var chainAll = this.__chain__, 19402 isHybrid = !!this.__actions__.length, 19403 isUnwrapped = retUnwrapped && !chainAll, 19404 onlyLazy = isLazy && !isHybrid; 19405 19406 if (!retUnwrapped && useLazy) { 19407 value = onlyLazy ? value : new LazyWrapper(this); 19408 var result = func.apply(value, args); 19409 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 19410 return new LodashWrapper(result, chainAll); 19411 } 19412 if (isUnwrapped && onlyLazy) { 19413 return func.apply(this, args); 19414 } 19415 result = this.thru(interceptor); 19416 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 19417 }; 19418 }); 19419 19420 // Add `Array` methods to `lodash.prototype`. 19421 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 19422 var func = arrayProto[methodName], 19423 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 19424 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 19425 19426 lodash.prototype[methodName] = function() { 19427 var args = arguments; 19428 if (retUnwrapped && !this.__chain__) { 19429 var value = this.value(); 19430 return func.apply(isArray(value) ? value : [], args); 19431 } 19432 return this[chainName](function(value) { 19433 return func.apply(isArray(value) ? value : [], args); 19434 }); 19435 }; 19436 }); 19437 19438 // Map minified method names to their real names. 19439 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 19440 var lodashFunc = lodash[methodName]; 19441 if (lodashFunc) { 19442 var key = (lodashFunc.name + ''), 19443 names = realNames[key] || (realNames[key] = []); 19444 19445 names.push({ 'name': methodName, 'func': lodashFunc }); 19446 } 19447 }); 19448 19449 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 19450 'name': 'wrapper', 19451 'func': undefined 19452 }]; 19453 19454 // Add methods to `LazyWrapper`. 19455 LazyWrapper.prototype.clone = lazyClone; 19456 LazyWrapper.prototype.reverse = lazyReverse; 19457 LazyWrapper.prototype.value = lazyValue; 19458 19459 // Add chain sequence methods to the `lodash` wrapper. 19460 lodash.prototype.at = wrapperAt; 19461 lodash.prototype.chain = wrapperChain; 19462 lodash.prototype.commit = wrapperCommit; 19463 lodash.prototype.next = wrapperNext; 19464 lodash.prototype.plant = wrapperPlant; 19465 lodash.prototype.reverse = wrapperReverse; 19466 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 19467 19468 // Add lazy aliases. 19469 lodash.prototype.first = lodash.prototype.head; 19470 19471 if (symIterator) { 19472 lodash.prototype[symIterator] = wrapperToIterator; 19473 } 19474 return lodash; 19475 }); 19476 19477 /*--------------------------------------------------------------------------*/ 19478 19479 // Export lodash. 19480 var _ = runInContext(); 19481 19482 // Some AMD build optimizers, like r.js, check for condition patterns like: 19483 if (true) { 19484 // Expose Lodash on the global object to prevent errors when Lodash is 19485 // loaded by a script tag in the presence of an AMD loader. 19486 // See http://requirejs.org/docs/errors.html#mismatch for more details. 19487 // Use `_.noConflict` to remove Lodash from the global object. 19488 root._ = _; 19489 19490 // Define as an anonymous module so, through path mapping, it can be 19491 // referenced as the "underscore" module. 19492 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 19493 return _; 19494 }).call(exports, __webpack_require__, exports, module), 19495 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 19496 } 19497 // Check for `exports` after `define` in case a build optimizer adds it. 19498 else if (freeModule) { 19499 // Export for Node.js. 19500 (freeModule.exports = _)._ = _; 19501 // Export for CommonJS support. 19502 freeExports._ = _; 19503 } 19504 else { 19505 // Export to the global object. 19506 root._ = _; 19507 } 19508}.call(this)); 19509 19510/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/webpack/buildin/global.js"), __webpack_require__("./node_modules/webpack/buildin/module.js")(module))) 19511 19512/***/ }), 19513
vendor: 5,510 bytes, lines 19514-19704
19514/***/ "./node_modules/process/browser.js": 19515/***/ (function(module, exports) { 19516 19517// shim for using process in browser 19518var process = module.exports = {}; 19519 19520// cached from whatever global is present so that test runners that stub it 19521// don't break things. But we need to wrap it in a try catch in case it is 19522// wrapped in strict mode code which doesn't define any globals. It's inside a 19523// function because try/catches deoptimize in certain engines. 19524 19525var cachedSetTimeout; 19526var cachedClearTimeout; 19527 19528function defaultSetTimout() { 19529 throw new Error('setTimeout has not been defined'); 19530} 19531function defaultClearTimeout () { 19532 throw new Error('clearTimeout has not been defined'); 19533} 19534(function () { 19535 try { 19536 if (typeof setTimeout === 'function') { 19537 cachedSetTimeout = setTimeout; 19538 } else { 19539 cachedSetTimeout = defaultSetTimout; 19540 } 19541 } catch (e) { 19542 cachedSetTimeout = defaultSetTimout; 19543 } 19544 try { 19545 if (typeof clearTimeout === 'function') { 19546 cachedClearTimeout = clearTimeout; 19547 } else { 19548 cachedClearTimeout = defaultClearTimeout; 19549 } 19550 } catch (e) { 19551 cachedClearTimeout = defaultClearTimeout; 19552 } 19553} ()) 19554function runTimeout(fun) { 19555 if (cachedSetTimeout === setTimeout) { 19556 //normal enviroments in sane situations 19557 return setTimeout(fun, 0); 19558 } 19559 // if setTimeout wasn't available but was latter defined 19560 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 19561 cachedSetTimeout = setTimeout; 19562 return setTimeout(fun, 0); 19563 } 19564 try { 19565 // when when somebody has screwed with setTimeout but no I.E. maddness 19566 return cachedSetTimeout(fun, 0); 19567 } catch(e){ 19568 try { 19569 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 19570 return cachedSetTimeout.call(null, fun, 0); 19571 } catch(e){ 19572 // 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 19573 return cachedSetTimeout.call(this, fun, 0); 19574 } 19575 } 19576 19577 19578} 19579function runClearTimeout(marker) { 19580 if (cachedClearTimeout === clearTimeout) { 19581 //normal enviroments in sane situations 19582 return clearTimeout(marker); 19583 } 19584 // if clearTimeout wasn't available but was latter defined 19585 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 19586 cachedClearTimeout = clearTimeout; 19587 return clearTimeout(marker); 19588 } 19589 try { 19590 // when when somebody has screwed with setTimeout but no I.E. maddness 19591 return cachedClearTimeout(marker); 19592 } catch (e){ 19593 try { 19594 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 19595 return cachedClearTimeout.call(null, marker); 19596 } catch (e){ 19597 // 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. 19598 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 19599 return cachedClearTimeout.call(this, marker); 19600 } 19601 } 19602 19603 19604 19605} 19606var queue = []; 19607var draining = false; 19608var currentQueue; 19609var queueIndex = -1; 19610 19611function cleanUpNextTick() { 19612 if (!draining || !currentQueue) { 19613 return; 19614 } 19615 draining = false; 19616 if (currentQueue.length) { 19617 queue = currentQueue.concat(queue); 19618 } else { 19619 queueIndex = -1; 19620 } 19621 if (queue.length) { 19622 drainQueue(); 19623 } 19624} 19625 19626function drainQueue() { 19627 if (draining) { 19628 return; 19629 } 19630 var timeout = runTimeout(cleanUpNextTick); 19631 draining = true; 19632 19633 var len = queue.length; 19634 while(len) { 19635 currentQueue = queue; 19636 queue = []; 19637 while (++queueIndex < len) { 19638 if (currentQueue) { 19639 currentQueue[queueIndex].run(); 19640 } 19641 } 19642 queueIndex = -1; 19643 len = queue.length; 19644 } 19645 currentQueue = null; 19646 draining = false; 19647 runClearTimeout(timeout); 19648} 19649 19650process.nextTick = function (fun) { 19651 var args = new Array(arguments.length - 1); 19652 if (arguments.length > 1) { 19653 for (var i = 1; i < arguments.length; i++) { 19654 args[i - 1] = arguments[i]; 19655 } 19656 } 19657 queue.push(new Item(fun, args)); 19658 if (queue.length === 1 && !draining) { 19659 runTimeout(drainQueue); 19660 } 19661}; 19662 19663// v8 likes predictible objects 19664function Item(fun, array) { 19665 this.fun = fun; 19666 this.array = array; 19667} 19668Item.prototype.run = function () { 19669 this.fun.apply(null, this.array); 19670}; 19671process.title = 'browser'; 19672process.browser = true; 19673process.env = {}; 19674process.argv = []; 19675process.version = ''; // empty string to avoid regexp issues 19676process.versions = {}; 19677 19678function noop() {} 19679 19680process.on = noop; 19681process.addListener = noop; 19682process.once = noop; 19683process.off = noop; 19684process.removeListener = noop; 19685process.removeAllListeners = noop; 19686process.emit = noop; 19687process.prependListener = noop; 19688process.prependOnceListener = noop; 19689 19690process.listeners = function (name) { return [] } 19691 19692process.binding = function (name) { 19693 throw new Error('process.binding is not supported'); 19694}; 19695 19696process.cwd = function () { return '/' }; 19697process.chdir = function (dir) { 19698 throw new Error('process.chdir is not supported'); 19699}; 19700process.umask = function() { return 0; }; 19701 19702 19703/***/ }), 19704
vendor: 6,820 bytes, lines 19705-19898
19705/***/ "./node_modules/setimmediate/setImmediate.js": 19706/***/ (function(module, exports, __webpack_require__) { 19707 19708/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { 19709 "use strict"; 19710 19711 if (global.setImmediate) { 19712 return; 19713 } 19714 19715 var nextHandle = 1; // Spec says greater than zero 19716 var tasksByHandle = {}; 19717 var currentlyRunningATask = false; 19718 var doc = global.document; 19719 var registerImmediate; 19720 19721 function setImmediate(callback) { 19722 // Callback can either be a function or a string 19723 if (typeof callback !== "function") { 19724 callback = new Function("" + callback); 19725 } 19726 // Copy function arguments 19727 var args = new Array(arguments.length - 1); 19728 for (var i = 0; i < args.length; i++) { 19729 args[i] = arguments[i + 1]; 19730 } 19731 // Store and register the task 19732 var task = { callback: callback, args: args }; 19733 tasksByHandle[nextHandle] = task; 19734 registerImmediate(nextHandle); 19735 return nextHandle++; 19736 } 19737 19738 function clearImmediate(handle) { 19739 delete tasksByHandle[handle]; 19740 } 19741 19742 function run(task) { 19743 var callback = task.callback; 19744 var args = task.args; 19745 switch (args.length) { 19746 case 0: 19747 callback(); 19748 break; 19749 case 1: 19750 callback(args[0]); 19751 break; 19752 case 2: 19753 callback(args[0], args[1]); 19754 break; 19755 case 3: 19756 callback(args[0], args[1], args[2]); 19757 break; 19758 default: 19759 callback.apply(undefined, args); 19760 break; 19761 } 19762 } 19763 19764 function runIfPresent(handle) { 19765 // From the spec: "Wait until any invocations of this algorithm started before this one have completed." 19766 // So if we're currently running a task, we'll need to delay this invocation. 19767 if (currentlyRunningATask) { 19768 // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a 19769 // "too much recursion" error. 19770 setTimeout(runIfPresent, 0, handle); 19771 } else { 19772 var task = tasksByHandle[handle]; 19773 if (task) { 19774 currentlyRunningATask = true; 19775 try { 19776 run(task); 19777 } finally { 19778 clearImmediate(handle); 19779 currentlyRunningATask = false; 19780 } 19781 } 19782 } 19783 } 19784 19785 function installNextTickImplementation() { 19786 registerImmediate = function(handle) { 19787 process.nextTick(function () { runIfPresent(handle); }); 19788 }; 19789 } 19790 19791 function canUsePostMessage() { 19792 // The test against `importScripts` prevents this implementation from being installed inside a web worker, 19793 // where `global.postMessage` means something completely different and can't be used for this purpose. 19794 if (global.postMessage && !global.importScripts) { 19795 var postMessageIsAsynchronous = true; 19796 var oldOnMessage = global.onmessage; 19797 global.onmessage = function() { 19798 postMessageIsAsynchronous = false; 19799 }; 19800 global.postMessage("", "*"); 19801 global.onmessage = oldOnMessage; 19802 return postMessageIsAsynchronous; 19803 } 19804 } 19805 19806 function installPostMessageImplementation() { 19807 // Installs an event handler on `global` for the `message` event: see 19808 // * https://developer.mozilla.org/en/DOM/window.postMessage 19809 // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages 19810 19811 var messagePrefix = "setImmediate$" + Math.random() + "$"; 19812 var onGlobalMessage = function(event) { 19813 if (event.source === global && 19814 typeof event.data === "string" && 19815 event.data.indexOf(messagePrefix) === 0) { 19816 runIfPresent(+event.data.slice(messagePrefix.length)); 19817 } 19818 }; 19819 19820 if (global.addEventListener) { 19821 global.addEventListener("message", onGlobalMessage, false); 19822 } else { 19823 global.attachEvent("onmessage", onGlobalMessage); 19824 } 19825 19826 registerImmediate = function(handle) { 19827 global.postMessage(messagePrefix + handle, "*"); 19828 }; 19829 } 19830 19831 function installMessageChannelImplementation() { 19832 var channel = new MessageChannel(); 19833 channel.port1.onmessage = function(event) { 19834 var handle = event.data; 19835 runIfPresent(handle); 19836 }; 19837 19838 registerImmediate = function(handle) { 19839 channel.port2.postMessage(handle); 19840 }; 19841 } 19842 19843 function installReadyStateChangeImplementation() { 19844 var html = doc.documentElement; 19845 registerImmediate = function(handle) { 19846 // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted 19847 // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called. 19848 var script = doc.createElement("script"); 19849 script.onreadystatechange = function () { 19850 runIfPresent(handle); 19851 script.onreadystatechange = null; 19852 html.removeChild(script); 19853 script = null; 19854 }; 19855 html.appendChild(script); 19856 }; 19857 } 19858 19859 function installSetTimeoutImplementation() { 19860 registerImmediate = function(handle) { 19861 setTimeout(runIfPresent, 0, handle); 19862 }; 19863 } 19864 19865 // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live. 19866 var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global); 19867 attachTo = attachTo && attachTo.setTimeout ? attachTo : global; 19868 19869 // Don't get fooled by e.g. browserify environments. 19870 if ({}.toString.call(global.process) === "[object process]") { 19871 // For Node.js before 0.9 19872 installNextTickImplementation(); 19873 19874 } else if (canUsePostMessage()) { 19875 // For non-IE10 modern browsers 19876 installPostMessageImplementation(); 19877 19878 } else if (global.MessageChannel) { 19879 // For web workers, where supported 19880 installMessageChannelImplementation(); 19881 19882 } else if (doc && "onreadystatechange" in doc.createElement("script")) { 19883 // For IE 6â8 19884 installReadyStateChangeImplementation(); 19885 19886 } else { 19887 // For older browsers 19888 installSetTimeoutImplementation(); 19889 } 19890 19891 attachTo.setImmediate = setImmediate; 19892 attachTo.clearImmediate = clearImmediate; 19893}(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self)); 19894 19895/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/webpack/buildin/global.js"), __webpack_require__("./node_modules/process/browser.js"))) 19896 19897/***/ }), 19898
vendor: 8,940 bytes, lines 19899-20124
19899/***/ "./node_modules/sprintf-js/src/sprintf.js": 19900/***/ (function(module, exports, __webpack_require__) { 19901 19902var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ 19903 19904!function() { 19905 'use strict' 19906 19907 var re = { 19908 not_string: /[^s]/, 19909 not_bool: /[^t]/, 19910 not_type: /[^T]/, 19911 not_primitive: /[^v]/, 19912 number: /[diefg]/, 19913 numeric_arg: /[bcdiefguxX]/, 19914 json: /[j]/, 19915 not_json: /[^j]/, 19916 text: /^[^\x25]+/, 19917 modulo: /^\x25{2}/, 19918 placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, 19919 key: /^([a-z_][a-z_\d]*)/i, 19920 key_access: /^\.([a-z_][a-z_\d]*)/i, 19921 index_access: /^\[(\d+)\]/, 19922 sign: /^[\+\-]/ 19923 } 19924 19925 function sprintf(key) { 19926 // `arguments` is not an array, but should be fine for this call 19927 return sprintf_format(sprintf_parse(key), arguments) 19928 } 19929 19930 function vsprintf(fmt, argv) { 19931 return sprintf.apply(null, [fmt].concat(argv || [])) 19932 } 19933 19934 function sprintf_format(parse_tree, argv) { 19935 var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, match, pad, pad_character, pad_length, is_positive, sign 19936 for (i = 0; i < tree_length; i++) { 19937 if (typeof parse_tree[i] === 'string') { 19938 output += parse_tree[i] 19939 } 19940 else if (Array.isArray(parse_tree[i])) { 19941 match = parse_tree[i] // convenience purposes only 19942 if (match[2]) { // keyword argument 19943 arg = argv[cursor] 19944 for (k = 0; k < match[2].length; k++) { 19945 if (!arg.hasOwnProperty(match[2][k])) { 19946 throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k])) 19947 } 19948 arg = arg[match[2][k]] 19949 } 19950 } 19951 else if (match[1]) { // positional argument (explicit) 19952 arg = argv[match[1]] 19953 } 19954 else { // positional argument (implicit) 19955 arg = argv[cursor++] 19956 } 19957 19958 if (re.not_type.test(match[8]) && re.not_primitive.test(match[8]) && arg instanceof Function) { 19959 arg = arg() 19960 } 19961 19962 if (re.numeric_arg.test(match[8]) && (typeof arg !== 'number' && isNaN(arg))) { 19963 throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) 19964 } 19965 19966 if (re.number.test(match[8])) { 19967 is_positive = arg >= 0 19968 } 19969 19970 switch (match[8]) { 19971 case 'b': 19972 arg = parseInt(arg, 10).toString(2) 19973 break 19974 case 'c': 19975 arg = String.fromCharCode(parseInt(arg, 10)) 19976 break 19977 case 'd': 19978 case 'i': 19979 arg = parseInt(arg, 10) 19980 break 19981 case 'j': 19982 arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0) 19983 break 19984 case 'e': 19985 arg = match[7] ? parseFloat(arg).toExponential(match[7]) : parseFloat(arg).toExponential() 19986 break 19987 case 'f': 19988 arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg) 19989 break 19990 case 'g': 19991 arg = match[7] ? String(Number(arg.toPrecision(match[7]))) : parseFloat(arg) 19992 break 19993 case 'o': 19994 arg = (parseInt(arg, 10) >>> 0).toString(8) 19995 break 19996 case 's': 19997 arg = String(arg) 19998 arg = (match[7] ? arg.substring(0, match[7]) : arg) 19999 break 20000 case 't': 20001 arg = String(!!arg) 20002 arg = (match[7] ? arg.substring(0, match[7]) : arg) 20003 break 20004 case 'T': 20005 arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase() 20006 arg = (match[7] ? arg.substring(0, match[7]) : arg) 20007 break 20008 case 'u': 20009 arg = parseInt(arg, 10) >>> 0 20010 break 20011 case 'v': 20012 arg = arg.valueOf() 20013 arg = (match[7] ? arg.substring(0, match[7]) : arg) 20014 break 20015 case 'x': 20016 arg = (parseInt(arg, 10) >>> 0).toString(16) 20017 break 20018 case 'X': 20019 arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase() 20020 break 20021 } 20022 if (re.json.test(match[8])) { 20023 output += arg 20024 } 20025 else { 20026 if (re.number.test(match[8]) && (!is_positive || match[3])) { 20027 sign = is_positive ? '+' : '-' 20028 arg = arg.toString().replace(re.sign, '') 20029 } 20030 else { 20031 sign = '' 20032 } 20033 pad_character = match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' ' 20034 pad_length = match[6] - (sign + arg).length 20035 pad = match[6] ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' 20036 output += match[5] ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg) 20037 } 20038 } 20039 } 20040 return output 20041 } 20042 20043 var sprintf_cache = Object.create(null) 20044 20045 function sprintf_parse(fmt) { 20046 if (sprintf_cache[fmt]) { 20047 return sprintf_cache[fmt] 20048 } 20049 20050 var _fmt = fmt, match, parse_tree = [], arg_names = 0 20051 while (_fmt) { 20052 if ((match = re.text.exec(_fmt)) !== null) { 20053 parse_tree.push(match[0]) 20054 } 20055 else if ((match = re.modulo.exec(_fmt)) !== null) { 20056 parse_tree.push('%') 20057 } 20058 else if ((match = re.placeholder.exec(_fmt)) !== null) { 20059 if (match[2]) { 20060 arg_names |= 1 20061 var field_list = [], replacement_field = match[2], field_match = [] 20062 if ((field_match = re.key.exec(replacement_field)) !== null) { 20063 field_list.push(field_match[1]) 20064 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { 20065 if ((field_match = re.key_access.exec(replacement_field)) !== null) { 20066 field_list.push(field_match[1]) 20067 } 20068 else if ((field_match = re.index_access.exec(replacement_field)) !== null) { 20069 field_list.push(field_match[1]) 20070 } 20071 else { 20072 throw new SyntaxError('[sprintf] failed to parse named argument key') 20073 } 20074 } 20075 } 20076 else { 20077 throw new SyntaxError('[sprintf] failed to parse named argument key') 20078 } 20079 match[2] = field_list 20080 } 20081 else { 20082 arg_names |= 2 20083 } 20084 if (arg_names === 3) { 20085 throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported') 20086 } 20087 parse_tree.push(match) 20088 } 20089 else { 20090 throw new SyntaxError('[sprintf] unexpected placeholder') 20091 } 20092 _fmt = _fmt.substring(match[0].length) 20093 } 20094 return sprintf_cache[fmt] = parse_tree 20095 } 20096 20097 /** 20098 * export to either browser or node.js 20099 */ 20100 /* eslint-disable quote-props */ 20101 if (true) { 20102 exports['sprintf'] = sprintf 20103 exports['vsprintf'] = vsprintf 20104 } 20105 if (typeof window !== 'undefined') { 20106 window['sprintf'] = sprintf 20107 window['vsprintf'] = vsprintf 20108 20109 if (true) { 20110 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 20111 return { 20112 'sprintf': sprintf, 20113 'vsprintf': vsprintf 20114 } 20115 }).call(exports, __webpack_require__, exports, module), 20116 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) 20117 } 20118 } 20119 /* eslint-enable quote-props */ 20120}() 20121 20122 20123/***/ }), 20124
vendor: 2,340 bytes, lines 20125-20195
20125/***/ "./node_modules/timers-browserify/main.js": 20126/***/ (function(module, exports, __webpack_require__) { 20127 20128/* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) || 20129 (typeof self !== "undefined" && self) || 20130 window; 20131var apply = Function.prototype.apply; 20132 20133// DOM APIs, for completeness 20134 20135exports.setTimeout = function() { 20136 return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout); 20137}; 20138exports.setInterval = function() { 20139 return new Timeout(apply.call(setInterval, scope, arguments), clearInterval); 20140}; 20141exports.clearTimeout = 20142exports.clearInterval = function(timeout) { 20143 if (timeout) { 20144 timeout.close(); 20145 } 20146}; 20147 20148function Timeout(id, clearFn) { 20149 this._id = id; 20150 this._clearFn = clearFn; 20151} 20152Timeout.prototype.unref = Timeout.prototype.ref = function() {}; 20153Timeout.prototype.close = function() { 20154 this._clearFn.call(scope, this._id); 20155}; 20156 20157// Does not start the time, just sets up the members needed. 20158exports.enroll = function(item, msecs) { 20159 clearTimeout(item._idleTimeoutId); 20160 item._idleTimeout = msecs; 20161}; 20162 20163exports.unenroll = function(item) { 20164 clearTimeout(item._idleTimeoutId); 20165 item._idleTimeout = -1; 20166}; 20167 20168exports._unrefActive = exports.active = function(item) { 20169 clearTimeout(item._idleTimeoutId); 20170 20171 var msecs = item._idleTimeout; 20172 if (msecs >= 0) { 20173 item._idleTimeoutId = setTimeout(function onTimeout() { 20174 if (item._onTimeout) 20175 item._onTimeout(); 20176 }, msecs); 20177 } 20178}; 20179 20180// setimmediate attaches itself to the global object 20181__webpack_require__("./node_modules/setimmediate/setImmediate.js"); 20182// On some exotic environments, it's not clear which object `setimmediate` was 20183// able to install onto. Search each possibility in the same order as the 20184// `setimmediate` library. 20185exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) || 20186 (typeof global !== "undefined" && global.setImmediate) || 20187 (this && this.setImmediate); 20188exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) || 20189 (typeof global !== "undefined" && global.clearImmediate) || 20190 (this && this.clearImmediate); 20191 20192/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/webpack/buildin/global.js"))) 20193 20194/***/ }), 20195
vendor: 11,228 bytes, lines 20196-20524
20196/***/ "./node_modules/vue-loader/lib/component-normalizer.js": 20197/***/ (function(module, exports) { 20198 20199/* globals __VUE_SSR_CONTEXT__ */ 20200 20201// IMPORTANT: Do NOT use ES2015 features in this file. 20202// This module is a runtime utility for cleaner component module output and will 20203// be included in the final webpack user bundle. 20204 20205module.exports = function normalizeComponent ( 20206 rawScriptExports, 20207 compiledTemplate, 20208 functionalTemplate, 20209 injectStyles, 20210 scopeId, 20211 moduleIdentifier /* server only */ 20212) { 20213 var esModule 20214 var scriptExports = rawScriptExports = rawScriptExports || {} 20215 20216 // ES6 modules interop 20217 var type = typeof rawScriptExports.default 20218 if (type === 'object' || type === 'function') { 20219 esModule = rawScriptExports 20220 scriptExports = rawScriptExports.default 20221 } 20222 20223 // Vue.extend constructor export interop 20224 var options = typeof scriptExports === 'function' 20225 ? scriptExports.options 20226 : scriptExports 20227 20228 // render functions 20229 if (compiledTemplate) { 20230 options.render = compiledTemplate.render 20231 options.staticRenderFns = compiledTemplate.staticRenderFns 20232 options._compiled = true 20233 } 20234 20235 // functional template 20236 if (functionalTemplate) { 20237 options.functional = true 20238 } 20239 20240 // scopedId 20241 if (scopeId) { 20242 options._scopeId = scopeId 20243 } 20244 20245 var hook 20246 if (moduleIdentifier) { // server build 20247 hook = function (context) { 20248 // 2.3 injection 20249 context = 20250 context || // cached call 20251 (this.$vnode && this.$vnode.ssrContext) || // stateful 20252 (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional 20253 // 2.2 with runInNewContext: true 20254 if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { 20255 context = __VUE_SSR_CONTEXT__ 20256 } 20257 // inject component styles 20258 if (injectStyles) { 20259 injectStyles.call(this, context) 20260 } 20261 // register component module identifier for async chunk inferrence 20262 if (context && context._registeredComponents) { 20263 context._registeredComponents.add(moduleIdentifier) 20264 } 20265 } 20266 // used by ssr in case component is cached and beforeCreate 20267 // never gets called 20268 options._ssrRegister = hook 20269 } else if (injectStyles) { 20270 hook = injectStyles 20271 } 20272 20273 if (hook) { 20274 var functional = options.functional 20275 var existing = functional 20276 ? options.render 20277 : options.beforeCreate 20278 20279 if (!functional) { 20280 // inject component registration as beforeCreate hook 20281 options.beforeCreate = existing 20282 ? [].concat(existing, hook) 20283 : [hook] 20284 } else { 20285 // for template-only hot-reload because in that case the render fn doesn't 20286 // go through the normalizer 20287 options._injectStyles = hook 20288 // register for functioal component in vue file 20289 options.render = function renderWithStyleInjection (h, context) { 20290 hook.call(context) 20291 return existing(h, context) 20292 } 20293 } 20294 } 20295 20296 return { 20297 esModule: esModule, 20298 exports: scriptExports, 20299 options: options 20300 } 20301} 20302 20303 20304/***/ }), 20305 20306/***/ "./node_modules/vue-loader/lib/template-compiler/index.js?{\"id\":\"data-v-52401b6f\",\"hasScoped\":false,\"buble\":{\"transforms\":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./resources/assets/js/components/Images.vue": 20307/***/ (function(module, exports, __webpack_require__) { 20308 20309var render = function() { 20310 var _vm = this 20311 var _h = _vm.$createElement 20312 var _c = _vm._self._c || _h 20313 return _c("div", [ 20314 !_vm.uploading 20315 ? _c("div", { staticClass: "small-12 columns nopad upload-img-input" }, [ 20316 _c("div", { staticStyle: { display: "none" } }, [ 20317 !_vm.limitReached 20318 ? _c("input", { 20319 attrs: { type: "file", multiple: "", id: "photosInput" }, 20320 on: { change: _vm.upload } 20321 }) 20322 : _vm._e() 20323 ]), 20324 _vm._v(" "), 20325 !_vm.limitReached 20326 ? _c( 20327 "label", 20328 { staticClass: "btn-lpurple", attrs: { for: "photosInput" } }, 20329 [_vm._v("Pasirinkite nuotraukas")] 20330 ) 20331 : _vm._e() 20332 ]) 20333 : _vm._e(), 20334 _vm._v(" "), 20335 _vm.errors.length 20336 ? _c( 20337 "div", 20338 { staticClass: "small-12 columns nopad upload-error" }, 20339 _vm._l(_vm.errors, function(error) { 20340 return _c("span", [_vm._v(_vm._s(error))]) 20341 }) 20342 ) 20343 : _vm._e(), 20344 _vm._v(" "), 20345 _c("div", { staticClass: "small-12 columns nopad main-photo-title" }, [ 20346 _vm._v("\n PagrindinÄ nuotrauka\n ") 20347 ]), 20348 _vm._v(" "), 20349 _c("div", { staticClass: "small-12 columns nopad post-ad-img-block" }, [ 20350 _vm.uploading 20351 ? _c("div", { staticClass: "photo-upload-overlay" }, [_vm._m(0)]) 20352 : _vm._e(), 20353 _vm._v(" "), 20354 _c( 20355 "ul", 20356 [ 20357 _vm._l(_vm.photos, function(item, index) { 20358 return _c("li", [ 20359 _c("div", { 20360 staticClass: "small-12 columns nopad post-ad-img", 20361 style: { 20362 background: 20363 "url(" + item.thumb_url + ") no-repeat center center" 20364 } 20365 }), 20366 _vm._v(" "), 20367 _c("ul", [ 20368 _c("li", [ 20369 _c( 20370 "a", 20371 { 20372 staticClass: "btn-lpurple-icon", 20373 attrs: { href: "#" }, 20374 on: { 20375 click: function($event) { 20376 $event.preventDefault() 20377 _vm.rotateRight(item) 20378 } 20379 } 20380 }, 20381 [ 20382 _c("i", { 20383 staticClass: "fal fa-repeat", 20384 attrs: { "aria-hidden": "true" } 20385 }) 20386 ] 20387 ) 20388 ]), 20389 _vm._v(" "), 20390 _c("li", [ 20391 _c( 20392 "a", 20393 { 20394 staticClass: "btn-lpurple-icon", 20395 attrs: { href: "#" }, 20396 on: { 20397 click: function($event) { 20398 $event.preventDefault() 20399 _vm.pushLeft(item) 20400 } 20401 } 20402 }, 20403 [ 20404 _c("i", { 20405 staticClass: "fal fa-long-arrow-left", 20406 attrs: { "aria-hidden": "true" } 20407 }) 20408 ] 20409 ) 20410 ]), 20411 _vm._v(" "), 20412 _c("li", [ 20413 _c( 20414 "a", 20415 { 20416 staticClass: "btn-lpurple-icon", 20417 attrs: { href: "#" }, 20418 on: { 20419 click: function($event) { 20420 $event.preventDefault() 20421 _vm.pushRight(item) 20422 } 20423 } 20424 }, 20425 [ 20426 _c("i", { 20427 staticClass: "fal fa-long-arrow-right", 20428 attrs: { "aria-hidden": "true" } 20429 }) 20430 ] 20431 ) 20432 ]), 20433 _vm._v(" "), 20434 _c("li", [ 20435 _c( 20436 "a", 20437 { 20438 staticClass: "btn-lpurple-icon", 20439 attrs: { href: "#" }, 20440 on: { 20441 click: function($event) { 20442 $event.preventDefault() 20443 _vm.itemDelete(item) 20444 } 20445 } 20446 }, 20447 [ 20448 _c("i", { 20449 staticClass: "fal fa-times", 20450 attrs: { "aria-hidden": "true" } 20451 }) 20452 ] 20453 ) 20454 ]) 20455 ]) 20456 ]) 20457 }), 20458 _vm._v(" "), 20459 _vm._l(1, function(n) { 20460 return _c("li", { on: { click: _vm.triggerInput } }, [ 20461 _c("div", { 20462 staticClass: "small-12 columns nopad post-ad-img", 20463 staticStyle: { background: "url('') no-repeat center center" } 20464 }), 20465 _vm._v(" "), 20466 _c("ul") 20467 ]) 20468 }) 20469 ], 20470 2 20471 ) 20472 ]) 20473 ]) 20474} 20475var staticRenderFns = [ 20476 function() { 20477 var _vm = this 20478 var _h = _vm.$createElement 20479 var _c = _vm._self._c || _h 20480 return _c("div", { staticClass: "centering-overlay-hold" }, [ 20481 _c("img", { attrs: { src: "/assets/build/img/loading.gif" } }), 20482 _vm._v(" "), 20483 _c("span", [_vm._v("Nuotraukos keliamosâ¦")]) 20484 ]) 20485 } 20486] 20487render._withStripped = true 20488module.exports = { render: render, staticRenderFns: staticRenderFns } 20489if (false) { 20490 module.hot.accept() 20491 if (module.hot.data) { 20492 require("vue-hot-reload-api") .rerender("data-v-52401b6f", module.exports) 20493 } 20494} 20495 20496/***/ }), 20497 20498/***/ "./node_modules/vue-style-loader/index.js!./node_modules/css-loader/index.js!./node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-52401b6f\",\"scoped\":false,\"hasInlineConfig\":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./resources/assets/js/components/Images.vue": 20499/***/ (function(module, exports, __webpack_require__) { 20500 20501// style-loader: Adds some css to the DOM by adding a <style> tag 20502 20503// load the styles 20504var content = __webpack_require__("./node_modules/css-loader/index.js!./node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-52401b6f\",\"scoped\":false,\"hasInlineConfig\":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./resources/assets/js/components/Images.vue"); 20505if(typeof content === 'string') content = [[module.i, content, '']]; 20506if(content.locals) module.exports = content.locals; 20507// add the styles to the DOM 20508var update = __webpack_require__("./node_modules/vue-style-loader/lib/addStylesClient.js")("6a6fd557", content, false, {}); 20509// Hot Module Replacement 20510if(false) { 20511 // When the styles change, update the <style> tags 20512 if(!content.locals) { 20513 module.hot.accept("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-52401b6f\",\"scoped\":false,\"hasInlineConfig\":true}!../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./Images.vue", function() { 20514 var newContent = require("!!../../../../node_modules/css-loader/index.js!../../../../node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-52401b6f\",\"scoped\":false,\"hasInlineConfig\":true}!../../../../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./Images.vue"); 20515 if(typeof newContent === 'string') newContent = [[module.id, newContent, '']]; 20516 update(newContent); 20517 }); 20518 } 20519 // When the module is disposed, remove the <style> tags 20520 module.hot.dispose(function() { update(); }); 20521} 20522 20523/***/ }), 20524
vendor: 6,404 bytes, lines 20525-20753
20525/***/ "./node_modules/vue-style-loader/lib/addStylesClient.js": 20526/***/ (function(module, exports, __webpack_require__) { 20527 20528/* 20529 MIT License http://www.opensource.org/licenses/mit-license.php 20530 Author Tobias Koppers @sokra 20531 Modified by Evan You @yyx990803 20532*/ 20533 20534var hasDocument = typeof document !== 'undefined' 20535 20536if (typeof DEBUG !== 'undefined' && DEBUG) { 20537 if (!hasDocument) { 20538 throw new Error( 20539 'vue-style-loader cannot be used in a non-browser environment. ' + 20540 "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment." 20541 ) } 20542} 20543 20544var listToStyles = __webpack_require__("./node_modules/vue-style-loader/lib/listToStyles.js") 20545 20546/* 20547type StyleObject = { 20548 id: number; 20549 parts: Array<StyleObjectPart> 20550} 20551 20552type StyleObjectPart = { 20553 css: string; 20554 media: string; 20555 sourceMap: ?string 20556} 20557*/ 20558 20559var stylesInDom = {/* 20560 [id: number]: { 20561 id: number, 20562 refs: number, 20563 parts: Array<(obj?: StyleObjectPart) => void> 20564 } 20565*/} 20566 20567var head = hasDocument && (document.head || document.getElementsByTagName('head')[0]) 20568var singletonElement = null 20569var singletonCounter = 0 20570var isProduction = false 20571var noop = function () {} 20572var options = null 20573var ssrIdKey = 'data-vue-ssr-id' 20574 20575// Force single-tag solution on IE6-9, which has a hard limit on the # of <style> 20576// tags it will allow on a page 20577var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase()) 20578 20579module.exports = function (parentId, list, _isProduction, _options) { 20580 isProduction = _isProduction 20581 20582 options = _options || {} 20583 20584 var styles = listToStyles(parentId, list) 20585 addStylesToDom(styles) 20586 20587 return function update (newList) { 20588 var mayRemove = [] 20589 for (var i = 0; i < styles.length; i++) { 20590 var item = styles[i] 20591 var domStyle = stylesInDom[item.id] 20592 domStyle.refs-- 20593 mayRemove.push(domStyle) 20594 } 20595 if (newList) { 20596 styles = listToStyles(parentId, newList) 20597 addStylesToDom(styles) 20598 } else { 20599 styles = [] 20600 } 20601 for (var i = 0; i < mayRemove.length; i++) { 20602 var domStyle = mayRemove[i] 20603 if (domStyle.refs === 0) { 20604 for (var j = 0; j < domStyle.parts.length; j++) { 20605 domStyle.parts[j]() 20606 } 20607 delete stylesInDom[domStyle.id] 20608 } 20609 } 20610 } 20611} 20612 20613function addStylesToDom (styles /* Array<StyleObject> */) { 20614 for (var i = 0; i < styles.length; i++) { 20615 var item = styles[i] 20616 var domStyle = stylesInDom[item.id] 20617 if (domStyle) { 20618 domStyle.refs++ 20619 for (var j = 0; j < domStyle.parts.length; j++) { 20620 domStyle.parts[j](item.parts[j]) 20621 } 20622 for (; j < item.parts.length; j++) { 20623 domStyle.parts.push(addStyle(item.parts[j])) 20624 } 20625 if (domStyle.parts.length > item.parts.length) { 20626 domStyle.parts.length = item.parts.length 20627 } 20628 } else { 20629 var parts = [] 20630 for (var j = 0; j < item.parts.length; j++) { 20631 parts.push(addStyle(item.parts[j])) 20632 } 20633 stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts } 20634 } 20635 } 20636} 20637 20638function createStyleElement () { 20639 var styleElement = document.createElement('style') 20640 styleElement.type = 'text/css' 20641 head.appendChild(styleElement) 20642 return styleElement 20643} 20644 20645function addStyle (obj /* StyleObjectPart */) { 20646 var update, remove 20647 var styleElement = document.querySelector('style[' + ssrIdKey + '~="' + obj.id + '"]') 20648 20649 if (styleElement) { 20650 if (isProduction) { 20651 // has SSR styles and in production mode. 20652 // simply do nothing. 20653 return noop 20654 } else { 20655 // has SSR styles but in dev mode. 20656 // for some reason Chrome can't handle source map in server-rendered 20657 // style tags - source maps in <style> only works if the style tag is 20658 // created and inserted dynamically. So we remove the server rendered 20659 // styles and inject new ones. 20660 styleElement.parentNode.removeChild(styleElement) 20661 } 20662 } 20663 20664 if (isOldIE) { 20665 // use singleton mode for IE9. 20666 var styleIndex = singletonCounter++ 20667 styleElement = singletonElement || (singletonElement = createStyleElement()) 20668 update = applyToSingletonTag.bind(null, styleElement, styleIndex, false) 20669 remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true) 20670 } else { 20671 // use multi-style-tag mode in all other cases 20672 styleElement = createStyleElement() 20673 update = applyToTag.bind(null, styleElement) 20674 remove = function () { 20675 styleElement.parentNode.removeChild(styleElement) 20676 } 20677 } 20678 20679 update(obj) 20680 20681 return function updateStyle (newObj /* StyleObjectPart */) { 20682 if (newObj) { 20683 if (newObj.css === obj.css && 20684 newObj.media === obj.media && 20685 newObj.sourceMap === obj.sourceMap) { 20686 return 20687 } 20688 update(obj = newObj) 20689 } else { 20690 remove() 20691 } 20692 } 20693} 20694 20695var replaceText = (function () { 20696 var textStore = [] 20697 20698 return function (index, replacement) { 20699 textStore[index] = replacement 20700 return textStore.filter(Boolean).join('\n') 20701 } 20702})() 20703 20704function applyToSingletonTag (styleElement, index, remove, obj) { 20705 var css = remove ? '' : obj.css 20706 20707 if (styleElement.styleSheet) { 20708 styleElement.styleSheet.cssText = replaceText(index, css) 20709 } else { 20710 var cssNode = document.createTextNode(css) 20711 var childNodes = styleElement.childNodes 20712 if (childNodes[index]) styleElement.removeChild(childNodes[index]) 20713 if (childNodes.length) { 20714 styleElement.insertBefore(cssNode, childNodes[index]) 20715 } else { 20716 styleElement.appendChild(cssNode) 20717 } 20718 } 20719} 20720 20721function applyToTag (styleElement, obj) { 20722 var css = obj.css 20723 var media = obj.media 20724 var sourceMap = obj.sourceMap 20725 20726 if (media) { 20727 styleElement.setAttribute('media', media) 20728 } 20729 if (options.ssrId) { 20730 styleElement.setAttribute(ssrIdKey, obj.id) 20731 } 20732 20733 if (sourceMap) { 20734 // https://developer.chrome.com/devtools/docs/javascript-debugging 20735 // this makes source maps inside style tags work properly in Chrome 20736 css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */' 20737 // http://stackoverflow.com/a/26603875 20738 css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */' 20739 } 20740 20741 if (styleElement.styleSheet) { 20742 styleElement.styleSheet.cssText = css 20743 } else { 20744 while (styleElement.firstChild) { 20745 styleElement.removeChild(styleElement.firstChild) 20746 } 20747 styleElement.appendChild(document.createTextNode(css)) 20748 } 20749} 20750 20751 20752/***/ }), 20753
vendor: 749 bytes, lines 20754-20787
20754/***/ "./node_modules/vue-style-loader/lib/listToStyles.js": 20755/***/ (function(module, exports) { 20756 20757/** 20758 * Translates the list format produced by css-loader into something 20759 * easier to manipulate. 20760 */ 20761module.exports = function listToStyles (parentId, list) { 20762 var styles = [] 20763 var newStyles = {} 20764 for (var i = 0; i < list.length; i++) { 20765 var item = list[i] 20766 var id = item[0] 20767 var css = item[1] 20768 var media = item[2] 20769 var sourceMap = item[3] 20770 var part = { 20771 id: parentId + ':' + i, 20772 css: css, 20773 media: media, 20774 sourceMap: sourceMap 20775 } 20776 if (!newStyles[id]) { 20777 styles.push(newStyles[id] = { id: id, parts: [part] }) 20778 } else { 20779 newStyles[id].parts.push(part) 20780 } 20781 } 20782 return styles 20783} 20784 20785 20786/***/ }), 20787
vendor: 290,419 bytes, lines 20788-31754
20788/***/ "./node_modules/vue/dist/vue.common.js": 20789/***/ (function(module, exports, __webpack_require__) { 20790 20791"use strict"; 20792/* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*! 20793 * Vue.js v2.5.16 20794 * (c) 2014-2018 Evan You 20795 * Released under the MIT License. 20796 */ 20797 20798 20799/* */ 20800 20801var emptyObject = Object.freeze({}); 20802 20803// these helpers produces better vm code in JS engines due to their 20804// explicitness and function inlining 20805function isUndef (v) { 20806 return v === undefined || v === null 20807} 20808 20809function isDef (v) { 20810 return v !== undefined && v !== null 20811} 20812 20813function isTrue (v) { 20814 return v === true 20815} 20816 20817function isFalse (v) { 20818 return v === false 20819} 20820 20821/** 20822 * Check if value is primitive 20823 */ 20824function isPrimitive (value) { 20825 return ( 20826 typeof value === 'string' || 20827 typeof value === 'number' || 20828 // $flow-disable-line 20829 typeof value === 'symbol' || 20830 typeof value === 'boolean' 20831 ) 20832} 20833 20834/** 20835 * Quick object check - this is primarily used to tell 20836 * Objects from primitive values when we know the value 20837 * is a JSON-compliant type. 20838 */ 20839function isObject (obj) { 20840 return obj !== null && typeof obj === 'object' 20841} 20842 20843/** 20844 * Get the raw type string of a value e.g. [object Object] 20845 */ 20846var _toString = Object.prototype.toString; 20847 20848function toRawType (value) { 20849 return _toString.call(value).slice(8, -1) 20850} 20851 20852/** 20853 * Strict object type check. Only returns true 20854 * for plain JavaScript objects. 20855 */ 20856function isPlainObject (obj) { 20857 return _toString.call(obj) === '[object Object]' 20858} 20859 20860function isRegExp (v) { 20861 return _toString.call(v) === '[object RegExp]' 20862} 20863 20864/** 20865 * Check if val is a valid array index. 20866 */ 20867function isValidArrayIndex (val) { 20868 var n = parseFloat(String(val)); 20869 return n >= 0 && Math.floor(n) === n && isFinite(val) 20870} 20871 20872/** 20873 * Convert a value to a string that is actually rendered. 20874 */ 20875function toString (val) { 20876 return val == null 20877 ? '' 20878 : typeof val === 'object' 20879 ? JSON.stringify(val, null, 2) 20880 : String(val) 20881} 20882 20883/** 20884 * Convert a input value to a number for persistence. 20885 * If the conversion fails, return original string. 20886 */ 20887function toNumber (val) { 20888 var n = parseFloat(val); 20889 return isNaN(n) ? val : n 20890} 20891 20892/** 20893 * Make a map and return a function for checking if a key 20894 * is in that map. 20895 */ 20896function makeMap ( 20897 str, 20898 expectsLowerCase 20899) { 20900 var map = Object.create(null); 20901 var list = str.split(','); 20902 for (var i = 0; i < list.length; i++) { 20903 map[list[i]] = true; 20904 } 20905 return expectsLowerCase 20906 ? function (val) { return map[val.toLowerCase()]; } 20907 : function (val) { return map[val]; } 20908} 20909 20910/** 20911 * Check if a tag is a built-in tag. 20912 */ 20913var isBuiltInTag = makeMap('slot,component', true); 20914 20915/** 20916 * Check if a attribute is a reserved attribute. 20917 */ 20918var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); 20919 20920/** 20921 * Remove an item from an array 20922 */ 20923function remove (arr, item) { 20924 if (arr.length) { 20925 var index = arr.indexOf(item); 20926 if (index > -1) { 20927 return arr.splice(index, 1) 20928 } 20929 } 20930} 20931 20932/** 20933 * Check whether the object has the property. 20934 */ 20935var hasOwnProperty = Object.prototype.hasOwnProperty; 20936function hasOwn (obj, key) { 20937 return hasOwnProperty.call(obj, key) 20938} 20939 20940/** 20941 * Create a cached version of a pure function. 20942 */ 20943function cached (fn) { 20944 var cache = Object.create(null); 20945 return (function cachedFn (str) { 20946 var hit = cache[str]; 20947 return hit || (cache[str] = fn(str)) 20948 }) 20949} 20950 20951/** 20952 * Camelize a hyphen-delimited string. 20953 */ 20954var camelizeRE = /-(\w)/g; 20955var camelize = cached(function (str) { 20956 return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) 20957}); 20958 20959/** 20960 * Capitalize a string. 20961 */ 20962var capitalize = cached(function (str) { 20963 return str.charAt(0).toUpperCase() + str.slice(1) 20964}); 20965 20966/** 20967 * Hyphenate a camelCase string. 20968 */ 20969var hyphenateRE = /\B([A-Z])/g; 20970var hyphenate = cached(function (str) { 20971 return str.replace(hyphenateRE, '-$1').toLowerCase() 20972}); 20973 20974/** 20975 * Simple bind polyfill for environments that do not support it... e.g. 20976 * PhantomJS 1.x. Technically we don't need this anymore since native bind is 20977 * now more performant in most browsers, but removing it would be breaking for 20978 * code that was able to run in PhantomJS 1.x, so this must be kept for 20979 * backwards compatibility. 20980 */ 20981 20982/* istanbul ignore next */ 20983function polyfillBind (fn, ctx) { 20984 function boundFn (a) { 20985 var l = arguments.length; 20986 return l 20987 ? l > 1 20988 ? fn.apply(ctx, arguments) 20989 : fn.call(ctx, a) 20990 : fn.call(ctx) 20991 } 20992 20993 boundFn._length = fn.length; 20994 return boundFn 20995} 20996 20997function nativeBind (fn, ctx) { 20998 return fn.bind(ctx) 20999} 21000 21001var bind = Function.prototype.bind 21002 ? nativeBind 21003 : polyfillBind; 21004 21005/** 21006 * Convert an Array-like object to a real Array. 21007 */ 21008function toArray (list, start) { 21009 start = start || 0; 21010 var i = list.length - start; 21011 var ret = new Array(i); 21012 while (i--) { 21013 ret[i] = list[i + start]; 21014 } 21015 return ret 21016} 21017 21018/** 21019 * Mix properties into target object. 21020 */ 21021function extend (to, _from) { 21022 for (var key in _from) { 21023 to[key] = _from[key]; 21024 } 21025 return to 21026} 21027 21028/** 21029 * Merge an Array of Objects into a single Object. 21030 */ 21031function toObject (arr) { 21032 var res = {}; 21033 for (var i = 0; i < arr.length; i++) { 21034 if (arr[i]) { 21035 extend(res, arr[i]); 21036 } 21037 } 21038 return res 21039} 21040 21041/** 21042 * Perform no operation. 21043 * Stubbing args to make Flow happy without leaving useless transpiled code 21044 * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) 21045 */ 21046function noop (a, b, c) {} 21047 21048/** 21049 * Always return false. 21050 */ 21051var no = function (a, b, c) { return false; }; 21052 21053/** 21054 * Return same value 21055 */ 21056var identity = function (_) { return _; }; 21057 21058/** 21059 * Generate a static keys string from compiler modules. 21060 */ 21061function genStaticKeys (modules) { 21062 return modules.reduce(function (keys, m) { 21063 return keys.concat(m.staticKeys || []) 21064 }, []).join(',') 21065} 21066 21067/** 21068 * Check if two values are loosely equal - that is, 21069 * if they are plain objects, do they have the same shape? 21070 */ 21071function looseEqual (a, b) { 21072 if (a === b) { return true } 21073 var isObjectA = isObject(a); 21074 var isObjectB = isObject(b); 21075 if (isObjectA && isObjectB) { 21076 try { 21077 var isArrayA = Array.isArray(a); 21078 var isArrayB = Array.isArray(b); 21079 if (isArrayA && isArrayB) { 21080 return a.length === b.length && a.every(function (e, i) { 21081 return looseEqual(e, b[i]) 21082 }) 21083 } else if (!isArrayA && !isArrayB) { 21084 var keysA = Object.keys(a); 21085 var keysB = Object.keys(b); 21086 return keysA.length === keysB.length && keysA.every(function (key) { 21087 return looseEqual(a[key], b[key]) 21088 }) 21089 } else { 21090 /* istanbul ignore next */ 21091 return false 21092 } 21093 } catch (e) { 21094 /* istanbul ignore next */ 21095 return false 21096 } 21097 } else if (!isObjectA && !isObjectB) { 21098 return String(a) === String(b) 21099 } else { 21100 return false 21101 } 21102} 21103 21104function looseIndexOf (arr, val) { 21105 for (var i = 0; i < arr.length; i++) { 21106 if (looseEqual(arr[i], val)) { return i } 21107 } 21108 return -1 21109} 21110 21111/** 21112 * Ensure a function is called only once. 21113 */ 21114function once (fn) { 21115 var called = false; 21116 return function () { 21117 if (!called) { 21118 called = true; 21119 fn.apply(this, arguments); 21120 } 21121 } 21122} 21123 21124var SSR_ATTR = 'data-server-rendered'; 21125 21126var ASSET_TYPES = [ 21127 'component', 21128 'directive', 21129 'filter' 21130]; 21131 21132var LIFECYCLE_HOOKS = [ 21133 'beforeCreate', 21134 'created', 21135 'beforeMount', 21136 'mounted', 21137 'beforeUpdate', 21138 'updated', 21139 'beforeDestroy', 21140 'destroyed', 21141 'activated', 21142 'deactivated', 21143 'errorCaptured' 21144]; 21145 21146/* */ 21147 21148var config = ({ 21149 /** 21150 * Option merge strategies (used in core/util/options) 21151 */ 21152 // $flow-disable-line 21153 optionMergeStrategies: Object.create(null), 21154 21155 /** 21156 * Whether to suppress warnings. 21157 */ 21158 silent: false, 21159 21160 /** 21161 * Show production mode tip message on boot? 21162 */ 21163 productionTip: "development" !== 'production', 21164 21165 /** 21166 * Whether to enable devtools 21167 */ 21168 devtools: "development" !== 'production', 21169 21170 /** 21171 * Whether to record perf 21172 */ 21173 performance: false, 21174 21175 /** 21176 * Error handler for watcher errors 21177 */ 21178 errorHandler: null, 21179 21180 /** 21181 * Warn handler for watcher warns 21182 */ 21183 warnHandler: null, 21184 21185 /** 21186 * Ignore certain custom elements 21187 */ 21188 ignoredElements: [], 21189 21190 /** 21191 * Custom user key aliases for v-on 21192 */ 21193 // $flow-disable-line 21194 keyCodes: Object.create(null), 21195 21196 /** 21197 * Check if a tag is reserved so that it cannot be registered as a 21198 * component. This is platform-dependent and may be overwritten. 21199 */ 21200 isReservedTag: no, 21201 21202 /** 21203 * Check if an attribute is reserved so that it cannot be used as a component 21204 * prop. This is platform-dependent and may be overwritten. 21205 */ 21206 isReservedAttr: no, 21207 21208 /** 21209 * Check if a tag is an unknown element. 21210 * Platform-dependent. 21211 */ 21212 isUnknownElement: no, 21213 21214 /** 21215 * Get the namespace of an element 21216 */ 21217 getTagNamespace: noop, 21218 21219 /** 21220 * Parse the real tag name for the specific platform. 21221 */ 21222 parsePlatformTagName: identity, 21223 21224 /** 21225 * Check if an attribute must be bound using property, e.g. value 21226 * Platform-dependent. 21227 */ 21228 mustUseProp: no, 21229 21230 /** 21231 * Exposed for legacy reasons 21232 */ 21233 _lifecycleHooks: LIFECYCLE_HOOKS 21234}) 21235 21236/* */ 21237 21238/** 21239 * Check if a string starts with $ or _ 21240 */ 21241function isReserved (str) { 21242 var c = (str + '').charCodeAt(0); 21243 return c === 0x24 || c === 0x5F 21244} 21245 21246/** 21247 * Define a property. 21248 */ 21249function def (obj, key, val, enumerable) { 21250 Object.defineProperty(obj, key, { 21251 value: val, 21252 enumerable: !!enumerable, 21253 writable: true, 21254 configurable: true 21255 }); 21256} 21257 21258/** 21259 * Parse simple path. 21260 */ 21261var bailRE = /[^\w.$]/; 21262function parsePath (path) { 21263 if (bailRE.test(path)) { 21264 return 21265 } 21266 var segments = path.split('.'); 21267 return function (obj) { 21268 for (var i = 0; i < segments.length; i++) { 21269 if (!obj) { return } 21270 obj = obj[segments[i]]; 21271 } 21272 return obj 21273 } 21274} 21275 21276/* */ 21277 21278// can we use __proto__? 21279var hasProto = '__proto__' in {}; 21280 21281// Browser environment sniffing 21282var inBrowser = typeof window !== 'undefined'; 21283var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; 21284var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase(); 21285var UA = inBrowser && window.navigator.userAgent.toLowerCase(); 21286var isIE = UA && /msie|trident/.test(UA); 21287var isIE9 = UA && UA.indexOf('msie 9.0') > 0; 21288var isEdge = UA && UA.indexOf('edge/') > 0; 21289var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'); 21290var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios'); 21291var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; 21292 21293// Firefox has a "watch" function on Object.prototype... 21294var nativeWatch = ({}).watch; 21295 21296var supportsPassive = false; 21297if (inBrowser) { 21298 try { 21299 var opts = {}; 21300 Object.defineProperty(opts, 'passive', ({ 21301 get: function get () { 21302 /* istanbul ignore next */ 21303 supportsPassive = true; 21304 } 21305 })); // https://github.com/facebook/flow/issues/285 21306 window.addEventListener('test-passive', null, opts); 21307 } catch (e) {} 21308} 21309 21310// this needs to be lazy-evaled because vue may be required before 21311// vue-server-renderer can set VUE_ENV 21312var _isServer; 21313var isServerRendering = function () { 21314 if (_isServer === undefined) { 21315 /* istanbul ignore if */ 21316 if (!inBrowser && !inWeex && typeof global !== 'undefined') { 21317 // detect presence of vue-server-renderer and avoid 21318 // Webpack shimming the process 21319 _isServer = global['process'].env.VUE_ENV === 'server'; 21320 } else { 21321 _isServer = false; 21322 } 21323 } 21324 return _isServer 21325}; 21326 21327// detect devtools 21328var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; 21329 21330/* istanbul ignore next */ 21331function isNative (Ctor) { 21332 return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) 21333} 21334 21335var hasSymbol = 21336 typeof Symbol !== 'undefined' && isNative(Symbol) && 21337 typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); 21338 21339var _Set; 21340/* istanbul ignore if */ // $flow-disable-line 21341if (typeof Set !== 'undefined' && isNative(Set)) { 21342 // use native Set when available. 21343 _Set = Set; 21344} else { 21345 // a non-standard Set polyfill that only works with primitive keys. 21346 _Set = (function () { 21347 function Set () { 21348 this.set = Object.create(null); 21349 } 21350 Set.prototype.has = function has (key) { 21351 return this.set[key] === true 21352 }; 21353 Set.prototype.add = function add (key) { 21354 this.set[key] = true; 21355 }; 21356 Set.prototype.clear = function clear () { 21357 this.set = Object.create(null); 21358 }; 21359 21360 return Set; 21361 }()); 21362} 21363 21364/* */ 21365 21366var warn = noop; 21367var tip = noop; 21368var generateComponentTrace = (noop); // work around flow check 21369var formatComponentName = (noop); 21370 21371if (true) { 21372 var hasConsole = typeof console !== 'undefined'; 21373 var classifyRE = /(?:^|[-_])(\w)/g; 21374 var classify = function (str) { return str 21375 .replace(classifyRE, function (c) { return c.toUpperCase(); }) 21376 .replace(/[-_]/g, ''); }; 21377 21378 warn = function (msg, vm) { 21379 var trace = vm ? generateComponentTrace(vm) : ''; 21380 21381 if (config.warnHandler) { 21382 config.warnHandler.call(null, msg, vm, trace); 21383 } else if (hasConsole && (!config.silent)) { 21384 console.error(("[Vue warn]: " + msg + trace)); 21385 } 21386 }; 21387 21388 tip = function (msg, vm) { 21389 if (hasConsole && (!config.silent)) { 21390 console.warn("[Vue tip]: " + msg + ( 21391 vm ? generateComponentTrace(vm) : '' 21392 )); 21393 } 21394 }; 21395 21396 formatComponentName = function (vm, includeFile) { 21397 if (vm.$root === vm) { 21398 return '<Root>' 21399 } 21400 var options = typeof vm === 'function' && vm.cid != null 21401 ? vm.options 21402 : vm._isVue 21403 ? vm.$options || vm.constructor.options 21404 : vm || {}; 21405 var name = options.name || options._componentTag; 21406 var file = options.__file; 21407 if (!name && file) { 21408 var match = file.match(/([^/\\]+)\.vue$/); 21409 name = match && match[1]; 21410 } 21411 21412 return ( 21413 (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") + 21414 (file && includeFile !== false ? (" at " + file) : '') 21415 ) 21416 }; 21417 21418 var repeat = function (str, n) { 21419 var res = ''; 21420 while (n) { 21421 if (n % 2 === 1) { res += str; } 21422 if (n > 1) { str += str; } 21423 n >>= 1; 21424 } 21425 return res 21426 }; 21427 21428 generateComponentTrace = function (vm) { 21429 if (vm._isVue && vm.$parent) { 21430 var tree = []; 21431 var currentRecursiveSequence = 0; 21432 while (vm) { 21433 if (tree.length > 0) { 21434 var last = tree[tree.length - 1]; 21435 if (last.constructor === vm.constructor) { 21436 currentRecursiveSequence++; 21437 vm = vm.$parent; 21438 continue 21439 } else if (currentRecursiveSequence > 0) { 21440 tree[tree.length - 1] = [last, currentRecursiveSequence]; 21441 currentRecursiveSequence = 0; 21442 } 21443 } 21444 tree.push(vm); 21445 vm = vm.$parent; 21446 } 21447 return '\n\nfound in\n\n' + tree 21448 .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) 21449 ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") 21450 : formatComponentName(vm))); }) 21451 .join('\n') 21452 } else { 21453 return ("\n\n(found in " + (formatComponentName(vm)) + ")") 21454 } 21455 }; 21456} 21457 21458/* */ 21459 21460 21461var uid = 0; 21462 21463/** 21464 * A dep is an observable that can have multiple 21465 * directives subscribing to it. 21466 */ 21467var Dep = function Dep () { 21468 this.id = uid++; 21469 this.subs = []; 21470}; 21471 21472Dep.prototype.addSub = function addSub (sub) { 21473 this.subs.push(sub); 21474}; 21475 21476Dep.prototype.removeSub = function removeSub (sub) { 21477 remove(this.subs, sub); 21478}; 21479 21480Dep.prototype.depend = function depend () { 21481 if (Dep.target) { 21482 Dep.target.addDep(this); 21483 } 21484}; 21485 21486Dep.prototype.notify = function notify () { 21487 // stabilize the subscriber list first 21488 var subs = this.subs.slice(); 21489 for (var i = 0, l = subs.length; i < l; i++) { 21490 subs[i].update(); 21491 } 21492}; 21493 21494// the current target watcher being evaluated. 21495// this is globally unique because there could be only one 21496// watcher being evaluated at any time. 21497Dep.target = null; 21498var targetStack = []; 21499 21500function pushTarget (_target) { 21501 if (Dep.target) { targetStack.push(Dep.target); } 21502 Dep.target = _target; 21503} 21504 21505function popTarget () { 21506 Dep.target = targetStack.pop(); 21507} 21508 21509/* */ 21510 21511var VNode = function VNode ( 21512 tag, 21513 data, 21514 children, 21515 text, 21516 elm, 21517 context, 21518 componentOptions, 21519 asyncFactory 21520) { 21521 this.tag = tag; 21522 this.data = data; 21523 this.children = children; 21524 this.text = text; 21525 this.elm = elm; 21526 this.ns = undefined; 21527 this.context = context; 21528 this.fnContext = undefined; 21529 this.fnOptions = undefined; 21530 this.fnScopeId = undefined; 21531 this.key = data && data.key; 21532 this.componentOptions = componentOptions; 21533 this.componentInstance = undefined; 21534 this.parent = undefined; 21535 this.raw = false; 21536 this.isStatic = false; 21537 this.isRootInsert = true; 21538 this.isComment = false; 21539 this.isCloned = false; 21540 this.isOnce = false; 21541 this.asyncFactory = asyncFactory; 21542 this.asyncMeta = undefined; 21543 this.isAsyncPlaceholder = false; 21544}; 21545 21546var prototypeAccessors = { child: { configurable: true } }; 21547 21548// DEPRECATED: alias for componentInstance for backwards compat. 21549/* istanbul ignore next */ 21550prototypeAccessors.child.get = function () { 21551 return this.componentInstance 21552}; 21553 21554Object.defineProperties( VNode.prototype, prototypeAccessors ); 21555 21556var createEmptyVNode = function (text) { 21557 if ( text === void 0 ) text = ''; 21558 21559 var node = new VNode(); 21560 node.text = text; 21561 node.isComment = true; 21562 return node 21563}; 21564 21565function createTextVNode (val) { 21566 return new VNode(undefined, undefined, undefined, String(val)) 21567} 21568 21569// optimized shallow clone 21570// used for static nodes and slot nodes because they may be reused across 21571// multiple renders, cloning them avoids errors when DOM manipulations rely 21572// on their elm reference. 21573function cloneVNode (vnode) { 21574 var cloned = new VNode( 21575 vnode.tag, 21576 vnode.data, 21577 vnode.children, 21578 vnode.text, 21579 vnode.elm, 21580 vnode.context, 21581 vnode.componentOptions, 21582 vnode.asyncFactory 21583 ); 21584 cloned.ns = vnode.ns; 21585 cloned.isStatic = vnode.isStatic; 21586 cloned.key = vnode.key; 21587 cloned.isComment = vnode.isComment; 21588 cloned.fnContext = vnode.fnContext; 21589 cloned.fnOptions = vnode.fnOptions; 21590 cloned.fnScopeId = vnode.fnScopeId; 21591 cloned.isCloned = true; 21592 return cloned 21593} 21594 21595/* 21596 * not type checking this file because flow doesn't play well with 21597 * dynamically accessing methods on Array prototype 21598 */ 21599 21600var arrayProto = Array.prototype; 21601var arrayMethods = Object.create(arrayProto); 21602 21603var methodsToPatch = [ 21604 'push', 21605 'pop', 21606 'shift', 21607 'unshift', 21608 'splice', 21609 'sort', 21610 'reverse' 21611]; 21612 21613/** 21614 * Intercept mutating methods and emit events 21615 */ 21616methodsToPatch.forEach(function (method) { 21617 // cache original method 21618 var original = arrayProto[method]; 21619 def(arrayMethods, method, function mutator () { 21620 var args = [], len = arguments.length; 21621 while ( len-- ) args[ len ] = arguments[ len ]; 21622 21623 var result = original.apply(this, args); 21624 var ob = this.__ob__; 21625 var inserted; 21626 switch (method) { 21627 case 'push': 21628 case 'unshift': 21629 inserted = args; 21630 break 21631 case 'splice': 21632 inserted = args.slice(2); 21633 break 21634 } 21635 if (inserted) { ob.observeArray(inserted); } 21636 // notify change 21637 ob.dep.notify(); 21638 return result 21639 }); 21640}); 21641 21642/* */ 21643 21644var arrayKeys = Object.getOwnPropertyNames(arrayMethods); 21645 21646/** 21647 * In some cases we may want to disable observation inside a component's 21648 * update computation. 21649 */ 21650var shouldObserve = true; 21651 21652function toggleObserving (value) { 21653 shouldObserve = value; 21654} 21655 21656/** 21657 * Observer class that is attached to each observed 21658 * object. Once attached, the observer converts the target 21659 * object's property keys into getter/setters that 21660 * collect dependencies and dispatch updates. 21661 */ 21662var Observer = function Observer (value) { 21663 this.value = value; 21664 this.dep = new Dep(); 21665 this.vmCount = 0; 21666 def(value, '__ob__', this); 21667 if (Array.isArray(value)) { 21668 var augment = hasProto 21669 ? protoAugment 21670 : copyAugment; 21671 augment(value, arrayMethods, arrayKeys); 21672 this.observeArray(value); 21673 } else { 21674 this.walk(value); 21675 } 21676}; 21677 21678/** 21679 * Walk through each property and convert them into 21680 * getter/setters. This method should only be called when 21681 * value type is Object. 21682 */ 21683Observer.prototype.walk = function walk (obj) { 21684 var keys = Object.keys(obj); 21685 for (var i = 0; i < keys.length; i++) { 21686 defineReactive(obj, keys[i]); 21687 } 21688}; 21689 21690/** 21691 * Observe a list of Array items. 21692 */ 21693Observer.prototype.observeArray = function observeArray (items) { 21694 for (var i = 0, l = items.length; i < l; i++) { 21695 observe(items[i]); 21696 } 21697}; 21698 21699// helpers 21700 21701/** 21702 * Augment an target Object or Array by intercepting 21703 * the prototype chain using __proto__ 21704 */ 21705function protoAugment (target, src, keys) { 21706 /* eslint-disable no-proto */ 21707 target.__proto__ = src; 21708 /* eslint-enable no-proto */ 21709} 21710 21711/** 21712 * Augment an target Object or Array by defining 21713 * hidden properties. 21714 */ 21715/* istanbul ignore next */ 21716function copyAugment (target, src, keys) { 21717 for (var i = 0, l = keys.length; i < l; i++) { 21718 var key = keys[i]; 21719 def(target, key, src[key]); 21720 } 21721} 21722 21723/** 21724 * Attempt to create an observer instance for a value, 21725 * returns the new observer if successfully observed, 21726 * or the existing observer if the value already has one. 21727 */ 21728function observe (value, asRootData) { 21729 if (!isObject(value) || value instanceof VNode) { 21730 return 21731 } 21732 var ob; 21733 if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { 21734 ob = value.__ob__; 21735 } else if ( 21736 shouldObserve && 21737 !isServerRendering() && 21738 (Array.isArray(value) || isPlainObject(value)) && 21739 Object.isExtensible(value) && 21740 !value._isVue 21741 ) { 21742 ob = new Observer(value); 21743 } 21744 if (asRootData && ob) { 21745 ob.vmCount++; 21746 } 21747 return ob 21748} 21749 21750/** 21751 * Define a reactive property on an Object. 21752 */ 21753function defineReactive ( 21754 obj, 21755 key, 21756 val, 21757 customSetter, 21758 shallow 21759) { 21760 var dep = new Dep(); 21761 21762 var property = Object.getOwnPropertyDescriptor(obj, key); 21763 if (property && property.configurable === false) { 21764 return 21765 } 21766 21767 // cater for pre-defined getter/setters 21768 var getter = property && property.get; 21769 if (!getter && arguments.length === 2) { 21770 val = obj[key]; 21771 } 21772 var setter = property && property.set; 21773 21774 var childOb = !shallow && observe(val); 21775 Object.defineProperty(obj, key, { 21776 enumerable: true, 21777 configurable: true, 21778 get: function reactiveGetter () { 21779 var value = getter ? getter.call(obj) : val; 21780 if (Dep.target) { 21781 dep.depend(); 21782 if (childOb) { 21783 childOb.dep.depend(); 21784 if (Array.isArray(value)) { 21785 dependArray(value); 21786 } 21787 } 21788 } 21789 return value 21790 }, 21791 set: function reactiveSetter (newVal) { 21792 var value = getter ? getter.call(obj) : val; 21793 /* eslint-disable no-self-compare */ 21794 if (newVal === value || (newVal !== newVal && value !== value)) { 21795 return 21796 } 21797 /* eslint-enable no-self-compare */ 21798 if ("development" !== 'production' && customSetter) { 21799 customSetter(); 21800 } 21801 if (setter) { 21802 setter.call(obj, newVal); 21803 } else { 21804 val = newVal; 21805 } 21806 childOb = !shallow && observe(newVal); 21807 dep.notify(); 21808 } 21809 }); 21810} 21811 21812/** 21813 * Set a property on an object. Adds the new property and 21814 * triggers change notification if the property doesn't 21815 * already exist. 21816 */ 21817function set (target, key, val) { 21818 if ("development" !== 'production' && 21819 (isUndef(target) || isPrimitive(target)) 21820 ) { 21821 warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target)))); 21822 } 21823 if (Array.isArray(target) && isValidArrayIndex(key)) { 21824 target.length = Math.max(target.length, key); 21825 target.splice(key, 1, val); 21826 return val 21827 } 21828 if (key in target && !(key in Object.prototype)) { 21829 target[key] = val; 21830 return val 21831 } 21832 var ob = (target).__ob__; 21833 if (target._isVue || (ob && ob.vmCount)) { 21834 "development" !== 'production' && warn( 21835 'Avoid adding reactive properties to a Vue instance or its root $data ' + 21836 'at runtime - declare it upfront in the data option.' 21837 ); 21838 return val 21839 } 21840 if (!ob) { 21841 target[key] = val; 21842 return val 21843 } 21844 defineReactive(ob.value, key, val); 21845 ob.dep.notify(); 21846 return val 21847} 21848 21849/** 21850 * Delete a property and trigger change if necessary. 21851 */ 21852function del (target, key) { 21853 if ("development" !== 'production' && 21854 (isUndef(target) || isPrimitive(target)) 21855 ) { 21856 warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target)))); 21857 } 21858 if (Array.isArray(target) && isValidArrayIndex(key)) { 21859 target.splice(key, 1); 21860 return 21861 } 21862 var ob = (target).__ob__; 21863 if (target._isVue || (ob && ob.vmCount)) { 21864 "development" !== 'production' && warn( 21865 'Avoid deleting properties on a Vue instance or its root $data ' + 21866 '- just set it to null.' 21867 ); 21868 return 21869 } 21870 if (!hasOwn(target, key)) { 21871 return 21872 } 21873 delete target[key]; 21874 if (!ob) { 21875 return 21876 } 21877 ob.dep.notify(); 21878} 21879 21880/** 21881 * Collect dependencies on array elements when the array is touched, since 21882 * we cannot intercept array element access like property getters. 21883 */ 21884function dependArray (value) { 21885 for (var e = (void 0), i = 0, l = value.length; i < l; i++) { 21886 e = value[i]; 21887 e && e.__ob__ && e.__ob__.dep.depend(); 21888 if (Array.isArray(e)) { 21889 dependArray(e); 21890 } 21891 } 21892} 21893 21894/* */ 21895 21896/** 21897 * Option overwriting strategies are functions that handle 21898 * how to merge a parent option value and a child option 21899 * value into the final value. 21900 */ 21901var strats = config.optionMergeStrategies; 21902 21903/** 21904 * Options with restrictions 21905 */ 21906if (true) { 21907 strats.el = strats.propsData = function (parent, child, vm, key) { 21908 if (!vm) { 21909 warn( 21910 "option \"" + key + "\" can only be used during instance " + 21911 'creation with the `new` keyword.' 21912 ); 21913 } 21914 return defaultStrat(parent, child) 21915 }; 21916} 21917 21918/** 21919 * Helper that recursively merges two data objects together. 21920 */ 21921function mergeData (to, from) { 21922 if (!from) { return to } 21923 var key, toVal, fromVal; 21924 var keys = Object.keys(from); 21925 for (var i = 0; i < keys.length; i++) { 21926 key = keys[i]; 21927 toVal = to[key]; 21928 fromVal = from[key]; 21929 if (!hasOwn(to, key)) { 21930 set(to, key, fromVal); 21931 } else if (isPlainObject(toVal) && isPlainObject(fromVal)) { 21932 mergeData(toVal, fromVal); 21933 } 21934 } 21935 return to 21936} 21937 21938/** 21939 * Data 21940 */ 21941function mergeDataOrFn ( 21942 parentVal, 21943 childVal, 21944 vm 21945) { 21946 if (!vm) { 21947 // in a Vue.extend merge, both should be functions 21948 if (!childVal) { 21949 return parentVal 21950 } 21951 if (!parentVal) { 21952 return childVal 21953 } 21954 // when parentVal & childVal are both present, 21955 // we need to return a function that returns the 21956 // merged result of both functions... no need to 21957 // check if parentVal is a function here because 21958 // it has to be a function to pass previous merges. 21959 return function mergedDataFn () { 21960 return mergeData( 21961 typeof childVal === 'function' ? childVal.call(this, this) : childVal, 21962 typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal 21963 ) 21964 } 21965 } else { 21966 return function mergedInstanceDataFn () { 21967 // instance merge 21968 var instanceData = typeof childVal === 'function' 21969 ? childVal.call(vm, vm) 21970 : childVal; 21971 var defaultData = typeof parentVal === 'function' 21972 ? parentVal.call(vm, vm) 21973 : parentVal; 21974 if (instanceData) { 21975 return mergeData(instanceData, defaultData) 21976 } else { 21977 return defaultData 21978 } 21979 } 21980 } 21981} 21982 21983strats.data = function ( 21984 parentVal, 21985 childVal, 21986 vm 21987) { 21988 if (!vm) { 21989 if (childVal && typeof childVal !== 'function') { 21990 "development" !== 'production' && warn( 21991 'The "data" option should be a function ' + 21992 'that returns a per-instance value in component ' + 21993 'definitions.', 21994 vm 21995 ); 21996 21997 return parentVal 21998 } 21999 return mergeDataOrFn(parentVal, childVal) 22000 } 22001 22002 return mergeDataOrFn(parentVal, childVal, vm) 22003}; 22004 22005/** 22006 * Hooks and props are merged as arrays. 22007 */ 22008function mergeHook ( 22009 parentVal, 22010 childVal 22011) { 22012 return childVal 22013 ? parentVal 22014 ? parentVal.concat(childVal) 22015 : Array.isArray(childVal) 22016 ? childVal 22017 : [childVal] 22018 : parentVal 22019} 22020 22021LIFECYCLE_HOOKS.forEach(function (hook) { 22022 strats[hook] = mergeHook; 22023}); 22024 22025/** 22026 * Assets 22027 * 22028 * When a vm is present (instance creation), we need to do 22029 * a three-way merge between constructor options, instance 22030 * options and parent options. 22031 */ 22032function mergeAssets ( 22033 parentVal, 22034 childVal, 22035 vm, 22036 key 22037) { 22038 var res = Object.create(parentVal || null); 22039 if (childVal) { 22040 "development" !== 'production' && assertObjectType(key, childVal, vm); 22041 return extend(res, childVal) 22042 } else { 22043 return res 22044 } 22045} 22046 22047ASSET_TYPES.forEach(function (type) { 22048 strats[type + 's'] = mergeAssets; 22049}); 22050 22051/** 22052 * Watchers. 22053 * 22054 * Watchers hashes should not overwrite one 22055 * another, so we merge them as arrays. 22056 */ 22057strats.watch = function ( 22058 parentVal, 22059 childVal, 22060 vm, 22061 key 22062) { 22063 // work around Firefox's Object.prototype.watch... 22064 if (parentVal === nativeWatch) { parentVal = undefined; } 22065 if (childVal === nativeWatch) { childVal = undefined; } 22066 /* istanbul ignore if */ 22067 if (!childVal) { return Object.create(parentVal || null) } 22068 if (true) { 22069 assertObjectType(key, childVal, vm); 22070 } 22071 if (!parentVal) { return childVal } 22072 var ret = {}; 22073 extend(ret, parentVal); 22074 for (var key$1 in childVal) { 22075 var parent = ret[key$1]; 22076 var child = childVal[key$1]; 22077 if (parent && !Array.isArray(parent)) { 22078 parent = [parent]; 22079 } 22080 ret[key$1] = parent 22081 ? parent.concat(child) 22082 : Array.isArray(child) ? child : [child]; 22083 } 22084 return ret 22085}; 22086 22087/** 22088 * Other object hashes. 22089 */ 22090strats.props = 22091strats.methods = 22092strats.inject = 22093strats.computed = function ( 22094 parentVal, 22095 childVal, 22096 vm, 22097 key 22098) { 22099 if (childVal && "development" !== 'production') { 22100 assertObjectType(key, childVal, vm); 22101 } 22102 if (!parentVal) { return childVal } 22103 var ret = Object.create(null); 22104 extend(ret, parentVal); 22105 if (childVal) { extend(ret, childVal); } 22106 return ret 22107}; 22108strats.provide = mergeDataOrFn; 22109 22110/** 22111 * Default strategy. 22112 */ 22113var defaultStrat = function (parentVal, childVal) { 22114 return childVal === undefined 22115 ? parentVal 22116 : childVal 22117}; 22118 22119/** 22120 * Validate component names 22121 */ 22122function checkComponents (options) { 22123 for (var key in options.components) { 22124 validateComponentName(key); 22125 } 22126} 22127 22128function validateComponentName (name) { 22129 if (!/^[a-zA-Z][\w-]*$/.test(name)) { 22130 warn( 22131 'Invalid component name: "' + name + '". Component names ' + 22132 'can only contain alphanumeric characters and the hyphen, ' + 22133 'and must start with a letter.' 22134 ); 22135 } 22136 if (isBuiltInTag(name) || config.isReservedTag(name)) { 22137 warn( 22138 'Do not use built-in or reserved HTML elements as component ' + 22139 'id: ' + name 22140 ); 22141 } 22142} 22143 22144/** 22145 * Ensure all props option syntax are normalized into the 22146 * Object-based format. 22147 */ 22148function normalizeProps (options, vm) { 22149 var props = options.props; 22150 if (!props) { return } 22151 var res = {}; 22152 var i, val, name; 22153 if (Array.isArray(props)) { 22154 i = props.length; 22155 while (i--) { 22156 val = props[i]; 22157 if (typeof val === 'string') { 22158 name = camelize(val); 22159 res[name] = { type: null }; 22160 } else if (true) { 22161 warn('props must be strings when using array syntax.'); 22162 } 22163 } 22164 } else if (isPlainObject(props)) { 22165 for (var key in props) { 22166 val = props[key]; 22167 name = camelize(key); 22168 res[name] = isPlainObject(val) 22169 ? val 22170 : { type: val }; 22171 } 22172 } else if (true) { 22173 warn( 22174 "Invalid value for option \"props\": expected an Array or an Object, " + 22175 "but got " + (toRawType(props)) + ".", 22176 vm 22177 ); 22178 } 22179 options.props = res; 22180} 22181 22182/** 22183 * Normalize all injections into Object-based format 22184 */ 22185function normalizeInject (options, vm) { 22186 var inject = options.inject; 22187 if (!inject) { return } 22188 var normalized = options.inject = {}; 22189 if (Array.isArray(inject)) { 22190 for (var i = 0; i < inject.length; i++) { 22191 normalized[inject[i]] = { from: inject[i] }; 22192 } 22193 } else if (isPlainObject(inject)) { 22194 for (var key in inject) { 22195 var val = inject[key]; 22196 normalized[key] = isPlainObject(val) 22197 ? extend({ from: key }, val) 22198 : { from: val }; 22199 } 22200 } else if (true) { 22201 warn( 22202 "Invalid value for option \"inject\": expected an Array or an Object, " + 22203 "but got " + (toRawType(inject)) + ".", 22204 vm 22205 ); 22206 } 22207} 22208 22209/** 22210 * Normalize raw function directives into object format. 22211 */ 22212function normalizeDirectives (options) { 22213 var dirs = options.directives; 22214 if (dirs) { 22215 for (var key in dirs) { 22216 var def = dirs[key]; 22217 if (typeof def === 'function') { 22218 dirs[key] = { bind: def, update: def }; 22219 } 22220 } 22221 } 22222} 22223 22224function assertObjectType (name, value, vm) { 22225 if (!isPlainObject(value)) { 22226 warn( 22227 "Invalid value for option \"" + name + "\": expected an Object, " + 22228 "but got " + (toRawType(value)) + ".", 22229 vm 22230 ); 22231 } 22232} 22233 22234/** 22235 * Merge two option objects into a new one. 22236 * Core utility used in both instantiation and inheritance. 22237 */ 22238function mergeOptions ( 22239 parent, 22240 child, 22241 vm 22242) { 22243 if (true) { 22244 checkComponents(child); 22245 } 22246 22247 if (typeof child === 'function') { 22248 child = child.options; 22249 } 22250 22251 normalizeProps(child, vm); 22252 normalizeInject(child, vm); 22253 normalizeDirectives(child); 22254 var extendsFrom = child.extends; 22255 if (extendsFrom) { 22256 parent = mergeOptions(parent, extendsFrom, vm); 22257 } 22258 if (child.mixins) { 22259 for (var i = 0, l = child.mixins.length; i < l; i++) { 22260 parent = mergeOptions(parent, child.mixins[i], vm); 22261 } 22262 } 22263 var options = {}; 22264 var key; 22265 for (key in parent) { 22266 mergeField(key); 22267 } 22268 for (key in child) { 22269 if (!hasOwn(parent, key)) { 22270 mergeField(key); 22271 } 22272 } 22273 function mergeField (key) { 22274 var strat = strats[key] || defaultStrat; 22275 options[key] = strat(parent[key], child[key], vm, key); 22276 } 22277 return options 22278} 22279 22280/** 22281 * Resolve an asset. 22282 * This function is used because child instances need access 22283 * to assets defined in its ancestor chain. 22284 */ 22285function resolveAsset ( 22286 options, 22287 type, 22288 id, 22289 warnMissing 22290) { 22291 /* istanbul ignore if */ 22292 if (typeof id !== 'string') { 22293 return 22294 } 22295 var assets = options[type]; 22296 // check local registration variations first 22297 if (hasOwn(assets, id)) { return assets[id] } 22298 var camelizedId = camelize(id); 22299 if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } 22300 var PascalCaseId = capitalize(camelizedId); 22301 if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } 22302 // fallback to prototype chain 22303 var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; 22304 if ("development" !== 'production' && warnMissing && !res) { 22305 warn( 22306 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, 22307 options 22308 ); 22309 } 22310 return res 22311} 22312 22313/* */ 22314 22315function validateProp ( 22316 key, 22317 propOptions, 22318 propsData, 22319 vm 22320) { 22321 var prop = propOptions[key]; 22322 var absent = !hasOwn(propsData, key); 22323 var value = propsData[key]; 22324 // boolean casting 22325 var booleanIndex = getTypeIndex(Boolean, prop.type); 22326 if (booleanIndex > -1) { 22327 if (absent && !hasOwn(prop, 'default')) { 22328 value = false; 22329 } else if (value === '' || value === hyphenate(key)) { 22330 // only cast empty string / same name to boolean if 22331 // boolean has higher priority 22332 var stringIndex = getTypeIndex(String, prop.type); 22333 if (stringIndex < 0 || booleanIndex < stringIndex) { 22334 value = true; 22335 } 22336 } 22337 } 22338 // check default value 22339 if (value === undefined) { 22340 value = getPropDefaultValue(vm, prop, key); 22341 // since the default value is a fresh copy, 22342 // make sure to observe it. 22343 var prevShouldObserve = shouldObserve; 22344 toggleObserving(true); 22345 observe(value); 22346 toggleObserving(prevShouldObserve); 22347 } 22348 if ( 22349 true 22350 ) { 22351 assertProp(prop, key, value, vm, absent); 22352 } 22353 return value 22354} 22355 22356/** 22357 * Get the default value of a prop. 22358 */ 22359function getPropDefaultValue (vm, prop, key) { 22360 // no default, return undefined 22361 if (!hasOwn(prop, 'default')) { 22362 return undefined 22363 } 22364 var def = prop.default; 22365 // warn against non-factory defaults for Object & Array 22366 if ("development" !== 'production' && isObject(def)) { 22367 warn( 22368 'Invalid default value for prop "' + key + '": ' + 22369 'Props with type Object/Array must use a factory function ' + 22370 'to return the default value.', 22371 vm 22372 ); 22373 } 22374 // the raw prop value was also undefined from previous render, 22375 // return previous default value to avoid unnecessary watcher trigger 22376 if (vm && vm.$options.propsData && 22377 vm.$options.propsData[key] === undefined && 22378 vm._props[key] !== undefined 22379 ) { 22380 return vm._props[key] 22381 } 22382 // call factory function for non-Function types 22383 // a value is Function if its prototype is function even across different execution context 22384 return typeof def === 'function' && getType(prop.type) !== 'Function' 22385 ? def.call(vm) 22386 : def 22387} 22388 22389/** 22390 * Assert whether a prop is valid. 22391 */ 22392function assertProp ( 22393 prop, 22394 name, 22395 value, 22396 vm, 22397 absent 22398) { 22399 if (prop.required && absent) { 22400 warn( 22401 'Missing required prop: "' + name + '"', 22402 vm 22403 ); 22404 return 22405 } 22406 if (value == null && !prop.required) { 22407 return 22408 } 22409 var type = prop.type; 22410 var valid = !type || type === true; 22411 var expectedTypes = []; 22412 if (type) { 22413 if (!Array.isArray(type)) { 22414 type = [type]; 22415 } 22416 for (var i = 0; i < type.length && !valid; i++) { 22417 var assertedType = assertType(value, type[i]); 22418 expectedTypes.push(assertedType.expectedType || ''); 22419 valid = assertedType.valid; 22420 } 22421 } 22422 if (!valid) { 22423 warn( 22424 "Invalid prop: type check failed for prop \"" + name + "\"." + 22425 " Expected " + (expectedTypes.map(capitalize).join(', ')) + 22426 ", got " + (toRawType(value)) + ".", 22427 vm 22428 ); 22429 return 22430 } 22431 var validator = prop.validator; 22432 if (validator) { 22433 if (!validator(value)) { 22434 warn( 22435 'Invalid prop: custom validator check failed for prop "' + name + '".', 22436 vm 22437 ); 22438 } 22439 } 22440} 22441 22442var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/; 22443 22444function assertType (value, type) { 22445 var valid; 22446 var expectedType = getType(type); 22447 if (simpleCheckRE.test(expectedType)) { 22448 var t = typeof value; 22449 valid = t === expectedType.toLowerCase(); 22450 // for primitive wrapper objects 22451 if (!valid && t === 'object') { 22452 valid = value instanceof type; 22453 } 22454 } else if (expectedType === 'Object') { 22455 valid = isPlainObject(value); 22456 } else if (expectedType === 'Array') { 22457 valid = Array.isArray(value); 22458 } else { 22459 valid = value instanceof type; 22460 } 22461 return { 22462 valid: valid, 22463 expectedType: expectedType 22464 } 22465} 22466 22467/** 22468 * Use function string name to check built-in types, 22469 * because a simple equality check will fail when running 22470 * across different vms / iframes. 22471 */ 22472function getType (fn) { 22473 var match = fn && fn.toString().match(/^\s*function (\w+)/); 22474 return match ? match[1] : '' 22475} 22476 22477function isSameType (a, b) { 22478 return getType(a) === getType(b) 22479} 22480 22481function getTypeIndex (type, expectedTypes) { 22482 if (!Array.isArray(expectedTypes)) { 22483 return isSameType(expectedTypes, type) ? 0 : -1 22484 } 22485 for (var i = 0, len = expectedTypes.length; i < len; i++) { 22486 if (isSameType(expectedTypes[i], type)) { 22487 return i 22488 } 22489 } 22490 return -1 22491} 22492 22493/* */ 22494 22495function handleError (err, vm, info) { 22496 if (vm) { 22497 var cur = vm; 22498 while ((cur = cur.$parent)) { 22499 var hooks = cur.$options.errorCaptured; 22500 if (hooks) { 22501 for (var i = 0; i < hooks.length; i++) { 22502 try { 22503 var capture = hooks[i].call(cur, err, vm, info) === false; 22504 if (capture) { return } 22505 } catch (e) { 22506 globalHandleError(e, cur, 'errorCaptured hook'); 22507 } 22508 } 22509 } 22510 } 22511 } 22512 globalHandleError(err, vm, info); 22513} 22514 22515function globalHandleError (err, vm, info) { 22516 if (config.errorHandler) { 22517 try { 22518 return config.errorHandler.call(null, err, vm, info) 22519 } catch (e) { 22520 logError(e, null, 'config.errorHandler'); 22521 } 22522 } 22523 logError(err, vm, info); 22524} 22525 22526function logError (err, vm, info) { 22527 if (true) { 22528 warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm); 22529 } 22530 /* istanbul ignore else */ 22531 if ((inBrowser || inWeex) && typeof console !== 'undefined') { 22532 console.error(err); 22533 } else { 22534 throw err 22535 } 22536} 22537 22538/* */ 22539/* globals MessageChannel */ 22540 22541var callbacks = []; 22542var pending = false; 22543 22544function flushCallbacks () { 22545 pending = false; 22546 var copies = callbacks.slice(0); 22547 callbacks.length = 0; 22548 for (var i = 0; i < copies.length; i++) { 22549 copies[i](); 22550 } 22551} 22552 22553// Here we have async deferring wrappers using both microtasks and (macro) tasks. 22554// In < 2.4 we used microtasks everywhere, but there are some scenarios where 22555// microtasks have too high a priority and fire in between supposedly 22556// sequential events (e.g. #4521, #6690) or even between bubbling of the same 22557// event (#6566). However, using (macro) tasks everywhere also has subtle problems 22558// when state is changed right before repaint (e.g. #6813, out-in transitions). 22559// Here we use microtask by default, but expose a way to force (macro) task when 22560// needed (e.g. in event handlers attached by v-on). 22561var microTimerFunc; 22562var macroTimerFunc; 22563var useMacroTask = false; 22564 22565// Determine (macro) task defer implementation. 22566// Technically setImmediate should be the ideal choice, but it's only available 22567// in IE. The only polyfill that consistently queues the callback after all DOM 22568// events triggered in the same loop is by using MessageChannel. 22569/* istanbul ignore if */ 22570if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) { 22571 macroTimerFunc = function () { 22572 setImmediate(flushCallbacks); 22573 }; 22574} else if (typeof MessageChannel !== 'undefined' && ( 22575 isNative(MessageChannel) || 22576 // PhantomJS 22577 MessageChannel.toString() === '[object MessageChannelConstructor]' 22578)) { 22579 var channel = new MessageChannel(); 22580 var port = channel.port2; 22581 channel.port1.onmessage = flushCallbacks; 22582 macroTimerFunc = function () { 22583 port.postMessage(1); 22584 }; 22585} else { 22586 /* istanbul ignore next */ 22587 macroTimerFunc = function () { 22588 setTimeout(flushCallbacks, 0); 22589 }; 22590} 22591 22592// Determine microtask defer implementation. 22593/* istanbul ignore next, $flow-disable-line */ 22594if (typeof Promise !== 'undefined' && isNative(Promise)) { 22595 var p = Promise.resolve(); 22596 microTimerFunc = function () { 22597 p.then(flushCallbacks); 22598 // in problematic UIWebViews, Promise.then doesn't completely break, but 22599 // it can get stuck in a weird state where callbacks are pushed into the 22600 // microtask queue but the queue isn't being flushed, until the browser 22601 // needs to do some other work, e.g. handle a timer. Therefore we can 22602 // "force" the microtask queue to be flushed by adding an empty timer. 22603 if (isIOS) { setTimeout(noop); } 22604 }; 22605} else { 22606 // fallback to macro 22607 microTimerFunc = macroTimerFunc; 22608} 22609 22610/** 22611 * Wrap a function so that if any code inside triggers state change, 22612 * the changes are queued using a (macro) task instead of a microtask. 22613 */ 22614function withMacroTask (fn) { 22615 return fn._withTask || (fn._withTask = function () { 22616 useMacroTask = true; 22617 var res = fn.apply(null, arguments); 22618 useMacroTask = false; 22619 return res 22620 }) 22621} 22622 22623function nextTick (cb, ctx) { 22624 var _resolve; 22625 callbacks.push(function () { 22626 if (cb) { 22627 try { 22628 cb.call(ctx); 22629 } catch (e) { 22630 handleError(e, ctx, 'nextTick'); 22631 } 22632 } else if (_resolve) { 22633 _resolve(ctx); 22634 } 22635 }); 22636 if (!pending) { 22637 pending = true; 22638 if (useMacroTask) { 22639 macroTimerFunc(); 22640 } else { 22641 microTimerFunc(); 22642 } 22643 } 22644 // $flow-disable-line 22645 if (!cb && typeof Promise !== 'undefined') { 22646 return new Promise(function (resolve) { 22647 _resolve = resolve; 22648 }) 22649 } 22650} 22651 22652/* */ 22653 22654var mark; 22655var measure; 22656 22657if (true) { 22658 var perf = inBrowser && window.performance; 22659 /* istanbul ignore if */ 22660 if ( 22661 perf && 22662 perf.mark && 22663 perf.measure && 22664 perf.clearMarks && 22665 perf.clearMeasures 22666 ) { 22667 mark = function (tag) { return perf.mark(tag); }; 22668 measure = function (name, startTag, endTag) { 22669 perf.measure(name, startTag, endTag); 22670 perf.clearMarks(startTag); 22671 perf.clearMarks(endTag); 22672 perf.clearMeasures(name); 22673 }; 22674 } 22675} 22676 22677/* not type checking this file because flow doesn't play well with Proxy */ 22678 22679var initProxy; 22680 22681if (true) { 22682 var allowedGlobals = makeMap( 22683 'Infinity,undefined,NaN,isFinite,isNaN,' + 22684 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 22685 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 22686 'require' // for Webpack/Browserify 22687 ); 22688 22689 var warnNonPresent = function (target, key) { 22690 warn( 22691 "Property or method \"" + key + "\" is not defined on the instance but " + 22692 'referenced during render. Make sure that this property is reactive, ' + 22693 'either in the data option, or for class-based components, by ' + 22694 'initializing the property. ' + 22695 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', 22696 target 22697 ); 22698 }; 22699 22700 var hasProxy = 22701 typeof Proxy !== 'undefined' && isNative(Proxy); 22702 22703 if (hasProxy) { 22704 var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); 22705 config.keyCodes = new Proxy(config.keyCodes, { 22706 set: function set (target, key, value) { 22707 if (isBuiltInModifier(key)) { 22708 warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key)); 22709 return false 22710 } else { 22711 target[key] = value; 22712 return true 22713 } 22714 } 22715 }); 22716 } 22717 22718 var hasHandler = { 22719 has: function has (target, key) { 22720 var has = key in target; 22721 var isAllowed = allowedGlobals(key) || key.charAt(0) === '_'; 22722 if (!has && !isAllowed) { 22723 warnNonPresent(target, key); 22724 } 22725 return has || !isAllowed 22726 } 22727 }; 22728 22729 var getHandler = { 22730 get: function get (target, key) { 22731 if (typeof key === 'string' && !(key in target)) { 22732 warnNonPresent(target, key); 22733 } 22734 return target[key] 22735 } 22736 }; 22737 22738 initProxy = function initProxy (vm) { 22739 if (hasProxy) { 22740 // determine which proxy handler to use 22741 var options = vm.$options; 22742 var handlers = options.render && options.render._withStripped 22743 ? getHandler 22744 : hasHandler; 22745 vm._renderProxy = new Proxy(vm, handlers); 22746 } else { 22747 vm._renderProxy = vm; 22748 } 22749 }; 22750} 22751 22752/* */ 22753 22754var seenObjects = new _Set(); 22755 22756/** 22757 * Recursively traverse an object to evoke all converted 22758 * getters, so that every nested property inside the object 22759 * is collected as a "deep" dependency. 22760 */ 22761function traverse (val) { 22762 _traverse(val, seenObjects); 22763 seenObjects.clear(); 22764} 22765 22766function _traverse (val, seen) { 22767 var i, keys; 22768 var isA = Array.isArray(val); 22769 if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) { 22770 return 22771 } 22772 if (val.__ob__) { 22773 var depId = val.__ob__.dep.id; 22774 if (seen.has(depId)) { 22775 return 22776 } 22777 seen.add(depId); 22778 } 22779 if (isA) { 22780 i = val.length; 22781 while (i--) { _traverse(val[i], seen); } 22782 } else { 22783 keys = Object.keys(val); 22784 i = keys.length; 22785 while (i--) { _traverse(val[keys[i]], seen); } 22786 } 22787} 22788 22789/* */ 22790 22791var normalizeEvent = cached(function (name) { 22792 var passive = name.charAt(0) === '&'; 22793 name = passive ? name.slice(1) : name; 22794 var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first 22795 name = once$$1 ? name.slice(1) : name; 22796 var capture = name.charAt(0) === '!'; 22797 name = capture ? name.slice(1) : name; 22798 return { 22799 name: name, 22800 once: once$$1, 22801 capture: capture, 22802 passive: passive 22803 } 22804}); 22805 22806function createFnInvoker (fns) { 22807 function invoker () { 22808 var arguments$1 = arguments; 22809 22810 var fns = invoker.fns; 22811 if (Array.isArray(fns)) { 22812 var cloned = fns.slice(); 22813 for (var i = 0; i < cloned.length; i++) { 22814 cloned[i].apply(null, arguments$1); 22815 } 22816 } else { 22817 // return handler return value for single handlers 22818 return fns.apply(null, arguments) 22819 } 22820 } 22821 invoker.fns = fns; 22822 return invoker 22823} 22824 22825function updateListeners ( 22826 on, 22827 oldOn, 22828 add, 22829 remove$$1, 22830 vm 22831) { 22832 var name, def, cur, old, event; 22833 for (name in on) { 22834 def = cur = on[name]; 22835 old = oldOn[name]; 22836 event = normalizeEvent(name); 22837 /* istanbul ignore if */ 22838 if (isUndef(cur)) { 22839 "development" !== 'production' && warn( 22840 "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), 22841 vm 22842 ); 22843 } else if (isUndef(old)) { 22844 if (isUndef(cur.fns)) { 22845 cur = on[name] = createFnInvoker(cur); 22846 } 22847 add(event.name, cur, event.once, event.capture, event.passive, event.params); 22848 } else if (cur !== old) { 22849 old.fns = cur; 22850 on[name] = old; 22851 } 22852 } 22853 for (name in oldOn) { 22854 if (isUndef(on[name])) { 22855 event = normalizeEvent(name); 22856 remove$$1(event.name, oldOn[name], event.capture); 22857 } 22858 } 22859} 22860 22861/* */ 22862 22863function mergeVNodeHook (def, hookKey, hook) { 22864 if (def instanceof VNode) { 22865 def = def.data.hook || (def.data.hook = {}); 22866 } 22867 var invoker; 22868 var oldHook = def[hookKey]; 22869 22870 function wrappedHook () { 22871 hook.apply(this, arguments); 22872 // important: remove merged hook to ensure it's called only once 22873 // and prevent memory leak 22874 remove(invoker.fns, wrappedHook); 22875 } 22876 22877 if (isUndef(oldHook)) { 22878 // no existing hook 22879 invoker = createFnInvoker([wrappedHook]); 22880 } else { 22881 /* istanbul ignore if */ 22882 if (isDef(oldHook.fns) && isTrue(oldHook.merged)) { 22883 // already a merged invoker 22884 invoker = oldHook; 22885 invoker.fns.push(wrappedHook); 22886 } else { 22887 // existing plain hook 22888 invoker = createFnInvoker([oldHook, wrappedHook]); 22889 } 22890 } 22891 22892 invoker.merged = true; 22893 def[hookKey] = invoker; 22894} 22895 22896/* */ 22897 22898function extractPropsFromVNodeData ( 22899 data, 22900 Ctor, 22901 tag 22902) { 22903 // we are only extracting raw values here. 22904 // validation and default values are handled in the child 22905 // component itself. 22906 var propOptions = Ctor.options.props; 22907 if (isUndef(propOptions)) { 22908 return 22909 } 22910 var res = {}; 22911 var attrs = data.attrs; 22912 var props = data.props; 22913 if (isDef(attrs) || isDef(props)) { 22914 for (var key in propOptions) { 22915 var altKey = hyphenate(key); 22916 if (true) { 22917 var keyInLowerCase = key.toLowerCase(); 22918 if ( 22919 key !== keyInLowerCase && 22920 attrs && hasOwn(attrs, keyInLowerCase) 22921 ) { 22922 tip( 22923 "Prop \"" + keyInLowerCase + "\" is passed to component " + 22924 (formatComponentName(tag || Ctor)) + ", but the declared prop name is" + 22925 " \"" + key + "\". " + 22926 "Note that HTML attributes are case-insensitive and camelCased " + 22927 "props need to use their kebab-case equivalents when using in-DOM " + 22928 "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"." 22929 ); 22930 } 22931 } 22932 checkProp(res, props, key, altKey, true) || 22933 checkProp(res, attrs, key, altKey, false); 22934 } 22935 } 22936 return res 22937} 22938 22939function checkProp ( 22940 res, 22941 hash, 22942 key, 22943 altKey, 22944 preserve 22945) { 22946 if (isDef(hash)) { 22947 if (hasOwn(hash, key)) { 22948 res[key] = hash[key]; 22949 if (!preserve) { 22950 delete hash[key]; 22951 } 22952 return true 22953 } else if (hasOwn(hash, altKey)) { 22954 res[key] = hash[altKey]; 22955 if (!preserve) { 22956 delete hash[altKey]; 22957 } 22958 return true 22959 } 22960 } 22961 return false 22962} 22963 22964/* */ 22965 22966// The template compiler attempts to minimize the need for normalization by 22967// statically analyzing the template at compile time. 22968// 22969// For plain HTML markup, normalization can be completely skipped because the 22970// generated render function is guaranteed to return Array<VNode>. There are 22971// two cases where extra normalization is needed: 22972 22973// 1. When the children contains components - because a functional component 22974// may return an Array instead of a single root. In this case, just a simple 22975// normalization is needed - if any child is an Array, we flatten the whole 22976// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep 22977// because functional components already normalize their own children. 22978function simpleNormalizeChildren (children) { 22979 for (var i = 0; i < children.length; i++) { 22980 if (Array.isArray(children[i])) { 22981 return Array.prototype.concat.apply([], children) 22982 } 22983 } 22984 return children 22985} 22986 22987// 2. When the children contains constructs that always generated nested Arrays, 22988// e.g. <template>, <slot>, v-for, or when the children is provided by user 22989// with hand-written render functions / JSX. In such cases a full normalization 22990// is needed to cater to all possible types of children values. 22991function normalizeChildren (children) { 22992 return isPrimitive(children) 22993 ? [createTextVNode(children)] 22994 : Array.isArray(children) 22995 ? normalizeArrayChildren(children) 22996 : undefined 22997} 22998 22999function isTextNode (node) { 23000 return isDef(node) && isDef(node.text) && isFalse(node.isComment) 23001} 23002 23003function normalizeArrayChildren (children, nestedIndex) { 23004 var res = []; 23005 var i, c, lastIndex, last; 23006 for (i = 0; i < children.length; i++) { 23007 c = children[i]; 23008 if (isUndef(c) || typeof c === 'boolean') { continue } 23009 lastIndex = res.length - 1; 23010 last = res[lastIndex]; 23011 // nested 23012 if (Array.isArray(c)) { 23013 if (c.length > 0) { 23014 c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)); 23015 // merge adjacent text nodes 23016 if (isTextNode(c[0]) && isTextNode(last)) { 23017 res[lastIndex] = createTextVNode(last.text + (c[0]).text); 23018 c.shift(); 23019 } 23020 res.push.apply(res, c); 23021 } 23022 } else if (isPrimitive(c)) { 23023 if (isTextNode(last)) { 23024 // merge adjacent text nodes 23025 // this is necessary for SSR hydration because text nodes are 23026 // essentially merged when rendered to HTML strings 23027 res[lastIndex] = createTextVNode(last.text + c); 23028 } else if (c !== '') { 23029 // convert primitive to vnode 23030 res.push(createTextVNode(c)); 23031 } 23032 } else { 23033 if (isTextNode(c) && isTextNode(last)) { 23034 // merge adjacent text nodes 23035 res[lastIndex] = createTextVNode(last.text + c.text); 23036 } else { 23037 // default key for nested array children (likely generated by v-for) 23038 if (isTrue(children._isVList) && 23039 isDef(c.tag) && 23040 isUndef(c.key) && 23041 isDef(nestedIndex)) { 23042 c.key = "__vlist" + nestedIndex + "_" + i + "__"; 23043 } 23044 res.push(c); 23045 } 23046 } 23047 } 23048 return res 23049} 23050 23051/* */ 23052 23053function ensureCtor (comp, base) { 23054 if ( 23055 comp.__esModule || 23056 (hasSymbol && comp[Symbol.toStringTag] === 'Module') 23057 ) { 23058 comp = comp.default; 23059 } 23060 return isObject(comp) 23061 ? base.extend(comp) 23062 : comp 23063} 23064 23065function createAsyncPlaceholder ( 23066 factory, 23067 data, 23068 context, 23069 children, 23070 tag 23071) { 23072 var node = createEmptyVNode(); 23073 node.asyncFactory = factory; 23074 node.asyncMeta = { data: data, context: context, children: children, tag: tag }; 23075 return node 23076} 23077 23078function resolveAsyncComponent ( 23079 factory, 23080 baseCtor, 23081 context 23082) { 23083 if (isTrue(factory.error) && isDef(factory.errorComp)) { 23084 return factory.errorComp 23085 } 23086 23087 if (isDef(factory.resolved)) { 23088 return factory.resolved 23089 } 23090 23091 if (isTrue(factory.loading) && isDef(factory.loadingComp)) { 23092 return factory.loadingComp 23093 } 23094 23095 if (isDef(factory.contexts)) { 23096 // already pending 23097 factory.contexts.push(context); 23098 } else { 23099 var contexts = factory.contexts = [context]; 23100 var sync = true; 23101 23102 var forceRender = function () { 23103 for (var i = 0, l = contexts.length; i < l; i++) { 23104 contexts[i].$forceUpdate(); 23105 } 23106 }; 23107 23108 var resolve = once(function (res) { 23109 // cache resolved 23110 factory.resolved = ensureCtor(res, baseCtor); 23111 // invoke callbacks only if this is not a synchronous resolve 23112 // (async resolves are shimmed as synchronous during SSR) 23113 if (!sync) { 23114 forceRender(); 23115 } 23116 }); 23117 23118 var reject = once(function (reason) { 23119 "development" !== 'production' && warn( 23120 "Failed to resolve async component: " + (String(factory)) + 23121 (reason ? ("\nReason: " + reason) : '') 23122 ); 23123 if (isDef(factory.errorComp)) { 23124 factory.error = true; 23125 forceRender(); 23126 } 23127 }); 23128 23129 var res = factory(resolve, reject); 23130 23131 if (isObject(res)) { 23132 if (typeof res.then === 'function') { 23133 // () => Promise 23134 if (isUndef(factory.resolved)) { 23135 res.then(resolve, reject); 23136 } 23137 } else if (isDef(res.component) && typeof res.component.then === 'function') { 23138 res.component.then(resolve, reject); 23139 23140 if (isDef(res.error)) { 23141 factory.errorComp = ensureCtor(res.error, baseCtor); 23142 } 23143 23144 if (isDef(res.loading)) { 23145 factory.loadingComp = ensureCtor(res.loading, baseCtor); 23146 if (res.delay === 0) { 23147 factory.loading = true; 23148 } else { 23149 setTimeout(function () { 23150 if (isUndef(factory.resolved) && isUndef(factory.error)) { 23151 factory.loading = true; 23152 forceRender(); 23153 } 23154 }, res.delay || 200); 23155 } 23156 } 23157 23158 if (isDef(res.timeout)) { 23159 setTimeout(function () { 23160 if (isUndef(factory.resolved)) { 23161 reject( 23162 true 23163 ? ("timeout (" + (res.timeout) + "ms)") 23164 : null 23165 ); 23166 } 23167 }, res.timeout); 23168 } 23169 } 23170 } 23171 23172 sync = false; 23173 // return in case resolved synchronously 23174 return factory.loading 23175 ? factory.loadingComp 23176 : factory.resolved 23177 } 23178} 23179 23180/* */ 23181 23182function isAsyncPlaceholder (node) { 23183 return node.isComment && node.asyncFactory 23184} 23185 23186/* */ 23187 23188function getFirstComponentChild (children) { 23189 if (Array.isArray(children)) { 23190 for (var i = 0; i < children.length; i++) { 23191 var c = children[i]; 23192 if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) { 23193 return c 23194 } 23195 } 23196 } 23197} 23198 23199/* */ 23200 23201/* */ 23202 23203function initEvents (vm) { 23204 vm._events = Object.create(null); 23205 vm._hasHookEvent = false; 23206 // init parent attached events 23207 var listeners = vm.$options._parentListeners; 23208 if (listeners) { 23209 updateComponentListeners(vm, listeners); 23210 } 23211} 23212 23213var target; 23214 23215function add (event, fn, once) { 23216 if (once) { 23217 target.$once(event, fn); 23218 } else { 23219 target.$on(event, fn); 23220 } 23221} 23222 23223function remove$1 (event, fn) { 23224 target.$off(event, fn); 23225} 23226 23227function updateComponentListeners ( 23228 vm, 23229 listeners, 23230 oldListeners 23231) { 23232 target = vm; 23233 updateListeners(listeners, oldListeners || {}, add, remove$1, vm); 23234 target = undefined; 23235} 23236 23237function eventsMixin (Vue) { 23238 var hookRE = /^hook:/; 23239 Vue.prototype.$on = function (event, fn) { 23240 var this$1 = this; 23241 23242 var vm = this; 23243 if (Array.isArray(event)) { 23244 for (var i = 0, l = event.length; i < l; i++) { 23245 this$1.$on(event[i], fn); 23246 } 23247 } else { 23248 (vm._events[event] || (vm._events[event] = [])).push(fn); 23249 // optimize hook:event cost by using a boolean flag marked at registration 23250 // instead of a hash lookup 23251 if (hookRE.test(event)) { 23252 vm._hasHookEvent = true; 23253 } 23254 } 23255 return vm 23256 }; 23257 23258 Vue.prototype.$once = function (event, fn) { 23259 var vm = this; 23260 function on () { 23261 vm.$off(event, on); 23262 fn.apply(vm, arguments); 23263 } 23264 on.fn = fn; 23265 vm.$on(event, on); 23266 return vm 23267 }; 23268 23269 Vue.prototype.$off = function (event, fn) { 23270 var this$1 = this; 23271 23272 var vm = this; 23273 // all 23274 if (!arguments.length) { 23275 vm._events = Object.create(null); 23276 return vm 23277 } 23278 // array of events 23279 if (Array.isArray(event)) { 23280 for (var i = 0, l = event.length; i < l; i++) { 23281 this$1.$off(event[i], fn); 23282 } 23283 return vm 23284 } 23285 // specific event 23286 var cbs = vm._events[event]; 23287 if (!cbs) { 23288 return vm 23289 } 23290 if (!fn) { 23291 vm._events[event] = null; 23292 return vm 23293 } 23294 if (fn) { 23295 // specific handler 23296 var cb; 23297 var i$1 = cbs.length; 23298 while (i$1--) { 23299 cb = cbs[i$1]; 23300 if (cb === fn || cb.fn === fn) { 23301 cbs.splice(i$1, 1); 23302 break 23303 } 23304 } 23305 } 23306 return vm 23307 }; 23308 23309 Vue.prototype.$emit = function (event) { 23310 var vm = this; 23311 if (true) { 23312 var lowerCaseEvent = event.toLowerCase(); 23313 if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) { 23314 tip( 23315 "Event \"" + lowerCaseEvent + "\" is emitted in component " + 23316 (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " + 23317 "Note that HTML attributes are case-insensitive and you cannot use " + 23318 "v-on to listen to camelCase events when using in-DOM templates. " + 23319 "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"." 23320 ); 23321 } 23322 } 23323 var cbs = vm._events[event]; 23324 if (cbs) { 23325 cbs = cbs.length > 1 ? toArray(cbs) : cbs; 23326 var args = toArray(arguments, 1); 23327 for (var i = 0, l = cbs.length; i < l; i++) { 23328 try { 23329 cbs[i].apply(vm, args); 23330 } catch (e) { 23331 handleError(e, vm, ("event handler for \"" + event + "\"")); 23332 } 23333 } 23334 } 23335 return vm 23336 }; 23337} 23338 23339/* */ 23340 23341 23342 23343/** 23344 * Runtime helper for resolving raw children VNodes into a slot object. 23345 */ 23346function resolveSlots ( 23347 children, 23348 context 23349) { 23350 var slots = {}; 23351 if (!children) { 23352 return slots 23353 } 23354 for (var i = 0, l = children.length; i < l; i++) { 23355 var child = children[i]; 23356 var data = child.data; 23357 // remove slot attribute if the node is resolved as a Vue slot node 23358 if (data && data.attrs && data.attrs.slot) { 23359 delete data.attrs.slot; 23360 } 23361 // named slots should only be respected if the vnode was rendered in the 23362 // same context. 23363 if ((child.context === context || child.fnContext === context) && 23364 data && data.slot != null 23365 ) { 23366 var name = data.slot; 23367 var slot = (slots[name] || (slots[name] = [])); 23368 if (child.tag === 'template') { 23369 slot.push.apply(slot, child.children || []); 23370 } else { 23371 slot.push(child); 23372 } 23373 } else { 23374 (slots.default || (slots.default = [])).push(child); 23375 } 23376 } 23377 // ignore slots that contains only whitespace 23378 for (var name$1 in slots) { 23379 if (slots[name$1].every(isWhitespace)) { 23380 delete slots[name$1]; 23381 } 23382 } 23383 return slots 23384} 23385 23386function isWhitespace (node) { 23387 return (node.isComment && !node.asyncFactory) || node.text === ' ' 23388} 23389 23390function resolveScopedSlots ( 23391 fns, // see flow/vnode 23392 res 23393) { 23394 res = res || {}; 23395 for (var i = 0; i < fns.length; i++) { 23396 if (Array.isArray(fns[i])) { 23397 resolveScopedSlots(fns[i], res); 23398 } else { 23399 res[fns[i].key] = fns[i].fn; 23400 } 23401 } 23402 return res 23403} 23404 23405/* */ 23406 23407var activeInstance = null; 23408var isUpdatingChildComponent = false; 23409 23410function initLifecycle (vm) { 23411 var options = vm.$options; 23412 23413 // locate first non-abstract parent 23414 var parent = options.parent; 23415 if (parent && !options.abstract) { 23416 while (parent.$options.abstract && parent.$parent) { 23417 parent = parent.$parent; 23418 } 23419 parent.$children.push(vm); 23420 } 23421 23422 vm.$parent = parent; 23423 vm.$root = parent ? parent.$root : vm; 23424 23425 vm.$children = []; 23426 vm.$refs = {}; 23427 23428 vm._watcher = null; 23429 vm._inactive = null; 23430 vm._directInactive = false; 23431 vm._isMounted = false; 23432 vm._isDestroyed = false; 23433 vm._isBeingDestroyed = false; 23434} 23435 23436function lifecycleMixin (Vue) { 23437 Vue.prototype._update = function (vnode, hydrating) { 23438 var vm = this; 23439 if (vm._isMounted) { 23440 callHook(vm, 'beforeUpdate'); 23441 } 23442 var prevEl = vm.$el; 23443 var prevVnode = vm._vnode; 23444 var prevActiveInstance = activeInstance; 23445 activeInstance = vm; 23446 vm._vnode = vnode; 23447 // Vue.prototype.__patch__ is injected in entry points 23448 // based on the rendering backend used. 23449 if (!prevVnode) { 23450 // initial render 23451 vm.$el = vm.__patch__( 23452 vm.$el, vnode, hydrating, false /* removeOnly */, 23453 vm.$options._parentElm, 23454 vm.$options._refElm 23455 ); 23456 // no need for the ref nodes after initial patch 23457 // this prevents keeping a detached DOM tree in memory (#5851) 23458 vm.$options._parentElm = vm.$options._refElm = null; 23459 } else { 23460 // updates 23461 vm.$el = vm.__patch__(prevVnode, vnode); 23462 } 23463 activeInstance = prevActiveInstance; 23464 // update __vue__ reference 23465 if (prevEl) { 23466 prevEl.__vue__ = null; 23467 } 23468 if (vm.$el) { 23469 vm.$el.__vue__ = vm; 23470 } 23471 // if parent is an HOC, update its $el as well 23472 if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) { 23473 vm.$parent.$el = vm.$el; 23474 } 23475 // updated hook is called by the scheduler to ensure that children are 23476 // updated in a parent's updated hook. 23477 }; 23478 23479 Vue.prototype.$forceUpdate = function () { 23480 var vm = this; 23481 if (vm._watcher) { 23482 vm._watcher.update(); 23483 } 23484 }; 23485 23486 Vue.prototype.$destroy = function () { 23487 var vm = this; 23488 if (vm._isBeingDestroyed) { 23489 return 23490 } 23491 callHook(vm, 'beforeDestroy'); 23492 vm._isBeingDestroyed = true; 23493 // remove self from parent 23494 var parent = vm.$parent; 23495 if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { 23496 remove(parent.$children, vm); 23497 } 23498 // teardown watchers 23499 if (vm._watcher) { 23500 vm._watcher.teardown(); 23501 } 23502 var i = vm._watchers.length; 23503 while (i--) { 23504 vm._watchers[i].teardown(); 23505 } 23506 // remove reference from data ob 23507 // frozen object may not have observer. 23508 if (vm._data.__ob__) { 23509 vm._data.__ob__.vmCount--; 23510 } 23511 // call the last hook... 23512 vm._isDestroyed = true; 23513 // invoke destroy hooks on current rendered tree 23514 vm.__patch__(vm._vnode, null); 23515 // fire destroyed hook 23516 callHook(vm, 'destroyed'); 23517 // turn off all instance listeners. 23518 vm.$off(); 23519 // remove __vue__ reference 23520 if (vm.$el) { 23521 vm.$el.__vue__ = null; 23522 } 23523 // release circular reference (#6759) 23524 if (vm.$vnode) { 23525 vm.$vnode.parent = null; 23526 } 23527 }; 23528} 23529 23530function mountComponent ( 23531 vm, 23532 el, 23533 hydrating 23534) { 23535 vm.$el = el; 23536 if (!vm.$options.render) { 23537 vm.$options.render = createEmptyVNode; 23538 if (true) { 23539 /* istanbul ignore if */ 23540 if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') || 23541 vm.$options.el || el) { 23542 warn( 23543 'You are using the runtime-only build of Vue where the template ' + 23544 'compiler is not available. Either pre-compile the templates into ' + 23545 'render functions, or use the compiler-included build.', 23546 vm 23547 ); 23548 } else { 23549 warn( 23550 'Failed to mount component: template or render function not defined.', 23551 vm 23552 ); 23553 } 23554 } 23555 } 23556 callHook(vm, 'beforeMount'); 23557 23558 var updateComponent; 23559 /* istanbul ignore if */ 23560 if ("development" !== 'production' && config.performance && mark) { 23561 updateComponent = function () { 23562 var name = vm._name; 23563 var id = vm._uid; 23564 var startTag = "vue-perf-start:" + id; 23565 var endTag = "vue-perf-end:" + id; 23566 23567 mark(startTag); 23568 var vnode = vm._render(); 23569 mark(endTag); 23570 measure(("vue " + name + " render"), startTag, endTag); 23571 23572 mark(startTag); 23573 vm._update(vnode, hydrating); 23574 mark(endTag); 23575 measure(("vue " + name + " patch"), startTag, endTag); 23576 }; 23577 } else { 23578 updateComponent = function () { 23579 vm._update(vm._render(), hydrating); 23580 }; 23581 } 23582 23583 // we set this to vm._watcher inside the watcher's constructor 23584 // since the watcher's initial patch may call $forceUpdate (e.g. inside child 23585 // component's mounted hook), which relies on vm._watcher being already defined 23586 new Watcher(vm, updateComponent, noop, null, true /* isRenderWatcher */); 23587 hydrating = false; 23588 23589 // manually mounted instance, call mounted on self 23590 // mounted is called for render-created child components in its inserted hook 23591 if (vm.$vnode == null) { 23592 vm._isMounted = true; 23593 callHook(vm, 'mounted'); 23594 } 23595 return vm 23596} 23597 23598function updateChildComponent ( 23599 vm, 23600 propsData, 23601 listeners, 23602 parentVnode, 23603 renderChildren 23604) { 23605 if (true) { 23606 isUpdatingChildComponent = true; 23607 } 23608 23609 // determine whether component has slot children 23610 // we need to do this before overwriting $options._renderChildren 23611 var hasChildren = !!( 23612 renderChildren || // has new static slots 23613 vm.$options._renderChildren || // has old static slots 23614 parentVnode.data.scopedSlots || // has new scoped slots 23615 vm.$scopedSlots !== emptyObject // has old scoped slots 23616 ); 23617 23618 vm.$options._parentVnode = parentVnode; 23619 vm.$vnode = parentVnode; // update vm's placeholder node without re-render 23620 23621 if (vm._vnode) { // update child tree's parent 23622 vm._vnode.parent = parentVnode; 23623 } 23624 vm.$options._renderChildren = renderChildren; 23625 23626 // update $attrs and $listeners hash 23627 // these are also reactive so they may trigger child update if the child 23628 // used them during render 23629 vm.$attrs = parentVnode.data.attrs || emptyObject; 23630 vm.$listeners = listeners || emptyObject; 23631 23632 // update props 23633 if (propsData && vm.$options.props) { 23634 toggleObserving(false); 23635 var props = vm._props; 23636 var propKeys = vm.$options._propKeys || []; 23637 for (var i = 0; i < propKeys.length; i++) { 23638 var key = propKeys[i]; 23639 var propOptions = vm.$options.props; // wtf flow? 23640 props[key] = validateProp(key, propOptions, propsData, vm); 23641 } 23642 toggleObserving(true); 23643 // keep a copy of raw propsData 23644 vm.$options.propsData = propsData; 23645 } 23646 23647 // update listeners 23648 listeners = listeners || emptyObject; 23649 var oldListeners = vm.$options._parentListeners; 23650 vm.$options._parentListeners = listeners; 23651 updateComponentListeners(vm, listeners, oldListeners); 23652 23653 // resolve slots + force update if has children 23654 if (hasChildren) { 23655 vm.$slots = resolveSlots(renderChildren, parentVnode.context); 23656 vm.$forceUpdate(); 23657 } 23658 23659 if (true) { 23660 isUpdatingChildComponent = false; 23661 } 23662} 23663 23664function isInInactiveTree (vm) { 23665 while (vm && (vm = vm.$parent)) { 23666 if (vm._inactive) { return true } 23667 } 23668 return false 23669} 23670 23671function activateChildComponent (vm, direct) { 23672 if (direct) { 23673 vm._directInactive = false; 23674 if (isInInactiveTree(vm)) { 23675 return 23676 } 23677 } else if (vm._directInactive) { 23678 return 23679 } 23680 if (vm._inactive || vm._inactive === null) { 23681 vm._inactive = false; 23682 for (var i = 0; i < vm.$children.length; i++) { 23683 activateChildComponent(vm.$children[i]); 23684 } 23685 callHook(vm, 'activated'); 23686 } 23687} 23688 23689function deactivateChildComponent (vm, direct) { 23690 if (direct) { 23691 vm._directInactive = true; 23692 if (isInInactiveTree(vm)) { 23693 return 23694 } 23695 } 23696 if (!vm._inactive) { 23697 vm._inactive = true; 23698 for (var i = 0; i < vm.$children.length; i++) { 23699 deactivateChildComponent(vm.$children[i]); 23700 } 23701 callHook(vm, 'deactivated'); 23702 } 23703} 23704 23705function callHook (vm, hook) { 23706 // #7573 disable dep collection when invoking lifecycle hooks 23707 pushTarget(); 23708 var handlers = vm.$options[hook]; 23709 if (handlers) { 23710 for (var i = 0, j = handlers.length; i < j; i++) { 23711 try { 23712 handlers[i].call(vm); 23713 } catch (e) { 23714 handleError(e, vm, (hook + " hook")); 23715 } 23716 } 23717 } 23718 if (vm._hasHookEvent) { 23719 vm.$emit('hook:' + hook); 23720 } 23721 popTarget(); 23722} 23723 23724/* */ 23725 23726 23727var MAX_UPDATE_COUNT = 100; 23728 23729var queue = []; 23730var activatedChildren = []; 23731var has = {}; 23732var circular = {}; 23733var waiting = false; 23734var flushing = false; 23735var index = 0; 23736 23737/** 23738 * Reset the scheduler's state. 23739 */ 23740function resetSchedulerState () { 23741 index = queue.length = activatedChildren.length = 0; 23742 has = {}; 23743 if (true) { 23744 circular = {}; 23745 } 23746 waiting = flushing = false; 23747} 23748 23749/** 23750 * Flush both queues and run the watchers. 23751 */ 23752function flushSchedulerQueue () { 23753 flushing = true; 23754 var watcher, id; 23755 23756 // Sort queue before flush. 23757 // This ensures that: 23758 // 1. Components are updated from parent to child. (because parent is always 23759 // created before the child) 23760 // 2. A component's user watchers are run before its render watcher (because 23761 // user watchers are created before the render watcher) 23762 // 3. If a component is destroyed during a parent component's watcher run, 23763 // its watchers can be skipped. 23764 queue.sort(function (a, b) { return a.id - b.id; }); 23765 23766 // do not cache length because more watchers might be pushed 23767 // as we run existing watchers 23768 for (index = 0; index < queue.length; index++) { 23769 watcher = queue[index]; 23770 id = watcher.id; 23771 has[id] = null; 23772 watcher.run(); 23773 // in dev build, check and stop circular updates. 23774 if ("development" !== 'production' && has[id] != null) { 23775 circular[id] = (circular[id] || 0) + 1; 23776 if (circular[id] > MAX_UPDATE_COUNT) { 23777 warn( 23778 'You may have an infinite update loop ' + ( 23779 watcher.user 23780 ? ("in watcher with expression \"" + (watcher.expression) + "\"") 23781 : "in a component render function." 23782 ), 23783 watcher.vm 23784 ); 23785 break 23786 } 23787 } 23788 } 23789 23790 // keep copies of post queues before resetting state 23791 var activatedQueue = activatedChildren.slice(); 23792 var updatedQueue = queue.slice(); 23793 23794 resetSchedulerState(); 23795 23796 // call component updated and activated hooks 23797 callActivatedHooks(activatedQueue); 23798 callUpdatedHooks(updatedQueue); 23799 23800 // devtool hook 23801 /* istanbul ignore if */ 23802 if (devtools && config.devtools) { 23803 devtools.emit('flush'); 23804 } 23805} 23806 23807function callUpdatedHooks (queue) { 23808 var i = queue.length; 23809 while (i--) { 23810 var watcher = queue[i]; 23811 var vm = watcher.vm; 23812 if (vm._watcher === watcher && vm._isMounted) { 23813 callHook(vm, 'updated'); 23814 } 23815 } 23816} 23817 23818/** 23819 * Queue a kept-alive component that was activated during patch. 23820 * The queue will be processed after the entire tree has been patched. 23821 */ 23822function queueActivatedComponent (vm) { 23823 // setting _inactive to false here so that a render function can 23824 // rely on checking whether it's in an inactive tree (e.g. router-view) 23825 vm._inactive = false; 23826 activatedChildren.push(vm); 23827} 23828 23829function callActivatedHooks (queue) { 23830 for (var i = 0; i < queue.length; i++) { 23831 queue[i]._inactive = true; 23832 activateChildComponent(queue[i], true /* true */); 23833 } 23834} 23835 23836/** 23837 * Push a watcher into the watcher queue. 23838 * Jobs with duplicate IDs will be skipped unless it's 23839 * pushed when the queue is being flushed. 23840 */ 23841function queueWatcher (watcher) { 23842 var id = watcher.id; 23843 if (has[id] == null) { 23844 has[id] = true; 23845 if (!flushing) { 23846 queue.push(watcher); 23847 } else { 23848 // if already flushing, splice the watcher based on its id 23849 // if already past its id, it will be run next immediately. 23850 var i = queue.length - 1; 23851 while (i > index && queue[i].id > watcher.id) { 23852 i--; 23853 } 23854 queue.splice(i + 1, 0, watcher); 23855 } 23856 // queue the flush 23857 if (!waiting) { 23858 waiting = true; 23859 nextTick(flushSchedulerQueue); 23860 } 23861 } 23862} 23863 23864/* */ 23865 23866var uid$1 = 0; 23867 23868/** 23869 * A watcher parses an expression, collects dependencies, 23870 * and fires callback when the expression value changes. 23871 * This is used for both the $watch() api and directives. 23872 */ 23873var Watcher = function Watcher ( 23874 vm, 23875 expOrFn, 23876 cb, 23877 options, 23878 isRenderWatcher 23879) { 23880 this.vm = vm; 23881 if (isRenderWatcher) { 23882 vm._watcher = this; 23883 } 23884 vm._watchers.push(this); 23885 // options 23886 if (options) { 23887 this.deep = !!options.deep; 23888 this.user = !!options.user; 23889 this.lazy = !!options.lazy; 23890 this.sync = !!options.sync; 23891 } else { 23892 this.deep = this.user = this.lazy = this.sync = false; 23893 } 23894 this.cb = cb; 23895 this.id = ++uid$1; // uid for batching 23896 this.active = true; 23897 this.dirty = this.lazy; // for lazy watchers 23898 this.deps = []; 23899 this.newDeps = []; 23900 this.depIds = new _Set(); 23901 this.newDepIds = new _Set(); 23902 this.expression = true 23903 ? expOrFn.toString() 23904 : ''; 23905 // parse expression for getter 23906 if (typeof expOrFn === 'function') { 23907 this.getter = expOrFn; 23908 } else { 23909 this.getter = parsePath(expOrFn); 23910 if (!this.getter) { 23911 this.getter = function () {}; 23912 "development" !== 'production' && warn( 23913 "Failed watching path: \"" + expOrFn + "\" " + 23914 'Watcher only accepts simple dot-delimited paths. ' + 23915 'For full control, use a function instead.', 23916 vm 23917 ); 23918 } 23919 } 23920 this.value = this.lazy 23921 ? undefined 23922 : this.get(); 23923}; 23924 23925/** 23926 * Evaluate the getter, and re-collect dependencies. 23927 */ 23928Watcher.prototype.get = function get () { 23929 pushTarget(this); 23930 var value; 23931 var vm = this.vm; 23932 try { 23933 value = this.getter.call(vm, vm); 23934 } catch (e) { 23935 if (this.user) { 23936 handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\"")); 23937 } else { 23938 throw e 23939 } 23940 } finally { 23941 // "touch" every property so they are all tracked as 23942 // dependencies for deep watching 23943 if (this.deep) { 23944 traverse(value); 23945 } 23946 popTarget(); 23947 this.cleanupDeps(); 23948 } 23949 return value 23950}; 23951 23952/** 23953 * Add a dependency to this directive. 23954 */ 23955Watcher.prototype.addDep = function addDep (dep) { 23956 var id = dep.id; 23957 if (!this.newDepIds.has(id)) { 23958 this.newDepIds.add(id); 23959 this.newDeps.push(dep); 23960 if (!this.depIds.has(id)) { 23961 dep.addSub(this); 23962 } 23963 } 23964}; 23965 23966/** 23967 * Clean up for dependency collection. 23968 */ 23969Watcher.prototype.cleanupDeps = function cleanupDeps () { 23970 var this$1 = this; 23971 23972 var i = this.deps.length; 23973 while (i--) { 23974 var dep = this$1.deps[i]; 23975 if (!this$1.newDepIds.has(dep.id)) { 23976 dep.removeSub(this$1); 23977 } 23978 } 23979 var tmp = this.depIds; 23980 this.depIds = this.newDepIds; 23981 this.newDepIds = tmp; 23982 this.newDepIds.clear(); 23983 tmp = this.deps; 23984 this.deps = this.newDeps; 23985 this.newDeps = tmp; 23986 this.newDeps.length = 0; 23987}; 23988 23989/** 23990 * Subscriber interface. 23991 * Will be called when a dependency changes. 23992 */ 23993Watcher.prototype.update = function update () { 23994 /* istanbul ignore else */ 23995 if (this.lazy) { 23996 this.dirty = true; 23997 } else if (this.sync) { 23998 this.run(); 23999 } else { 24000 queueWatcher(this); 24001 } 24002}; 24003 24004/** 24005 * Scheduler job interface. 24006 * Will be called by the scheduler. 24007 */ 24008Watcher.prototype.run = function run () { 24009 if (this.active) { 24010 var value = this.get(); 24011 if ( 24012 value !== this.value || 24013 // Deep watchers and watchers on Object/Arrays should fire even 24014 // when the value is the same, because the value may 24015 // have mutated. 24016 isObject(value) || 24017 this.deep 24018 ) { 24019 // set new value 24020 var oldValue = this.value; 24021 this.value = value; 24022 if (this.user) { 24023 try { 24024 this.cb.call(this.vm, value, oldValue); 24025 } catch (e) { 24026 handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\"")); 24027 } 24028 } else { 24029 this.cb.call(this.vm, value, oldValue); 24030 } 24031 } 24032 } 24033}; 24034 24035/** 24036 * Evaluate the value of the watcher. 24037 * This only gets called for lazy watchers. 24038 */ 24039Watcher.prototype.evaluate = function evaluate () { 24040 this.value = this.get(); 24041 this.dirty = false; 24042}; 24043 24044/** 24045 * Depend on all deps collected by this watcher. 24046 */ 24047Watcher.prototype.depend = function depend () { 24048 var this$1 = this; 24049 24050 var i = this.deps.length; 24051 while (i--) { 24052 this$1.deps[i].depend(); 24053 } 24054}; 24055 24056/** 24057 * Remove self from all dependencies' subscriber list. 24058 */ 24059Watcher.prototype.teardown = function teardown () { 24060 var this$1 = this; 24061 24062 if (this.active) { 24063 // remove self from vm's watcher list 24064 // this is a somewhat expensive operation so we skip it 24065 // if the vm is being destroyed. 24066 if (!this.vm._isBeingDestroyed) { 24067 remove(this.vm._watchers, this); 24068 } 24069 var i = this.deps.length; 24070 while (i--) { 24071 this$1.deps[i].removeSub(this$1); 24072 } 24073 this.active = false; 24074 } 24075}; 24076 24077/* */ 24078 24079var sharedPropertyDefinition = { 24080 enumerable: true, 24081 configurable: true, 24082 get: noop, 24083 set: noop 24084}; 24085 24086function proxy (target, sourceKey, key) { 24087 sharedPropertyDefinition.get = function proxyGetter () { 24088 return this[sourceKey][key] 24089 }; 24090 sharedPropertyDefinition.set = function proxySetter (val) { 24091 this[sourceKey][key] = val; 24092 }; 24093 Object.defineProperty(target, key, sharedPropertyDefinition); 24094} 24095 24096function initState (vm) { 24097 vm._watchers = []; 24098 var opts = vm.$options; 24099 if (opts.props) { initProps(vm, opts.props); } 24100 if (opts.methods) { initMethods(vm, opts.methods); } 24101 if (opts.data) { 24102 initData(vm); 24103 } else { 24104 observe(vm._data = {}, true /* asRootData */); 24105 } 24106 if (opts.computed) { initComputed(vm, opts.computed); } 24107 if (opts.watch && opts.watch !== nativeWatch) { 24108 initWatch(vm, opts.watch); 24109 } 24110} 24111 24112function initProps (vm, propsOptions) { 24113 var propsData = vm.$options.propsData || {}; 24114 var props = vm._props = {}; 24115 // cache prop keys so that future props updates can iterate using Array 24116 // instead of dynamic object key enumeration. 24117 var keys = vm.$options._propKeys = []; 24118 var isRoot = !vm.$parent; 24119 // root instance props should be converted 24120 if (!isRoot) { 24121 toggleObserving(false); 24122 } 24123 var loop = function ( key ) { 24124 keys.push(key); 24125 var value = validateProp(key, propsOptions, propsData, vm); 24126 /* istanbul ignore else */ 24127 if (true) { 24128 var hyphenatedKey = hyphenate(key); 24129 if (isReservedAttribute(hyphenatedKey) || 24130 config.isReservedAttr(hyphenatedKey)) { 24131 warn( 24132 ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."), 24133 vm 24134 ); 24135 } 24136 defineReactive(props, key, value, function () { 24137 if (vm.$parent && !isUpdatingChildComponent) { 24138 warn( 24139 "Avoid mutating a prop directly since the value will be " + 24140 "overwritten whenever the parent component re-renders. " + 24141 "Instead, use a data or computed property based on the prop's " + 24142 "value. Prop being mutated: \"" + key + "\"", 24143 vm 24144 ); 24145 } 24146 }); 24147 } else { 24148 defineReactive(props, key, value); 24149 } 24150 // static props are already proxied on the component's prototype 24151 // during Vue.extend(). We only need to proxy props defined at 24152 // instantiation here. 24153 if (!(key in vm)) { 24154 proxy(vm, "_props", key); 24155 } 24156 }; 24157 24158 for (var key in propsOptions) loop( key ); 24159 toggleObserving(true); 24160} 24161 24162function initData (vm) { 24163 var data = vm.$options.data; 24164 data = vm._data = typeof data === 'function' 24165 ? getData(data, vm) 24166 : data || {}; 24167 if (!isPlainObject(data)) { 24168 data = {}; 24169 "development" !== 'production' && warn( 24170 'data functions should return an object:\n' + 24171 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', 24172 vm 24173 ); 24174 } 24175 // proxy data on instance 24176 var keys = Object.keys(data); 24177 var props = vm.$options.props; 24178 var methods = vm.$options.methods; 24179 var i = keys.length; 24180 while (i--) { 24181 var key = keys[i]; 24182 if (true) { 24183 if (methods && hasOwn(methods, key)) { 24184 warn( 24185 ("Method \"" + key + "\" has already been defined as a data property."), 24186 vm 24187 ); 24188 } 24189 } 24190 if (props && hasOwn(props, key)) { 24191 "development" !== 'production' && warn( 24192 "The data property \"" + key + "\" is already declared as a prop. " + 24193 "Use prop default value instead.", 24194 vm 24195 ); 24196 } else if (!isReserved(key)) { 24197 proxy(vm, "_data", key); 24198 } 24199 } 24200 // observe data 24201 observe(data, true /* asRootData */); 24202} 24203 24204function getData (data, vm) { 24205 // #7573 disable dep collection when invoking data getters 24206 pushTarget(); 24207 try { 24208 return data.call(vm, vm) 24209 } catch (e) { 24210 handleError(e, vm, "data()"); 24211 return {} 24212 } finally { 24213 popTarget(); 24214 } 24215} 24216 24217var computedWatcherOptions = { lazy: true }; 24218 24219function initComputed (vm, computed) { 24220 // $flow-disable-line 24221 var watchers = vm._computedWatchers = Object.create(null); 24222 // computed properties are just getters during SSR 24223 var isSSR = isServerRendering(); 24224 24225 for (var key in computed) { 24226 var userDef = computed[key]; 24227 var getter = typeof userDef === 'function' ? userDef : userDef.get; 24228 if ("development" !== 'production' && getter == null) { 24229 warn( 24230 ("Getter is missing for computed property \"" + key + "\"."), 24231 vm 24232 ); 24233 } 24234 24235 if (!isSSR) { 24236 // create internal watcher for the computed property. 24237 watchers[key] = new Watcher( 24238 vm, 24239 getter || noop, 24240 noop, 24241 computedWatcherOptions 24242 ); 24243 } 24244 24245 // component-defined computed properties are already defined on the 24246 // component prototype. We only need to define computed properties defined 24247 // at instantiation here. 24248 if (!(key in vm)) { 24249 defineComputed(vm, key, userDef); 24250 } else if (true) { 24251 if (key in vm.$data) { 24252 warn(("The computed property \"" + key + "\" is already defined in data."), vm); 24253 } else if (vm.$options.props && key in vm.$options.props) { 24254 warn(("The computed property \"" + key + "\" is already defined as a prop."), vm); 24255 } 24256 } 24257 } 24258} 24259 24260function defineComputed ( 24261 target, 24262 key, 24263 userDef 24264) { 24265 var shouldCache = !isServerRendering(); 24266 if (typeof userDef === 'function') { 24267 sharedPropertyDefinition.get = shouldCache 24268 ? createComputedGetter(key) 24269 : userDef; 24270 sharedPropertyDefinition.set = noop; 24271 } else { 24272 sharedPropertyDefinition.get = userDef.get 24273 ? shouldCache && userDef.cache !== false 24274 ? createComputedGetter(key) 24275 : userDef.get 24276 : noop; 24277 sharedPropertyDefinition.set = userDef.set 24278 ? userDef.set 24279 : noop; 24280 } 24281 if ("development" !== 'production' && 24282 sharedPropertyDefinition.set === noop) { 24283 sharedPropertyDefinition.set = function () { 24284 warn( 24285 ("Computed property \"" + key + "\" was assigned to but it has no setter."), 24286 this 24287 ); 24288 }; 24289 } 24290 Object.defineProperty(target, key, sharedPropertyDefinition); 24291} 24292 24293function createComputedGetter (key) { 24294 return function computedGetter () { 24295 var watcher = this._computedWatchers && this._computedWatchers[key]; 24296 if (watcher) { 24297 if (watcher.dirty) { 24298 watcher.evaluate(); 24299 } 24300 if (Dep.target) { 24301 watcher.depend(); 24302 } 24303 return watcher.value 24304 } 24305 } 24306} 24307 24308function initMethods (vm, methods) { 24309 var props = vm.$options.props; 24310 for (var key in methods) { 24311 if (true) { 24312 if (methods[key] == null) { 24313 warn( 24314 "Method \"" + key + "\" has an undefined value in the component definition. " + 24315 "Did you reference the function correctly?", 24316 vm 24317 ); 24318 } 24319 if (props && hasOwn(props, key)) { 24320 warn( 24321 ("Method \"" + key + "\" has already been defined as a prop."), 24322 vm 24323 ); 24324 } 24325 if ((key in vm) && isReserved(key)) { 24326 warn( 24327 "Method \"" + key + "\" conflicts with an existing Vue instance method. " + 24328 "Avoid defining component methods that start with _ or $." 24329 ); 24330 } 24331 } 24332 vm[key] = methods[key] == null ? noop : bind(methods[key], vm); 24333 } 24334} 24335 24336function initWatch (vm, watch) { 24337 for (var key in watch) { 24338 var handler = watch[key]; 24339 if (Array.isArray(handler)) { 24340 for (var i = 0; i < handler.length; i++) { 24341 createWatcher(vm, key, handler[i]); 24342 } 24343 } else { 24344 createWatcher(vm, key, handler); 24345 } 24346 } 24347} 24348 24349function createWatcher ( 24350 vm, 24351 expOrFn, 24352 handler, 24353 options 24354) { 24355 if (isPlainObject(handler)) { 24356 options = handler; 24357 handler = handler.handler; 24358 } 24359 if (typeof handler === 'string') { 24360 handler = vm[handler]; 24361 } 24362 return vm.$watch(expOrFn, handler, options) 24363} 24364 24365function stateMixin (Vue) { 24366 // flow somehow has problems with directly declared definition object 24367 // when using Object.defineProperty, so we have to procedurally build up 24368 // the object here. 24369 var dataDef = {}; 24370 dataDef.get = function () { return this._data }; 24371 var propsDef = {}; 24372 propsDef.get = function () { return this._props }; 24373 if (true) { 24374 dataDef.set = function (newData) { 24375 warn( 24376 'Avoid replacing instance root $data. ' + 24377 'Use nested data properties instead.', 24378 this 24379 ); 24380 }; 24381 propsDef.set = function () { 24382 warn("$props is readonly.", this); 24383 }; 24384 } 24385 Object.defineProperty(Vue.prototype, '$data', dataDef); 24386 Object.defineProperty(Vue.prototype, '$props', propsDef); 24387 24388 Vue.prototype.$set = set; 24389 Vue.prototype.$delete = del; 24390 24391 Vue.prototype.$watch = function ( 24392 expOrFn, 24393 cb, 24394 options 24395 ) { 24396 var vm = this; 24397 if (isPlainObject(cb)) { 24398 return createWatcher(vm, expOrFn, cb, options) 24399 } 24400 options = options || {}; 24401 options.user = true; 24402 var watcher = new Watcher(vm, expOrFn, cb, options); 24403 if (options.immediate) { 24404 cb.call(vm, watcher.value); 24405 } 24406 return function unwatchFn () { 24407 watcher.teardown(); 24408 } 24409 }; 24410} 24411 24412/* */ 24413 24414function initProvide (vm) { 24415 var provide = vm.$options.provide; 24416 if (provide) { 24417 vm._provided = typeof provide === 'function' 24418 ? provide.call(vm) 24419 : provide; 24420 } 24421} 24422 24423function initInjections (vm) { 24424 var result = resolveInject(vm.$options.inject, vm); 24425 if (result) { 24426 toggleObserving(false); 24427 Object.keys(result).forEach(function (key) { 24428 /* istanbul ignore else */ 24429 if (true) { 24430 defineReactive(vm, key, result[key], function () { 24431 warn( 24432 "Avoid mutating an injected value directly since the changes will be " + 24433 "overwritten whenever the provided component re-renders. " + 24434 "injection being mutated: \"" + key + "\"", 24435 vm 24436 ); 24437 }); 24438 } else { 24439 defineReactive(vm, key, result[key]); 24440 } 24441 }); 24442 toggleObserving(true); 24443 } 24444} 24445 24446function resolveInject (inject, vm) { 24447 if (inject) { 24448 // inject is :any because flow is not smart enough to figure out cached 24449 var result = Object.create(null); 24450 var keys = hasSymbol 24451 ? Reflect.ownKeys(inject).filter(function (key) { 24452 /* istanbul ignore next */ 24453 return Object.getOwnPropertyDescriptor(inject, key).enumerable 24454 }) 24455 : Object.keys(inject); 24456 24457 for (var i = 0; i < keys.length; i++) { 24458 var key = keys[i]; 24459 var provideKey = inject[key].from; 24460 var source = vm; 24461 while (source) { 24462 if (source._provided && hasOwn(source._provided, provideKey)) { 24463 result[key] = source._provided[provideKey]; 24464 break 24465 } 24466 source = source.$parent; 24467 } 24468 if (!source) { 24469 if ('default' in inject[key]) { 24470 var provideDefault = inject[key].default; 24471 result[key] = typeof provideDefault === 'function' 24472 ? provideDefault.call(vm) 24473 : provideDefault; 24474 } else if (true) { 24475 warn(("Injection \"" + key + "\" not found"), vm); 24476 } 24477 } 24478 } 24479 return result 24480 } 24481} 24482 24483/* */ 24484 24485/** 24486 * Runtime helper for rendering v-for lists. 24487 */ 24488function renderList ( 24489 val, 24490 render 24491) { 24492 var ret, i, l, keys, key; 24493 if (Array.isArray(val) || typeof val === 'string') { 24494 ret = new Array(val.length); 24495 for (i = 0, l = val.length; i < l; i++) { 24496 ret[i] = render(val[i], i); 24497 } 24498 } else if (typeof val === 'number') { 24499 ret = new Array(val); 24500 for (i = 0; i < val; i++) { 24501 ret[i] = render(i + 1, i); 24502 } 24503 } else if (isObject(val)) { 24504 keys = Object.keys(val); 24505 ret = new Array(keys.length); 24506 for (i = 0, l = keys.length; i < l; i++) { 24507 key = keys[i]; 24508 ret[i] = render(val[key], key, i); 24509 } 24510 } 24511 if (isDef(ret)) { 24512 (ret)._isVList = true; 24513 } 24514 return ret 24515} 24516 24517/* */ 24518 24519/** 24520 * Runtime helper for rendering <slot> 24521 */ 24522function renderSlot ( 24523 name, 24524 fallback, 24525 props, 24526 bindObject 24527) { 24528 var scopedSlotFn = this.$scopedSlots[name]; 24529 var nodes; 24530 if (scopedSlotFn) { // scoped slot 24531 props = props || {}; 24532 if (bindObject) { 24533 if ("development" !== 'production' && !isObject(bindObject)) { 24534 warn( 24535 'slot v-bind without argument expects an Object', 24536 this 24537 ); 24538 } 24539 props = extend(extend({}, bindObject), props); 24540 } 24541 nodes = scopedSlotFn(props) || fallback; 24542 } else { 24543 var slotNodes = this.$slots[name]; 24544 // warn duplicate slot usage 24545 if (slotNodes) { 24546 if ("development" !== 'production' && slotNodes._rendered) { 24547 warn( 24548 "Duplicate presence of slot \"" + name + "\" found in the same render tree " + 24549 "- this will likely cause render errors.", 24550 this 24551 ); 24552 } 24553 slotNodes._rendered = true; 24554 } 24555 nodes = slotNodes || fallback; 24556 } 24557 24558 var target = props && props.slot; 24559 if (target) { 24560 return this.$createElement('template', { slot: target }, nodes) 24561 } else { 24562 return nodes 24563 } 24564} 24565 24566/* */ 24567 24568/** 24569 * Runtime helper for resolving filters 24570 */ 24571function resolveFilter (id) { 24572 return resolveAsset(this.$options, 'filters', id, true) || identity 24573} 24574 24575/* */ 24576 24577function isKeyNotMatch (expect, actual) { 24578 if (Array.isArray(expect)) { 24579 return expect.indexOf(actual) === -1 24580 } else { 24581 return expect !== actual 24582 } 24583} 24584 24585/** 24586 * Runtime helper for checking keyCodes from config. 24587 * exposed as Vue.prototype._k 24588 * passing in eventKeyName as last argument separately for backwards compat 24589 */ 24590function checkKeyCodes ( 24591 eventKeyCode, 24592 key, 24593 builtInKeyCode, 24594 eventKeyName, 24595 builtInKeyName 24596) { 24597 var mappedKeyCode = config.keyCodes[key] || builtInKeyCode; 24598 if (builtInKeyName && eventKeyName && !config.keyCodes[key]) { 24599 return isKeyNotMatch(builtInKeyName, eventKeyName) 24600 } else if (mappedKeyCode) { 24601 return isKeyNotMatch(mappedKeyCode, eventKeyCode) 24602 } else if (eventKeyName) { 24603 return hyphenate(eventKeyName) !== key 24604 } 24605} 24606 24607/* */ 24608 24609/** 24610 * Runtime helper for merging v-bind="object" into a VNode's data. 24611 */ 24612function bindObjectProps ( 24613 data, 24614 tag, 24615 value, 24616 asProp, 24617 isSync 24618) { 24619 if (value) { 24620 if (!isObject(value)) { 24621 "development" !== 'production' && warn( 24622 'v-bind without argument expects an Object or Array value', 24623 this 24624 ); 24625 } else { 24626 if (Array.isArray(value)) { 24627 value = toObject(value); 24628 } 24629 var hash; 24630 var loop = function ( key ) { 24631 if ( 24632 key === 'class' || 24633 key === 'style' || 24634 isReservedAttribute(key) 24635 ) { 24636 hash = data; 24637 } else { 24638 var type = data.attrs && data.attrs.type; 24639 hash = asProp || config.mustUseProp(tag, type, key) 24640 ? data.domProps || (data.domProps = {}) 24641 : data.attrs || (data.attrs = {}); 24642 } 24643 if (!(key in hash)) { 24644 hash[key] = value[key]; 24645 24646 if (isSync) { 24647 var on = data.on || (data.on = {}); 24648 on[("update:" + key)] = function ($event) { 24649 value[key] = $event; 24650 }; 24651 } 24652 } 24653 }; 24654 24655 for (var key in value) loop( key ); 24656 } 24657 } 24658 return data 24659} 24660 24661/* */ 24662 24663/** 24664 * Runtime helper for rendering static trees. 24665 */ 24666function renderStatic ( 24667 index, 24668 isInFor 24669) { 24670 var cached = this._staticTrees || (this._staticTrees = []); 24671 var tree = cached[index]; 24672 // if has already-rendered static tree and not inside v-for, 24673 // we can reuse the same tree. 24674 if (tree && !isInFor) { 24675 return tree 24676 } 24677 // otherwise, render a fresh tree. 24678 tree = cached[index] = this.$options.staticRenderFns[index].call( 24679 this._renderProxy, 24680 null, 24681 this // for render fns generated for functional component templates 24682 ); 24683 markStatic(tree, ("__static__" + index), false); 24684 return tree 24685} 24686 24687/** 24688 * Runtime helper for v-once. 24689 * Effectively it means marking the node as static with a unique key. 24690 */ 24691function markOnce ( 24692 tree, 24693 index, 24694 key 24695) { 24696 markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true); 24697 return tree 24698} 24699 24700function markStatic ( 24701 tree, 24702 key, 24703 isOnce 24704) { 24705 if (Array.isArray(tree)) { 24706 for (var i = 0; i < tree.length; i++) { 24707 if (tree[i] && typeof tree[i] !== 'string') { 24708 markStaticNode(tree[i], (key + "_" + i), isOnce); 24709 } 24710 } 24711 } else { 24712 markStaticNode(tree, key, isOnce); 24713 } 24714} 24715 24716function markStaticNode (node, key, isOnce) { 24717 node.isStatic = true; 24718 node.key = key; 24719 node.isOnce = isOnce; 24720} 24721 24722/* */ 24723 24724function bindObjectListeners (data, value) { 24725 if (value) { 24726 if (!isPlainObject(value)) { 24727 "development" !== 'production' && warn( 24728 'v-on without argument expects an Object value', 24729 this 24730 ); 24731 } else { 24732 var on = data.on = data.on ? extend({}, data.on) : {}; 24733 for (var key in value) { 24734 var existing = on[key]; 24735 var ours = value[key]; 24736 on[key] = existing ? [].concat(existing, ours) : ours; 24737 } 24738 } 24739 } 24740 return data 24741} 24742 24743/* */ 24744 24745function installRenderHelpers (target) { 24746 target._o = markOnce; 24747 target._n = toNumber; 24748 target._s = toString; 24749 target._l = renderList; 24750 target._t = renderSlot; 24751 target._q = looseEqual; 24752 target._i = looseIndexOf; 24753 target._m = renderStatic; 24754 target._f = resolveFilter; 24755 target._k = checkKeyCodes; 24756 target._b = bindObjectProps; 24757 target._v = createTextVNode; 24758 target._e = createEmptyVNode; 24759 target._u = resolveScopedSlots; 24760 target._g = bindObjectListeners; 24761} 24762 24763/* */ 24764 24765function FunctionalRenderContext ( 24766 data, 24767 props, 24768 children, 24769 parent, 24770 Ctor 24771) { 24772 var options = Ctor.options; 24773 // ensure the createElement function in functional components 24774 // gets a unique context - this is necessary for correct named slot check 24775 var contextVm; 24776 if (hasOwn(parent, '_uid')) { 24777 contextVm = Object.create(parent); 24778 // $flow-disable-line 24779 contextVm._original = parent; 24780 } else { 24781 // the context vm passed in is a functional context as well. 24782 // in this case we want to make sure we are able to get a hold to the 24783 // real context instance. 24784 contextVm = parent; 24785 // $flow-disable-line 24786 parent = parent._original; 24787 } 24788 var isCompiled = isTrue(options._compiled); 24789 var needNormalization = !isCompiled; 24790 24791 this.data = data; 24792 this.props = props; 24793 this.children = children; 24794 this.parent = parent; 24795 this.listeners = data.on || emptyObject; 24796 this.injections = resolveInject(options.inject, parent); 24797 this.slots = function () { return resolveSlots(children, parent); }; 24798 24799 // support for compiled functional template 24800 if (isCompiled) { 24801 // exposing $options for renderStatic() 24802 this.$options = options; 24803 // pre-resolve slots for renderSlot() 24804 this.$slots = this.slots(); 24805 this.$scopedSlots = data.scopedSlots || emptyObject; 24806 } 24807 24808 if (options._scopeId) { 24809 this._c = function (a, b, c, d) { 24810 var vnode = createElement(contextVm, a, b, c, d, needNormalization); 24811 if (vnode && !Array.isArray(vnode)) { 24812 vnode.fnScopeId = options._scopeId; 24813 vnode.fnContext = parent; 24814 } 24815 return vnode 24816 }; 24817 } else { 24818 this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); }; 24819 } 24820} 24821 24822installRenderHelpers(FunctionalRenderContext.prototype); 24823 24824function createFunctionalComponent ( 24825 Ctor, 24826 propsData, 24827 data, 24828 contextVm, 24829 children 24830) { 24831 var options = Ctor.options; 24832 var props = {}; 24833 var propOptions = options.props; 24834 if (isDef(propOptions)) { 24835 for (var key in propOptions) { 24836 props[key] = validateProp(key, propOptions, propsData || emptyObject); 24837 } 24838 } else { 24839 if (isDef(data.attrs)) { mergeProps(props, data.attrs); } 24840 if (isDef(data.props)) { mergeProps(props, data.props); } 24841 } 24842 24843 var renderContext = new FunctionalRenderContext( 24844 data, 24845 props, 24846 children, 24847 contextVm, 24848 Ctor 24849 ); 24850 24851 var vnode = options.render.call(null, renderContext._c, renderContext); 24852 24853 if (vnode instanceof VNode) { 24854 return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options) 24855 } else if (Array.isArray(vnode)) { 24856 var vnodes = normalizeChildren(vnode) || []; 24857 var res = new Array(vnodes.length); 24858 for (var i = 0; i < vnodes.length; i++) { 24859 res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options); 24860 } 24861 return res 24862 } 24863} 24864 24865function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) { 24866 // #7817 clone node before setting fnContext, otherwise if the node is reused 24867 // (e.g. it was from a cached normal slot) the fnContext causes named slots 24868 // that should not be matched to match. 24869 var clone = cloneVNode(vnode); 24870 clone.fnContext = contextVm; 24871 clone.fnOptions = options; 24872 if (data.slot) { 24873 (clone.data || (clone.data = {})).slot = data.slot; 24874 } 24875 return clone 24876} 24877 24878function mergeProps (to, from) { 24879 for (var key in from) { 24880 to[camelize(key)] = from[key]; 24881 } 24882} 24883 24884/* */ 24885 24886 24887 24888 24889// Register the component hook to weex native render engine. 24890// The hook will be triggered by native, not javascript. 24891 24892 24893// Updates the state of the component to weex native render engine. 24894 24895/* */ 24896 24897// https://github.com/Hanks10100/weex-native-directive/tree/master/component 24898 24899// listening on native callback 24900 24901/* */ 24902 24903/* */ 24904 24905// inline hooks to be invoked on component VNodes during patch 24906var componentVNodeHooks = { 24907 init: function init ( 24908 vnode, 24909 hydrating, 24910 parentElm, 24911 refElm 24912 ) { 24913 if ( 24914 vnode.componentInstance && 24915 !vnode.componentInstance._isDestroyed && 24916 vnode.data.keepAlive 24917 ) { 24918 // kept-alive components, treat as a patch 24919 var mountedNode = vnode; // work around flow 24920 componentVNodeHooks.prepatch(mountedNode, mountedNode); 24921 } else { 24922 var child = vnode.componentInstance = createComponentInstanceForVnode( 24923 vnode, 24924 activeInstance, 24925 parentElm, 24926 refElm 24927 ); 24928 child.$mount(hydrating ? vnode.elm : undefined, hydrating); 24929 } 24930 }, 24931 24932 prepatch: function prepatch (oldVnode, vnode) { 24933 var options = vnode.componentOptions; 24934 var child = vnode.componentInstance = oldVnode.componentInstance; 24935 updateChildComponent( 24936 child, 24937 options.propsData, // updated props 24938 options.listeners, // updated listeners 24939 vnode, // new parent vnode 24940 options.children // new children 24941 ); 24942 }, 24943 24944 insert: function insert (vnode) { 24945 var context = vnode.context; 24946 var componentInstance = vnode.componentInstance; 24947 if (!componentInstance._isMounted) { 24948 componentInstance._isMounted = true; 24949 callHook(componentInstance, 'mounted'); 24950 } 24951 if (vnode.data.keepAlive) { 24952 if (context._isMounted) { 24953 // vue-router#1212 24954 // During updates, a kept-alive component's child components may 24955 // change, so directly walking the tree here may call activated hooks 24956 // on incorrect children. Instead we push them into a queue which will 24957 // be processed after the whole patch process ended. 24958 queueActivatedComponent(componentInstance); 24959 } else { 24960 activateChildComponent(componentInstance, true /* direct */); 24961 } 24962 } 24963 }, 24964 24965 destroy: function destroy (vnode) { 24966 var componentInstance = vnode.componentInstance; 24967 if (!componentInstance._isDestroyed) { 24968 if (!vnode.data.keepAlive) { 24969 componentInstance.$destroy(); 24970 } else { 24971 deactivateChildComponent(componentInstance, true /* direct */); 24972 } 24973 } 24974 } 24975}; 24976 24977var hooksToMerge = Object.keys(componentVNodeHooks); 24978 24979function createComponent ( 24980 Ctor, 24981 data, 24982 context, 24983 children, 24984 tag 24985) { 24986 if (isUndef(Ctor)) { 24987 return 24988 } 24989 24990 var baseCtor = context.$options._base; 24991 24992 // plain options object: turn it into a constructor 24993 if (isObject(Ctor)) { 24994 Ctor = baseCtor.extend(Ctor); 24995 } 24996 24997 // if at this stage it's not a constructor or an async component factory, 24998 // reject. 24999 if (typeof Ctor !== 'function') { 25000 if (true) { 25001 warn(("Invalid Component definition: " + (String(Ctor))), context); 25002 } 25003 return 25004 } 25005 25006 // async component 25007 var asyncFactory; 25008 if (isUndef(Ctor.cid)) { 25009 asyncFactory = Ctor; 25010 Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context); 25011 if (Ctor === undefined) { 25012 // return a placeholder node for async component, which is rendered 25013 // as a comment node but preserves all the raw information for the node. 25014 // the information will be used for async server-rendering and hydration. 25015 return createAsyncPlaceholder( 25016 asyncFactory, 25017 data, 25018 context, 25019 children, 25020 tag 25021 ) 25022 } 25023 } 25024 25025 data = data || {}; 25026 25027 // resolve constructor options in case global mixins are applied after 25028 // component constructor creation 25029 resolveConstructorOptions(Ctor); 25030 25031 // transform component v-model data into props & events 25032 if (isDef(data.model)) { 25033 transformModel(Ctor.options, data); 25034 } 25035 25036 // extract props 25037 var propsData = extractPropsFromVNodeData(data, Ctor, tag); 25038 25039 // functional component 25040 if (isTrue(Ctor.options.functional)) { 25041 return createFunctionalComponent(Ctor, propsData, data, context, children) 25042 } 25043 25044 // extract listeners, since these needs to be treated as 25045 // child component listeners instead of DOM listeners 25046 var listeners = data.on; 25047 // replace with listeners with .native modifier 25048 // so it gets processed during parent component patch. 25049 data.on = data.nativeOn; 25050 25051 if (isTrue(Ctor.options.abstract)) { 25052 // abstract components do not keep anything 25053 // other than props & listeners & slot 25054 25055 // work around flow 25056 var slot = data.slot; 25057 data = {}; 25058 if (slot) { 25059 data.slot = slot; 25060 } 25061 } 25062 25063 // install component management hooks onto the placeholder node 25064 installComponentHooks(data); 25065 25066 // return a placeholder vnode 25067 var name = Ctor.options.name || tag; 25068 var vnode = new VNode( 25069 ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), 25070 data, undefined, undefined, undefined, context, 25071 { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }, 25072 asyncFactory 25073 ); 25074 25075 // Weex specific: invoke recycle-list optimized @render function for 25076 // extracting cell-slot template. 25077 // https://github.com/Hanks10100/weex-native-directive/tree/master/component 25078 /* istanbul ignore if */ 25079 return vnode 25080} 25081 25082function createComponentInstanceForVnode ( 25083 vnode, // we know it's MountedComponentVNode but flow doesn't 25084 parent, // activeInstance in lifecycle state 25085 parentElm, 25086 refElm 25087) { 25088 var options = { 25089 _isComponent: true, 25090 parent: parent, 25091 _parentVnode: vnode, 25092 _parentElm: parentElm || null, 25093 _refElm: refElm || null 25094 }; 25095 // check inline-template render functions 25096 var inlineTemplate = vnode.data.inlineTemplate; 25097 if (isDef(inlineTemplate)) { 25098 options.render = inlineTemplate.render; 25099 options.staticRenderFns = inlineTemplate.staticRenderFns; 25100 } 25101 return new vnode.componentOptions.Ctor(options) 25102} 25103 25104function installComponentHooks (data) { 25105 var hooks = data.hook || (data.hook = {}); 25106 for (var i = 0; i < hooksToMerge.length; i++) { 25107 var key = hooksToMerge[i]; 25108 hooks[key] = componentVNodeHooks[key]; 25109 } 25110} 25111 25112// transform component v-model info (value and callback) into 25113// prop and event handler respectively. 25114function transformModel (options, data) { 25115 var prop = (options.model && options.model.prop) || 'value'; 25116 var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value; 25117 var on = data.on || (data.on = {}); 25118 if (isDef(on[event])) { 25119 on[event] = [data.model.callback].concat(on[event]); 25120 } else { 25121 on[event] = data.model.callback; 25122 } 25123} 25124 25125/* */ 25126 25127var SIMPLE_NORMALIZE = 1; 25128var ALWAYS_NORMALIZE = 2; 25129 25130// wrapper function for providing a more flexible interface 25131// without getting yelled at by flow 25132function createElement ( 25133 context, 25134 tag, 25135 data, 25136 children, 25137 normalizationType, 25138 alwaysNormalize 25139) { 25140 if (Array.isArray(data) || isPrimitive(data)) { 25141 normalizationType = children; 25142 children = data; 25143 data = undefined; 25144 } 25145 if (isTrue(alwaysNormalize)) { 25146 normalizationType = ALWAYS_NORMALIZE; 25147 } 25148 return _createElement(context, tag, data, children, normalizationType) 25149} 25150 25151function _createElement ( 25152 context, 25153 tag, 25154 data, 25155 children, 25156 normalizationType 25157) { 25158 if (isDef(data) && isDef((data).__ob__)) { 25159 "development" !== 'production' && warn( 25160 "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" + 25161 'Always create fresh vnode data objects in each render!', 25162 context 25163 ); 25164 return createEmptyVNode() 25165 } 25166 // object syntax in v-bind 25167 if (isDef(data) && isDef(data.is)) { 25168 tag = data.is; 25169 } 25170 if (!tag) { 25171 // in case of component :is set to falsy value 25172 return createEmptyVNode() 25173 } 25174 // warn against non-primitive key 25175 if ("development" !== 'production' && 25176 isDef(data) && isDef(data.key) && !isPrimitive(data.key) 25177 ) { 25178 { 25179 warn( 25180 'Avoid using non-primitive value as key, ' + 25181 'use string/number value instead.', 25182 context 25183 ); 25184 } 25185 } 25186 // support single function children as default scoped slot 25187 if (Array.isArray(children) && 25188 typeof children[0] === 'function' 25189 ) { 25190 data = data || {}; 25191 data.scopedSlots = { default: children[0] }; 25192 children.length = 0; 25193 } 25194 if (normalizationType === ALWAYS_NORMALIZE) { 25195 children = normalizeChildren(children); 25196 } else if (normalizationType === SIMPLE_NORMALIZE) { 25197 children = simpleNormalizeChildren(children); 25198 } 25199 var vnode, ns; 25200 if (typeof tag === 'string') { 25201 var Ctor; 25202 ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag); 25203 if (config.isReservedTag(tag)) { 25204 // platform built-in elements 25205 vnode = new VNode( 25206 config.parsePlatformTagName(tag), data, children, 25207 undefined, undefined, context 25208 ); 25209 } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) { 25210 // component 25211 vnode = createComponent(Ctor, data, context, children, tag); 25212 } else { 25213 // unknown or unlisted namespaced elements 25214 // check at runtime because it may get assigned a namespace when its 25215 // parent normalizes children 25216 vnode = new VNode( 25217 tag, data, children, 25218 undefined, undefined, context 25219 ); 25220 } 25221 } else { 25222 // direct component options / constructor 25223 vnode = createComponent(tag, data, context, children); 25224 } 25225 if (Array.isArray(vnode)) { 25226 return vnode 25227 } else if (isDef(vnode)) { 25228 if (isDef(ns)) { applyNS(vnode, ns); } 25229 if (isDef(data)) { registerDeepBindings(data); } 25230 return vnode 25231 } else { 25232 return createEmptyVNode() 25233 } 25234} 25235 25236function applyNS (vnode, ns, force) { 25237 vnode.ns = ns; 25238 if (vnode.tag === 'foreignObject') { 25239 // use default namespace inside foreignObject 25240 ns = undefined; 25241 force = true; 25242 } 25243 if (isDef(vnode.children)) { 25244 for (var i = 0, l = vnode.children.length; i < l; i++) { 25245 var child = vnode.children[i]; 25246 if (isDef(child.tag) && ( 25247 isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) { 25248 applyNS(child, ns, force); 25249 } 25250 } 25251 } 25252} 25253 25254// ref #5318 25255// necessary to ensure parent re-render when deep bindings like :style and 25256// :class are used on slot nodes 25257function registerDeepBindings (data) { 25258 if (isObject(data.style)) { 25259 traverse(data.style); 25260 } 25261 if (isObject(data.class)) { 25262 traverse(data.class); 25263 } 25264} 25265 25266/* */ 25267 25268function initRender (vm) { 25269 vm._vnode = null; // the root of the child tree 25270 vm._staticTrees = null; // v-once cached trees 25271 var options = vm.$options; 25272 var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree 25273 var renderContext = parentVnode && parentVnode.context; 25274 vm.$slots = resolveSlots(options._renderChildren, renderContext); 25275 vm.$scopedSlots = emptyObject; 25276 // bind the createElement fn to this instance 25277 // so that we get proper render context inside it. 25278 // args order: tag, data, children, normalizationType, alwaysNormalize 25279 // internal version is used by render functions compiled from templates 25280 vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); }; 25281 // normalization is always applied for the public version, used in 25282 // user-written render functions. 25283 vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }; 25284 25285 // $attrs & $listeners are exposed for easier HOC creation. 25286 // they need to be reactive so that HOCs using them are always updated 25287 var parentData = parentVnode && parentVnode.data; 25288 25289 /* istanbul ignore else */ 25290 if (true) { 25291 defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () { 25292 !isUpdatingChildComponent && warn("$attrs is readonly.", vm); 25293 }, true); 25294 defineReactive(vm, '$listeners', options._parentListeners || emptyObject, function () { 25295 !isUpdatingChildComponent && warn("$listeners is readonly.", vm); 25296 }, true); 25297 } else { 25298 defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true); 25299 defineReactive(vm, '$listeners', options._parentListeners || emptyObject, null, true); 25300 } 25301} 25302 25303function renderMixin (Vue) { 25304 // install runtime convenience helpers 25305 installRenderHelpers(Vue.prototype); 25306 25307 Vue.prototype.$nextTick = function (fn) { 25308 return nextTick(fn, this) 25309 }; 25310 25311 Vue.prototype._render = function () { 25312 var vm = this; 25313 var ref = vm.$options; 25314 var render = ref.render; 25315 var _parentVnode = ref._parentVnode; 25316 25317 // reset _rendered flag on slots for duplicate slot check 25318 if (true) { 25319 for (var key in vm.$slots) { 25320 // $flow-disable-line 25321 vm.$slots[key]._rendered = false; 25322 } 25323 } 25324 25325 if (_parentVnode) { 25326 vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject; 25327 } 25328 25329 // set parent vnode. this allows render functions to have access 25330 // to the data on the placeholder node. 25331 vm.$vnode = _parentVnode; 25332 // render self 25333 var vnode; 25334 try { 25335 vnode = render.call(vm._renderProxy, vm.$createElement); 25336 } catch (e) { 25337 handleError(e, vm, "render"); 25338 // return error render result, 25339 // or previous vnode to prevent render error causing blank component 25340 /* istanbul ignore else */ 25341 if (true) { 25342 if (vm.$options.renderError) { 25343 try { 25344 vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e); 25345 } catch (e) { 25346 handleError(e, vm, "renderError"); 25347 vnode = vm._vnode; 25348 } 25349 } else { 25350 vnode = vm._vnode; 25351 } 25352 } else { 25353 vnode = vm._vnode; 25354 } 25355 } 25356 // return empty vnode in case the render function errored out 25357 if (!(vnode instanceof VNode)) { 25358 if ("development" !== 'production' && Array.isArray(vnode)) { 25359 warn( 25360 'Multiple root nodes returned from render function. Render function ' + 25361 'should return a single root node.', 25362 vm 25363 ); 25364 } 25365 vnode = createEmptyVNode(); 25366 } 25367 // set parent 25368 vnode.parent = _parentVnode; 25369 return vnode 25370 }; 25371} 25372 25373/* */ 25374 25375var uid$3 = 0; 25376 25377function initMixin (Vue) { 25378 Vue.prototype._init = function (options) { 25379 var vm = this; 25380 // a uid 25381 vm._uid = uid$3++; 25382 25383 var startTag, endTag; 25384 /* istanbul ignore if */ 25385 if ("development" !== 'production' && config.performance && mark) { 25386 startTag = "vue-perf-start:" + (vm._uid); 25387 endTag = "vue-perf-end:" + (vm._uid); 25388 mark(startTag); 25389 } 25390 25391 // a flag to avoid this being observed 25392 vm._isVue = true; 25393 // merge options 25394 if (options && options._isComponent) { 25395 // optimize internal component instantiation 25396 // since dynamic options merging is pretty slow, and none of the 25397 // internal component options needs special treatment. 25398 initInternalComponent(vm, options); 25399 } else { 25400 vm.$options = mergeOptions( 25401 resolveConstructorOptions(vm.constructor), 25402 options || {}, 25403 vm 25404 ); 25405 } 25406 /* istanbul ignore else */ 25407 if (true) { 25408 initProxy(vm); 25409 } else { 25410 vm._renderProxy = vm; 25411 } 25412 // expose real self 25413 vm._self = vm; 25414 initLifecycle(vm); 25415 initEvents(vm); 25416 initRender(vm); 25417 callHook(vm, 'beforeCreate'); 25418 initInjections(vm); // resolve injections before data/props 25419 initState(vm); 25420 initProvide(vm); // resolve provide after data/props 25421 callHook(vm, 'created'); 25422 25423 /* istanbul ignore if */ 25424 if ("development" !== 'production' && config.performance && mark) { 25425 vm._name = formatComponentName(vm, false); 25426 mark(endTag); 25427 measure(("vue " + (vm._name) + " init"), startTag, endTag); 25428 } 25429 25430 if (vm.$options.el) { 25431 vm.$mount(vm.$options.el); 25432 } 25433 }; 25434} 25435 25436function initInternalComponent (vm, options) { 25437 var opts = vm.$options = Object.create(vm.constructor.options); 25438 // doing this because it's faster than dynamic enumeration. 25439 var parentVnode = options._parentVnode; 25440 opts.parent = options.parent; 25441 opts._parentVnode = parentVnode; 25442 opts._parentElm = options._parentElm; 25443 opts._refElm = options._refElm; 25444 25445 var vnodeComponentOptions = parentVnode.componentOptions; 25446 opts.propsData = vnodeComponentOptions.propsData; 25447 opts._parentListeners = vnodeComponentOptions.listeners; 25448 opts._renderChildren = vnodeComponentOptions.children; 25449 opts._componentTag = vnodeComponentOptions.tag; 25450 25451 if (options.render) { 25452 opts.render = options.render; 25453 opts.staticRenderFns = options.staticRenderFns; 25454 } 25455} 25456 25457function resolveConstructorOptions (Ctor) { 25458 var options = Ctor.options; 25459 if (Ctor.super) { 25460 var superOptions = resolveConstructorOptions(Ctor.super); 25461 var cachedSuperOptions = Ctor.superOptions; 25462 if (superOptions !== cachedSuperOptions) { 25463 // super option changed, 25464 // need to resolve new options. 25465 Ctor.superOptions = superOptions; 25466 // check if there are any late-modified/attached options (#4976) 25467 var modifiedOptions = resolveModifiedOptions(Ctor); 25468 // update base extend options 25469 if (modifiedOptions) { 25470 extend(Ctor.extendOptions, modifiedOptions); 25471 } 25472 options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions); 25473 if (options.name) { 25474 options.components[options.name] = Ctor; 25475 } 25476 } 25477 } 25478 return options 25479} 25480 25481function resolveModifiedOptions (Ctor) { 25482 var modified; 25483 var latest = Ctor.options; 25484 var extended = Ctor.extendOptions; 25485 var sealed = Ctor.sealedOptions; 25486 for (var key in latest) { 25487 if (latest[key] !== sealed[key]) { 25488 if (!modified) { modified = {}; } 25489 modified[key] = dedupe(latest[key], extended[key], sealed[key]); 25490 } 25491 } 25492 return modified 25493} 25494 25495function dedupe (latest, extended, sealed) { 25496 // compare latest and sealed to ensure lifecycle hooks won't be duplicated 25497 // between merges 25498 if (Array.isArray(latest)) { 25499 var res = []; 25500 sealed = Array.isArray(sealed) ? sealed : [sealed]; 25501 extended = Array.isArray(extended) ? extended : [extended]; 25502 for (var i = 0; i < latest.length; i++) { 25503 // push original options and not sealed options to exclude duplicated options 25504 if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) { 25505 res.push(latest[i]); 25506 } 25507 } 25508 return res 25509 } else { 25510 return latest 25511 } 25512} 25513 25514function Vue (options) { 25515 if ("development" !== 'production' && 25516 !(this instanceof Vue) 25517 ) { 25518 warn('Vue is a constructor and should be called with the `new` keyword'); 25519 } 25520 this._init(options); 25521} 25522 25523initMixin(Vue); 25524stateMixin(Vue); 25525eventsMixin(Vue); 25526lifecycleMixin(Vue); 25527renderMixin(Vue); 25528 25529/* */ 25530 25531function initUse (Vue) { 25532 Vue.use = function (plugin) { 25533 var installedPlugins = (this._installedPlugins || (this._installedPlugins = [])); 25534 if (installedPlugins.indexOf(plugin) > -1) { 25535 return this 25536 } 25537 25538 // additional parameters 25539 var args = toArray(arguments, 1); 25540 args.unshift(this); 25541 if (typeof plugin.install === 'function') { 25542 plugin.install.apply(plugin, args); 25543 } else if (typeof plugin === 'function') { 25544 plugin.apply(null, args); 25545 } 25546 installedPlugins.push(plugin); 25547 return this 25548 }; 25549} 25550 25551/* */ 25552 25553function initMixin$1 (Vue) { 25554 Vue.mixin = function (mixin) { 25555 this.options = mergeOptions(this.options, mixin); 25556 return this 25557 }; 25558} 25559 25560/* */ 25561 25562function initExtend (Vue) { 25563 /** 25564 * Each instance constructor, including Vue, has a unique 25565 * cid. This enables us to create wrapped "child 25566 * constructors" for prototypal inheritance and cache them. 25567 */ 25568 Vue.cid = 0; 25569 var cid = 1; 25570 25571 /** 25572 * Class inheritance 25573 */ 25574 Vue.extend = function (extendOptions) { 25575 extendOptions = extendOptions || {}; 25576 var Super = this; 25577 var SuperId = Super.cid; 25578 var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {}); 25579 if (cachedCtors[SuperId]) { 25580 return cachedCtors[SuperId] 25581 } 25582 25583 var name = extendOptions.name || Super.options.name; 25584 if ("development" !== 'production' && name) { 25585 validateComponentName(name); 25586 } 25587 25588 var Sub = function VueComponent (options) { 25589 this._init(options); 25590 }; 25591 Sub.prototype = Object.create(Super.prototype); 25592 Sub.prototype.constructor = Sub; 25593 Sub.cid = cid++; 25594 Sub.options = mergeOptions( 25595 Super.options, 25596 extendOptions 25597 ); 25598 Sub['super'] = Super; 25599 25600 // For props and computed properties, we define the proxy getters on 25601 // the Vue instances at extension time, on the extended prototype. This 25602 // avoids Object.defineProperty calls for each instance created. 25603 if (Sub.options.props) { 25604 initProps$1(Sub); 25605 } 25606 if (Sub.options.computed) { 25607 initComputed$1(Sub); 25608 } 25609 25610 // allow further extension/mixin/plugin usage 25611 Sub.extend = Super.extend; 25612 Sub.mixin = Super.mixin; 25613 Sub.use = Super.use; 25614 25615 // create asset registers, so extended classes 25616 // can have their private assets too. 25617 ASSET_TYPES.forEach(function (type) { 25618 Sub[type] = Super[type]; 25619 }); 25620 // enable recursive self-lookup 25621 if (name) { 25622 Sub.options.components[name] = Sub; 25623 } 25624 25625 // keep a reference to the super options at extension time. 25626 // later at instantiation we can check if Super's options have 25627 // been updated. 25628 Sub.superOptions = Super.options; 25629 Sub.extendOptions = extendOptions; 25630 Sub.sealedOptions = extend({}, Sub.options); 25631 25632 // cache constructor 25633 cachedCtors[SuperId] = Sub; 25634 return Sub 25635 }; 25636} 25637 25638function initProps$1 (Comp) { 25639 var props = Comp.options.props; 25640 for (var key in props) { 25641 proxy(Comp.prototype, "_props", key); 25642 } 25643} 25644 25645function initComputed$1 (Comp) { 25646 var computed = Comp.options.computed; 25647 for (var key in computed) { 25648 defineComputed(Comp.prototype, key, computed[key]); 25649 } 25650} 25651 25652/* */ 25653 25654function initAssetRegisters (Vue) { 25655 /** 25656 * Create asset registration methods. 25657 */ 25658 ASSET_TYPES.forEach(function (type) { 25659 Vue[type] = function ( 25660 id, 25661 definition 25662 ) { 25663 if (!definition) { 25664 return this.options[type + 's'][id] 25665 } else { 25666 /* istanbul ignore if */ 25667 if ("development" !== 'production' && type === 'component') { 25668 validateComponentName(id); 25669 } 25670 if (type === 'component' && isPlainObject(definition)) { 25671 definition.name = definition.name || id; 25672 definition = this.options._base.extend(definition); 25673 } 25674 if (type === 'directive' && typeof definition === 'function') { 25675 definition = { bind: definition, update: definition }; 25676 } 25677 this.options[type + 's'][id] = definition; 25678 return definition 25679 } 25680 }; 25681 }); 25682} 25683 25684/* */ 25685 25686function getComponentName (opts) { 25687 return opts && (opts.Ctor.options.name || opts.tag) 25688} 25689 25690function matches (pattern, name) { 25691 if (Array.isArray(pattern)) { 25692 return pattern.indexOf(name) > -1 25693 } else if (typeof pattern === 'string') { 25694 return pattern.split(',').indexOf(name) > -1 25695 } else if (isRegExp(pattern)) { 25696 return pattern.test(name) 25697 } 25698 /* istanbul ignore next */ 25699 return false 25700} 25701 25702function pruneCache (keepAliveInstance, filter) { 25703 var cache = keepAliveInstance.cache; 25704 var keys = keepAliveInstance.keys; 25705 var _vnode = keepAliveInstance._vnode; 25706 for (var key in cache) { 25707 var cachedNode = cache[key]; 25708 if (cachedNode) { 25709 var name = getComponentName(cachedNode.componentOptions); 25710 if (name && !filter(name)) { 25711 pruneCacheEntry(cache, key, keys, _vnode); 25712 } 25713 } 25714 } 25715} 25716 25717function pruneCacheEntry ( 25718 cache, 25719 key, 25720 keys, 25721 current 25722) { 25723 var cached$$1 = cache[key]; 25724 if (cached$$1 && (!current || cached$$1.tag !== current.tag)) { 25725 cached$$1.componentInstance.$destroy(); 25726 } 25727 cache[key] = null; 25728 remove(keys, key); 25729} 25730 25731var patternTypes = [String, RegExp, Array]; 25732 25733var KeepAlive = { 25734 name: 'keep-alive', 25735 abstract: true, 25736 25737 props: { 25738 include: patternTypes, 25739 exclude: patternTypes, 25740 max: [String, Number] 25741 }, 25742 25743 created: function created () { 25744 this.cache = Object.create(null); 25745 this.keys = []; 25746 }, 25747 25748 destroyed: function destroyed () { 25749 var this$1 = this; 25750 25751 for (var key in this$1.cache) { 25752 pruneCacheEntry(this$1.cache, key, this$1.keys); 25753 } 25754 }, 25755 25756 mounted: function mounted () { 25757 var this$1 = this; 25758 25759 this.$watch('include', function (val) { 25760 pruneCache(this$1, function (name) { return matches(val, name); }); 25761 }); 25762 this.$watch('exclude', function (val) { 25763 pruneCache(this$1, function (name) { return !matches(val, name); }); 25764 }); 25765 }, 25766 25767 render: function render () { 25768 var slot = this.$slots.default; 25769 var vnode = getFirstComponentChild(slot); 25770 var componentOptions = vnode && vnode.componentOptions; 25771 if (componentOptions) { 25772 // check pattern 25773 var name = getComponentName(componentOptions); 25774 var ref = this; 25775 var include = ref.include; 25776 var exclude = ref.exclude; 25777 if ( 25778 // not included 25779 (include && (!name || !matches(include, name))) || 25780 // excluded 25781 (exclude && name && matches(exclude, name)) 25782 ) { 25783 return vnode 25784 } 25785 25786 var ref$1 = this; 25787 var cache = ref$1.cache; 25788 var keys = ref$1.keys; 25789 var key = vnode.key == null 25790 // same constructor may get registered as different local components 25791 // so cid alone is not enough (#3269) 25792 ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '') 25793 : vnode.key; 25794 if (cache[key]) { 25795 vnode.componentInstance = cache[key].componentInstance; 25796 // make current key freshest 25797 remove(keys, key); 25798 keys.push(key); 25799 } else { 25800 cache[key] = vnode; 25801 keys.push(key); 25802 // prune oldest entry 25803 if (this.max && keys.length > parseInt(this.max)) { 25804 pruneCacheEntry(cache, keys[0], keys, this._vnode); 25805 } 25806 } 25807 25808 vnode.data.keepAlive = true; 25809 } 25810 return vnode || (slot && slot[0]) 25811 } 25812} 25813 25814var builtInComponents = { 25815 KeepAlive: KeepAlive 25816} 25817 25818/* */ 25819 25820function initGlobalAPI (Vue) { 25821 // config 25822 var configDef = {}; 25823 configDef.get = function () { return config; }; 25824 if (true) { 25825 configDef.set = function () { 25826 warn( 25827 'Do not replace the Vue.config object, set individual fields instead.' 25828 ); 25829 }; 25830 } 25831 Object.defineProperty(Vue, 'config', configDef); 25832 25833 // exposed util methods. 25834 // NOTE: these are not considered part of the public API - avoid relying on 25835 // them unless you are aware of the risk. 25836 Vue.util = { 25837 warn: warn, 25838 extend: extend, 25839 mergeOptions: mergeOptions, 25840 defineReactive: defineReactive 25841 }; 25842 25843 Vue.set = set; 25844 Vue.delete = del; 25845 Vue.nextTick = nextTick; 25846 25847 Vue.options = Object.create(null); 25848 ASSET_TYPES.forEach(function (type) { 25849 Vue.options[type + 's'] = Object.create(null); 25850 }); 25851 25852 // this is used to identify the "base" constructor to extend all plain-object 25853 // components with in Weex's multi-instance scenarios. 25854 Vue.options._base = Vue; 25855 25856 extend(Vue.options.components, builtInComponents); 25857 25858 initUse(Vue); 25859 initMixin$1(Vue); 25860 initExtend(Vue); 25861 initAssetRegisters(Vue); 25862} 25863 25864initGlobalAPI(Vue); 25865 25866Object.defineProperty(Vue.prototype, '$isServer', { 25867 get: isServerRendering 25868}); 25869 25870Object.defineProperty(Vue.prototype, '$ssrContext', { 25871 get: function get () { 25872 /* istanbul ignore next */ 25873 return this.$vnode && this.$vnode.ssrContext 25874 } 25875}); 25876 25877// expose FunctionalRenderContext for ssr runtime helper installation 25878Object.defineProperty(Vue, 'FunctionalRenderContext', { 25879 value: FunctionalRenderContext 25880}); 25881 25882Vue.version = '2.5.16'; 25883 25884/* */ 25885 25886// these are reserved for web because they are directly compiled away 25887// during template compilation 25888var isReservedAttr = makeMap('style,class'); 25889 25890// attributes that should be using props for binding 25891var acceptValue = makeMap('input,textarea,option,select,progress'); 25892var mustUseProp = function (tag, type, attr) { 25893 return ( 25894 (attr === 'value' && acceptValue(tag)) && type !== 'button' || 25895 (attr === 'selected' && tag === 'option') || 25896 (attr === 'checked' && tag === 'input') || 25897 (attr === 'muted' && tag === 'video') 25898 ) 25899}; 25900 25901var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck'); 25902 25903var isBooleanAttr = makeMap( 25904 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + 25905 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + 25906 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + 25907 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + 25908 'required,reversed,scoped,seamless,selected,sortable,translate,' + 25909 'truespeed,typemustmatch,visible' 25910); 25911 25912var xlinkNS = 'http://www.w3.org/1999/xlink'; 25913 25914var isXlink = function (name) { 25915 return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink' 25916}; 25917 25918var getXlinkProp = function (name) { 25919 return isXlink(name) ? name.slice(6, name.length) : '' 25920}; 25921 25922var isFalsyAttrValue = function (val) { 25923 return val == null || val === false 25924}; 25925 25926/* */ 25927 25928function genClassForVnode (vnode) { 25929 var data = vnode.data; 25930 var parentNode = vnode; 25931 var childNode = vnode; 25932 while (isDef(childNode.componentInstance)) { 25933 childNode = childNode.componentInstance._vnode; 25934 if (childNode && childNode.data) { 25935 data = mergeClassData(childNode.data, data); 25936 } 25937 } 25938 while (isDef(parentNode = parentNode.parent)) { 25939 if (parentNode && parentNode.data) { 25940 data = mergeClassData(data, parentNode.data); 25941 } 25942 } 25943 return renderClass(data.staticClass, data.class) 25944} 25945 25946function mergeClassData (child, parent) { 25947 return { 25948 staticClass: concat(child.staticClass, parent.staticClass), 25949 class: isDef(child.class) 25950 ? [child.class, parent.class] 25951 : parent.class 25952 } 25953} 25954 25955function renderClass ( 25956 staticClass, 25957 dynamicClass 25958) { 25959 if (isDef(staticClass) || isDef(dynamicClass)) { 25960 return concat(staticClass, stringifyClass(dynamicClass)) 25961 } 25962 /* istanbul ignore next */ 25963 return '' 25964} 25965 25966function concat (a, b) { 25967 return a ? b ? (a + ' ' + b) : a : (b || '') 25968} 25969 25970function stringifyClass (value) { 25971 if (Array.isArray(value)) { 25972 return stringifyArray(value) 25973 } 25974 if (isObject(value)) { 25975 return stringifyObject(value) 25976 } 25977 if (typeof value === 'string') { 25978 return value 25979 } 25980 /* istanbul ignore next */ 25981 return '' 25982} 25983 25984function stringifyArray (value) { 25985 var res = ''; 25986 var stringified; 25987 for (var i = 0, l = value.length; i < l; i++) { 25988 if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') { 25989 if (res) { res += ' '; } 25990 res += stringified; 25991 } 25992 } 25993 return res 25994} 25995 25996function stringifyObject (value) { 25997 var res = ''; 25998 for (var key in value) { 25999 if (value[key]) { 26000 if (res) { res += ' '; } 26001 res += key; 26002 } 26003 } 26004 return res 26005} 26006 26007/* */ 26008 26009var namespaceMap = { 26010 svg: 'http://www.w3.org/2000/svg', 26011 math: 'http://www.w3.org/1998/Math/MathML' 26012}; 26013 26014var isHTMLTag = makeMap( 26015 'html,body,base,head,link,meta,style,title,' + 26016 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + 26017 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' + 26018 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + 26019 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + 26020 'embed,object,param,source,canvas,script,noscript,del,ins,' + 26021 'caption,col,colgroup,table,thead,tbody,td,th,tr,' + 26022 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + 26023 'output,progress,select,textarea,' + 26024 'details,dialog,menu,menuitem,summary,' + 26025 'content,element,shadow,template,blockquote,iframe,tfoot' 26026); 26027 26028// this map is intentionally selective, only covering SVG elements that may 26029// contain child elements. 26030var isSVG = makeMap( 26031 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' + 26032 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + 26033 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', 26034 true 26035); 26036 26037var isPreTag = function (tag) { return tag === 'pre'; }; 26038 26039var isReservedTag = function (tag) { 26040 return isHTMLTag(tag) || isSVG(tag) 26041}; 26042 26043function getTagNamespace (tag) { 26044 if (isSVG(tag)) { 26045 return 'svg' 26046 } 26047 // basic support for MathML 26048 // note it doesn't support other MathML elements being component roots 26049 if (tag === 'math') { 26050 return 'math' 26051 } 26052} 26053 26054var unknownElementCache = Object.create(null); 26055function isUnknownElement (tag) { 26056 /* istanbul ignore if */ 26057 if (!inBrowser) { 26058 return true 26059 } 26060 if (isReservedTag(tag)) { 26061 return false 26062 } 26063 tag = tag.toLowerCase(); 26064 /* istanbul ignore if */ 26065 if (unknownElementCache[tag] != null) { 26066 return unknownElementCache[tag] 26067 } 26068 var el = document.createElement(tag); 26069 if (tag.indexOf('-') > -1) { 26070 // http://stackoverflow.com/a/28210364/1070244 26071 return (unknownElementCache[tag] = ( 26072 el.constructor === window.HTMLUnknownElement || 26073 el.constructor === window.HTMLElement 26074 )) 26075 } else { 26076 return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString())) 26077 } 26078} 26079 26080var isTextInputType = makeMap('text,number,password,search,email,tel,url'); 26081 26082/* */ 26083 26084/** 26085 * Query an element selector if it's not an element already. 26086 */ 26087function query (el) { 26088 if (typeof el === 'string') { 26089 var selected = document.querySelector(el); 26090 if (!selected) { 26091 "development" !== 'production' && warn( 26092 'Cannot find element: ' + el 26093 ); 26094 return document.createElement('div') 26095 } 26096 return selected 26097 } else { 26098 return el 26099 } 26100} 26101 26102/* */ 26103 26104function createElement$1 (tagName, vnode) { 26105 var elm = document.createElement(tagName); 26106 if (tagName !== 'select') { 26107 return elm 26108 } 26109 // false or null will remove the attribute but undefined will not 26110 if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) { 26111 elm.setAttribute('multiple', 'multiple'); 26112 } 26113 return elm 26114} 26115 26116function createElementNS (namespace, tagName) { 26117 return document.createElementNS(namespaceMap[namespace], tagName) 26118} 26119 26120function createTextNode (text) { 26121 return document.createTextNode(text) 26122} 26123 26124function createComment (text) { 26125 return document.createComment(text) 26126} 26127 26128function insertBefore (parentNode, newNode, referenceNode) { 26129 parentNode.insertBefore(newNode, referenceNode); 26130} 26131 26132function removeChild (node, child) { 26133 node.removeChild(child); 26134} 26135 26136function appendChild (node, child) { 26137 node.appendChild(child); 26138} 26139 26140function parentNode (node) { 26141 return node.parentNode 26142} 26143 26144function nextSibling (node) { 26145 return node.nextSibling 26146} 26147 26148function tagName (node) { 26149 return node.tagName 26150} 26151 26152function setTextContent (node, text) { 26153 node.textContent = text; 26154} 26155 26156function setStyleScope (node, scopeId) { 26157 node.setAttribute(scopeId, ''); 26158} 26159 26160 26161var nodeOps = Object.freeze({ 26162 createElement: createElement$1, 26163 createElementNS: createElementNS, 26164 createTextNode: createTextNode, 26165 createComment: createComment, 26166 insertBefore: insertBefore, 26167 removeChild: removeChild, 26168 appendChild: appendChild, 26169 parentNode: parentNode, 26170 nextSibling: nextSibling, 26171 tagName: tagName, 26172 setTextContent: setTextContent, 26173 setStyleScope: setStyleScope 26174}); 26175 26176/* */ 26177 26178var ref = { 26179 create: function create (_, vnode) { 26180 registerRef(vnode); 26181 }, 26182 update: function update (oldVnode, vnode) { 26183 if (oldVnode.data.ref !== vnode.data.ref) { 26184 registerRef(oldVnode, true); 26185 registerRef(vnode); 26186 } 26187 }, 26188 destroy: function destroy (vnode) { 26189 registerRef(vnode, true); 26190 } 26191} 26192 26193function registerRef (vnode, isRemoval) { 26194 var key = vnode.data.ref; 26195 if (!isDef(key)) { return } 26196 26197 var vm = vnode.context; 26198 var ref = vnode.componentInstance || vnode.elm; 26199 var refs = vm.$refs; 26200 if (isRemoval) { 26201 if (Array.isArray(refs[key])) { 26202 remove(refs[key], ref); 26203 } else if (refs[key] === ref) { 26204 refs[key] = undefined; 26205 } 26206 } else { 26207 if (vnode.data.refInFor) { 26208 if (!Array.isArray(refs[key])) { 26209 refs[key] = [ref]; 26210 } else if (refs[key].indexOf(ref) < 0) { 26211 // $flow-disable-line 26212 refs[key].push(ref); 26213 } 26214 } else { 26215 refs[key] = ref; 26216 } 26217 } 26218} 26219 26220/** 26221 * Virtual DOM patching algorithm based on Snabbdom by 26222 * Simon Friis Vindum (@paldepind) 26223 * Licensed under the MIT License 26224 * https://github.com/paldepind/snabbdom/blob/master/LICENSE 26225 * 26226 * modified by Evan You (@yyx990803) 26227 * 26228 * Not type-checking this because this file is perf-critical and the cost 26229 * of making flow understand it is not worth it. 26230 */ 26231 26232var emptyNode = new VNode('', {}, []); 26233 26234var hooks = ['create', 'activate', 'update', 'remove', 'destroy']; 26235 26236function sameVnode (a, b) { 26237 return ( 26238 a.key === b.key && ( 26239 ( 26240 a.tag === b.tag && 26241 a.isComment === b.isComment && 26242 isDef(a.data) === isDef(b.data) && 26243 sameInputType(a, b) 26244 ) || ( 26245 isTrue(a.isAsyncPlaceholder) && 26246 a.asyncFactory === b.asyncFactory && 26247 isUndef(b.asyncFactory.error) 26248 ) 26249 ) 26250 ) 26251} 26252 26253function sameInputType (a, b) { 26254 if (a.tag !== 'input') { return true } 26255 var i; 26256 var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type; 26257 var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type; 26258 return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB) 26259} 26260 26261function createKeyToOldIdx (children, beginIdx, endIdx) { 26262 var i, key; 26263 var map = {}; 26264 for (i = beginIdx; i <= endIdx; ++i) { 26265 key = children[i].key; 26266 if (isDef(key)) { map[key] = i; } 26267 } 26268 return map 26269} 26270 26271function createPatchFunction (backend) { 26272 var i, j; 26273 var cbs = {}; 26274 26275 var modules = backend.modules; 26276 var nodeOps = backend.nodeOps; 26277 26278 for (i = 0; i < hooks.length; ++i) { 26279 cbs[hooks[i]] = []; 26280 for (j = 0; j < modules.length; ++j) { 26281 if (isDef(modules[j][hooks[i]])) { 26282 cbs[hooks[i]].push(modules[j][hooks[i]]); 26283 } 26284 } 26285 } 26286 26287 function emptyNodeAt (elm) { 26288 return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm) 26289 } 26290 26291 function createRmCb (childElm, listeners) { 26292 function remove () { 26293 if (--remove.listeners === 0) { 26294 removeNode(childElm); 26295 } 26296 } 26297 remove.listeners = listeners; 26298 return remove 26299 } 26300 26301 function removeNode (el) { 26302 var parent = nodeOps.parentNode(el); 26303 // element may have already been removed due to v-html / v-text 26304 if (isDef(parent)) { 26305 nodeOps.removeChild(parent, el); 26306 } 26307 } 26308 26309 function isUnknownElement$$1 (vnode, inVPre) { 26310 return ( 26311 !inVPre && 26312 !vnode.ns && 26313 !( 26314 config.ignoredElements.length && 26315 config.ignoredElements.some(function (ignore) { 26316 return isRegExp(ignore) 26317 ? ignore.test(vnode.tag) 26318 : ignore === vnode.tag 26319 }) 26320 ) && 26321 config.isUnknownElement(vnode.tag) 26322 ) 26323 } 26324 26325 var creatingElmInVPre = 0; 26326 26327 function createElm ( 26328 vnode, 26329 insertedVnodeQueue, 26330 parentElm, 26331 refElm, 26332 nested, 26333 ownerArray, 26334 index 26335 ) { 26336 if (isDef(vnode.elm) && isDef(ownerArray)) { 26337 // This vnode was used in a previous render! 26338 // now it's used as a new node, overwriting its elm would cause 26339 // potential patch errors down the road when it's used as an insertion 26340 // reference node. Instead, we clone the node on-demand before creating 26341 // associated DOM element for it. 26342 vnode = ownerArray[index] = cloneVNode(vnode); 26343 } 26344 26345 vnode.isRootInsert = !nested; // for transition enter check 26346 if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) { 26347 return 26348 } 26349 26350 var data = vnode.data; 26351 var children = vnode.children; 26352 var tag = vnode.tag; 26353 if (isDef(tag)) { 26354 if (true) { 26355 if (data && data.pre) { 26356 creatingElmInVPre++; 26357 } 26358 if (isUnknownElement$$1(vnode, creatingElmInVPre)) { 26359 warn( 26360 'Unknown custom element: <' + tag + '> - did you ' + 26361 'register the component correctly? For recursive components, ' + 26362 'make sure to provide the "name" option.', 26363 vnode.context 26364 ); 26365 } 26366 } 26367 26368 vnode.elm = vnode.ns 26369 ? nodeOps.createElementNS(vnode.ns, tag) 26370 : nodeOps.createElement(tag, vnode); 26371 setScope(vnode); 26372 26373 /* istanbul ignore if */ 26374 { 26375 createChildren(vnode, children, insertedVnodeQueue); 26376 if (isDef(data)) { 26377 invokeCreateHooks(vnode, insertedVnodeQueue); 26378 } 26379 insert(parentElm, vnode.elm, refElm); 26380 } 26381 26382 if ("development" !== 'production' && data && data.pre) { 26383 creatingElmInVPre--; 26384 } 26385 } else if (isTrue(vnode.isComment)) { 26386 vnode.elm = nodeOps.createComment(vnode.text); 26387 insert(parentElm, vnode.elm, refElm); 26388 } else { 26389 vnode.elm = nodeOps.createTextNode(vnode.text); 26390 insert(parentElm, vnode.elm, refElm); 26391 } 26392 } 26393 26394 function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) { 26395 var i = vnode.data; 26396 if (isDef(i)) { 26397 var isReactivated = isDef(vnode.componentInstance) && i.keepAlive; 26398 if (isDef(i = i.hook) && isDef(i = i.init)) { 26399 i(vnode, false /* hydrating */, parentElm, refElm); 26400 } 26401 // after calling the init hook, if the vnode is a child component 26402 // it should've created a child instance and mounted it. the child 26403 // component also has set the placeholder vnode's elm. 26404 // in that case we can just return the element and be done. 26405 if (isDef(vnode.componentInstance)) { 26406 initComponent(vnode, insertedVnodeQueue); 26407 if (isTrue(isReactivated)) { 26408 reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm); 26409 } 26410 return true 26411 } 26412 } 26413 } 26414 26415 function initComponent (vnode, insertedVnodeQueue) { 26416 if (isDef(vnode.data.pendingInsert)) { 26417 insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert); 26418 vnode.data.pendingInsert = null; 26419 } 26420 vnode.elm = vnode.componentInstance.$el; 26421 if (isPatchable(vnode)) { 26422 invokeCreateHooks(vnode, insertedVnodeQueue); 26423 setScope(vnode); 26424 } else { 26425 // empty component root. 26426 // skip all element-related modules except for ref (#3455) 26427 registerRef(vnode); 26428 // make sure to invoke the insert hook 26429 insertedVnodeQueue.push(vnode); 26430 } 26431 } 26432 26433 function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) { 26434 var i; 26435 // hack for #4339: a reactivated component with inner transition 26436 // does not trigger because the inner node's created hooks are not called 26437 // again. It's not ideal to involve module-specific logic in here but 26438 // there doesn't seem to be a better way to do it. 26439 var innerNode = vnode; 26440 while (innerNode.componentInstance) { 26441 innerNode = innerNode.componentInstance._vnode; 26442 if (isDef(i = innerNode.data) && isDef(i = i.transition)) { 26443 for (i = 0; i < cbs.activate.length; ++i) { 26444 cbs.activate[i](emptyNode, innerNode); 26445 } 26446 insertedVnodeQueue.push(innerNode); 26447 break 26448 } 26449 } 26450 // unlike a newly created component, 26451 // a reactivated keep-alive component doesn't insert itself 26452 insert(parentElm, vnode.elm, refElm); 26453 } 26454 26455 function insert (parent, elm, ref$$1) { 26456 if (isDef(parent)) { 26457 if (isDef(ref$$1)) { 26458 if (ref$$1.parentNode === parent) { 26459 nodeOps.insertBefore(parent, elm, ref$$1); 26460 } 26461 } else { 26462 nodeOps.appendChild(parent, elm); 26463 } 26464 } 26465 } 26466 26467 function createChildren (vnode, children, insertedVnodeQueue) { 26468 if (Array.isArray(children)) { 26469 if (true) { 26470 checkDuplicateKeys(children); 26471 } 26472 for (var i = 0; i < children.length; ++i) { 26473 createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i); 26474 } 26475 } else if (isPrimitive(vnode.text)) { 26476 nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text))); 26477 } 26478 } 26479 26480 function isPatchable (vnode) { 26481 while (vnode.componentInstance) { 26482 vnode = vnode.componentInstance._vnode; 26483 } 26484 return isDef(vnode.tag) 26485 } 26486 26487 function invokeCreateHooks (vnode, insertedVnodeQueue) { 26488 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) { 26489 cbs.create[i$1](emptyNode, vnode); 26490 } 26491 i = vnode.data.hook; // Reuse variable 26492 if (isDef(i)) { 26493 if (isDef(i.create)) { i.create(emptyNode, vnode); } 26494 if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); } 26495 } 26496 } 26497 26498 // set scope id attribute for scoped CSS. 26499 // this is implemented as a special case to avoid the overhead 26500 // of going through the normal attribute patching process. 26501 function setScope (vnode) { 26502 var i; 26503 if (isDef(i = vnode.fnScopeId)) { 26504 nodeOps.setStyleScope(vnode.elm, i); 26505 } else { 26506 var ancestor = vnode; 26507 while (ancestor) { 26508 if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) { 26509 nodeOps.setStyleScope(vnode.elm, i); 26510 } 26511 ancestor = ancestor.parent; 26512 } 26513 } 26514 // for slot content they should also get the scopeId from the host instance. 26515 if (isDef(i = activeInstance) && 26516 i !== vnode.context && 26517 i !== vnode.fnContext && 26518 isDef(i = i.$options._scopeId) 26519 ) { 26520 nodeOps.setStyleScope(vnode.elm, i); 26521 } 26522 } 26523 26524 function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) { 26525 for (; startIdx <= endIdx; ++startIdx) { 26526 createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx); 26527 } 26528 } 26529 26530 function invokeDestroyHook (vnode) { 26531 var i, j; 26532 var data = vnode.data; 26533 if (isDef(data)) { 26534 if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); } 26535 for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); } 26536 } 26537 if (isDef(i = vnode.children)) { 26538 for (j = 0; j < vnode.children.length; ++j) { 26539 invokeDestroyHook(vnode.children[j]); 26540 } 26541 } 26542 } 26543 26544 function removeVnodes (parentElm, vnodes, startIdx, endIdx) { 26545 for (; startIdx <= endIdx; ++startIdx) { 26546 var ch = vnodes[startIdx]; 26547 if (isDef(ch)) { 26548 if (isDef(ch.tag)) { 26549 removeAndInvokeRemoveHook(ch); 26550 invokeDestroyHook(ch); 26551 } else { // Text node 26552 removeNode(ch.elm); 26553 } 26554 } 26555 } 26556 } 26557 26558 function removeAndInvokeRemoveHook (vnode, rm) { 26559 if (isDef(rm) || isDef(vnode.data)) { 26560 var i; 26561 var listeners = cbs.remove.length + 1; 26562 if (isDef(rm)) { 26563 // we have a recursively passed down rm callback 26564 // increase the listeners count 26565 rm.listeners += listeners; 26566 } else { 26567 // directly removing 26568 rm = createRmCb(vnode.elm, listeners); 26569 } 26570 // recursively invoke hooks on child component root node 26571 if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) { 26572 removeAndInvokeRemoveHook(i, rm); 26573 } 26574 for (i = 0; i < cbs.remove.length; ++i) { 26575 cbs.remove[i](vnode, rm); 26576 } 26577 if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) { 26578 i(vnode, rm); 26579 } else { 26580 rm(); 26581 } 26582 } else { 26583 removeNode(vnode.elm); 26584 } 26585 } 26586 26587 function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { 26588 var oldStartIdx = 0; 26589 var newStartIdx = 0; 26590 var oldEndIdx = oldCh.length - 1; 26591 var oldStartVnode = oldCh[0]; 26592 var oldEndVnode = oldCh[oldEndIdx]; 26593 var newEndIdx = newCh.length - 1; 26594 var newStartVnode = newCh[0]; 26595 var newEndVnode = newCh[newEndIdx]; 26596 var oldKeyToIdx, idxInOld, vnodeToMove, refElm; 26597 26598 // removeOnly is a special flag used only by <transition-group> 26599 // to ensure removed elements stay in correct relative positions 26600 // during leaving transitions 26601 var canMove = !removeOnly; 26602 26603 if (true) { 26604 checkDuplicateKeys(newCh); 26605 } 26606 26607 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { 26608 if (isUndef(oldStartVnode)) { 26609 oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left 26610 } else if (isUndef(oldEndVnode)) { 26611 oldEndVnode = oldCh[--oldEndIdx]; 26612 } else if (sameVnode(oldStartVnode, newStartVnode)) { 26613 patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue); 26614 oldStartVnode = oldCh[++oldStartIdx]; 26615 newStartVnode = newCh[++newStartIdx]; 26616 } else if (sameVnode(oldEndVnode, newEndVnode)) { 26617 patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue); 26618 oldEndVnode = oldCh[--oldEndIdx]; 26619 newEndVnode = newCh[--newEndIdx]; 26620 } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right 26621 patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue); 26622 canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)); 26623 oldStartVnode = oldCh[++oldStartIdx]; 26624 newEndVnode = newCh[--newEndIdx]; 26625 } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left 26626 patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue); 26627 canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm); 26628 oldEndVnode = oldCh[--oldEndIdx]; 26629 newStartVnode = newCh[++newStartIdx]; 26630 } else { 26631 if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); } 26632 idxInOld = isDef(newStartVnode.key) 26633 ? oldKeyToIdx[newStartVnode.key] 26634 : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx); 26635 if (isUndef(idxInOld)) { // New element 26636 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); 26637 } else { 26638 vnodeToMove = oldCh[idxInOld]; 26639 if (sameVnode(vnodeToMove, newStartVnode)) { 26640 patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue); 26641 oldCh[idxInOld] = undefined; 26642 canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm); 26643 } else { 26644 // same key but different element. treat as new element 26645 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); 26646 } 26647 } 26648 newStartVnode = newCh[++newStartIdx]; 26649 } 26650 } 26651 if (oldStartIdx > oldEndIdx) { 26652 refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm; 26653 addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue); 26654 } else if (newStartIdx > newEndIdx) { 26655 removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx); 26656 } 26657 } 26658 26659 function checkDuplicateKeys (children) { 26660 var seenKeys = {}; 26661 for (var i = 0; i < children.length; i++) { 26662 var vnode = children[i]; 26663 var key = vnode.key; 26664 if (isDef(key)) { 26665 if (seenKeys[key]) { 26666 warn( 26667 ("Duplicate keys detected: '" + key + "'. This may cause an update error."), 26668 vnode.context 26669 ); 26670 } else { 26671 seenKeys[key] = true; 26672 } 26673 } 26674 } 26675 } 26676 26677 function findIdxInOld (node, oldCh, start, end) { 26678 for (var i = start; i < end; i++) { 26679 var c = oldCh[i]; 26680 if (isDef(c) && sameVnode(node, c)) { return i } 26681 } 26682 } 26683 26684 function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) { 26685 if (oldVnode === vnode) { 26686 return 26687 } 26688 26689 var elm = vnode.elm = oldVnode.elm; 26690 26691 if (isTrue(oldVnode.isAsyncPlaceholder)) { 26692 if (isDef(vnode.asyncFactory.resolved)) { 26693 hydrate(oldVnode.elm, vnode, insertedVnodeQueue); 26694 } else { 26695 vnode.isAsyncPlaceholder = true; 26696 } 26697 return 26698 } 26699 26700 // reuse element for static trees. 26701 // note we only do this if the vnode is cloned - 26702 // if the new node is not cloned it means the render functions have been 26703 // reset by the hot-reload-api and we need to do a proper re-render. 26704 if (isTrue(vnode.isStatic) && 26705 isTrue(oldVnode.isStatic) && 26706 vnode.key === oldVnode.key && 26707 (isTrue(vnode.isCloned) || isTrue(vnode.isOnce)) 26708 ) { 26709 vnode.componentInstance = oldVnode.componentInstance; 26710 return 26711 } 26712 26713 var i; 26714 var data = vnode.data; 26715 if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) { 26716 i(oldVnode, vnode); 26717 } 26718 26719 var oldCh = oldVnode.children; 26720 var ch = vnode.children; 26721 if (isDef(data) && isPatchable(vnode)) { 26722 for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); } 26723 if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); } 26724 } 26725 if (isUndef(vnode.text)) { 26726 if (isDef(oldCh) && isDef(ch)) { 26727 if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); } 26728 } else if (isDef(ch)) { 26729 if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); } 26730 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue); 26731 } else if (isDef(oldCh)) { 26732 removeVnodes(elm, oldCh, 0, oldCh.length - 1); 26733 } else if (isDef(oldVnode.text)) { 26734 nodeOps.setTextContent(elm, ''); 26735 } 26736 } else if (oldVnode.text !== vnode.text) { 26737 nodeOps.setTextContent(elm, vnode.text); 26738 } 26739 if (isDef(data)) { 26740 if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); } 26741 } 26742 } 26743 26744 function invokeInsertHook (vnode, queue, initial) { 26745 // delay insert hooks for component root nodes, invoke them after the 26746 // element is really inserted 26747 if (isTrue(initial) && isDef(vnode.parent)) { 26748 vnode.parent.data.pendingInsert = queue; 26749 } else { 26750 for (var i = 0; i < queue.length; ++i) { 26751 queue[i].data.hook.insert(queue[i]); 26752 } 26753 } 26754 } 26755 26756 var hydrationBailed = false; 26757 // list of modules that can skip create hook during hydration because they 26758 // are already rendered on the client or has no need for initialization 26759 // Note: style is excluded because it relies on initial clone for future 26760 // deep updates (#7063). 26761 var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key'); 26762 26763 // Note: this is a browser-only function so we can assume elms are DOM nodes. 26764 function hydrate (elm, vnode, insertedVnodeQueue, inVPre) { 26765 var i; 26766 var tag = vnode.tag; 26767 var data = vnode.data; 26768 var children = vnode.children; 26769 inVPre = inVPre || (data && data.pre); 26770 vnode.elm = elm; 26771 26772 if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) { 26773 vnode.isAsyncPlaceholder = true; 26774 return true 26775 } 26776 // assert node match 26777 if (true) { 26778 if (!assertNodeMatch(elm, vnode, inVPre)) { 26779 return false 26780 } 26781 } 26782 if (isDef(data)) { 26783 if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); } 26784 if (isDef(i = vnode.componentInstance)) { 26785 // child component. it should have hydrated its own tree. 26786 initComponent(vnode, insertedVnodeQueue); 26787 return true 26788 } 26789 } 26790 if (isDef(tag)) { 26791 if (isDef(children)) { 26792 // empty element, allow client to pick up and populate children 26793 if (!elm.hasChildNodes()) { 26794 createChildren(vnode, children, insertedVnodeQueue); 26795 } else { 26796 // v-html and domProps: innerHTML 26797 if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) { 26798 if (i !== elm.innerHTML) { 26799 /* istanbul ignore if */ 26800 if ("development" !== 'production' && 26801 typeof console !== 'undefined' && 26802 !hydrationBailed 26803 ) { 26804 hydrationBailed = true; 26805 console.warn('Parent: ', elm); 26806 console.warn('server innerHTML: ', i); 26807 console.warn('client innerHTML: ', elm.innerHTML); 26808 } 26809 return false 26810 } 26811 } else { 26812 // iterate and compare children lists 26813 var childrenMatch = true; 26814 var childNode = elm.firstChild; 26815 for (var i$1 = 0; i$1 < children.length; i$1++) { 26816 if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) { 26817 childrenMatch = false; 26818 break 26819 } 26820 childNode = childNode.nextSibling; 26821 } 26822 // if childNode is not null, it means the actual childNodes list is 26823 // longer than the virtual children list. 26824 if (!childrenMatch || childNode) { 26825 /* istanbul ignore if */ 26826 if ("development" !== 'production' && 26827 typeof console !== 'undefined' && 26828 !hydrationBailed 26829 ) { 26830 hydrationBailed = true; 26831 console.warn('Parent: ', elm); 26832 console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); 26833 } 26834 return false 26835 } 26836 } 26837 } 26838 } 26839 if (isDef(data)) { 26840 var fullInvoke = false; 26841 for (var key in data) { 26842 if (!isRenderedModule(key)) { 26843 fullInvoke = true; 26844 invokeCreateHooks(vnode, insertedVnodeQueue); 26845 break 26846 } 26847 } 26848 if (!fullInvoke && data['class']) { 26849 // ensure collecting deps for deep class bindings for future updates 26850 traverse(data['class']); 26851 } 26852 } 26853 } else if (elm.data !== vnode.text) { 26854 elm.data = vnode.text; 26855 } 26856 return true 26857 } 26858 26859 function assertNodeMatch (node, vnode, inVPre) { 26860 if (isDef(vnode.tag)) { 26861 return vnode.tag.indexOf('vue-component') === 0 || ( 26862 !isUnknownElement$$1(vnode, inVPre) && 26863 vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase()) 26864 ) 26865 } else { 26866 return node.nodeType === (vnode.isComment ? 8 : 3) 26867 } 26868 } 26869 26870 return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) { 26871 if (isUndef(vnode)) { 26872 if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); } 26873 return 26874 } 26875 26876 var isInitialPatch = false; 26877 var insertedVnodeQueue = []; 26878 26879 if (isUndef(oldVnode)) { 26880 // empty mount (likely as component), create new root element 26881 isInitialPatch = true; 26882 createElm(vnode, insertedVnodeQueue, parentElm, refElm); 26883 } else { 26884 var isRealElement = isDef(oldVnode.nodeType); 26885 if (!isRealElement && sameVnode(oldVnode, vnode)) { 26886 // patch existing root node 26887 patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly); 26888 } else { 26889 if (isRealElement) { 26890 // mounting to a real element 26891 // check if this is server-rendered content and if we can perform 26892 // a successful hydration. 26893 if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) { 26894 oldVnode.removeAttribute(SSR_ATTR); 26895 hydrating = true; 26896 } 26897 if (isTrue(hydrating)) { 26898 if (hydrate(oldVnode, vnode, insertedVnodeQueue)) { 26899 invokeInsertHook(vnode, insertedVnodeQueue, true); 26900 return oldVnode 26901 } else if (true) { 26902 warn( 26903 'The client-side rendered virtual DOM tree is not matching ' + 26904 'server-rendered content. This is likely caused by incorrect ' + 26905 'HTML markup, for example nesting block-level elements inside ' + 26906 '<p>, or missing <tbody>. Bailing hydration and performing ' + 26907 'full client-side render.' 26908 ); 26909 } 26910 } 26911 // either not server-rendered, or hydration failed. 26912 // create an empty node and replace it 26913 oldVnode = emptyNodeAt(oldVnode); 26914 } 26915 26916 // replacing existing element 26917 var oldElm = oldVnode.elm; 26918 var parentElm$1 = nodeOps.parentNode(oldElm); 26919 26920 // create new node 26921 createElm( 26922 vnode, 26923 insertedVnodeQueue, 26924 // extremely rare edge case: do not insert if old element is in a 26925 // leaving transition. Only happens when combining transition + 26926 // keep-alive + HOCs. (#4590) 26927 oldElm._leaveCb ? null : parentElm$1, 26928 nodeOps.nextSibling(oldElm) 26929 ); 26930 26931 // update parent placeholder node element, recursively 26932 if (isDef(vnode.parent)) { 26933 var ancestor = vnode.parent; 26934 var patchable = isPatchable(vnode); 26935 while (ancestor) { 26936 for (var i = 0; i < cbs.destroy.length; ++i) { 26937 cbs.destroy[i](ancestor); 26938 } 26939 ancestor.elm = vnode.elm; 26940 if (patchable) { 26941 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) { 26942 cbs.create[i$1](emptyNode, ancestor); 26943 } 26944 // #6513 26945 // invoke insert hooks that may have been merged by create hooks. 26946 // e.g. for directives that uses the "inserted" hook. 26947 var insert = ancestor.data.hook.insert; 26948 if (insert.merged) { 26949 // start at index 1 to avoid re-invoking component mounted hook 26950 for (var i$2 = 1; i$2 < insert.fns.length; i$2++) { 26951 insert.fns[i$2](); 26952 } 26953 } 26954 } else { 26955 registerRef(ancestor); 26956 } 26957 ancestor = ancestor.parent; 26958 } 26959 } 26960 26961 // destroy old node 26962 if (isDef(parentElm$1)) { 26963 removeVnodes(parentElm$1, [oldVnode], 0, 0); 26964 } else if (isDef(oldVnode.tag)) { 26965 invokeDestroyHook(oldVnode); 26966 } 26967 } 26968 } 26969 26970 invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch); 26971 return vnode.elm 26972 } 26973} 26974 26975/* */ 26976 26977var directives = { 26978 create: updateDirectives, 26979 update: updateDirectives, 26980 destroy: function unbindDirectives (vnode) { 26981 updateDirectives(vnode, emptyNode); 26982 } 26983} 26984 26985function updateDirectives (oldVnode, vnode) { 26986 if (oldVnode.data.directives || vnode.data.directives) { 26987 _update(oldVnode, vnode); 26988 } 26989} 26990 26991function _update (oldVnode, vnode) { 26992 var isCreate = oldVnode === emptyNode; 26993 var isDestroy = vnode === emptyNode; 26994 var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context); 26995 var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context); 26996 26997 var dirsWithInsert = []; 26998 var dirsWithPostpatch = []; 26999 27000 var key, oldDir, dir; 27001 for (key in newDirs) { 27002 oldDir = oldDirs[key]; 27003 dir = newDirs[key]; 27004 if (!oldDir) { 27005 // new directive, bind 27006 callHook$1(dir, 'bind', vnode, oldVnode); 27007 if (dir.def && dir.def.inserted) { 27008 dirsWithInsert.push(dir); 27009 } 27010 } else { 27011 // existing directive, update 27012 dir.oldValue = oldDir.value; 27013 callHook$1(dir, 'update', vnode, oldVnode); 27014 if (dir.def && dir.def.componentUpdated) { 27015 dirsWithPostpatch.push(dir); 27016 } 27017 } 27018 } 27019 27020 if (dirsWithInsert.length) { 27021 var callInsert = function () { 27022 for (var i = 0; i < dirsWithInsert.length; i++) { 27023 callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode); 27024 } 27025 }; 27026 if (isCreate) { 27027 mergeVNodeHook(vnode, 'insert', callInsert); 27028 } else { 27029 callInsert(); 27030 } 27031 } 27032 27033 if (dirsWithPostpatch.length) { 27034 mergeVNodeHook(vnode, 'postpatch', function () { 27035 for (var i = 0; i < dirsWithPostpatch.length; i++) { 27036 callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); 27037 } 27038 }); 27039 } 27040 27041 if (!isCreate) { 27042 for (key in oldDirs) { 27043 if (!newDirs[key]) { 27044 // no longer present, unbind 27045 callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy); 27046 } 27047 } 27048 } 27049} 27050 27051var emptyModifiers = Object.create(null); 27052 27053function normalizeDirectives$1 ( 27054 dirs, 27055 vm 27056) { 27057 var res = Object.create(null); 27058 if (!dirs) { 27059 // $flow-disable-line 27060 return res 27061 } 27062 var i, dir; 27063 for (i = 0; i < dirs.length; i++) { 27064 dir = dirs[i]; 27065 if (!dir.modifiers) { 27066 // $flow-disable-line 27067 dir.modifiers = emptyModifiers; 27068 } 27069 res[getRawDirName(dir)] = dir; 27070 dir.def = resolveAsset(vm.$options, 'directives', dir.name, true); 27071 } 27072 // $flow-disable-line 27073 return res 27074} 27075 27076function getRawDirName (dir) { 27077 return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.'))) 27078} 27079 27080function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) { 27081 var fn = dir.def && dir.def[hook]; 27082 if (fn) { 27083 try { 27084 fn(vnode.elm, dir, vnode, oldVnode, isDestroy); 27085 } catch (e) { 27086 handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook")); 27087 } 27088 } 27089} 27090 27091var baseModules = [ 27092 ref, 27093 directives 27094] 27095 27096/* */ 27097 27098function updateAttrs (oldVnode, vnode) { 27099 var opts = vnode.componentOptions; 27100 if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) { 27101 return 27102 } 27103 if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) { 27104 return 27105 } 27106 var key, cur, old; 27107 var elm = vnode.elm; 27108 var oldAttrs = oldVnode.data.attrs || {}; 27109 var attrs = vnode.data.attrs || {}; 27110 // clone observed objects, as the user probably wants to mutate it 27111 if (isDef(attrs.__ob__)) { 27112 attrs = vnode.data.attrs = extend({}, attrs); 27113 } 27114 27115 for (key in attrs) { 27116 cur = attrs[key]; 27117 old = oldAttrs[key]; 27118 if (old !== cur) { 27119 setAttr(elm, key, cur); 27120 } 27121 } 27122 // #4391: in IE9, setting type can reset value for input[type=radio] 27123 // #6666: IE/Edge forces progress value down to 1 before setting a max 27124 /* istanbul ignore if */ 27125 if ((isIE || isEdge) && attrs.value !== oldAttrs.value) { 27126 setAttr(elm, 'value', attrs.value); 27127 } 27128 for (key in oldAttrs) { 27129 if (isUndef(attrs[key])) { 27130 if (isXlink(key)) { 27131 elm.removeAttributeNS(xlinkNS, getXlinkProp(key)); 27132 } else if (!isEnumeratedAttr(key)) { 27133 elm.removeAttribute(key); 27134 } 27135 } 27136 } 27137} 27138 27139function setAttr (el, key, value) { 27140 if (el.tagName.indexOf('-') > -1) { 27141 baseSetAttr(el, key, value); 27142 } else if (isBooleanAttr(key)) { 27143 // set attribute for blank value 27144 // e.g. <option disabled>Select one</option> 27145 if (isFalsyAttrValue(value)) { 27146 el.removeAttribute(key); 27147 } else { 27148 // technically allowfullscreen is a boolean attribute for <iframe>, 27149 // but Flash expects a value of "true" when used on <embed> tag 27150 value = key === 'allowfullscreen' && el.tagName === 'EMBED' 27151 ? 'true' 27152 : key; 27153 el.setAttribute(key, value); 27154 } 27155 } else if (isEnumeratedAttr(key)) { 27156 el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'); 27157 } else if (isXlink(key)) { 27158 if (isFalsyAttrValue(value)) { 27159 el.removeAttributeNS(xlinkNS, getXlinkProp(key)); 27160 } else { 27161 el.setAttributeNS(xlinkNS, key, value); 27162 } 27163 } else { 27164 baseSetAttr(el, key, value); 27165 } 27166} 27167 27168function baseSetAttr (el, key, value) { 27169 if (isFalsyAttrValue(value)) { 27170 el.removeAttribute(key); 27171 } else { 27172 // #7138: IE10 & 11 fires input event when setting placeholder on 27173 // <textarea>... block the first input event and remove the blocker 27174 // immediately. 27175 /* istanbul ignore if */ 27176 if ( 27177 isIE && !isIE9 && 27178 el.tagName === 'TEXTAREA' && 27179 key === 'placeholder' && !el.__ieph 27180 ) { 27181 var blocker = function (e) { 27182 e.stopImmediatePropagation(); 27183 el.removeEventListener('input', blocker); 27184 }; 27185 el.addEventListener('input', blocker); 27186 // $flow-disable-line 27187 el.__ieph = true; /* IE placeholder patched */ 27188 } 27189 el.setAttribute(key, value); 27190 } 27191} 27192 27193var attrs = { 27194 create: updateAttrs, 27195 update: updateAttrs 27196} 27197 27198/* */ 27199 27200function updateClass (oldVnode, vnode) { 27201 var el = vnode.elm; 27202 var data = vnode.data; 27203 var oldData = oldVnode.data; 27204 if ( 27205 isUndef(data.staticClass) && 27206 isUndef(data.class) && ( 27207 isUndef(oldData) || ( 27208 isUndef(oldData.staticClass) && 27209 isUndef(oldData.class) 27210 ) 27211 ) 27212 ) { 27213 return 27214 } 27215 27216 var cls = genClassForVnode(vnode); 27217 27218 // handle transition classes 27219 var transitionClass = el._transitionClasses; 27220 if (isDef(transitionClass)) { 27221 cls = concat(cls, stringifyClass(transitionClass)); 27222 } 27223 27224 // set the class 27225 if (cls !== el._prevClass) { 27226 el.setAttribute('class', cls); 27227 el._prevClass = cls; 27228 } 27229} 27230 27231var klass = { 27232 create: updateClass, 27233 update: updateClass 27234} 27235 27236/* */ 27237 27238var validDivisionCharRE = /[\w).+\-_$\]]/; 27239 27240function parseFilters (exp) { 27241 var inSingle = false; 27242 var inDouble = false; 27243 var inTemplateString = false; 27244 var inRegex = false; 27245 var curly = 0; 27246 var square = 0; 27247 var paren = 0; 27248 var lastFilterIndex = 0; 27249 var c, prev, i, expression, filters; 27250 27251 for (i = 0; i < exp.length; i++) { 27252 prev = c; 27253 c = exp.charCodeAt(i); 27254 if (inSingle) { 27255 if (c === 0x27 && prev !== 0x5C) { inSingle = false; } 27256 } else if (inDouble) { 27257 if (c === 0x22 && prev !== 0x5C) { inDouble = false; } 27258 } else if (inTemplateString) { 27259 if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; } 27260 } else if (inRegex) { 27261 if (c === 0x2f && prev !== 0x5C) { inRegex = false; } 27262 } else if ( 27263 c === 0x7C && // pipe 27264 exp.charCodeAt(i + 1) !== 0x7C && 27265 exp.charCodeAt(i - 1) !== 0x7C && 27266 !curly && !square && !paren 27267 ) { 27268 if (expression === undefined) { 27269 // first filter, end of expression 27270 lastFilterIndex = i + 1; 27271 expression = exp.slice(0, i).trim(); 27272 } else { 27273 pushFilter(); 27274 } 27275 } else { 27276 switch (c) { 27277 case 0x22: inDouble = true; break // " 27278 case 0x27: inSingle = true; break // ' 27279 case 0x60: inTemplateString = true; break // ` 27280 case 0x28: paren++; break // ( 27281 case 0x29: paren--; break // ) 27282 case 0x5B: square++; break // [ 27283 case 0x5D: square--; break // ] 27284 case 0x7B: curly++; break // { 27285 case 0x7D: curly--; break // } 27286 } 27287 if (c === 0x2f) { // / 27288 var j = i - 1; 27289 var p = (void 0); 27290 // find first non-whitespace prev char 27291 for (; j >= 0; j--) { 27292 p = exp.charAt(j); 27293 if (p !== ' ') { break } 27294 } 27295 if (!p || !validDivisionCharRE.test(p)) { 27296 inRegex = true; 27297 } 27298 } 27299 } 27300 } 27301 27302 if (expression === undefined) { 27303 expression = exp.slice(0, i).trim(); 27304 } else if (lastFilterIndex !== 0) { 27305 pushFilter(); 27306 } 27307 27308 function pushFilter () { 27309 (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim()); 27310 lastFilterIndex = i + 1; 27311 } 27312 27313 if (filters) { 27314 for (i = 0; i < filters.length; i++) { 27315 expression = wrapFilter(expression, filters[i]); 27316 } 27317 } 27318 27319 return expression 27320} 27321 27322function wrapFilter (exp, filter) { 27323 var i = filter.indexOf('('); 27324 if (i < 0) { 27325 // _f: resolveFilter 27326 return ("_f(\"" + filter + "\")(" + exp + ")") 27327 } else { 27328 var name = filter.slice(0, i); 27329 var args = filter.slice(i + 1); 27330 return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args)) 27331 } 27332} 27333 27334/* */ 27335 27336function baseWarn (msg) { 27337 console.error(("[Vue compiler]: " + msg)); 27338} 27339 27340function pluckModuleFunction ( 27341 modules, 27342 key 27343) { 27344 return modules 27345 ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; }) 27346 : [] 27347} 27348 27349function addProp (el, name, value) { 27350 (el.props || (el.props = [])).push({ name: name, value: value }); 27351 el.plain = false; 27352} 27353 27354function addAttr (el, name, value) { 27355 (el.attrs || (el.attrs = [])).push({ name: name, value: value }); 27356 el.plain = false; 27357} 27358 27359// add a raw attr (use this in preTransforms) 27360function addRawAttr (el, name, value) { 27361 el.attrsMap[name] = value; 27362 el.attrsList.push({ name: name, value: value }); 27363} 27364 27365function addDirective ( 27366 el, 27367 name, 27368 rawName, 27369 value, 27370 arg, 27371 modifiers 27372) { 27373 (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers }); 27374 el.plain = false; 27375} 27376 27377function addHandler ( 27378 el, 27379 name, 27380 value, 27381 modifiers, 27382 important, 27383 warn 27384) { 27385 modifiers = modifiers || emptyObject; 27386 // warn prevent and passive modifier 27387 /* istanbul ignore if */ 27388 if ( 27389 "development" !== 'production' && warn && 27390 modifiers.prevent && modifiers.passive 27391 ) { 27392 warn( 27393 'passive and prevent can\'t be used together. ' + 27394 'Passive handler can\'t prevent default event.' 27395 ); 27396 } 27397 27398 // check capture modifier 27399 if (modifiers.capture) { 27400 delete modifiers.capture; 27401 name = '!' + name; // mark the event as captured 27402 } 27403 if (modifiers.once) { 27404 delete modifiers.once; 27405 name = '~' + name; // mark the event as once 27406 } 27407 /* istanbul ignore if */ 27408 if (modifiers.passive) { 27409 delete modifiers.passive; 27410 name = '&' + name; // mark the event as passive 27411 } 27412 27413 // normalize click.right and click.middle since they don't actually fire 27414 // this is technically browser-specific, but at least for now browsers are 27415 // the only target envs that have right/middle clicks. 27416 if (name === 'click') { 27417 if (modifiers.right) { 27418 name = 'contextmenu'; 27419 delete modifiers.right; 27420 } else if (modifiers.middle) { 27421 name = 'mouseup'; 27422 } 27423 } 27424 27425 var events; 27426 if (modifiers.native) { 27427 delete modifiers.native; 27428 events = el.nativeEvents || (el.nativeEvents = {}); 27429 } else { 27430 events = el.events || (el.events = {}); 27431 } 27432 27433 var newHandler = { 27434 value: value.trim() 27435 }; 27436 if (modifiers !== emptyObject) { 27437 newHandler.modifiers = modifiers; 27438 } 27439 27440 var handlers = events[name]; 27441 /* istanbul ignore if */ 27442 if (Array.isArray(handlers)) { 27443 important ? handlers.unshift(newHandler) : handlers.push(newHandler); 27444 } else if (handlers) { 27445 events[name] = important ? [newHandler, handlers] : [handlers, newHandler]; 27446 } else { 27447 events[name] = newHandler; 27448 } 27449 27450 el.plain = false; 27451} 27452 27453function getBindingAttr ( 27454 el, 27455 name, 27456 getStatic 27457) { 27458 var dynamicValue = 27459 getAndRemoveAttr(el, ':' + name) || 27460 getAndRemoveAttr(el, 'v-bind:' + name); 27461 if (dynamicValue != null) { 27462 return parseFilters(dynamicValue) 27463 } else if (getStatic !== false) { 27464 var staticValue = getAndRemoveAttr(el, name); 27465 if (staticValue != null) { 27466 return JSON.stringify(staticValue) 27467 } 27468 } 27469} 27470 27471// note: this only removes the attr from the Array (attrsList) so that it 27472// doesn't get processed by processAttrs. 27473// By default it does NOT remove it from the map (attrsMap) because the map is 27474// needed during codegen. 27475function getAndRemoveAttr ( 27476 el, 27477 name, 27478 removeFromMap 27479) { 27480 var val; 27481 if ((val = el.attrsMap[name]) != null) { 27482 var list = el.attrsList; 27483 for (var i = 0, l = list.length; i < l; i++) { 27484 if (list[i].name === name) { 27485 list.splice(i, 1); 27486 break 27487 } 27488 } 27489 } 27490 if (removeFromMap) { 27491 delete el.attrsMap[name]; 27492 } 27493 return val 27494} 27495 27496/* */ 27497 27498/** 27499 * Cross-platform code generation for component v-model 27500 */ 27501function genComponentModel ( 27502 el, 27503 value, 27504 modifiers 27505) { 27506 var ref = modifiers || {}; 27507 var number = ref.number; 27508 var trim = ref.trim; 27509 27510 var baseValueExpression = '$$v'; 27511 var valueExpression = baseValueExpression; 27512 if (trim) { 27513 valueExpression = 27514 "(typeof " + baseValueExpression + " === 'string'" + 27515 "? " + baseValueExpression + ".trim()" + 27516 ": " + baseValueExpression + ")"; 27517 } 27518 if (number) { 27519 valueExpression = "_n(" + valueExpression + ")"; 27520 } 27521 var assignment = genAssignmentCode(value, valueExpression); 27522 27523 el.model = { 27524 value: ("(" + value + ")"), 27525 expression: ("\"" + value + "\""), 27526 callback: ("function (" + baseValueExpression + ") {" + assignment + "}") 27527 }; 27528} 27529 27530/** 27531 * Cross-platform codegen helper for generating v-model value assignment code. 27532 */ 27533function genAssignmentCode ( 27534 value, 27535 assignment 27536) { 27537 var res = parseModel(value); 27538 if (res.key === null) { 27539 return (value + "=" + assignment) 27540 } else { 27541 return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")") 27542 } 27543} 27544 27545/** 27546 * Parse a v-model expression into a base path and a final key segment. 27547 * Handles both dot-path and possible square brackets. 27548 * 27549 * Possible cases: 27550 * 27551 * - test 27552 * - test[key] 27553 * - test[test1[key]] 27554 * - test["a"][key] 27555 * - xxx.test[a[a].test1[key]] 27556 * - test.xxx.a["asa"][test1[key]] 27557 * 27558 */ 27559 27560var len; 27561var str; 27562var chr; 27563var index$1; 27564var expressionPos; 27565var expressionEndPos; 27566 27567 27568 27569function parseModel (val) { 27570 // Fix https://github.com/vuejs/vue/pull/7730 27571 // allow v-model="obj.val " (trailing whitespace) 27572 val = val.trim(); 27573 len = val.length; 27574 27575 if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) { 27576 index$1 = val.lastIndexOf('.'); 27577 if (index$1 > -1) { 27578 return { 27579 exp: val.slice(0, index$1), 27580 key: '"' + val.slice(index$1 + 1) + '"' 27581 } 27582 } else { 27583 return { 27584 exp: val, 27585 key: null 27586 } 27587 } 27588 } 27589 27590 str = val; 27591 index$1 = expressionPos = expressionEndPos = 0; 27592 27593 while (!eof()) { 27594 chr = next(); 27595 /* istanbul ignore if */ 27596 if (isStringStart(chr)) { 27597 parseString(chr); 27598 } else if (chr === 0x5B) { 27599 parseBracket(chr); 27600 } 27601 } 27602 27603 return { 27604 exp: val.slice(0, expressionPos), 27605 key: val.slice(expressionPos + 1, expressionEndPos) 27606 } 27607} 27608 27609function next () { 27610 return str.charCodeAt(++index$1) 27611} 27612 27613function eof () { 27614 return index$1 >= len 27615} 27616 27617function isStringStart (chr) { 27618 return chr === 0x22 || chr === 0x27 27619} 27620 27621function parseBracket (chr) { 27622 var inBracket = 1; 27623 expressionPos = index$1; 27624 while (!eof()) { 27625 chr = next(); 27626 if (isStringStart(chr)) { 27627 parseString(chr); 27628 continue 27629 } 27630 if (chr === 0x5B) { inBracket++; } 27631 if (chr === 0x5D) { inBracket--; } 27632 if (inBracket === 0) { 27633 expressionEndPos = index$1; 27634 break 27635 } 27636 } 27637} 27638 27639function parseString (chr) { 27640 var stringQuote = chr; 27641 while (!eof()) { 27642 chr = next(); 27643 if (chr === stringQuote) { 27644 break 27645 } 27646 } 27647} 27648 27649/* */ 27650 27651var warn$1; 27652 27653// in some cases, the event used has to be determined at runtime 27654// so we used some reserved tokens during compile. 27655var RANGE_TOKEN = '__r'; 27656var CHECKBOX_RADIO_TOKEN = '__c'; 27657 27658function model ( 27659 el, 27660 dir, 27661 _warn 27662) { 27663 warn$1 = _warn; 27664 var value = dir.value; 27665 var modifiers = dir.modifiers; 27666 var tag = el.tag; 27667 var type = el.attrsMap.type; 27668 27669 if (true) { 27670 // inputs with type="file" are read only and setting the input's 27671 // value will throw an error. 27672 if (tag === 'input' && type === 'file') { 27673 warn$1( 27674 "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" + 27675 "File inputs are read only. Use a v-on:change listener instead." 27676 ); 27677 } 27678 } 27679 27680 if (el.component) { 27681 genComponentModel(el, value, modifiers); 27682 // component v-model doesn't need extra runtime 27683 return false 27684 } else if (tag === 'select') { 27685 genSelect(el, value, modifiers); 27686 } else if (tag === 'input' && type === 'checkbox') { 27687 genCheckboxModel(el, value, modifiers); 27688 } else if (tag === 'input' && type === 'radio') { 27689 genRadioModel(el, value, modifiers); 27690 } else if (tag === 'input' || tag === 'textarea') { 27691 genDefaultModel(el, value, modifiers); 27692 } else if (!config.isReservedTag(tag)) { 27693 genComponentModel(el, value, modifiers); 27694 // component v-model doesn't need extra runtime 27695 return false 27696 } else if (true) { 27697 warn$1( 27698 "<" + (el.tag) + " v-model=\"" + value + "\">: " + 27699 "v-model is not supported on this element type. " + 27700 'If you are working with contenteditable, it\'s recommended to ' + 27701 'wrap a library dedicated for that purpose inside a custom component.' 27702 ); 27703 } 27704 27705 // ensure runtime directive metadata 27706 return true 27707} 27708 27709function genCheckboxModel ( 27710 el, 27711 value, 27712 modifiers 27713) { 27714 var number = modifiers && modifiers.number; 27715 var valueBinding = getBindingAttr(el, 'value') || 'null'; 27716 var trueValueBinding = getBindingAttr(el, 'true-value') || 'true'; 27717 var falseValueBinding = getBindingAttr(el, 'false-value') || 'false'; 27718 addProp(el, 'checked', 27719 "Array.isArray(" + value + ")" + 27720 "?_i(" + value + "," + valueBinding + ")>-1" + ( 27721 trueValueBinding === 'true' 27722 ? (":(" + value + ")") 27723 : (":_q(" + value + "," + trueValueBinding + ")") 27724 ) 27725 ); 27726 addHandler(el, 'change', 27727 "var $$a=" + value + "," + 27728 '$$el=$event.target,' + 27729 "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" + 27730 'if(Array.isArray($$a)){' + 27731 "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," + 27732 '$$i=_i($$a,$$v);' + 27733 "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" + 27734 "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" + 27735 "}else{" + (genAssignmentCode(value, '$$c')) + "}", 27736 null, true 27737 ); 27738} 27739 27740function genRadioModel ( 27741 el, 27742 value, 27743 modifiers 27744) { 27745 var number = modifiers && modifiers.number; 27746 var valueBinding = getBindingAttr(el, 'value') || 'null'; 27747 valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding; 27748 addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")")); 27749 addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true); 27750} 27751 27752function genSelect ( 27753 el, 27754 value, 27755 modifiers 27756) { 27757 var number = modifiers && modifiers.number; 27758 var selectedVal = "Array.prototype.filter" + 27759 ".call($event.target.options,function(o){return o.selected})" + 27760 ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" + 27761 "return " + (number ? '_n(val)' : 'val') + "})"; 27762 27763 var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'; 27764 var code = "var $$selectedVal = " + selectedVal + ";"; 27765 code = code + " " + (genAssignmentCode(value, assignment)); 27766 addHandler(el, 'change', code, null, true); 27767} 27768 27769function genDefaultModel ( 27770 el, 27771 value, 27772 modifiers 27773) { 27774 var type = el.attrsMap.type; 27775 27776 // warn if v-bind:value conflicts with v-model 27777 // except for inputs with v-bind:type 27778 if (true) { 27779 var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value']; 27780 var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type']; 27781 if (value$1 && !typeBinding) { 27782 var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'; 27783 warn$1( 27784 binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " + 27785 'because the latter already expands to a value binding internally' 27786 ); 27787 } 27788 } 27789 27790 var ref = modifiers || {}; 27791 var lazy = ref.lazy; 27792 var number = ref.number; 27793 var trim = ref.trim; 27794 var needCompositionGuard = !lazy && type !== 'range'; 27795 var event = lazy 27796 ? 'change' 27797 : type === 'range' 27798 ? RANGE_TOKEN 27799 : 'input'; 27800 27801 var valueExpression = '$event.target.value'; 27802 if (trim) { 27803 valueExpression = "$event.target.value.trim()"; 27804 } 27805 if (number) { 27806 valueExpression = "_n(" + valueExpression + ")"; 27807 } 27808 27809 var code = genAssignmentCode(value, valueExpression); 27810 if (needCompositionGuard) { 27811 code = "if($event.target.composing)return;" + code; 27812 } 27813 27814 addProp(el, 'value', ("(" + value + ")")); 27815 addHandler(el, event, code, null, true); 27816 if (trim || number) { 27817 addHandler(el, 'blur', '$forceUpdate()'); 27818 } 27819} 27820 27821/* */ 27822 27823// normalize v-model event tokens that can only be determined at runtime. 27824// it's important to place the event as the first in the array because 27825// the whole point is ensuring the v-model callback gets called before 27826// user-attached handlers. 27827function normalizeEvents (on) { 27828 /* istanbul ignore if */ 27829 if (isDef(on[RANGE_TOKEN])) { 27830 // IE input[type=range] only supports `change` event 27831 var event = isIE ? 'change' : 'input'; 27832 on[event] = [].concat(on[RANGE_TOKEN], on[event] || []); 27833 delete on[RANGE_TOKEN]; 27834 } 27835 // This was originally intended to fix #4521 but no longer necessary 27836 // after 2.5. Keeping it for backwards compat with generated code from < 2.4 27837 /* istanbul ignore if */ 27838 if (isDef(on[CHECKBOX_RADIO_TOKEN])) { 27839 on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []); 27840 delete on[CHECKBOX_RADIO_TOKEN]; 27841 } 27842} 27843 27844var target$1; 27845 27846function createOnceHandler (handler, event, capture) { 27847 var _target = target$1; // save current target element in closure 27848 return function onceHandler () { 27849 var res = handler.apply(null, arguments); 27850 if (res !== null) { 27851 remove$2(event, onceHandler, capture, _target); 27852 } 27853 } 27854} 27855 27856function add$1 ( 27857 event, 27858 handler, 27859 once$$1, 27860 capture, 27861 passive 27862) { 27863 handler = withMacroTask(handler); 27864 if (once$$1) { handler = createOnceHandler(handler, event, capture); } 27865 target$1.addEventListener( 27866 event, 27867 handler, 27868 supportsPassive 27869 ? { capture: capture, passive: passive } 27870 : capture 27871 ); 27872} 27873 27874function remove$2 ( 27875 event, 27876 handler, 27877 capture, 27878 _target 27879) { 27880 (_target || target$1).removeEventListener( 27881 event, 27882 handler._withTask || handler, 27883 capture 27884 ); 27885} 27886 27887function updateDOMListeners (oldVnode, vnode) { 27888 if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) { 27889 return 27890 } 27891 var on = vnode.data.on || {}; 27892 var oldOn = oldVnode.data.on || {}; 27893 target$1 = vnode.elm; 27894 normalizeEvents(on); 27895 updateListeners(on, oldOn, add$1, remove$2, vnode.context); 27896 target$1 = undefined; 27897} 27898 27899var events = { 27900 create: updateDOMListeners, 27901 update: updateDOMListeners 27902} 27903 27904/* */ 27905 27906function updateDOMProps (oldVnode, vnode) { 27907 if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) { 27908 return 27909 } 27910 var key, cur; 27911 var elm = vnode.elm; 27912 var oldProps = oldVnode.data.domProps || {}; 27913 var props = vnode.data.domProps || {}; 27914 // clone observed objects, as the user probably wants to mutate it 27915 if (isDef(props.__ob__)) { 27916 props = vnode.data.domProps = extend({}, props); 27917 } 27918 27919 for (key in oldProps) { 27920 if (isUndef(props[key])) { 27921 elm[key] = ''; 27922 } 27923 } 27924 for (key in props) { 27925 cur = props[key]; 27926 // ignore children if the node has textContent or innerHTML, 27927 // as these will throw away existing DOM nodes and cause removal errors 27928 // on subsequent patches (#3360) 27929 if (key === 'textContent' || key === 'innerHTML') { 27930 if (vnode.children) { vnode.children.length = 0; } 27931 if (cur === oldProps[key]) { continue } 27932 // #6601 work around Chrome version <= 55 bug where single textNode 27933 // replaced by innerHTML/textContent retains its parentNode property 27934 if (elm.childNodes.length === 1) { 27935 elm.removeChild(elm.childNodes[0]); 27936 } 27937 } 27938 27939 if (key === 'value') { 27940 // store value as _value as well since 27941 // non-string values will be stringified 27942 elm._value = cur; 27943 // avoid resetting cursor position when value is the same 27944 var strCur = isUndef(cur) ? '' : String(cur); 27945 if (shouldUpdateValue(elm, strCur)) { 27946 elm.value = strCur; 27947 } 27948 } else { 27949 elm[key] = cur; 27950 } 27951 } 27952} 27953 27954// check platforms/web/util/attrs.js acceptValue 27955 27956 27957function shouldUpdateValue (elm, checkVal) { 27958 return (!elm.composing && ( 27959 elm.tagName === 'OPTION' || 27960 isNotInFocusAndDirty(elm, checkVal) || 27961 isDirtyWithModifiers(elm, checkVal) 27962 )) 27963} 27964 27965function isNotInFocusAndDirty (elm, checkVal) { 27966 // return true when textbox (.number and .trim) loses focus and its value is 27967 // not equal to the updated value 27968 var notInFocus = true; 27969 // #6157 27970 // work around IE bug when accessing document.activeElement in an iframe 27971 try { notInFocus = document.activeElement !== elm; } catch (e) {} 27972 return notInFocus && elm.value !== checkVal 27973} 27974 27975function isDirtyWithModifiers (elm, newVal) { 27976 var value = elm.value; 27977 var modifiers = elm._vModifiers; // injected by v-model runtime 27978 if (isDef(modifiers)) { 27979 if (modifiers.lazy) { 27980 // inputs with lazy should only be updated when not in focus 27981 return false 27982 } 27983 if (modifiers.number) { 27984 return toNumber(value) !== toNumber(newVal) 27985 } 27986 if (modifiers.trim) { 27987 return value.trim() !== newVal.trim() 27988 } 27989 } 27990 return value !== newVal 27991} 27992 27993var domProps = { 27994 create: updateDOMProps, 27995 update: updateDOMProps 27996} 27997 27998/* */ 27999 28000var parseStyleText = cached(function (cssText) { 28001 var res = {}; 28002 var listDelimiter = /;(?![^(]*\))/g; 28003 var propertyDelimiter = /:(.+)/; 28004 cssText.split(listDelimiter).forEach(function (item) { 28005 if (item) { 28006 var tmp = item.split(propertyDelimiter); 28007 tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim()); 28008 } 28009 }); 28010 return res 28011}); 28012 28013// merge static and dynamic style data on the same vnode 28014function normalizeStyleData (data) { 28015 var style = normalizeStyleBinding(data.style); 28016 // static style is pre-processed into an object during compilation 28017 // and is always a fresh object, so it's safe to merge into it 28018 return data.staticStyle 28019 ? extend(data.staticStyle, style) 28020 : style 28021} 28022 28023// normalize possible array / string values into Object 28024function normalizeStyleBinding (bindingStyle) { 28025 if (Array.isArray(bindingStyle)) { 28026 return toObject(bindingStyle) 28027 } 28028 if (typeof bindingStyle === 'string') { 28029 return parseStyleText(bindingStyle) 28030 } 28031 return bindingStyle 28032} 28033 28034/** 28035 * parent component style should be after child's 28036 * so that parent component's style could override it 28037 */ 28038function getStyle (vnode, checkChild) { 28039 var res = {}; 28040 var styleData; 28041 28042 if (checkChild) { 28043 var childNode = vnode; 28044 while (childNode.componentInstance) { 28045 childNode = childNode.componentInstance._vnode; 28046 if ( 28047 childNode && childNode.data && 28048 (styleData = normalizeStyleData(childNode.data)) 28049 ) { 28050 extend(res, styleData); 28051 } 28052 } 28053 } 28054 28055 if ((styleData = normalizeStyleData(vnode.data))) { 28056 extend(res, styleData); 28057 } 28058 28059 var parentNode = vnode; 28060 while ((parentNode = parentNode.parent)) { 28061 if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) { 28062 extend(res, styleData); 28063 } 28064 } 28065 return res 28066} 28067 28068/* */ 28069 28070var cssVarRE = /^--/; 28071var importantRE = /\s*!important$/; 28072var setProp = function (el, name, val) { 28073 /* istanbul ignore if */ 28074 if (cssVarRE.test(name)) { 28075 el.style.setProperty(name, val); 28076 } else if (importantRE.test(val)) { 28077 el.style.setProperty(name, val.replace(importantRE, ''), 'important'); 28078 } else { 28079 var normalizedName = normalize(name); 28080 if (Array.isArray(val)) { 28081 // Support values array created by autoprefixer, e.g. 28082 // {display: ["-webkit-box", "-ms-flexbox", "flex"]} 28083 // Set them one by one, and the browser will only set those it can recognize 28084 for (var i = 0, len = val.length; i < len; i++) { 28085 el.style[normalizedName] = val[i]; 28086 } 28087 } else { 28088 el.style[normalizedName] = val; 28089 } 28090 } 28091}; 28092 28093var vendorNames = ['Webkit', 'Moz', 'ms']; 28094 28095var emptyStyle; 28096var normalize = cached(function (prop) { 28097 emptyStyle = emptyStyle || document.createElement('div').style; 28098 prop = camelize(prop); 28099 if (prop !== 'filter' && (prop in emptyStyle)) { 28100 return prop 28101 } 28102 var capName = prop.charAt(0).toUpperCase() + prop.slice(1); 28103 for (var i = 0; i < vendorNames.length; i++) { 28104 var name = vendorNames[i] + capName; 28105 if (name in emptyStyle) { 28106 return name 28107 } 28108 } 28109}); 28110 28111function updateStyle (oldVnode, vnode) { 28112 var data = vnode.data; 28113 var oldData = oldVnode.data; 28114 28115 if (isUndef(data.staticStyle) && isUndef(data.style) && 28116 isUndef(oldData.staticStyle) && isUndef(oldData.style) 28117 ) { 28118 return 28119 } 28120 28121 var cur, name; 28122 var el = vnode.elm; 28123 var oldStaticStyle = oldData.staticStyle; 28124 var oldStyleBinding = oldData.normalizedStyle || oldData.style || {}; 28125 28126 // if static style exists, stylebinding already merged into it when doing normalizeStyleData 28127 var oldStyle = oldStaticStyle || oldStyleBinding; 28128 28129 var style = normalizeStyleBinding(vnode.data.style) || {}; 28130 28131 // store normalized style under a different key for next diff 28132 // make sure to clone it if it's reactive, since the user likely wants 28133 // to mutate it. 28134 vnode.data.normalizedStyle = isDef(style.__ob__) 28135 ? extend({}, style) 28136 : style; 28137 28138 var newStyle = getStyle(vnode, true); 28139 28140 for (name in oldStyle) { 28141 if (isUndef(newStyle[name])) { 28142 setProp(el, name, ''); 28143 } 28144 } 28145 for (name in newStyle) { 28146 cur = newStyle[name]; 28147 if (cur !== oldStyle[name]) { 28148 // ie9 setting to null has no effect, must use empty string 28149 setProp(el, name, cur == null ? '' : cur); 28150 } 28151 } 28152} 28153 28154var style = { 28155 create: updateStyle, 28156 update: updateStyle 28157} 28158 28159/* */ 28160 28161/** 28162 * Add class with compatibility for SVG since classList is not supported on 28163 * SVG elements in IE 28164 */ 28165function addClass (el, cls) { 28166 /* istanbul ignore if */ 28167 if (!cls || !(cls = cls.trim())) { 28168 return 28169 } 28170 28171 /* istanbul ignore else */ 28172 if (el.classList) { 28173 if (cls.indexOf(' ') > -1) { 28174 cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); }); 28175 } else { 28176 el.classList.add(cls); 28177 } 28178 } else { 28179 var cur = " " + (el.getAttribute('class') || '') + " "; 28180 if (cur.indexOf(' ' + cls + ' ') < 0) { 28181 el.setAttribute('class', (cur + cls).trim()); 28182 } 28183 } 28184} 28185 28186/** 28187 * Remove class with compatibility for SVG since classList is not supported on 28188 * SVG elements in IE 28189 */ 28190function removeClass (el, cls) { 28191 /* istanbul ignore if */ 28192 if (!cls || !(cls = cls.trim())) { 28193 return 28194 } 28195 28196 /* istanbul ignore else */ 28197 if (el.classList) { 28198 if (cls.indexOf(' ') > -1) { 28199 cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); }); 28200 } else { 28201 el.classList.remove(cls); 28202 } 28203 if (!el.classList.length) { 28204 el.removeAttribute('class'); 28205 } 28206 } else { 28207 var cur = " " + (el.getAttribute('class') || '') + " "; 28208 var tar = ' ' + cls + ' '; 28209 while (cur.indexOf(tar) >= 0) { 28210 cur = cur.replace(tar, ' '); 28211 } 28212 cur = cur.trim(); 28213 if (cur) { 28214 el.setAttribute('class', cur); 28215 } else { 28216 el.removeAttribute('class'); 28217 } 28218 } 28219} 28220 28221/* */ 28222 28223function resolveTransition (def) { 28224 if (!def) { 28225 return 28226 } 28227 /* istanbul ignore else */ 28228 if (typeof def === 'object') { 28229 var res = {}; 28230 if (def.css !== false) { 28231 extend(res, autoCssTransition(def.name || 'v')); 28232 } 28233 extend(res, def); 28234 return res 28235 } else if (typeof def === 'string') { 28236 return autoCssTransition(def) 28237 } 28238} 28239 28240var autoCssTransition = cached(function (name) { 28241 return { 28242 enterClass: (name + "-enter"), 28243 enterToClass: (name + "-enter-to"), 28244 enterActiveClass: (name + "-enter-active"), 28245 leaveClass: (name + "-leave"), 28246 leaveToClass: (name + "-leave-to"), 28247 leaveActiveClass: (name + "-leave-active") 28248 } 28249}); 28250 28251var hasTransition = inBrowser && !isIE9; 28252var TRANSITION = 'transition'; 28253var ANIMATION = 'animation'; 28254 28255// Transition property/event sniffing 28256var transitionProp = 'transition'; 28257var transitionEndEvent = 'transitionend'; 28258var animationProp = 'animation'; 28259var animationEndEvent = 'animationend'; 28260if (hasTransition) { 28261 /* istanbul ignore if */ 28262 if (window.ontransitionend === undefined && 28263 window.onwebkittransitionend !== undefined 28264 ) { 28265 transitionProp = 'WebkitTransition'; 28266 transitionEndEvent = 'webkitTransitionEnd'; 28267 } 28268 if (window.onanimationend === undefined && 28269 window.onwebkitanimationend !== undefined 28270 ) { 28271 animationProp = 'WebkitAnimation'; 28272 animationEndEvent = 'webkitAnimationEnd'; 28273 } 28274} 28275 28276// binding to window is necessary to make hot reload work in IE in strict mode 28277var raf = inBrowser 28278 ? window.requestAnimationFrame 28279 ? window.requestAnimationFrame.bind(window) 28280 : setTimeout 28281 : /* istanbul ignore next */ function (fn) { return fn(); }; 28282 28283function nextFrame (fn) { 28284 raf(function () { 28285 raf(fn); 28286 }); 28287} 28288 28289function addTransitionClass (el, cls) { 28290 var transitionClasses = el._transitionClasses || (el._transitionClasses = []); 28291 if (transitionClasses.indexOf(cls) < 0) { 28292 transitionClasses.push(cls); 28293 addClass(el, cls); 28294 } 28295} 28296 28297function removeTransitionClass (el, cls) { 28298 if (el._transitionClasses) { 28299 remove(el._transitionClasses, cls); 28300 } 28301 removeClass(el, cls); 28302} 28303 28304function whenTransitionEnds ( 28305 el, 28306 expectedType, 28307 cb 28308) { 28309 var ref = getTransitionInfo(el, expectedType); 28310 var type = ref.type; 28311 var timeout = ref.timeout; 28312 var propCount = ref.propCount; 28313 if (!type) { return cb() } 28314 var event = type === TRANSITION ? transitionEndEvent : animationEndEvent; 28315 var ended = 0; 28316 var end = function () { 28317 el.removeEventListener(event, onEnd); 28318 cb(); 28319 }; 28320 var onEnd = function (e) { 28321 if (e.target === el) { 28322 if (++ended >= propCount) { 28323 end(); 28324 } 28325 } 28326 }; 28327 setTimeout(function () { 28328 if (ended < propCount) { 28329 end(); 28330 } 28331 }, timeout + 1); 28332 el.addEventListener(event, onEnd); 28333} 28334 28335var transformRE = /\b(transform|all)(,|$)/; 28336 28337function getTransitionInfo (el, expectedType) { 28338 var styles = window.getComputedStyle(el); 28339 var transitionDelays = styles[transitionProp + 'Delay'].split(', '); 28340 var transitionDurations = styles[transitionProp + 'Duration'].split(', '); 28341 var transitionTimeout = getTimeout(transitionDelays, transitionDurations); 28342 var animationDelays = styles[animationProp + 'Delay'].split(', '); 28343 var animationDurations = styles[animationProp + 'Duration'].split(', '); 28344 var animationTimeout = getTimeout(animationDelays, animationDurations); 28345 28346 var type; 28347 var timeout = 0; 28348 var propCount = 0; 28349 /* istanbul ignore if */ 28350 if (expectedType === TRANSITION) { 28351 if (transitionTimeout > 0) { 28352 type = TRANSITION; 28353 timeout = transitionTimeout; 28354 propCount = transitionDurations.length; 28355 } 28356 } else if (expectedType === ANIMATION) { 28357 if (animationTimeout > 0) { 28358 type = ANIMATION; 28359 timeout = animationTimeout; 28360 propCount = animationDurations.length; 28361 } 28362 } else { 28363 timeout = Math.max(transitionTimeout, animationTimeout); 28364 type = timeout > 0 28365 ? transitionTimeout > animationTimeout 28366 ? TRANSITION 28367 : ANIMATION 28368 : null; 28369 propCount = type 28370 ? type === TRANSITION 28371 ? transitionDurations.length 28372 : animationDurations.length 28373 : 0; 28374 } 28375 var hasTransform = 28376 type === TRANSITION && 28377 transformRE.test(styles[transitionProp + 'Property']); 28378 return { 28379 type: type, 28380 timeout: timeout, 28381 propCount: propCount, 28382 hasTransform: hasTransform 28383 } 28384} 28385 28386function getTimeout (delays, durations) { 28387 /* istanbul ignore next */ 28388 while (delays.length < durations.length) { 28389 delays = delays.concat(delays); 28390 } 28391 28392 return Math.max.apply(null, durations.map(function (d, i) { 28393 return toMs(d) + toMs(delays[i]) 28394 })) 28395} 28396 28397function toMs (s) { 28398 return Number(s.slice(0, -1)) * 1000 28399} 28400 28401/* */ 28402 28403function enter (vnode, toggleDisplay) { 28404 var el = vnode.elm; 28405 28406 // call leave callback now 28407 if (isDef(el._leaveCb)) { 28408 el._leaveCb.cancelled = true; 28409 el._leaveCb(); 28410 } 28411 28412 var data = resolveTransition(vnode.data.transition); 28413 if (isUndef(data)) { 28414 return 28415 } 28416 28417 /* istanbul ignore if */ 28418 if (isDef(el._enterCb) || el.nodeType !== 1) { 28419 return 28420 } 28421 28422 var css = data.css; 28423 var type = data.type; 28424 var enterClass = data.enterClass; 28425 var enterToClass = data.enterToClass; 28426 var enterActiveClass = data.enterActiveClass; 28427 var appearClass = data.appearClass; 28428 var appearToClass = data.appearToClass; 28429 var appearActiveClass = data.appearActiveClass; 28430 var beforeEnter = data.beforeEnter; 28431 var enter = data.enter; 28432 var afterEnter = data.afterEnter; 28433 var enterCancelled = data.enterCancelled; 28434 var beforeAppear = data.beforeAppear; 28435 var appear = data.appear; 28436 var afterAppear = data.afterAppear; 28437 var appearCancelled = data.appearCancelled; 28438 var duration = data.duration; 28439 28440 // activeInstance will always be the <transition> component managing this 28441 // transition. One edge case to check is when the <transition> is placed 28442 // as the root node of a child component. In that case we need to check 28443 // <transition>'s parent for appear check. 28444 var context = activeInstance; 28445 var transitionNode = activeInstance.$vnode; 28446 while (transitionNode && transitionNode.parent) { 28447 transitionNode = transitionNode.parent; 28448 context = transitionNode.context; 28449 } 28450 28451 var isAppear = !context._isMounted || !vnode.isRootInsert; 28452 28453 if (isAppear && !appear && appear !== '') { 28454 return 28455 } 28456 28457 var startClass = isAppear && appearClass 28458 ? appearClass 28459 : enterClass; 28460 var activeClass = isAppear && appearActiveClass 28461 ? appearActiveClass 28462 : enterActiveClass; 28463 var toClass = isAppear && appearToClass 28464 ? appearToClass 28465 : enterToClass; 28466 28467 var beforeEnterHook = isAppear 28468 ? (beforeAppear || beforeEnter) 28469 : beforeEnter; 28470 var enterHook = isAppear 28471 ? (typeof appear === 'function' ? appear : enter) 28472 : enter; 28473 var afterEnterHook = isAppear 28474 ? (afterAppear || afterEnter) 28475 : afterEnter; 28476 var enterCancelledHook = isAppear 28477 ? (appearCancelled || enterCancelled) 28478 : enterCancelled; 28479 28480 var explicitEnterDuration = toNumber( 28481 isObject(duration) 28482 ? duration.enter 28483 : duration 28484 ); 28485 28486 if ("development" !== 'production' && explicitEnterDuration != null) { 28487 checkDuration(explicitEnterDuration, 'enter', vnode); 28488 } 28489 28490 var expectsCSS = css !== false && !isIE9; 28491 var userWantsControl = getHookArgumentsLength(enterHook); 28492 28493 var cb = el._enterCb = once(function () { 28494 if (expectsCSS) { 28495 removeTransitionClass(el, toClass); 28496 removeTransitionClass(el, activeClass); 28497 } 28498 if (cb.cancelled) { 28499 if (expectsCSS) { 28500 removeTransitionClass(el, startClass); 28501 } 28502 enterCancelledHook && enterCancelledHook(el); 28503 } else { 28504 afterEnterHook && afterEnterHook(el); 28505 } 28506 el._enterCb = null; 28507 }); 28508 28509 if (!vnode.data.show) { 28510 // remove pending leave element on enter by injecting an insert hook 28511 mergeVNodeHook(vnode, 'insert', function () { 28512 var parent = el.parentNode; 28513 var pendingNode = parent && parent._pending && parent._pending[vnode.key]; 28514 if (pendingNode && 28515 pendingNode.tag === vnode.tag && 28516 pendingNode.elm._leaveCb 28517 ) { 28518 pendingNode.elm._leaveCb(); 28519 } 28520 enterHook && enterHook(el, cb); 28521 }); 28522 } 28523 28524 // start enter transition 28525 beforeEnterHook && beforeEnterHook(el); 28526 if (expectsCSS) { 28527 addTransitionClass(el, startClass); 28528 addTransitionClass(el, activeClass); 28529 nextFrame(function () { 28530 removeTransitionClass(el, startClass); 28531 if (!cb.cancelled) { 28532 addTransitionClass(el, toClass); 28533 if (!userWantsControl) { 28534 if (isValidDuration(explicitEnterDuration)) { 28535 setTimeout(cb, explicitEnterDuration); 28536 } else { 28537 whenTransitionEnds(el, type, cb); 28538 } 28539 } 28540 } 28541 }); 28542 } 28543 28544 if (vnode.data.show) { 28545 toggleDisplay && toggleDisplay(); 28546 enterHook && enterHook(el, cb); 28547 } 28548 28549 if (!expectsCSS && !userWantsControl) { 28550 cb(); 28551 } 28552} 28553 28554function leave (vnode, rm) { 28555 var el = vnode.elm; 28556 28557 // call enter callback now 28558 if (isDef(el._enterCb)) { 28559 el._enterCb.cancelled = true; 28560 el._enterCb(); 28561 } 28562 28563 var data = resolveTransition(vnode.data.transition); 28564 if (isUndef(data) || el.nodeType !== 1) { 28565 return rm() 28566 } 28567 28568 /* istanbul ignore if */ 28569 if (isDef(el._leaveCb)) { 28570 return 28571 } 28572 28573 var css = data.css; 28574 var type = data.type; 28575 var leaveClass = data.leaveClass; 28576 var leaveToClass = data.leaveToClass; 28577 var leaveActiveClass = data.leaveActiveClass; 28578 var beforeLeave = data.beforeLeave; 28579 var leave = data.leave; 28580 var afterLeave = data.afterLeave; 28581 var leaveCancelled = data.leaveCancelled; 28582 var delayLeave = data.delayLeave; 28583 var duration = data.duration; 28584 28585 var expectsCSS = css !== false && !isIE9; 28586 var userWantsControl = getHookArgumentsLength(leave); 28587 28588 var explicitLeaveDuration = toNumber( 28589 isObject(duration) 28590 ? duration.leave 28591 : duration 28592 ); 28593 28594 if ("development" !== 'production' && isDef(explicitLeaveDuration)) { 28595 checkDuration(explicitLeaveDuration, 'leave', vnode); 28596 } 28597 28598 var cb = el._leaveCb = once(function () { 28599 if (el.parentNode && el.parentNode._pending) { 28600 el.parentNode._pending[vnode.key] = null; 28601 } 28602 if (expectsCSS) { 28603 removeTransitionClass(el, leaveToClass); 28604 removeTransitionClass(el, leaveActiveClass); 28605 } 28606 if (cb.cancelled) { 28607 if (expectsCSS) { 28608 removeTransitionClass(el, leaveClass); 28609 } 28610 leaveCancelled && leaveCancelled(el); 28611 } else { 28612 rm(); 28613 afterLeave && afterLeave(el); 28614 } 28615 el._leaveCb = null; 28616 }); 28617 28618 if (delayLeave) { 28619 delayLeave(performLeave); 28620 } else { 28621 performLeave(); 28622 } 28623 28624 function performLeave () { 28625 // the delayed leave may have already been cancelled 28626 if (cb.cancelled) { 28627 return 28628 } 28629 // record leaving element 28630 if (!vnode.data.show) { 28631 (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode; 28632 } 28633 beforeLeave && beforeLeave(el); 28634 if (expectsCSS) { 28635 addTransitionClass(el, leaveClass); 28636 addTransitionClass(el, leaveActiveClass); 28637 nextFrame(function () { 28638 removeTransitionClass(el, leaveClass); 28639 if (!cb.cancelled) { 28640 addTransitionClass(el, leaveToClass); 28641 if (!userWantsControl) { 28642 if (isValidDuration(explicitLeaveDuration)) { 28643 setTimeout(cb, explicitLeaveDuration); 28644 } else { 28645 whenTransitionEnds(el, type, cb); 28646 } 28647 } 28648 } 28649 }); 28650 } 28651 leave && leave(el, cb); 28652 if (!expectsCSS && !userWantsControl) { 28653 cb(); 28654 } 28655 } 28656} 28657 28658// only used in dev mode 28659function checkDuration (val, name, vnode) { 28660 if (typeof val !== 'number') { 28661 warn( 28662 "<transition> explicit " + name + " duration is not a valid number - " + 28663 "got " + (JSON.stringify(val)) + ".", 28664 vnode.context 28665 ); 28666 } else if (isNaN(val)) { 28667 warn( 28668 "<transition> explicit " + name + " duration is NaN - " + 28669 'the duration expression might be incorrect.', 28670 vnode.context 28671 ); 28672 } 28673} 28674 28675function isValidDuration (val) { 28676 return typeof val === 'number' && !isNaN(val) 28677} 28678 28679/** 28680 * Normalize a transition hook's argument length. The hook may be: 28681 * - a merged hook (invoker) with the original in .fns 28682 * - a wrapped component method (check ._length) 28683 * - a plain function (.length) 28684 */ 28685function getHookArgumentsLength (fn) { 28686 if (isUndef(fn)) { 28687 return false 28688 } 28689 var invokerFns = fn.fns; 28690 if (isDef(invokerFns)) { 28691 // invoker 28692 return getHookArgumentsLength( 28693 Array.isArray(invokerFns) 28694 ? invokerFns[0] 28695 : invokerFns 28696 ) 28697 } else { 28698 return (fn._length || fn.length) > 1 28699 } 28700} 28701 28702function _enter (_, vnode) { 28703 if (vnode.data.show !== true) { 28704 enter(vnode); 28705 } 28706} 28707 28708var transition = inBrowser ? { 28709 create: _enter, 28710 activate: _enter, 28711 remove: function remove$$1 (vnode, rm) { 28712 /* istanbul ignore else */ 28713 if (vnode.data.show !== true) { 28714 leave(vnode, rm); 28715 } else { 28716 rm(); 28717 } 28718 } 28719} : {} 28720 28721var platformModules = [ 28722 attrs, 28723 klass, 28724 events, 28725 domProps, 28726 style, 28727 transition 28728] 28729 28730/* */ 28731 28732// the directive module should be applied last, after all 28733// built-in modules have been applied. 28734var modules = platformModules.concat(baseModules); 28735 28736var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules }); 28737 28738/** 28739 * Not type checking this file because flow doesn't like attaching 28740 * properties to Elements. 28741 */ 28742 28743/* istanbul ignore if */ 28744if (isIE9) { 28745 // http://www.matts411.com/post/internet-explorer-9-oninput/ 28746 document.addEventListener('selectionchange', function () { 28747 var el = document.activeElement; 28748 if (el && el.vmodel) { 28749 trigger(el, 'input'); 28750 } 28751 }); 28752} 28753 28754var directive = { 28755 inserted: function inserted (el, binding, vnode, oldVnode) { 28756 if (vnode.tag === 'select') { 28757 // #6903 28758 if (oldVnode.elm && !oldVnode.elm._vOptions) { 28759 mergeVNodeHook(vnode, 'postpatch', function () { 28760 directive.componentUpdated(el, binding, vnode); 28761 }); 28762 } else { 28763 setSelected(el, binding, vnode.context); 28764 } 28765 el._vOptions = [].map.call(el.options, getValue); 28766 } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) { 28767 el._vModifiers = binding.modifiers; 28768 if (!binding.modifiers.lazy) { 28769 el.addEventListener('compositionstart', onCompositionStart); 28770 el.addEventListener('compositionend', onCompositionEnd); 28771 // Safari < 10.2 & UIWebView doesn't fire compositionend when 28772 // switching focus before confirming composition choice 28773 // this also fixes the issue where some browsers e.g. iOS Chrome 28774 // fires "change" instead of "input" on autocomplete. 28775 el.addEventListener('change', onCompositionEnd); 28776 /* istanbul ignore if */ 28777 if (isIE9) { 28778 el.vmodel = true; 28779 } 28780 } 28781 } 28782 }, 28783 28784 componentUpdated: function componentUpdated (el, binding, vnode) { 28785 if (vnode.tag === 'select') { 28786 setSelected(el, binding, vnode.context); 28787 // in case the options rendered by v-for have changed, 28788 // it's possible that the value is out-of-sync with the rendered options. 28789 // detect such cases and filter out values that no longer has a matching 28790 // option in the DOM. 28791 var prevOptions = el._vOptions; 28792 var curOptions = el._vOptions = [].map.call(el.options, getValue); 28793 if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) { 28794 // trigger change event if 28795 // no matching option found for at least one value 28796 var needReset = el.multiple 28797 ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); }) 28798 : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions); 28799 if (needReset) { 28800 trigger(el, 'change'); 28801 } 28802 } 28803 } 28804 } 28805}; 28806 28807function setSelected (el, binding, vm) { 28808 actuallySetSelected(el, binding, vm); 28809 /* istanbul ignore if */ 28810 if (isIE || isEdge) { 28811 setTimeout(function () { 28812 actuallySetSelected(el, binding, vm); 28813 }, 0); 28814 } 28815} 28816 28817function actuallySetSelected (el, binding, vm) { 28818 var value = binding.value; 28819 var isMultiple = el.multiple; 28820 if (isMultiple && !Array.isArray(value)) { 28821 "development" !== 'production' && warn( 28822 "<select multiple v-model=\"" + (binding.expression) + "\"> " + 28823 "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)), 28824 vm 28825 ); 28826 return 28827 } 28828 var selected, option; 28829 for (var i = 0, l = el.options.length; i < l; i++) { 28830 option = el.options[i]; 28831 if (isMultiple) { 28832 selected = looseIndexOf(value, getValue(option)) > -1; 28833 if (option.selected !== selected) { 28834 option.selected = selected; 28835 } 28836 } else { 28837 if (looseEqual(getValue(option), value)) { 28838 if (el.selectedIndex !== i) { 28839 el.selectedIndex = i; 28840 } 28841 return 28842 } 28843 } 28844 } 28845 if (!isMultiple) { 28846 el.selectedIndex = -1; 28847 } 28848} 28849 28850function hasNoMatchingOption (value, options) { 28851 return options.every(function (o) { return !looseEqual(o, value); }) 28852} 28853 28854function getValue (option) { 28855 return '_value' in option 28856 ? option._value 28857 : option.value 28858} 28859 28860function onCompositionStart (e) { 28861 e.target.composing = true; 28862} 28863 28864function onCompositionEnd (e) { 28865 // prevent triggering an input event for no reason 28866 if (!e.target.composing) { return } 28867 e.target.composing = false; 28868 trigger(e.target, 'input'); 28869} 28870 28871function trigger (el, type) { 28872 var e = document.createEvent('HTMLEvents'); 28873 e.initEvent(type, true, true); 28874 el.dispatchEvent(e); 28875} 28876 28877/* */ 28878 28879// recursively search for possible transition defined inside the component root 28880function locateNode (vnode) { 28881 return vnode.componentInstance && (!vnode.data || !vnode.data.transition) 28882 ? locateNode(vnode.componentInstance._vnode) 28883 : vnode 28884} 28885 28886var show = { 28887 bind: function bind (el, ref, vnode) { 28888 var value = ref.value; 28889 28890 vnode = locateNode(vnode); 28891 var transition$$1 = vnode.data && vnode.data.transition; 28892 var originalDisplay = el.__vOriginalDisplay = 28893 el.style.display === 'none' ? '' : el.style.display; 28894 if (value && transition$$1) { 28895 vnode.data.show = true; 28896 enter(vnode, function () { 28897 el.style.display = originalDisplay; 28898 }); 28899 } else { 28900 el.style.display = value ? originalDisplay : 'none'; 28901 } 28902 }, 28903 28904 update: function update (el, ref, vnode) { 28905 var value = ref.value; 28906 var oldValue = ref.oldValue; 28907 28908 /* istanbul ignore if */ 28909 if (!value === !oldValue) { return } 28910 vnode = locateNode(vnode); 28911 var transition$$1 = vnode.data && vnode.data.transition; 28912 if (transition$$1) { 28913 vnode.data.show = true; 28914 if (value) { 28915 enter(vnode, function () { 28916 el.style.display = el.__vOriginalDisplay; 28917 }); 28918 } else { 28919 leave(vnode, function () { 28920 el.style.display = 'none'; 28921 }); 28922 } 28923 } else { 28924 el.style.display = value ? el.__vOriginalDisplay : 'none'; 28925 } 28926 }, 28927 28928 unbind: function unbind ( 28929 el, 28930 binding, 28931 vnode, 28932 oldVnode, 28933 isDestroy 28934 ) { 28935 if (!isDestroy) { 28936 el.style.display = el.__vOriginalDisplay; 28937 } 28938 } 28939} 28940 28941var platformDirectives = { 28942 model: directive, 28943 show: show 28944} 28945 28946/* */ 28947 28948// Provides transition support for a single element/component. 28949// supports transition mode (out-in / in-out) 28950 28951var transitionProps = { 28952 name: String, 28953 appear: Boolean, 28954 css: Boolean, 28955 mode: String, 28956 type: String, 28957 enterClass: String, 28958 leaveClass: String, 28959 enterToClass: String, 28960 leaveToClass: String, 28961 enterActiveClass: String, 28962 leaveActiveClass: String, 28963 appearClass: String, 28964 appearActiveClass: String, 28965 appearToClass: String, 28966 duration: [Number, String, Object] 28967}; 28968 28969// in case the child is also an abstract component, e.g. <keep-alive> 28970// we want to recursively retrieve the real component to be rendered 28971function getRealChild (vnode) { 28972 var compOptions = vnode && vnode.componentOptions; 28973 if (compOptions && compOptions.Ctor.options.abstract) { 28974 return getRealChild(getFirstComponentChild(compOptions.children)) 28975 } else { 28976 return vnode 28977 } 28978} 28979 28980function extractTransitionData (comp) { 28981 var data = {}; 28982 var options = comp.$options; 28983 // props 28984 for (var key in options.propsData) { 28985 data[key] = comp[key]; 28986 } 28987 // events. 28988 // extract listeners and pass them directly to the transition methods 28989 var listeners = options._parentListeners; 28990 for (var key$1 in listeners) { 28991 data[camelize(key$1)] = listeners[key$1]; 28992 } 28993 return data 28994} 28995 28996function placeholder (h, rawChild) { 28997 if (/\d-keep-alive$/.test(rawChild.tag)) { 28998 return h('keep-alive', { 28999 props: rawChild.componentOptions.propsData 29000 }) 29001 } 29002} 29003 29004function hasParentTransition (vnode) { 29005 while ((vnode = vnode.parent)) { 29006 if (vnode.data.transition) { 29007 return true 29008 } 29009 } 29010} 29011 29012function isSameChild (child, oldChild) { 29013 return oldChild.key === child.key && oldChild.tag === child.tag 29014} 29015 29016var Transition = { 29017 name: 'transition', 29018 props: transitionProps, 29019 abstract: true, 29020 29021 render: function render (h) { 29022 var this$1 = this; 29023 29024 var children = this.$slots.default; 29025 if (!children) { 29026 return 29027 } 29028 29029 // filter out text nodes (possible whitespaces) 29030 children = children.filter(function (c) { return c.tag || isAsyncPlaceholder(c); }); 29031 /* istanbul ignore if */ 29032 if (!children.length) { 29033 return 29034 } 29035 29036 // warn multiple elements 29037 if ("development" !== 'production' && children.length > 1) { 29038 warn( 29039 '<transition> can only be used on a single element. Use ' + 29040 '<transition-group> for lists.', 29041 this.$parent 29042 ); 29043 } 29044 29045 var mode = this.mode; 29046 29047 // warn invalid mode 29048 if ("development" !== 'production' && 29049 mode && mode !== 'in-out' && mode !== 'out-in' 29050 ) { 29051 warn( 29052 'invalid <transition> mode: ' + mode, 29053 this.$parent 29054 ); 29055 } 29056 29057 var rawChild = children[0]; 29058 29059 // if this is a component root node and the component's 29060 // parent container node also has transition, skip. 29061 if (hasParentTransition(this.$vnode)) { 29062 return rawChild 29063 } 29064 29065 // apply transition data to child 29066 // use getRealChild() to ignore abstract components e.g. keep-alive 29067 var child = getRealChild(rawChild); 29068 /* istanbul ignore if */ 29069 if (!child) { 29070 return rawChild 29071 } 29072 29073 if (this._leaving) { 29074 return placeholder(h, rawChild) 29075 } 29076 29077 // ensure a key that is unique to the vnode type and to this transition 29078 // component instance. This key will be used to remove pending leaving nodes 29079 // during entering. 29080 var id = "__transition-" + (this._uid) + "-"; 29081 child.key = child.key == null 29082 ? child.isComment 29083 ? id + 'comment' 29084 : id + child.tag 29085 : isPrimitive(child.key) 29086 ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key) 29087 : child.key; 29088 29089 var data = (child.data || (child.data = {})).transition = extractTransitionData(this); 29090 var oldRawChild = this._vnode; 29091 var oldChild = getRealChild(oldRawChild); 29092 29093 // mark v-show 29094 // so that the transition module can hand over the control to the directive 29095 if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) { 29096 child.data.show = true; 29097 } 29098 29099 if ( 29100 oldChild && 29101 oldChild.data && 29102 !isSameChild(child, oldChild) && 29103 !isAsyncPlaceholder(oldChild) && 29104 // #6687 component root is a comment node 29105 !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment) 29106 ) { 29107 // replace old child transition data with fresh one 29108 // important for dynamic transitions! 29109 var oldData = oldChild.data.transition = extend({}, data); 29110 // handle transition mode 29111 if (mode === 'out-in') { 29112 // return placeholder node and queue update when leave finishes 29113 this._leaving = true; 29114 mergeVNodeHook(oldData, 'afterLeave', function () { 29115 this$1._leaving = false; 29116 this$1.$forceUpdate(); 29117 }); 29118 return placeholder(h, rawChild) 29119 } else if (mode === 'in-out') { 29120 if (isAsyncPlaceholder(child)) { 29121 return oldRawChild 29122 } 29123 var delayedLeave; 29124 var performLeave = function () { delayedLeave(); }; 29125 mergeVNodeHook(data, 'afterEnter', performLeave); 29126 mergeVNodeHook(data, 'enterCancelled', performLeave); 29127 mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; }); 29128 } 29129 } 29130 29131 return rawChild 29132 } 29133} 29134 29135/* */ 29136 29137// Provides transition support for list items. 29138// supports move transitions using the FLIP technique. 29139 29140// Because the vdom's children update algorithm is "unstable" - i.e. 29141// it doesn't guarantee the relative positioning of removed elements, 29142// we force transition-group to update its children into two passes: 29143// in the first pass, we remove all nodes that need to be removed, 29144// triggering their leaving transition; in the second pass, we insert/move 29145// into the final desired state. This way in the second pass removed 29146// nodes will remain where they should be. 29147 29148var props = extend({ 29149 tag: String, 29150 moveClass: String 29151}, transitionProps); 29152 29153delete props.mode; 29154 29155var TransitionGroup = { 29156 props: props, 29157 29158 render: function render (h) { 29159 var tag = this.tag || this.$vnode.data.tag || 'span'; 29160 var map = Object.create(null); 29161 var prevChildren = this.prevChildren = this.children; 29162 var rawChildren = this.$slots.default || []; 29163 var children = this.children = []; 29164 var transitionData = extractTransitionData(this); 29165 29166 for (var i = 0; i < rawChildren.length; i++) { 29167 var c = rawChildren[i]; 29168 if (c.tag) { 29169 if (c.key != null && String(c.key).indexOf('__vlist') !== 0) { 29170 children.push(c); 29171 map[c.key] = c 29172 ;(c.data || (c.data = {})).transition = transitionData; 29173 } else if (true) { 29174 var opts = c.componentOptions; 29175 var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag; 29176 warn(("<transition-group> children must be keyed: <" + name + ">")); 29177 } 29178 } 29179 } 29180 29181 if (prevChildren) { 29182 var kept = []; 29183 var removed = []; 29184 for (var i$1 = 0; i$1 < prevChildren.length; i$1++) { 29185 var c$1 = prevChildren[i$1]; 29186 c$1.data.transition = transitionData; 29187 c$1.data.pos = c$1.elm.getBoundingClientRect(); 29188 if (map[c$1.key]) { 29189 kept.push(c$1); 29190 } else { 29191 removed.push(c$1); 29192 } 29193 } 29194 this.kept = h(tag, null, kept); 29195 this.removed = removed; 29196 } 29197 29198 return h(tag, null, children) 29199 }, 29200 29201 beforeUpdate: function beforeUpdate () { 29202 // force removing pass 29203 this.__patch__( 29204 this._vnode, 29205 this.kept, 29206 false, // hydrating 29207 true // removeOnly (!important, avoids unnecessary moves) 29208 ); 29209 this._vnode = this.kept; 29210 }, 29211 29212 updated: function updated () { 29213 var children = this.prevChildren; 29214 var moveClass = this.moveClass || ((this.name || 'v') + '-move'); 29215 if (!children.length || !this.hasMove(children[0].elm, moveClass)) { 29216 return 29217 } 29218 29219 // we divide the work into three loops to avoid mixing DOM reads and writes 29220 // in each iteration - which helps prevent layout thrashing. 29221 children.forEach(callPendingCbs); 29222 children.forEach(recordPosition); 29223 children.forEach(applyTranslation); 29224 29225 // force reflow to put everything in position 29226 // assign to this to avoid being removed in tree-shaking 29227 // $flow-disable-line 29228 this._reflow = document.body.offsetHeight; 29229 29230 children.forEach(function (c) { 29231 if (c.data.moved) { 29232 var el = c.elm; 29233 var s = el.style; 29234 addTransitionClass(el, moveClass); 29235 s.transform = s.WebkitTransform = s.transitionDuration = ''; 29236 el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) { 29237 if (!e || /transform$/.test(e.propertyName)) { 29238 el.removeEventListener(transitionEndEvent, cb); 29239 el._moveCb = null; 29240 removeTransitionClass(el, moveClass); 29241 } 29242 }); 29243 } 29244 }); 29245 }, 29246 29247 methods: { 29248 hasMove: function hasMove (el, moveClass) { 29249 /* istanbul ignore if */ 29250 if (!hasTransition) { 29251 return false 29252 } 29253 /* istanbul ignore if */ 29254 if (this._hasMove) { 29255 return this._hasMove 29256 } 29257 // Detect whether an element with the move class applied has 29258 // CSS transitions. Since the element may be inside an entering 29259 // transition at this very moment, we make a clone of it and remove 29260 // all other transition classes applied to ensure only the move class 29261 // is applied. 29262 var clone = el.cloneNode(); 29263 if (el._transitionClasses) { 29264 el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); }); 29265 } 29266 addClass(clone, moveClass); 29267 clone.style.display = 'none'; 29268 this.$el.appendChild(clone); 29269 var info = getTransitionInfo(clone); 29270 this.$el.removeChild(clone); 29271 return (this._hasMove = info.hasTransform) 29272 } 29273 } 29274} 29275 29276function callPendingCbs (c) { 29277 /* istanbul ignore if */ 29278 if (c.elm._moveCb) { 29279 c.elm._moveCb(); 29280 } 29281 /* istanbul ignore if */ 29282 if (c.elm._enterCb) { 29283 c.elm._enterCb(); 29284 } 29285} 29286 29287function recordPosition (c) { 29288 c.data.newPos = c.elm.getBoundingClientRect(); 29289} 29290 29291function applyTranslation (c) { 29292 var oldPos = c.data.pos; 29293 var newPos = c.data.newPos; 29294 var dx = oldPos.left - newPos.left; 29295 var dy = oldPos.top - newPos.top; 29296 if (dx || dy) { 29297 c.data.moved = true; 29298 var s = c.elm.style; 29299 s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)"; 29300 s.transitionDuration = '0s'; 29301 } 29302} 29303 29304var platformComponents = { 29305 Transition: Transition, 29306 TransitionGroup: TransitionGroup 29307} 29308 29309/* */ 29310 29311// install platform specific utils 29312Vue.config.mustUseProp = mustUseProp; 29313Vue.config.isReservedTag = isReservedTag; 29314Vue.config.isReservedAttr = isReservedAttr; 29315Vue.config.getTagNamespace = getTagNamespace; 29316Vue.config.isUnknownElement = isUnknownElement; 29317 29318// install platform runtime directives & components 29319extend(Vue.options.directives, platformDirectives); 29320extend(Vue.options.components, platformComponents); 29321 29322// install platform patch function 29323Vue.prototype.__patch__ = inBrowser ? patch : noop; 29324 29325// public mount method 29326Vue.prototype.$mount = function ( 29327 el, 29328 hydrating 29329) { 29330 el = el && inBrowser ? query(el) : undefined; 29331 return mountComponent(this, el, hydrating) 29332}; 29333 29334// devtools global hook 29335/* istanbul ignore next */ 29336if (inBrowser) { 29337 setTimeout(function () { 29338 if (config.devtools) { 29339 if (devtools) { 29340 devtools.emit('init', Vue); 29341 } else if ( 29342 "development" !== 'production' && 29343 "development" !== 'test' && 29344 isChrome 29345 ) { 29346 console[console.info ? 'info' : 'log']( 29347 'Download the Vue Devtools extension for a better development experience:\n' + 29348 'https://github.com/vuejs/vue-devtools' 29349 ); 29350 } 29351 } 29352 if ("development" !== 'production' && 29353 "development" !== 'test' && 29354 config.productionTip !== false && 29355 typeof console !== 'undefined' 29356 ) { 29357 console[console.info ? 'info' : 'log']( 29358 "You are running Vue in development mode.\n" + 29359 "Make sure to turn on production mode when deploying for production.\n" + 29360 "See more tips at https://vuejs.org/guide/deployment.html" 29361 ); 29362 } 29363 }, 0); 29364} 29365 29366/* */ 29367 29368var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g; 29369var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; 29370 29371var buildRegex = cached(function (delimiters) { 29372 var open = delimiters[0].replace(regexEscapeRE, '\\$&'); 29373 var close = delimiters[1].replace(regexEscapeRE, '\\$&'); 29374 return new RegExp(open + '((?:.|\\n)+?)' + close, 'g') 29375}); 29376 29377 29378 29379function parseText ( 29380 text, 29381 delimiters 29382) { 29383 var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE; 29384 if (!tagRE.test(text)) { 29385 return 29386 } 29387 var tokens = []; 29388 var rawTokens = []; 29389 var lastIndex = tagRE.lastIndex = 0; 29390 var match, index, tokenValue; 29391 while ((match = tagRE.exec(text))) { 29392 index = match.index; 29393 // push text token 29394 if (index > lastIndex) { 29395 rawTokens.push(tokenValue = text.slice(lastIndex, index)); 29396 tokens.push(JSON.stringify(tokenValue)); 29397 } 29398 // tag token 29399 var exp = parseFilters(match[1].trim()); 29400 tokens.push(("_s(" + exp + ")")); 29401 rawTokens.push({ '@binding': exp }); 29402 lastIndex = index + match[0].length; 29403 } 29404 if (lastIndex < text.length) { 29405 rawTokens.push(tokenValue = text.slice(lastIndex)); 29406 tokens.push(JSON.stringify(tokenValue)); 29407 } 29408 return { 29409 expression: tokens.join('+'), 29410 tokens: rawTokens 29411 } 29412} 29413 29414/* */ 29415 29416function transformNode (el, options) { 29417 var warn = options.warn || baseWarn; 29418 var staticClass = getAndRemoveAttr(el, 'class'); 29419 if ("development" !== 'production' && staticClass) { 29420 var res = parseText(staticClass, options.delimiters); 29421 if (res) { 29422 warn( 29423 "class=\"" + staticClass + "\": " + 29424 'Interpolation inside attributes has been removed. ' + 29425 'Use v-bind or the colon shorthand instead. For example, ' + 29426 'instead of <div class="{{ val }}">, use <div :class="val">.' 29427 ); 29428 } 29429 } 29430 if (staticClass) { 29431 el.staticClass = JSON.stringify(staticClass); 29432 } 29433 var classBinding = getBindingAttr(el, 'class', false /* getStatic */); 29434 if (classBinding) { 29435 el.classBinding = classBinding; 29436 } 29437} 29438 29439function genData (el) { 29440 var data = ''; 29441 if (el.staticClass) { 29442 data += "staticClass:" + (el.staticClass) + ","; 29443 } 29444 if (el.classBinding) { 29445 data += "class:" + (el.classBinding) + ","; 29446 } 29447 return data 29448} 29449 29450var klass$1 = { 29451 staticKeys: ['staticClass'], 29452 transformNode: transformNode, 29453 genData: genData 29454} 29455 29456/* */ 29457 29458function transformNode$1 (el, options) { 29459 var warn = options.warn || baseWarn; 29460 var staticStyle = getAndRemoveAttr(el, 'style'); 29461 if (staticStyle) { 29462 /* istanbul ignore if */ 29463 if (true) { 29464 var res = parseText(staticStyle, options.delimiters); 29465 if (res) { 29466 warn( 29467 "style=\"" + staticStyle + "\": " + 29468 'Interpolation inside attributes has been removed. ' + 29469 'Use v-bind or the colon shorthand instead. For example, ' + 29470 'instead of <div style="{{ val }}">, use <div :style="val">.' 29471 ); 29472 } 29473 } 29474 el.staticStyle = JSON.stringify(parseStyleText(staticStyle)); 29475 } 29476 29477 var styleBinding = getBindingAttr(el, 'style', false /* getStatic */); 29478 if (styleBinding) { 29479 el.styleBinding = styleBinding; 29480 } 29481} 29482 29483function genData$1 (el) { 29484 var data = ''; 29485 if (el.staticStyle) { 29486 data += "staticStyle:" + (el.staticStyle) + ","; 29487 } 29488 if (el.styleBinding) { 29489 data += "style:(" + (el.styleBinding) + "),"; 29490 } 29491 return data 29492} 29493 29494var style$1 = { 29495 staticKeys: ['staticStyle'], 29496 transformNode: transformNode$1, 29497 genData: genData$1 29498} 29499 29500/* */ 29501 29502var decoder; 29503 29504var he = { 29505 decode: function decode (html) { 29506 decoder = decoder || document.createElement('div'); 29507 decoder.innerHTML = html; 29508 return decoder.textContent 29509 } 29510} 29511 29512/* */ 29513 29514var isUnaryTag = makeMap( 29515 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + 29516 'link,meta,param,source,track,wbr' 29517); 29518 29519// Elements that you can, intentionally, leave open 29520// (and which close themselves) 29521var canBeLeftOpenTag = makeMap( 29522 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source' 29523); 29524 29525// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3 29526// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content 29527var isNonPhrasingTag = makeMap( 29528 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' + 29529 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' + 29530 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' + 29531 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' + 29532 'title,tr,track' 29533); 29534 29535/** 29536 * Not type-checking this file because it's mostly vendor code. 29537 */ 29538 29539/*! 29540 * HTML Parser By John Resig (ejohn.org) 29541 * Modified by Juriy "kangax" Zaytsev 29542 * Original code by Erik Arvidsson, Mozilla Public License 29543 * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js 29544 */ 29545 29546// Regular Expressions for parsing tags and attributes 29547var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; 29548// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName 29549// but for Vue templates we can enforce a simple charset 29550var ncname = '[a-zA-Z_][\\w\\-\\.]*'; 29551var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")"; 29552var startTagOpen = new RegExp(("^<" + qnameCapture)); 29553var startTagClose = /^\s*(\/?)>/; 29554var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>")); 29555var doctype = /^<!DOCTYPE [^>]+>/i; 29556// #7298: escape - to avoid being pased as HTML comment when inlined in page 29557var comment = /^<!\--/; 29558var conditionalComment = /^<!\[/; 29559 29560var IS_REGEX_CAPTURING_BROKEN = false; 29561'x'.replace(/x(.)?/g, function (m, g) { 29562 IS_REGEX_CAPTURING_BROKEN = g === ''; 29563}); 29564 29565// Special Elements (can contain anything) 29566var isPlainTextElement = makeMap('script,style,textarea', true); 29567var reCache = {}; 29568 29569var decodingMap = { 29570 '<': '<', 29571 '>': '>', 29572 '"': '"', 29573 '&': '&', 29574 ' ': '\n', 29575 '	': '\t' 29576}; 29577var encodedAttr = /&(?:lt|gt|quot|amp);/g; 29578var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10|#9);/g; 29579 29580// #5992 29581var isIgnoreNewlineTag = makeMap('pre,textarea', true); 29582var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; }; 29583 29584function decodeAttr (value, shouldDecodeNewlines) { 29585 var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr; 29586 return value.replace(re, function (match) { return decodingMap[match]; }) 29587} 29588 29589function parseHTML (html, options) { 29590 var stack = []; 29591 var expectHTML = options.expectHTML; 29592 var isUnaryTag$$1 = options.isUnaryTag || no; 29593 var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no; 29594 var index = 0; 29595 var last, lastTag; 29596 while (html) { 29597 last = html; 29598 // Make sure we're not in a plaintext content element like script/style 29599 if (!lastTag || !isPlainTextElement(lastTag)) { 29600 var textEnd = html.indexOf('<'); 29601 if (textEnd === 0) { 29602 // Comment: 29603 if (comment.test(html)) { 29604 var commentEnd = html.indexOf('-->'); 29605 29606 if (commentEnd >= 0) { 29607 if (options.shouldKeepComment) { 29608 options.comment(html.substring(4, commentEnd)); 29609 } 29610 advance(commentEnd + 3); 29611 continue 29612 } 29613 } 29614 29615 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment 29616 if (conditionalComment.test(html)) { 29617 var conditionalEnd = html.indexOf(']>'); 29618 29619 if (conditionalEnd >= 0) { 29620 advance(conditionalEnd + 2); 29621 continue 29622 } 29623 } 29624 29625 // Doctype: 29626 var doctypeMatch = html.match(doctype); 29627 if (doctypeMatch) { 29628 advance(doctypeMatch[0].length); 29629 continue 29630 } 29631 29632 // End tag: 29633 var endTagMatch = html.match(endTag); 29634 if (endTagMatch) { 29635 var curIndex = index; 29636 advance(endTagMatch[0].length); 29637 parseEndTag(endTagMatch[1], curIndex, index); 29638 continue 29639 } 29640 29641 // Start tag: 29642 var startTagMatch = parseStartTag(); 29643 if (startTagMatch) { 29644 handleStartTag(startTagMatch); 29645 if (shouldIgnoreFirstNewline(lastTag, html)) { 29646 advance(1); 29647 } 29648 continue 29649 } 29650 } 29651 29652 var text = (void 0), rest = (void 0), next = (void 0); 29653 if (textEnd >= 0) { 29654 rest = html.slice(textEnd); 29655 while ( 29656 !endTag.test(rest) && 29657 !startTagOpen.test(rest) && 29658 !comment.test(rest) && 29659 !conditionalComment.test(rest) 29660 ) { 29661 // < in plain text, be forgiving and treat it as text 29662 next = rest.indexOf('<', 1); 29663 if (next < 0) { break } 29664 textEnd += next; 29665 rest = html.slice(textEnd); 29666 } 29667 text = html.substring(0, textEnd); 29668 advance(textEnd); 29669 } 29670 29671 if (textEnd < 0) { 29672 text = html; 29673 html = ''; 29674 } 29675 29676 if (options.chars && text) { 29677 options.chars(text); 29678 } 29679 } else { 29680 var endTagLength = 0; 29681 var stackedTag = lastTag.toLowerCase(); 29682 var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i')); 29683 var rest$1 = html.replace(reStackedTag, function (all, text, endTag) { 29684 endTagLength = endTag.length; 29685 if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') { 29686 text = text 29687 .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298 29688 .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1'); 29689 } 29690 if (shouldIgnoreFirstNewline(stackedTag, text)) { 29691 text = text.slice(1); 29692 } 29693 if (options.chars) { 29694 options.chars(text); 29695 } 29696 return '' 29697 }); 29698 index += html.length - rest$1.length; 29699 html = rest$1; 29700 parseEndTag(stackedTag, index - endTagLength, index); 29701 } 29702 29703 if (html === last) { 29704 options.chars && options.chars(html); 29705 if ("development" !== 'production' && !stack.length && options.warn) { 29706 options.warn(("Mal-formatted tag at end of template: \"" + html + "\"")); 29707 } 29708 break 29709 } 29710 } 29711 29712 // Clean up any remaining tags 29713 parseEndTag(); 29714 29715 function advance (n) { 29716 index += n; 29717 html = html.substring(n); 29718 } 29719 29720 function parseStartTag () { 29721 var start = html.match(startTagOpen); 29722 if (start) { 29723 var match = { 29724 tagName: start[1], 29725 attrs: [], 29726 start: index 29727 }; 29728 advance(start[0].length); 29729 var end, attr; 29730 while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) { 29731 advance(attr[0].length); 29732 match.attrs.push(attr); 29733 } 29734 if (end) { 29735 match.unarySlash = end[1]; 29736 advance(end[0].length); 29737 match.end = index; 29738 return match 29739 } 29740 } 29741 } 29742 29743 function handleStartTag (match) { 29744 var tagName = match.tagName; 29745 var unarySlash = match.unarySlash; 29746 29747 if (expectHTML) { 29748 if (lastTag === 'p' && isNonPhrasingTag(tagName)) { 29749 parseEndTag(lastTag); 29750 } 29751 if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) { 29752 parseEndTag(tagName); 29753 } 29754 } 29755 29756 var unary = isUnaryTag$$1(tagName) || !!unarySlash; 29757 29758 var l = match.attrs.length; 29759 var attrs = new Array(l); 29760 for (var i = 0; i < l; i++) { 29761 var args = match.attrs[i]; 29762 // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778 29763 if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) { 29764 if (args[3] === '') { delete args[3]; } 29765 if (args[4] === '') { delete args[4]; } 29766 if (args[5] === '') { delete args[5]; } 29767 } 29768 var value = args[3] || args[4] || args[5] || ''; 29769 var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href' 29770 ? options.shouldDecodeNewlinesForHref 29771 : options.shouldDecodeNewlines; 29772 attrs[i] = { 29773 name: args[1], 29774 value: decodeAttr(value, shouldDecodeNewlines) 29775 }; 29776 } 29777 29778 if (!unary) { 29779 stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs }); 29780 lastTag = tagName; 29781 } 29782 29783 if (options.start) { 29784 options.start(tagName, attrs, unary, match.start, match.end); 29785 } 29786 } 29787 29788 function parseEndTag (tagName, start, end) { 29789 var pos, lowerCasedTagName; 29790 if (start == null) { start = index; } 29791 if (end == null) { end = index; } 29792 29793 if (tagName) { 29794 lowerCasedTagName = tagName.toLowerCase(); 29795 } 29796 29797 // Find the closest opened tag of the same type 29798 if (tagName) { 29799 for (pos = stack.length - 1; pos >= 0; pos--) { 29800 if (stack[pos].lowerCasedTag === lowerCasedTagName) { 29801 break 29802 } 29803 } 29804 } else { 29805 // If no tag name is provided, clean shop 29806 pos = 0; 29807 } 29808 29809 if (pos >= 0) { 29810 // Close all the open elements, up the stack 29811 for (var i = stack.length - 1; i >= pos; i--) { 29812 if ("development" !== 'production' && 29813 (i > pos || !tagName) && 29814 options.warn 29815 ) { 29816 options.warn( 29817 ("tag <" + (stack[i].tag) + "> has no matching end tag.") 29818 ); 29819 } 29820 if (options.end) { 29821 options.end(stack[i].tag, start, end); 29822 } 29823 } 29824 29825 // Remove the open elements from the stack 29826 stack.length = pos; 29827 lastTag = pos && stack[pos - 1].tag; 29828 } else if (lowerCasedTagName === 'br') { 29829 if (options.start) { 29830 options.start(tagName, [], true, start, end); 29831 } 29832 } else if (lowerCasedTagName === 'p') { 29833 if (options.start) { 29834 options.start(tagName, [], false, start, end); 29835 } 29836 if (options.end) { 29837 options.end(tagName, start, end); 29838 } 29839 } 29840 } 29841} 29842 29843/* */ 29844 29845var onRE = /^@|^v-on:/; 29846var dirRE = /^v-|^@|^:/; 29847var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/; 29848var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; 29849var stripParensRE = /^\(|\)$/g; 29850 29851var argRE = /:(.*)$/; 29852var bindRE = /^:|^v-bind:/; 29853var modifierRE = /\.[^.]+/g; 29854 29855var decodeHTMLCached = cached(he.decode); 29856 29857// configurable state 29858var warn$2; 29859var delimiters; 29860var transforms; 29861var preTransforms; 29862var postTransforms; 29863var platformIsPreTag; 29864var platformMustUseProp; 29865var platformGetTagNamespace; 29866 29867 29868 29869function createASTElement ( 29870 tag, 29871 attrs, 29872 parent 29873) { 29874 return { 29875 type: 1, 29876 tag: tag, 29877 attrsList: attrs, 29878 attrsMap: makeAttrsMap(attrs), 29879 parent: parent, 29880 children: [] 29881 } 29882} 29883 29884/** 29885 * Convert HTML string to AST. 29886 */ 29887function parse ( 29888 template, 29889 options 29890) { 29891 warn$2 = options.warn || baseWarn; 29892 29893 platformIsPreTag = options.isPreTag || no; 29894 platformMustUseProp = options.mustUseProp || no; 29895 platformGetTagNamespace = options.getTagNamespace || no; 29896 29897 transforms = pluckModuleFunction(options.modules, 'transformNode'); 29898 preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); 29899 postTransforms = pluckModuleFunction(options.modules, 'postTransformNode'); 29900 29901 delimiters = options.delimiters; 29902 29903 var stack = []; 29904 var preserveWhitespace = options.preserveWhitespace !== false; 29905 var root; 29906 var currentParent; 29907 var inVPre = false; 29908 var inPre = false; 29909 var warned = false; 29910 29911 function warnOnce (msg) { 29912 if (!warned) { 29913 warned = true; 29914 warn$2(msg); 29915 } 29916 } 29917 29918 function closeElement (element) { 29919 // check pre state 29920 if (element.pre) { 29921 inVPre = false; 29922 } 29923 if (platformIsPreTag(element.tag)) { 29924 inPre = false; 29925 } 29926 // apply post-transforms 29927 for (var i = 0; i < postTransforms.length; i++) { 29928 postTransforms[i](element, options); 29929 } 29930 } 29931 29932 parseHTML(template, { 29933 warn: warn$2, 29934 expectHTML: options.expectHTML, 29935 isUnaryTag: options.isUnaryTag, 29936 canBeLeftOpenTag: options.canBeLeftOpenTag, 29937 shouldDecodeNewlines: options.shouldDecodeNewlines, 29938 shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref, 29939 shouldKeepComment: options.comments, 29940 start: function start (tag, attrs, unary) { 29941 // check namespace. 29942 // inherit parent ns if there is one 29943 var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag); 29944 29945 // handle IE svg bug 29946 /* istanbul ignore if */ 29947 if (isIE && ns === 'svg') { 29948 attrs = guardIESVGBug(attrs); 29949 } 29950 29951 var element = createASTElement(tag, attrs, currentParent); 29952 if (ns) { 29953 element.ns = ns; 29954 } 29955 29956 if (isForbiddenTag(element) && !isServerRendering()) { 29957 element.forbidden = true; 29958 "development" !== 'production' && warn$2( 29959 'Templates should only be responsible for mapping the state to the ' + 29960 'UI. Avoid placing tags with side-effects in your templates, such as ' + 29961 "<" + tag + ">" + ', as they will not be parsed.' 29962 ); 29963 } 29964 29965 // apply pre-transforms 29966 for (var i = 0; i < preTransforms.length; i++) { 29967 element = preTransforms[i](element, options) || element; 29968 } 29969 29970 if (!inVPre) { 29971 processPre(element); 29972 if (element.pre) { 29973 inVPre = true; 29974 } 29975 } 29976 if (platformIsPreTag(element.tag)) { 29977 inPre = true; 29978 } 29979 if (inVPre) { 29980 processRawAttrs(element); 29981 } else if (!element.processed) { 29982 // structural directives 29983 processFor(element); 29984 processIf(element); 29985 processOnce(element); 29986 // element-scope stuff 29987 processElement(element, options); 29988 } 29989 29990 function checkRootConstraints (el) { 29991 if (true) { 29992 if (el.tag === 'slot' || el.tag === 'template') { 29993 warnOnce( 29994 "Cannot use <" + (el.tag) + "> as component root element because it may " + 29995 'contain multiple nodes.' 29996 ); 29997 } 29998 if (el.attrsMap.hasOwnProperty('v-for')) { 29999 warnOnce( 30000 'Cannot use v-for on stateful component root element because ' + 30001 'it renders multiple elements.' 30002 ); 30003 } 30004 } 30005 } 30006 30007 // tree management 30008 if (!root) { 30009 root = element; 30010 checkRootConstraints(root); 30011 } else if (!stack.length) { 30012 // allow root elements with v-if, v-else-if and v-else 30013 if (root.if && (element.elseif || element.else)) { 30014 checkRootConstraints(element); 30015 addIfCondition(root, { 30016 exp: element.elseif, 30017 block: element 30018 }); 30019 } else if (true) { 30020 warnOnce( 30021 "Component template should contain exactly one root element. " + 30022 "If you are using v-if on multiple elements, " + 30023 "use v-else-if to chain them instead." 30024 ); 30025 } 30026 } 30027 if (currentParent && !element.forbidden) { 30028 if (element.elseif || element.else) { 30029 processIfConditions(element, currentParent); 30030 } else if (element.slotScope) { // scoped slot 30031 currentParent.plain = false; 30032 var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element; 30033 } else { 30034 currentParent.children.push(element); 30035 element.parent = currentParent; 30036 } 30037 } 30038 if (!unary) { 30039 currentParent = element; 30040 stack.push(element); 30041 } else { 30042 closeElement(element); 30043 } 30044 }, 30045 30046 end: function end () { 30047 // remove trailing whitespace 30048 var element = stack[stack.length - 1]; 30049 var lastNode = element.children[element.children.length - 1]; 30050 if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) { 30051 element.children.pop(); 30052 } 30053 // pop stack 30054 stack.length -= 1; 30055 currentParent = stack[stack.length - 1]; 30056 closeElement(element); 30057 }, 30058 30059 chars: function chars (text) { 30060 if (!currentParent) { 30061 if (true) { 30062 if (text === template) { 30063 warnOnce( 30064 'Component template requires a root element, rather than just text.' 30065 ); 30066 } else if ((text = text.trim())) { 30067 warnOnce( 30068 ("text \"" + text + "\" outside root element will be ignored.") 30069 ); 30070 } 30071 } 30072 return 30073 } 30074 // IE textarea placeholder bug 30075 /* istanbul ignore if */ 30076 if (isIE && 30077 currentParent.tag === 'textarea' && 30078 currentParent.attrsMap.placeholder === text 30079 ) { 30080 return 30081 } 30082 var children = currentParent.children; 30083 text = inPre || text.trim() 30084 ? isTextTag(currentParent) ? text : decodeHTMLCached(text) 30085 // only preserve whitespace if its not right after a starting tag 30086 : preserveWhitespace && children.length ? ' ' : ''; 30087 if (text) { 30088 var res; 30089 if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) { 30090 children.push({ 30091 type: 2, 30092 expression: res.expression, 30093 tokens: res.tokens, 30094 text: text 30095 }); 30096 } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') { 30097 children.push({ 30098 type: 3, 30099 text: text 30100 }); 30101 } 30102 } 30103 }, 30104 comment: function comment (text) { 30105 currentParent.children.push({ 30106 type: 3, 30107 text: text, 30108 isComment: true 30109 }); 30110 } 30111 }); 30112 return root 30113} 30114 30115function processPre (el) { 30116 if (getAndRemoveAttr(el, 'v-pre') != null) { 30117 el.pre = true; 30118 } 30119} 30120 30121function processRawAttrs (el) { 30122 var l = el.attrsList.length; 30123 if (l) { 30124 var attrs = el.attrs = new Array(l); 30125 for (var i = 0; i < l; i++) { 30126 attrs[i] = { 30127 name: el.attrsList[i].name, 30128 value: JSON.stringify(el.attrsList[i].value) 30129 }; 30130 } 30131 } else if (!el.pre) { 30132 // non root node in pre blocks with no attributes 30133 el.plain = true; 30134 } 30135} 30136 30137function processElement (element, options) { 30138 processKey(element); 30139 30140 // determine whether this is a plain element after 30141 // removing structural attributes 30142 element.plain = !element.key && !element.attrsList.length; 30143 30144 processRef(element); 30145 processSlot(element); 30146 processComponent(element); 30147 for (var i = 0; i < transforms.length; i++) { 30148 element = transforms[i](element, options) || element; 30149 } 30150 processAttrs(element); 30151} 30152 30153function processKey (el) { 30154 var exp = getBindingAttr(el, 'key'); 30155 if (exp) { 30156 if ("development" !== 'production' && el.tag === 'template') { 30157 warn$2("<template> cannot be keyed. Place the key on real elements instead."); 30158 } 30159 el.key = exp; 30160 } 30161} 30162 30163function processRef (el) { 30164 var ref = getBindingAttr(el, 'ref'); 30165 if (ref) { 30166 el.ref = ref; 30167 el.refInFor = checkInFor(el); 30168 } 30169} 30170 30171function processFor (el) { 30172 var exp; 30173 if ((exp = getAndRemoveAttr(el, 'v-for'))) { 30174 var res = parseFor(exp); 30175 if (res) { 30176 extend(el, res); 30177 } else if (true) { 30178 warn$2( 30179 ("Invalid v-for expression: " + exp) 30180 ); 30181 } 30182 } 30183} 30184 30185 30186 30187function parseFor (exp) { 30188 var inMatch = exp.match(forAliasRE); 30189 if (!inMatch) { return } 30190 var res = {}; 30191 res.for = inMatch[2].trim(); 30192 var alias = inMatch[1].trim().replace(stripParensRE, ''); 30193 var iteratorMatch = alias.match(forIteratorRE); 30194 if (iteratorMatch) { 30195 res.alias = alias.replace(forIteratorRE, ''); 30196 res.iterator1 = iteratorMatch[1].trim(); 30197 if (iteratorMatch[2]) { 30198 res.iterator2 = iteratorMatch[2].trim(); 30199 } 30200 } else { 30201 res.alias = alias; 30202 } 30203 return res 30204} 30205 30206function processIf (el) { 30207 var exp = getAndRemoveAttr(el, 'v-if'); 30208 if (exp) { 30209 el.if = exp; 30210 addIfCondition(el, { 30211 exp: exp, 30212 block: el 30213 }); 30214 } else { 30215 if (getAndRemoveAttr(el, 'v-else') != null) { 30216 el.else = true; 30217 } 30218 var elseif = getAndRemoveAttr(el, 'v-else-if'); 30219 if (elseif) { 30220 el.elseif = elseif; 30221 } 30222 } 30223} 30224 30225function processIfConditions (el, parent) { 30226 var prev = findPrevElement(parent.children); 30227 if (prev && prev.if) { 30228 addIfCondition(prev, { 30229 exp: el.elseif, 30230 block: el 30231 }); 30232 } else if (true) { 30233 warn$2( 30234 "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " + 30235 "used on element <" + (el.tag) + "> without corresponding v-if." 30236 ); 30237 } 30238} 30239 30240function findPrevElement (children) { 30241 var i = children.length; 30242 while (i--) { 30243 if (children[i].type === 1) { 30244 return children[i] 30245 } else { 30246 if ("development" !== 'production' && children[i].text !== ' ') { 30247 warn$2( 30248 "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " + 30249 "will be ignored." 30250 ); 30251 } 30252 children.pop(); 30253 } 30254 } 30255} 30256 30257function addIfCondition (el, condition) { 30258 if (!el.ifConditions) { 30259 el.ifConditions = []; 30260 } 30261 el.ifConditions.push(condition); 30262} 30263 30264function processOnce (el) { 30265 var once$$1 = getAndRemoveAttr(el, 'v-once'); 30266 if (once$$1 != null) { 30267 el.once = true; 30268 } 30269} 30270 30271function processSlot (el) { 30272 if (el.tag === 'slot') { 30273 el.slotName = getBindingAttr(el, 'name'); 30274 if ("development" !== 'production' && el.key) { 30275 warn$2( 30276 "`key` does not work on <slot> because slots are abstract outlets " + 30277 "and can possibly expand into multiple elements. " + 30278 "Use the key on a wrapping element instead." 30279 ); 30280 } 30281 } else { 30282 var slotScope; 30283 if (el.tag === 'template') { 30284 slotScope = getAndRemoveAttr(el, 'scope'); 30285 /* istanbul ignore if */ 30286 if ("development" !== 'production' && slotScope) { 30287 warn$2( 30288 "the \"scope\" attribute for scoped slots have been deprecated and " + 30289 "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " + 30290 "can also be used on plain elements in addition to <template> to " + 30291 "denote scoped slots.", 30292 true 30293 ); 30294 } 30295 el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope'); 30296 } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) { 30297 /* istanbul ignore if */ 30298 if ("development" !== 'production' && el.attrsMap['v-for']) { 30299 warn$2( 30300 "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " + 30301 "(v-for takes higher priority). Use a wrapper <template> for the " + 30302 "scoped slot to make it clearer.", 30303 true 30304 ); 30305 } 30306 el.slotScope = slotScope; 30307 } 30308 var slotTarget = getBindingAttr(el, 'slot'); 30309 if (slotTarget) { 30310 el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget; 30311 // preserve slot as an attribute for native shadow DOM compat 30312 // only for non-scoped slots. 30313 if (el.tag !== 'template' && !el.slotScope) { 30314 addAttr(el, 'slot', slotTarget); 30315 } 30316 } 30317 } 30318} 30319 30320function processComponent (el) { 30321 var binding; 30322 if ((binding = getBindingAttr(el, 'is'))) { 30323 el.component = binding; 30324 } 30325 if (getAndRemoveAttr(el, 'inline-template') != null) { 30326 el.inlineTemplate = true; 30327 } 30328} 30329 30330function processAttrs (el) { 30331 var list = el.attrsList; 30332 var i, l, name, rawName, value, modifiers, isProp; 30333 for (i = 0, l = list.length; i < l; i++) { 30334 name = rawName = list[i].name; 30335 value = list[i].value; 30336 if (dirRE.test(name)) { 30337 // mark element as dynamic 30338 el.hasBindings = true; 30339 // modifiers 30340 modifiers = parseModifiers(name); 30341 if (modifiers) { 30342 name = name.replace(modifierRE, ''); 30343 } 30344 if (bindRE.test(name)) { // v-bind 30345 name = name.replace(bindRE, ''); 30346 value = parseFilters(value); 30347 isProp = false; 30348 if (modifiers) { 30349 if (modifiers.prop) { 30350 isProp = true; 30351 name = camelize(name); 30352 if (name === 'innerHtml') { name = 'innerHTML'; } 30353 } 30354 if (modifiers.camel) { 30355 name = camelize(name); 30356 } 30357 if (modifiers.sync) { 30358 addHandler( 30359 el, 30360 ("update:" + (camelize(name))), 30361 genAssignmentCode(value, "$event") 30362 ); 30363 } 30364 } 30365 if (isProp || ( 30366 !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name) 30367 )) { 30368 addProp(el, name, value); 30369 } else { 30370 addAttr(el, name, value); 30371 } 30372 } else if (onRE.test(name)) { // v-on 30373 name = name.replace(onRE, ''); 30374 addHandler(el, name, value, modifiers, false, warn$2); 30375 } else { // normal directives 30376 name = name.replace(dirRE, ''); 30377 // parse arg 30378 var argMatch = name.match(argRE); 30379 var arg = argMatch && argMatch[1]; 30380 if (arg) { 30381 name = name.slice(0, -(arg.length + 1)); 30382 } 30383 addDirective(el, name, rawName, value, arg, modifiers); 30384 if ("development" !== 'production' && name === 'model') { 30385 checkForAliasModel(el, value); 30386 } 30387 } 30388 } else { 30389 // literal attribute 30390 if (true) { 30391 var res = parseText(value, delimiters); 30392 if (res) { 30393 warn$2( 30394 name + "=\"" + value + "\": " + 30395 'Interpolation inside attributes has been removed. ' + 30396 'Use v-bind or the colon shorthand instead. For example, ' + 30397 'instead of <div id="{{ val }}">, use <div :id="val">.' 30398 ); 30399 } 30400 } 30401 addAttr(el, name, JSON.stringify(value)); 30402 // #6887 firefox doesn't update muted state if set via attribute 30403 // even immediately after element creation 30404 if (!el.component && 30405 name === 'muted' && 30406 platformMustUseProp(el.tag, el.attrsMap.type, name)) { 30407 addProp(el, name, 'true'); 30408 } 30409 } 30410 } 30411} 30412 30413function checkInFor (el) { 30414 var parent = el; 30415 while (parent) { 30416 if (parent.for !== undefined) { 30417 return true 30418 } 30419 parent = parent.parent; 30420 } 30421 return false 30422} 30423 30424function parseModifiers (name) { 30425 var match = name.match(modifierRE); 30426 if (match) { 30427 var ret = {}; 30428 match.forEach(function (m) { ret[m.slice(1)] = true; }); 30429 return ret 30430 } 30431} 30432 30433function makeAttrsMap (attrs) { 30434 var map = {}; 30435 for (var i = 0, l = attrs.length; i < l; i++) { 30436 if ( 30437 "development" !== 'production' && 30438 map[attrs[i].name] && !isIE && !isEdge 30439 ) { 30440 warn$2('duplicate attribute: ' + attrs[i].name); 30441 } 30442 map[attrs[i].name] = attrs[i].value; 30443 } 30444 return map 30445} 30446 30447// for script (e.g. type="x/template") or style, do not decode content 30448function isTextTag (el) { 30449 return el.tag === 'script' || el.tag === 'style' 30450} 30451 30452function isForbiddenTag (el) { 30453 return ( 30454 el.tag === 'style' || 30455 (el.tag === 'script' && ( 30456 !el.attrsMap.type || 30457 el.attrsMap.type === 'text/javascript' 30458 )) 30459 ) 30460} 30461 30462var ieNSBug = /^xmlns:NS\d+/; 30463var ieNSPrefix = /^NS\d+:/; 30464 30465/* istanbul ignore next */ 30466function guardIESVGBug (attrs) { 30467 var res = []; 30468 for (var i = 0; i < attrs.length; i++) { 30469 var attr = attrs[i]; 30470 if (!ieNSBug.test(attr.name)) { 30471 attr.name = attr.name.replace(ieNSPrefix, ''); 30472 res.push(attr); 30473 } 30474 } 30475 return res 30476} 30477 30478function checkForAliasModel (el, value) { 30479 var _el = el; 30480 while (_el) { 30481 if (_el.for && _el.alias === value) { 30482 warn$2( 30483 "<" + (el.tag) + " v-model=\"" + value + "\">: " + 30484 "You are binding v-model directly to a v-for iteration alias. " + 30485 "This will not be able to modify the v-for source array because " + 30486 "writing to the alias is like modifying a function local variable. " + 30487 "Consider using an array of objects and use v-model on an object property instead." 30488 ); 30489 } 30490 _el = _el.parent; 30491 } 30492} 30493 30494/* */ 30495 30496/** 30497 * Expand input[v-model] with dyanmic type bindings into v-if-else chains 30498 * Turn this: 30499 * <input v-model="data[type]" :type="type"> 30500 * into this: 30501 * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]"> 30502 * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]"> 30503 * <input v-else :type="type" v-model="data[type]"> 30504 */ 30505 30506function preTransformNode (el, options) { 30507 if (el.tag === 'input') { 30508 var map = el.attrsMap; 30509 if (!map['v-model']) { 30510 return 30511 } 30512 30513 var typeBinding; 30514 if (map[':type'] || map['v-bind:type']) { 30515 typeBinding = getBindingAttr(el, 'type'); 30516 } 30517 if (!map.type && !typeBinding && map['v-bind']) { 30518 typeBinding = "(" + (map['v-bind']) + ").type"; 30519 } 30520 30521 if (typeBinding) { 30522 var ifCondition = getAndRemoveAttr(el, 'v-if', true); 30523 var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : ""; 30524 var hasElse = getAndRemoveAttr(el, 'v-else', true) != null; 30525 var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true); 30526 // 1. checkbox 30527 var branch0 = cloneASTElement(el); 30528 // process for on the main node 30529 processFor(branch0); 30530 addRawAttr(branch0, 'type', 'checkbox'); 30531 processElement(branch0, options); 30532 branch0.processed = true; // prevent it from double-processed 30533 branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra; 30534 addIfCondition(branch0, { 30535 exp: branch0.if, 30536 block: branch0 30537 }); 30538 // 2. add radio else-if condition 30539 var branch1 = cloneASTElement(el); 30540 getAndRemoveAttr(branch1, 'v-for', true); 30541 addRawAttr(branch1, 'type', 'radio'); 30542 processElement(branch1, options); 30543 addIfCondition(branch0, { 30544 exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra, 30545 block: branch1 30546 }); 30547 // 3. other 30548 var branch2 = cloneASTElement(el); 30549 getAndRemoveAttr(branch2, 'v-for', true); 30550 addRawAttr(branch2, ':type', typeBinding); 30551 processElement(branch2, options); 30552 addIfCondition(branch0, { 30553 exp: ifCondition, 30554 block: branch2 30555 }); 30556 30557 if (hasElse) { 30558 branch0.else = true; 30559 } else if (elseIfCondition) { 30560 branch0.elseif = elseIfCondition; 30561 } 30562 30563 return branch0 30564 } 30565 } 30566} 30567 30568function cloneASTElement (el) { 30569 return createASTElement(el.tag, el.attrsList.slice(), el.parent) 30570} 30571 30572var model$2 = { 30573 preTransformNode: preTransformNode 30574} 30575 30576var modules$1 = [ 30577 klass$1, 30578 style$1, 30579 model$2 30580] 30581 30582/* */ 30583 30584function text (el, dir) { 30585 if (dir.value) { 30586 addProp(el, 'textContent', ("_s(" + (dir.value) + ")")); 30587 } 30588} 30589 30590/* */ 30591 30592function html (el, dir) { 30593 if (dir.value) { 30594 addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")")); 30595 } 30596} 30597 30598var directives$1 = { 30599 model: model, 30600 text: text, 30601 html: html 30602} 30603 30604/* */ 30605 30606var baseOptions = { 30607 expectHTML: true, 30608 modules: modules$1, 30609 directives: directives$1, 30610 isPreTag: isPreTag, 30611 isUnaryTag: isUnaryTag, 30612 mustUseProp: mustUseProp, 30613 canBeLeftOpenTag: canBeLeftOpenTag, 30614 isReservedTag: isReservedTag, 30615 getTagNamespace: getTagNamespace, 30616 staticKeys: genStaticKeys(modules$1) 30617}; 30618 30619/* */ 30620 30621var isStaticKey; 30622var isPlatformReservedTag; 30623 30624var genStaticKeysCached = cached(genStaticKeys$1); 30625 30626/** 30627 * Goal of the optimizer: walk the generated template AST tree 30628 * and detect sub-trees that are purely static, i.e. parts of 30629 * the DOM that never needs to change. 30630 * 30631 * Once we detect these sub-trees, we can: 30632 * 30633 * 1. Hoist them into constants, so that we no longer need to 30634 * create fresh nodes for them on each re-render; 30635 * 2. Completely skip them in the patching process. 30636 */ 30637function optimize (root, options) { 30638 if (!root) { return } 30639 isStaticKey = genStaticKeysCached(options.staticKeys || ''); 30640 isPlatformReservedTag = options.isReservedTag || no; 30641 // first pass: mark all non-static nodes. 30642 markStatic$1(root); 30643 // second pass: mark static roots. 30644 markStaticRoots(root, false); 30645} 30646 30647function genStaticKeys$1 (keys) { 30648 return makeMap( 30649 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' + 30650 (keys ? ',' + keys : '') 30651 ) 30652} 30653 30654function markStatic$1 (node) { 30655 node.static = isStatic(node); 30656 if (node.type === 1) { 30657 // do not make component slot content static. this avoids 30658 // 1. components not able to mutate slot nodes 30659 // 2. static slot content fails for hot-reloading 30660 if ( 30661 !isPlatformReservedTag(node.tag) && 30662 node.tag !== 'slot' && 30663 node.attrsMap['inline-template'] == null 30664 ) { 30665 return 30666 } 30667 for (var i = 0, l = node.children.length; i < l; i++) { 30668 var child = node.children[i]; 30669 markStatic$1(child); 30670 if (!child.static) { 30671 node.static = false; 30672 } 30673 } 30674 if (node.ifConditions) { 30675 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) { 30676 var block = node.ifConditions[i$1].block; 30677 markStatic$1(block); 30678 if (!block.static) { 30679 node.static = false; 30680 } 30681 } 30682 } 30683 } 30684} 30685 30686function markStaticRoots (node, isInFor) { 30687 if (node.type === 1) { 30688 if (node.static || node.once) { 30689 node.staticInFor = isInFor; 30690 } 30691 // For a node to qualify as a static root, it should have children that 30692 // are not just static text. Otherwise the cost of hoisting out will 30693 // outweigh the benefits and it's better off to just always render it fresh. 30694 if (node.static && node.children.length && !( 30695 node.children.length === 1 && 30696 node.children[0].type === 3 30697 )) { 30698 node.staticRoot = true; 30699 return 30700 } else { 30701 node.staticRoot = false; 30702 } 30703 if (node.children) { 30704 for (var i = 0, l = node.children.length; i < l; i++) { 30705 markStaticRoots(node.children[i], isInFor || !!node.for); 30706 } 30707 } 30708 if (node.ifConditions) { 30709 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) { 30710 markStaticRoots(node.ifConditions[i$1].block, isInFor); 30711 } 30712 } 30713 } 30714} 30715 30716function isStatic (node) { 30717 if (node.type === 2) { // expression 30718 return false 30719 } 30720 if (node.type === 3) { // text 30721 return true 30722 } 30723 return !!(node.pre || ( 30724 !node.hasBindings && // no dynamic bindings 30725 !node.if && !node.for && // not v-if or v-for or v-else 30726 !isBuiltInTag(node.tag) && // not a built-in 30727 isPlatformReservedTag(node.tag) && // not a component 30728 !isDirectChildOfTemplateFor(node) && 30729 Object.keys(node).every(isStaticKey) 30730 )) 30731} 30732 30733function isDirectChildOfTemplateFor (node) { 30734 while (node.parent) { 30735 node = node.parent; 30736 if (node.tag !== 'template') { 30737 return false 30738 } 30739 if (node.for) { 30740 return true 30741 } 30742 } 30743 return false 30744} 30745 30746/* */ 30747 30748var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; 30749var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; 30750 30751// KeyboardEvent.keyCode aliases 30752var keyCodes = { 30753 esc: 27, 30754 tab: 9, 30755 enter: 13, 30756 space: 32, 30757 up: 38, 30758 left: 37, 30759 right: 39, 30760 down: 40, 30761 'delete': [8, 46] 30762}; 30763 30764// KeyboardEvent.key aliases 30765var keyNames = { 30766 esc: 'Escape', 30767 tab: 'Tab', 30768 enter: 'Enter', 30769 space: ' ', 30770 // #7806: IE11 uses key names without `Arrow` prefix for arrow keys. 30771 up: ['Up', 'ArrowUp'], 30772 left: ['Left', 'ArrowLeft'], 30773 right: ['Right', 'ArrowRight'], 30774 down: ['Down', 'ArrowDown'], 30775 'delete': ['Backspace', 'Delete'] 30776}; 30777 30778// #4868: modifiers that prevent the execution of the listener 30779// need to explicitly return null so that we can determine whether to remove 30780// the listener for .once 30781var genGuard = function (condition) { return ("if(" + condition + ")return null;"); }; 30782 30783var modifierCode = { 30784 stop: '$event.stopPropagation();', 30785 prevent: '$event.preventDefault();', 30786 self: genGuard("$event.target !== $event.currentTarget"), 30787 ctrl: genGuard("!$event.ctrlKey"), 30788 shift: genGuard("!$event.shiftKey"), 30789 alt: genGuard("!$event.altKey"), 30790 meta: genGuard("!$event.metaKey"), 30791 left: genGuard("'button' in $event && $event.button !== 0"), 30792 middle: genGuard("'button' in $event && $event.button !== 1"), 30793 right: genGuard("'button' in $event && $event.button !== 2") 30794}; 30795 30796function genHandlers ( 30797 events, 30798 isNative, 30799 warn 30800) { 30801 var res = isNative ? 'nativeOn:{' : 'on:{'; 30802 for (var name in events) { 30803 res += "\"" + name + "\":" + (genHandler(name, events[name])) + ","; 30804 } 30805 return res.slice(0, -1) + '}' 30806} 30807 30808function genHandler ( 30809 name, 30810 handler 30811) { 30812 if (!handler) { 30813 return 'function(){}' 30814 } 30815 30816 if (Array.isArray(handler)) { 30817 return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]") 30818 } 30819 30820 var isMethodPath = simplePathRE.test(handler.value); 30821 var isFunctionExpression = fnExpRE.test(handler.value); 30822 30823 if (!handler.modifiers) { 30824 if (isMethodPath || isFunctionExpression) { 30825 return handler.value 30826 } 30827 /* istanbul ignore if */ 30828 return ("function($event){" + (handler.value) + "}") // inline statement 30829 } else { 30830 var code = ''; 30831 var genModifierCode = ''; 30832 var keys = []; 30833 for (var key in handler.modifiers) { 30834 if (modifierCode[key]) { 30835 genModifierCode += modifierCode[key]; 30836 // left/right 30837 if (keyCodes[key]) { 30838 keys.push(key); 30839 } 30840 } else if (key === 'exact') { 30841 var modifiers = (handler.modifiers); 30842 genModifierCode += genGuard( 30843 ['ctrl', 'shift', 'alt', 'meta'] 30844 .filter(function (keyModifier) { return !modifiers[keyModifier]; }) 30845 .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); }) 30846 .join('||') 30847 ); 30848 } else { 30849 keys.push(key); 30850 } 30851 } 30852 if (keys.length) { 30853 code += genKeyFilter(keys); 30854 } 30855 // Make sure modifiers like prevent and stop get executed after key filtering 30856 if (genModifierCode) { 30857 code += genModifierCode; 30858 } 30859 var handlerCode = isMethodPath 30860 ? ("return " + (handler.value) + "($event)") 30861 : isFunctionExpression 30862 ? ("return (" + (handler.value) + ")($event)") 30863 : handler.value; 30864 /* istanbul ignore if */ 30865 return ("function($event){" + code + handlerCode + "}") 30866 } 30867} 30868 30869function genKeyFilter (keys) { 30870 return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;") 30871} 30872 30873function genFilterCode (key) { 30874 var keyVal = parseInt(key, 10); 30875 if (keyVal) { 30876 return ("$event.keyCode!==" + keyVal) 30877 } 30878 var keyCode = keyCodes[key]; 30879 var keyName = keyNames[key]; 30880 return ( 30881 "_k($event.keyCode," + 30882 (JSON.stringify(key)) + "," + 30883 (JSON.stringify(keyCode)) + "," + 30884 "$event.key," + 30885 "" + (JSON.stringify(keyName)) + 30886 ")" 30887 ) 30888} 30889 30890/* */ 30891 30892function on (el, dir) { 30893 if ("development" !== 'production' && dir.modifiers) { 30894 warn("v-on without argument does not support modifiers."); 30895 } 30896 el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); }; 30897} 30898 30899/* */ 30900 30901function bind$1 (el, dir) { 30902 el.wrapData = function (code) { 30903 return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")") 30904 }; 30905} 30906 30907/* */ 30908 30909var baseDirectives = { 30910 on: on, 30911 bind: bind$1, 30912 cloak: noop 30913} 30914 30915/* */ 30916 30917var CodegenState = function CodegenState (options) { 30918 this.options = options; 30919 this.warn = options.warn || baseWarn; 30920 this.transforms = pluckModuleFunction(options.modules, 'transformCode'); 30921 this.dataGenFns = pluckModuleFunction(options.modules, 'genData'); 30922 this.directives = extend(extend({}, baseDirectives), options.directives); 30923 var isReservedTag = options.isReservedTag || no; 30924 this.maybeComponent = function (el) { return !isReservedTag(el.tag); }; 30925 this.onceId = 0; 30926 this.staticRenderFns = []; 30927}; 30928 30929 30930 30931function generate ( 30932 ast, 30933 options 30934) { 30935 var state = new CodegenState(options); 30936 var code = ast ? genElement(ast, state) : '_c("div")'; 30937 return { 30938 render: ("with(this){return " + code + "}"), 30939 staticRenderFns: state.staticRenderFns 30940 } 30941} 30942 30943function genElement (el, state) { 30944 if (el.staticRoot && !el.staticProcessed) { 30945 return genStatic(el, state) 30946 } else if (el.once && !el.onceProcessed) { 30947 return genOnce(el, state) 30948 } else if (el.for && !el.forProcessed) { 30949 return genFor(el, state) 30950 } else if (el.if && !el.ifProcessed) { 30951 return genIf(el, state) 30952 } else if (el.tag === 'template' && !el.slotTarget) { 30953 return genChildren(el, state) || 'void 0' 30954 } else if (el.tag === 'slot') { 30955 return genSlot(el, state) 30956 } else { 30957 // component or element 30958 var code; 30959 if (el.component) { 30960 code = genComponent(el.component, el, state); 30961 } else { 30962 var data = el.plain ? undefined : genData$2(el, state); 30963 30964 var children = el.inlineTemplate ? null : genChildren(el, state, true); 30965 code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; 30966 } 30967 // module transforms 30968 for (var i = 0; i < state.transforms.length; i++) { 30969 code = state.transforms[i](el, code); 30970 } 30971 return code 30972 } 30973} 30974 30975// hoist static sub-trees out 30976function genStatic (el, state) { 30977 el.staticProcessed = true; 30978 state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}")); 30979 return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")") 30980} 30981 30982// v-once 30983function genOnce (el, state) { 30984 el.onceProcessed = true; 30985 if (el.if && !el.ifProcessed) { 30986 return genIf(el, state) 30987 } else if (el.staticInFor) { 30988 var key = ''; 30989 var parent = el.parent; 30990 while (parent) { 30991 if (parent.for) { 30992 key = parent.key; 30993 break 30994 } 30995 parent = parent.parent; 30996 } 30997 if (!key) { 30998 "development" !== 'production' && state.warn( 30999 "v-once can only be used inside v-for that is keyed. " 31000 ); 31001 return genElement(el, state) 31002 } 31003 return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")") 31004 } else { 31005 return genStatic(el, state) 31006 } 31007} 31008 31009function genIf ( 31010 el, 31011 state, 31012 altGen, 31013 altEmpty 31014) { 31015 el.ifProcessed = true; // avoid recursion 31016 return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty) 31017} 31018 31019function genIfConditions ( 31020 conditions, 31021 state, 31022 altGen, 31023 altEmpty 31024) { 31025 if (!conditions.length) { 31026 return altEmpty || '_e()' 31027 } 31028 31029 var condition = conditions.shift(); 31030 if (condition.exp) { 31031 return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty))) 31032 } else { 31033 return ("" + (genTernaryExp(condition.block))) 31034 } 31035 31036 // v-if with v-once should generate code like (a)?_m(0):_m(1) 31037 function genTernaryExp (el) { 31038 return altGen 31039 ? altGen(el, state) 31040 : el.once 31041 ? genOnce(el, state) 31042 : genElement(el, state) 31043 } 31044} 31045 31046function genFor ( 31047 el, 31048 state, 31049 altGen, 31050 altHelper 31051) { 31052 var exp = el.for; 31053 var alias = el.alias; 31054 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; 31055 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; 31056 31057 if ("development" !== 'production' && 31058 state.maybeComponent(el) && 31059 el.tag !== 'slot' && 31060 el.tag !== 'template' && 31061 !el.key 31062 ) { 31063 state.warn( 31064 "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " + 31065 "v-for should have explicit keys. " + 31066 "See https://vuejs.org/guide/list.html#key for more info.", 31067 true /* tip */ 31068 ); 31069 } 31070 31071 el.forProcessed = true; // avoid recursion 31072 return (altHelper || '_l') + "((" + exp + ")," + 31073 "function(" + alias + iterator1 + iterator2 + "){" + 31074 "return " + ((altGen || genElement)(el, state)) + 31075 '})' 31076} 31077 31078function genData$2 (el, state) { 31079 var data = '{'; 31080 31081 // directives first. 31082 // directives may mutate the el's other properties before they are generated. 31083 var dirs = genDirectives(el, state); 31084 if (dirs) { data += dirs + ','; } 31085 31086 // key 31087 if (el.key) { 31088 data += "key:" + (el.key) + ","; 31089 } 31090 // ref 31091 if (el.ref) { 31092 data += "ref:" + (el.ref) + ","; 31093 } 31094 if (el.refInFor) { 31095 data += "refInFor:true,"; 31096 } 31097 // pre 31098 if (el.pre) { 31099 data += "pre:true,"; 31100 } 31101 // record original tag name for components using "is" attribute 31102 if (el.component) { 31103 data += "tag:\"" + (el.tag) + "\","; 31104 } 31105 // module data generation functions 31106 for (var i = 0; i < state.dataGenFns.length; i++) { 31107 data += state.dataGenFns[i](el); 31108 } 31109 // attributes 31110 if (el.attrs) { 31111 data += "attrs:{" + (genProps(el.attrs)) + "},"; 31112 } 31113 // DOM props 31114 if (el.props) { 31115 data += "domProps:{" + (genProps(el.props)) + "},"; 31116 } 31117 // event handlers 31118 if (el.events) { 31119 data += (genHandlers(el.events, false, state.warn)) + ","; 31120 } 31121 if (el.nativeEvents) { 31122 data += (genHandlers(el.nativeEvents, true, state.warn)) + ","; 31123 } 31124 // slot target 31125 // only for non-scoped slots 31126 if (el.slotTarget && !el.slotScope) { 31127 data += "slot:" + (el.slotTarget) + ","; 31128 } 31129 // scoped slots 31130 if (el.scopedSlots) { 31131 data += (genScopedSlots(el.scopedSlots, state)) + ","; 31132 } 31133 // component v-model 31134 if (el.model) { 31135 data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},"; 31136 } 31137 // inline-template 31138 if (el.inlineTemplate) { 31139 var inlineTemplate = genInlineTemplate(el, state); 31140 if (inlineTemplate) { 31141 data += inlineTemplate + ","; 31142 } 31143 } 31144 data = data.replace(/,$/, '') + '}'; 31145 // v-bind data wrap 31146 if (el.wrapData) { 31147 data = el.wrapData(data); 31148 } 31149 // v-on data wrap 31150 if (el.wrapListeners) { 31151 data = el.wrapListeners(data); 31152 } 31153 return data 31154} 31155 31156function genDirectives (el, state) { 31157 var dirs = el.directives; 31158 if (!dirs) { return } 31159 var res = 'directives:['; 31160 var hasRuntime = false; 31161 var i, l, dir, needRuntime; 31162 for (i = 0, l = dirs.length; i < l; i++) { 31163 dir = dirs[i]; 31164 needRuntime = true; 31165 var gen = state.directives[dir.name]; 31166 if (gen) { 31167 // compile-time directive that manipulates AST. 31168 // returns true if it also needs a runtime counterpart. 31169 needRuntime = !!gen(el, dir, state.warn); 31170 } 31171 if (needRuntime) { 31172 hasRuntime = true; 31173 res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},"; 31174 } 31175 } 31176 if (hasRuntime) { 31177 return res.slice(0, -1) + ']' 31178 } 31179} 31180 31181function genInlineTemplate (el, state) { 31182 var ast = el.children[0]; 31183 if ("development" !== 'production' && ( 31184 el.children.length !== 1 || ast.type !== 1 31185 )) { 31186 state.warn('Inline-template components must have exactly one child element.'); 31187 } 31188 if (ast.type === 1) { 31189 var inlineRenderFns = generate(ast, state.options); 31190 return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}") 31191 } 31192} 31193 31194function genScopedSlots ( 31195 slots, 31196 state 31197) { 31198 return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { 31199 return genScopedSlot(key, slots[key], state) 31200 }).join(',')) + "])") 31201} 31202 31203function genScopedSlot ( 31204 key, 31205 el, 31206 state 31207) { 31208 if (el.for && !el.forProcessed) { 31209 return genForScopedSlot(key, el, state) 31210 } 31211 var fn = "function(" + (String(el.slotScope)) + "){" + 31212 "return " + (el.tag === 'template' 31213 ? el.if 31214 ? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined") 31215 : genChildren(el, state) || 'undefined' 31216 : genElement(el, state)) + "}"; 31217 return ("{key:" + key + ",fn:" + fn + "}") 31218} 31219 31220function genForScopedSlot ( 31221 key, 31222 el, 31223 state 31224) { 31225 var exp = el.for; 31226 var alias = el.alias; 31227 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; 31228 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; 31229 el.forProcessed = true; // avoid recursion 31230 return "_l((" + exp + ")," + 31231 "function(" + alias + iterator1 + iterator2 + "){" + 31232 "return " + (genScopedSlot(key, el, state)) + 31233 '})' 31234} 31235 31236function genChildren ( 31237 el, 31238 state, 31239 checkSkip, 31240 altGenElement, 31241 altGenNode 31242) { 31243 var children = el.children; 31244 if (children.length) { 31245 var el$1 = children[0]; 31246 // optimize single v-for 31247 if (children.length === 1 && 31248 el$1.for && 31249 el$1.tag !== 'template' && 31250 el$1.tag !== 'slot' 31251 ) { 31252 return (altGenElement || genElement)(el$1, state) 31253 } 31254 var normalizationType = checkSkip 31255 ? getNormalizationType(children, state.maybeComponent) 31256 : 0; 31257 var gen = altGenNode || genNode; 31258 return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : '')) 31259 } 31260} 31261 31262// determine the normalization needed for the children array. 31263// 0: no normalization needed 31264// 1: simple normalization needed (possible 1-level deep nested array) 31265// 2: full normalization needed 31266function getNormalizationType ( 31267 children, 31268 maybeComponent 31269) { 31270 var res = 0; 31271 for (var i = 0; i < children.length; i++) { 31272 var el = children[i]; 31273 if (el.type !== 1) { 31274 continue 31275 } 31276 if (needsNormalization(el) || 31277 (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) { 31278 res = 2; 31279 break 31280 } 31281 if (maybeComponent(el) || 31282 (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) { 31283 res = 1; 31284 } 31285 } 31286 return res 31287} 31288 31289function needsNormalization (el) { 31290 return el.for !== undefined || el.tag === 'template' || el.tag === 'slot' 31291} 31292 31293function genNode (node, state) { 31294 if (node.type === 1) { 31295 return genElement(node, state) 31296 } if (node.type === 3 && node.isComment) { 31297 return genComment(node) 31298 } else { 31299 return genText(node) 31300 } 31301} 31302 31303function genText (text) { 31304 return ("_v(" + (text.type === 2 31305 ? text.expression // no need for () because already wrapped in _s() 31306 : transformSpecialNewlines(JSON.stringify(text.text))) + ")") 31307} 31308 31309function genComment (comment) { 31310 return ("_e(" + (JSON.stringify(comment.text)) + ")") 31311} 31312 31313function genSlot (el, state) { 31314 var slotName = el.slotName || '"default"'; 31315 var children = genChildren(el, state); 31316 var res = "_t(" + slotName + (children ? ("," + children) : ''); 31317 var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}"); 31318 var bind$$1 = el.attrsMap['v-bind']; 31319 if ((attrs || bind$$1) && !children) { 31320 res += ",null"; 31321 } 31322 if (attrs) { 31323 res += "," + attrs; 31324 } 31325 if (bind$$1) { 31326 res += (attrs ? '' : ',null') + "," + bind$$1; 31327 } 31328 return res + ')' 31329} 31330 31331// componentName is el.component, take it as argument to shun flow's pessimistic refinement 31332function genComponent ( 31333 componentName, 31334 el, 31335 state 31336) { 31337 var children = el.inlineTemplate ? null : genChildren(el, state, true); 31338 return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")") 31339} 31340 31341function genProps (props) { 31342 var res = ''; 31343 for (var i = 0; i < props.length; i++) { 31344 var prop = props[i]; 31345 /* istanbul ignore if */ 31346 { 31347 res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ","; 31348 } 31349 } 31350 return res.slice(0, -1) 31351} 31352 31353// #3895, #4268 31354function transformSpecialNewlines (text) { 31355 return text 31356 .replace(/\u2028/g, '\\u2028') 31357 .replace(/\u2029/g, '\\u2029') 31358} 31359 31360/* */ 31361 31362// these keywords should not appear inside expressions, but operators like 31363// typeof, instanceof and in are allowed 31364var prohibitedKeywordRE = new RegExp('\\b' + ( 31365 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + 31366 'super,throw,while,yield,delete,export,import,return,switch,default,' + 31367 'extends,finally,continue,debugger,function,arguments' 31368).split(',').join('\\b|\\b') + '\\b'); 31369 31370// these unary operators should not be used as property/method names 31371var unaryOperatorsRE = new RegExp('\\b' + ( 31372 'delete,typeof,void' 31373).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)'); 31374 31375// strip strings in expressions 31376var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g; 31377 31378// detect problematic expressions in a template 31379function detectErrors (ast) { 31380 var errors = []; 31381 if (ast) { 31382 checkNode(ast, errors); 31383 } 31384 return errors 31385} 31386 31387function checkNode (node, errors) { 31388 if (node.type === 1) { 31389 for (var name in node.attrsMap) { 31390 if (dirRE.test(name)) { 31391 var value = node.attrsMap[name]; 31392 if (value) { 31393 if (name === 'v-for') { 31394 checkFor(node, ("v-for=\"" + value + "\""), errors); 31395 } else if (onRE.test(name)) { 31396 checkEvent(value, (name + "=\"" + value + "\""), errors); 31397 } else { 31398 checkExpression(value, (name + "=\"" + value + "\""), errors); 31399 } 31400 } 31401 } 31402 } 31403 if (node.children) { 31404 for (var i = 0; i < node.children.length; i++) { 31405 checkNode(node.children[i], errors); 31406 } 31407 } 31408 } else if (node.type === 2) { 31409 checkExpression(node.expression, node.text, errors); 31410 } 31411} 31412 31413function checkEvent (exp, text, errors) { 31414 var stipped = exp.replace(stripStringRE, ''); 31415 var keywordMatch = stipped.match(unaryOperatorsRE); 31416 if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') { 31417 errors.push( 31418 "avoid using JavaScript unary operator as property name: " + 31419 "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()) 31420 ); 31421 } 31422 checkExpression(exp, text, errors); 31423} 31424 31425function checkFor (node, text, errors) { 31426 checkExpression(node.for || '', text, errors); 31427 checkIdentifier(node.alias, 'v-for alias', text, errors); 31428 checkIdentifier(node.iterator1, 'v-for iterator', text, errors); 31429 checkIdentifier(node.iterator2, 'v-for iterator', text, errors); 31430} 31431 31432function checkIdentifier ( 31433 ident, 31434 type, 31435 text, 31436 errors 31437) { 31438 if (typeof ident === 'string') { 31439 try { 31440 new Function(("var " + ident + "=_")); 31441 } catch (e) { 31442 errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim()))); 31443 } 31444 } 31445} 31446 31447function checkExpression (exp, text, errors) { 31448 try { 31449 new Function(("return " + exp)); 31450 } catch (e) { 31451 var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE); 31452 if (keywordMatch) { 31453 errors.push( 31454 "avoid using JavaScript keyword as property name: " + 31455 "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()) 31456 ); 31457 } else { 31458 errors.push( 31459 "invalid expression: " + (e.message) + " in\n\n" + 31460 " " + exp + "\n\n" + 31461 " Raw expression: " + (text.trim()) + "\n" 31462 ); 31463 } 31464 } 31465} 31466 31467/* */ 31468 31469function createFunction (code, errors) { 31470 try { 31471 return new Function(code) 31472 } catch (err) { 31473 errors.push({ err: err, code: code }); 31474 return noop 31475 } 31476} 31477 31478function createCompileToFunctionFn (compile) { 31479 var cache = Object.create(null); 31480 31481 return function compileToFunctions ( 31482 template, 31483 options, 31484 vm 31485 ) { 31486 options = extend({}, options); 31487 var warn$$1 = options.warn || warn; 31488 delete options.warn; 31489 31490 /* istanbul ignore if */ 31491 if (true) { 31492 // detect possible CSP restriction 31493 try { 31494 new Function('return 1'); 31495 } catch (e) { 31496 if (e.toString().match(/unsafe-eval|CSP/)) { 31497 warn$$1( 31498 'It seems you are using the standalone build of Vue.js in an ' + 31499 'environment with Content Security Policy that prohibits unsafe-eval. ' + 31500 'The template compiler cannot work in this environment. Consider ' + 31501 'relaxing the policy to allow unsafe-eval or pre-compiling your ' + 31502 'templates into render functions.' 31503 ); 31504 } 31505 } 31506 } 31507 31508 // check cache 31509 var key = options.delimiters 31510 ? String(options.delimiters) + template 31511 : template; 31512 if (cache[key]) { 31513 return cache[key] 31514 } 31515 31516 // compile 31517 var compiled = compile(template, options); 31518 31519 // check compilation errors/tips 31520 if (true) { 31521 if (compiled.errors && compiled.errors.length) { 31522 warn$$1( 31523 "Error compiling template:\n\n" + template + "\n\n" + 31524 compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n', 31525 vm 31526 ); 31527 } 31528 if (compiled.tips && compiled.tips.length) { 31529 compiled.tips.forEach(function (msg) { return tip(msg, vm); }); 31530 } 31531 } 31532 31533 // turn code into functions 31534 var res = {}; 31535 var fnGenErrors = []; 31536 res.render = createFunction(compiled.render, fnGenErrors); 31537 res.staticRenderFns = compiled.staticRenderFns.map(function (code) { 31538 return createFunction(code, fnGenErrors) 31539 }); 31540 31541 // check function generation errors. 31542 // this should only happen if there is a bug in the compiler itself. 31543 // mostly for codegen development use 31544 /* istanbul ignore if */ 31545 if (true) { 31546 if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) { 31547 warn$$1( 31548 "Failed to generate render function:\n\n" + 31549 fnGenErrors.map(function (ref) { 31550 var err = ref.err; 31551 var code = ref.code; 31552 31553 return ((err.toString()) + " in\n\n" + code + "\n"); 31554 }).join('\n'), 31555 vm 31556 ); 31557 } 31558 } 31559 31560 return (cache[key] = res) 31561 } 31562} 31563 31564/* */ 31565 31566function createCompilerCreator (baseCompile) { 31567 return function createCompiler (baseOptions) { 31568 function compile ( 31569 template, 31570 options 31571 ) { 31572 var finalOptions = Object.create(baseOptions); 31573 var errors = []; 31574 var tips = []; 31575 finalOptions.warn = function (msg, tip) { 31576 (tip ? tips : errors).push(msg); 31577 }; 31578 31579 if (options) { 31580 // merge custom modules 31581 if (options.modules) { 31582 finalOptions.modules = 31583 (baseOptions.modules || []).concat(options.modules); 31584 } 31585 // merge custom directives 31586 if (options.directives) { 31587 finalOptions.directives = extend( 31588 Object.create(baseOptions.directives || null), 31589 options.directives 31590 ); 31591 } 31592 // copy other options 31593 for (var key in options) { 31594 if (key !== 'modules' && key !== 'directives') { 31595 finalOptions[key] = options[key]; 31596 } 31597 } 31598 } 31599 31600 var compiled = baseCompile(template, finalOptions); 31601 if (true) { 31602 errors.push.apply(errors, detectErrors(compiled.ast)); 31603 } 31604 compiled.errors = errors; 31605 compiled.tips = tips; 31606 return compiled 31607 } 31608 31609 return { 31610 compile: compile, 31611 compileToFunctions: createCompileToFunctionFn(compile) 31612 } 31613 } 31614} 31615 31616/* */ 31617 31618// `createCompilerCreator` allows creating compilers that use alternative 31619// parser/optimizer/codegen, e.g the SSR optimizing compiler. 31620// Here we just export a default compiler using the default parts. 31621var createCompiler = createCompilerCreator(function baseCompile ( 31622 template, 31623 options 31624) { 31625 var ast = parse(template.trim(), options); 31626 if (options.optimize !== false) { 31627 optimize(ast, options); 31628 } 31629 var code = generate(ast, options); 31630 return { 31631 ast: ast, 31632 render: code.render, 31633 staticRenderFns: code.staticRenderFns 31634 } 31635}); 31636 31637/* */ 31638 31639var ref$1 = createCompiler(baseOptions); 31640var compileToFunctions = ref$1.compileToFunctions; 31641 31642/* */ 31643 31644// check whether current browser encodes a char inside attribute values 31645var div; 31646function getShouldDecode (href) { 31647 div = div || document.createElement('div'); 31648 div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>"; 31649 return div.innerHTML.indexOf(' ') > 0 31650} 31651 31652// #3663: IE encodes newlines inside attribute values while other browsers don't 31653var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false; 31654// #6828: chrome encodes content in a[href] 31655var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false; 31656 31657/* */ 31658 31659var idToTemplate = cached(function (id) { 31660 var el = query(id); 31661 return el && el.innerHTML 31662}); 31663 31664var mount = Vue.prototype.$mount; 31665Vue.prototype.$mount = function ( 31666 el, 31667 hydrating 31668) { 31669 el = el && query(el); 31670 31671 /* istanbul ignore if */ 31672 if (el === document.body || el === document.documentElement) { 31673 "development" !== 'production' && warn( 31674 "Do not mount Vue to <html> or <body> - mount to normal elements instead." 31675 ); 31676 return this 31677 } 31678 31679 var options = this.$options; 31680 // resolve template/el and convert to render function 31681 if (!options.render) { 31682 var template = options.template; 31683 if (template) { 31684 if (typeof template === 'string') { 31685 if (template.charAt(0) === '#') { 31686 template = idToTemplate(template); 31687 /* istanbul ignore if */ 31688 if ("development" !== 'production' && !template) { 31689 warn( 31690 ("Template element not found or is empty: " + (options.template)), 31691 this 31692 ); 31693 } 31694 } 31695 } else if (template.nodeType) { 31696 template = template.innerHTML; 31697 } else { 31698 if (true) { 31699 warn('invalid template option:' + template, this); 31700 } 31701 return this 31702 } 31703 } else if (el) { 31704 template = getOuterHTML(el); 31705 } 31706 if (template) { 31707 /* istanbul ignore if */ 31708 if ("development" !== 'production' && config.performance && mark) { 31709 mark('compile'); 31710 } 31711 31712 var ref = compileToFunctions(template, { 31713 shouldDecodeNewlines: shouldDecodeNewlines, 31714 shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref, 31715 delimiters: options.delimiters, 31716 comments: options.comments 31717 }, this); 31718 var render = ref.render; 31719 var staticRenderFns = ref.staticRenderFns; 31720 options.render = render; 31721 options.staticRenderFns = staticRenderFns; 31722 31723 /* istanbul ignore if */ 31724 if ("development" !== 'production' && config.performance && mark) { 31725 mark('compile end'); 31726 measure(("vue " + (this._name) + " compile"), 'compile', 'compile end'); 31727 } 31728 } 31729 } 31730 return mount.call(this, el, hydrating) 31731}; 31732 31733/** 31734 * Get outerHTML of elements, taking care 31735 * of SVG elements in IE as well. 31736 */ 31737function getOuterHTML (el) { 31738 if (el.outerHTML) { 31739 return el.outerHTML 31740 } else { 31741 var container = document.createElement('div'); 31742 container.appendChild(el.cloneNode(true)); 31743 return container.innerHTML 31744 } 31745} 31746 31747Vue.compile = compileToFunctions; 31748 31749module.exports = Vue; 31750 31751/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/webpack/buildin/global.js"), __webpack_require__("./node_modules/timers-browserify/main.js").setImmediate)) 31752 31753/***/ }), 31754
vendor: 587 bytes, lines 31755-31782
31755/***/ "./node_modules/webpack/buildin/global.js": 31756/***/ (function(module, exports) { 31757 31758var g; 31759 31760// This works in non-strict mode 31761g = (function() { 31762 return this; 31763})(); 31764 31765try { 31766 // This works if eval is allowed (see CSP) 31767 g = g || Function("return this")() || (1,eval)("this"); 31768} catch(e) { 31769 // This works if the window reference is available 31770 if(typeof window === "object") 31771 g = window; 31772} 31773 31774// g can still be undefined, but nothing to do about it... 31775// We return undefined, instead of nothing here, so it's 31776// easier to handle this case. if(!global) { ...} 31777 31778module.exports = g; 31779 31780 31781/***/ }), 31782
vendor: 594 bytes, lines 31783-31811
31783/***/ "./node_modules/webpack/buildin/module.js": 31784/***/ (function(module, exports) { 31785 31786module.exports = function(module) { 31787 if(!module.webpackPolyfill) { 31788 module.deprecate = function() {}; 31789 module.paths = []; 31790 // module.parent = undefined by default 31791 if(!module.children) module.children = []; 31792 Object.defineProperty(module, "loaded", { 31793 enumerable: true, 31794 get: function() { 31795 return module.l; 31796 } 31797 }); 31798 Object.defineProperty(module, "id", { 31799 enumerable: true, 31800 get: function() { 31801 return module.i; 31802 } 31803 }); 31804 module.webpackPolyfill = 1; 31805 } 31806 return module; 31807}; 31808 31809 31810/***/ }), 31811
31812/***/ "./resources/assets/js/app.js": 31813/***/ (function(module, exports, __webpack_require__) { 31814 31815__webpack_require__("./resources/assets/js/bootstrap.js"); 31816 31817Vue.component('Images', __webpack_require__("./resources/assets/js/components/Images.vue")); 31818 31819if (document.getElementById("app-image-uploader")) { 31820 var appForm = new Vue({ 31821 el: '#app-image-uploader', 31822 data: { 31823 image: null, 31824 submitted: false, 31825 31826 country_id: null, 31827 region_id: null, 31828 city_id: null, 31829 no_region_country: null, 31830 selected: 0, 31831 31832 title_limit: 80, 31833 31834 images_uploading: null, 31835 videos_uploading: null, 31836 old_category_id: null 31837 }, 31838 created: function created() { 31839 var vm = this; 31840 31841 Event.listen('images-uploading', function (value) { 31842 vm.images_uploading = value; 31843 }); 31844 }, 31845 computed: { 31846 titleRemaining: function titleRemaining() { 31847 //let left = this.title_limit - this.title.length; 31848 //return '('+left+' characters left)'; 31849 }, 31850 uploadInProgress: function uploadInProgress() { 31851 return this.images_uploading || this.videos_uploading; 31852 }, 31853 canContinue: function canContinue() { 31854 return !this.uploadInProgress && !this.submitted; 31855 } 31856 }, 31857 methods: { 31858 inputClicked: function inputClicked(field) { 31859 this.form.errors.clear(field); 31860 } 31861 }, 31862 watch: { 31863 form: { 31864 handler: function handler(newValue) { 31865 // let vm = this; 31866 // Reset affiliaton on category change 31867 /*if (newValue.category_id != vm.old_category_id) { 31868 vm.old_category_id = newValue.category_id; 31869 vm.form.affiliation_id = ''; 31870 }*/ 31871 }, 31872 deep: true 31873 } 31874 } 31875 }); 31876 31877 window.app = appForm; 31878} 31879 31880window.Cookies = __webpack_require__("./node_modules/js-cookie/src/js.cookie.js"); 31881 31882var europeCookie = __webpack_require__("./core/mokyklos/cookie_policy-plugin/resources/js/europeCookie.js").default; 31883new europeCookie(); 31884 31885var notificationCookie = __webpack_require__("./resources/assets/js/notificationCookie.js").default; 31886new notificationCookie(); 31887 31888/***/ }), 31889
31890/***/ "./resources/assets/js/bootstrap.js": 31891/***/ (function(module, exports, __webpack_require__) { 31892 31893var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 31894 31895function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 31896 31897window._ = __webpack_require__("./node_modules/lodash/lodash.js"); 31898 31899/** 31900 * Vue is a modern JavaScript library for building interactive web interfaces 31901 * using reactive data binding and reusable components. Vue's API is clean 31902 * and simple, leaving you to focus on building your next great project. 31903 */ 31904 31905var sprintf = __webpack_require__("./node_modules/sprintf-js/src/sprintf.js").sprintf; 31906 31907window.Vue = __webpack_require__("./node_modules/vue/dist/vue.common.js"); 31908 31909Vue.swap = function (arr, x, y) { 31910 var origin = arr[x]; 31911 arr.splice(x, 1, arr[y]); 31912 Vue.set(arr, y, origin); 31913}; 31914 31915/** 31916 * We'll load the axios HTTP library which allows us to easily issue requests 31917 * to our Laravel back-end. This library automatically handles sending the 31918 * CSRF token as a header based on the value of the "XSRF" token cookie. 31919 */ 31920window.axios = __webpack_require__("./node_modules/axios/index.js"); 31921 31922window.axios.defaults.headers.common = { 31923 'X-CSRF-TOKEN': window.Laravel.csrfToken, 31924 'X-Requested-With': 'XMLHttpRequest' 31925}; 31926 31927var Event = window.Event = new (function () { 31928 function _class() { 31929 _classCallCheck(this, _class); 31930 31931 this.vue = new Vue(); 31932 } 31933 31934 _createClass(_class, [{ 31935 key: 'dispatch', 31936 value: function dispatch(event) { 31937 var _vue; 31938 31939 for (var _len = arguments.length, data = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 31940 data[_key - 1] = arguments[_key]; 31941 } 31942 31943 (_vue = this.vue).$emit.apply(_vue, [event].concat(data)); 31944 } 31945 }, { 31946 key: 'listen', 31947 value: function listen(event, callback) { 31948 this.vue.$on(event, callback); 31949 } 31950 }]); 31951 31952 return _class; 31953}())(); 31954 31955/***/ }), 31956
31957/***/ "./resources/assets/js/components/Images.vue": 31958/***/ (function(module, exports, __webpack_require__) { 31959 31960var disposed = false 31961function injectStyle (ssrContext) { 31962 if (disposed) return 31963 __webpack_require__("./node_modules/vue-style-loader/index.js!./node_modules/css-loader/index.js!./node_modules/vue-loader/lib/style-compiler/index.js?{\"vue\":true,\"id\":\"data-v-52401b6f\",\"scoped\":false,\"hasInlineConfig\":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./resources/assets/js/components/Images.vue") 31964} 31965var normalizeComponent = __webpack_require__("./node_modules/vue-loader/lib/component-normalizer.js") 31966/* script */ 31967var __vue_script__ = __webpack_require__("./node_modules/babel-loader/lib/index.js?{\"cacheDirectory\":true,\"presets\":[[\"env\",{\"modules\":false,\"targets\":{\"browsers\":[\"> 2%\"],\"uglify\":true}}]],\"plugins\":[\"transform-object-rest-spread\",[\"transform-runtime\",{\"polyfill\":false,\"helpers\":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/Images.vue") 31968/* template */ 31969var __vue_template__ = __webpack_require__("./node_modules/vue-loader/lib/template-compiler/index.js?{\"id\":\"data-v-52401b6f\",\"hasScoped\":false,\"buble\":{\"transforms\":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./resources/assets/js/components/Images.vue") 31970/* template functional */ 31971var __vue_template_functional__ = false 31972/* styles */ 31973var __vue_styles__ = injectStyle 31974/* scopeId */ 31975var __vue_scopeId__ = null 31976/* moduleIdentifier (server only) */ 31977var __vue_module_identifier__ = null 31978var Component = normalizeComponent( 31979 __vue_script__, 31980 __vue_template__, 31981 __vue_template_functional__, 31982 __vue_styles__, 31983 __vue_scopeId__, 31984 __vue_module_identifier__ 31985) 31986Component.options.__file = "resources/assets/js/components/Images.vue" 31987 31988/* hot reload */ 31989if (false) {(function () { 31990 var hotAPI = require("vue-hot-reload-api") 31991 hotAPI.install(require("vue"), false) 31992 if (!hotAPI.compatible) return 31993 module.hot.accept() 31994 if (!module.hot.data) { 31995 hotAPI.createRecord("data-v-52401b6f", Component.options) 31996 } else { 31997 hotAPI.reload("data-v-52401b6f", Component.options) 31998 } 31999 module.hot.dispose(function (data) { 32000 disposed = true 32001 }) 32002})()} 32003 32004module.exports = Component.exports 32005 32006 32007/***/ }), 32008
32009/***/ "./resources/assets/js/notificationCookie.js": 32010/***/ (function(module, __webpack_exports__, __webpack_require__) { 32011 32012"use strict"; 32013Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); 32014var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 32015 32016function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 32017 32018var NotificationCookie = function () { 32019 function NotificationCookie() { 32020 var expires = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 32021 32022 _classCallCheck(this, NotificationCookie); 32023 32024 // cookie name for language 32025 this.cookieName = 'notificationCookie'; 32026 32027 // cookie wrapper (div) 32028 this.cookieWrapper = '#notificationCookieWrapper'; 32029 32030 // cookie closer (<a id="notification_cookie_close">) 32031 this.cookieCloser = '#notificationCookieClose'; 32032 32033 // days when notification cookie expires 32034 expires = 365; 32035 32036 // cookie exists, do not show the wrapper! 32037 // no more processing, so we don't bind events 32038 // or whatever 32039 if (this.exists()) { 32040 return false; 32041 } 32042 32043 // custom expires days passed? 32044 if (expires) { 32045 this.expires = expires; 32046 } 32047 32048 // bind jquery 32049 this.cookieWrapper = $(this.cookieWrapper); 32050 this.cookieCloser = $(this.cookieCloser); 32051 32052 // display the wrapper, since no cookie was set 32053 this.displayCookieBlock(); 32054 32055 // cookie does not exists, so bind event to listen 32056 // for `accept events` 32057 this.bindOnChange(); 32058 } 32059 32060 _createClass(NotificationCookie, [{ 32061 key: 'bindOnChange', 32062 value: function bindOnChange() { 32063 this.cookieCloser.on('click', function (event) { 32064 event.preventDefault(); 32065 var closerId = this.cookieCloser.data('id'); 32066 this.setCookieName(closerId); 32067 32068 this.remember(); 32069 }.bind(this)); 32070 } 32071 }, { 32072 key: 'displayCookieBlock', 32073 value: function displayCookieBlock() { 32074 this.cookieWrapper.css('display', 'block'); 32075 } 32076 }, { 32077 key: 'exists', 32078 value: function exists() { 32079 if (Cookies.get(this.getCookieName())) { 32080 return true; 32081 } 32082 32083 return false; 32084 } 32085 32086 // store the changes in Cookies 32087 32088 }, { 32089 key: 'remember', 32090 value: function remember() { 32091 Cookies.set(this.cookieName, '1', { 32092 expires: this.expires, 32093 path: '/', 32094 domain: document.domain 32095 }); 32096 32097 this.cookieWrapper.css('display', 'none'); 32098 } 32099 }, { 32100 key: 'setCookieName', 32101 value: function setCookieName(id) { 32102 this.cookieName = this.cookieName + id; 32103 } 32104 }, { 32105 key: 'getCookieName', 32106 value: function getCookieName() { 32107 var id = $(this.cookieCloser).data('id'); 32108 32109 return this.cookieName + id; 32110 } 32111 }]); 32112 32113 return NotificationCookie; 32114}(); 32115 32116/* harmony default export */ __webpack_exports__["default"] = (NotificationCookie); 32117 32118/***/ }), 32119
32120/***/ "./vendor/mokyklos/default-theme/scss/app.scss": 32121/***/ (function(module, exports) { 32122 32123// removed by extract-text-webpack-plugin 32124 32125/***/ })
32125, 32126 32127/***/ 0: 32128/***/ (function(module, exports, __webpack_require__) { 32129 32130__webpack_require__("./resources/assets/js/app.js"); 32131module.exports = __webpack_require__("./vendor/mokyklos/default-theme/scss/app.scss"); 32132 32133 32134/***/ }) 32135 32136/******/ });
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.